org.apache.cocoon.auth.impl
Class StandardUser

java.lang.Object
  extended byorg.apache.cocoon.auth.impl.StandardUser
All Implemented Interfaces:
Serializable, org.apache.cocoon.auth.User
Direct Known Subclasses:
PipelineSecurityHandler.PipelineSHUser, ServletSecurityHandler.ServletUser

public class StandardUser
extends Object
implements org.apache.cocoon.auth.User, Serializable

This object represents the current user. Each user must have a unique identifier (per SecurityHandler).

Version:
$Id: StandardUser.html 1304280 2012-03-23 11:18:01Z ilgrosso $
See Also:
Serialized Form

Field Summary
protected  Map attributes
          The user attributes.
protected  String id
          The unique id of the user.
protected  List roles
          Cache the roles info.
 
Fields inherited from interface org.apache.cocoon.auth.User
ATTRIBUTE_PRINCIPAL
 
Constructor Summary
StandardUser()
          Create a new user object.
StandardUser(String userId)
          Create a new user object.
 
Method Summary
 Object getAttribute(String key)
           
 Iterator getAttributeNames()
           
 String getId()
           
 boolean isUserInRole(String role)
          Check if the user is in a given role.
 void removeAttribute(String key)
           
 void setAttribute(String key, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

protected String id
The unique id of the user.


attributes

protected final Map attributes
The user attributes.


roles

protected List roles
Cache the roles info.

Constructor Detail

StandardUser

public StandardUser(String userId)
Create a new user object.

Parameters:
userId - The unique identifier for this user.

StandardUser

public StandardUser()
Create a new user object. If you use this constructor, you have to ensure that the id of the user is set accordingly before the user object is used

Method Detail

getId

public String getId()
Specified by:
getId in interface org.apache.cocoon.auth.User
See Also:
User.getId()

setAttribute

public void setAttribute(String key,
                         Object value)
Specified by:
setAttribute in interface org.apache.cocoon.auth.User
See Also:
User.setAttribute(java.lang.String, java.lang.Object)

removeAttribute

public void removeAttribute(String key)
Specified by:
removeAttribute in interface org.apache.cocoon.auth.User
See Also:
User.removeAttribute(java.lang.String)

getAttribute

public Object getAttribute(String key)
Specified by:
getAttribute in interface org.apache.cocoon.auth.User
See Also:
User.getAttribute(java.lang.String)

getAttributeNames

public Iterator getAttributeNames()
Specified by:
getAttributeNames in interface org.apache.cocoon.auth.User
See Also:
User.getAttributeNames()

isUserInRole

public boolean isUserInRole(String role)
Check if the user is in a given role. This default implementation checks the two attributes "roles" and "role". If the incomming role is found in one of the two attributes, true is returned. Subclasses should override this method.

Specified by:
isUserInRole in interface org.apache.cocoon.auth.User
Parameters:
role - The role to test.
Returns:
Returns true if the user has the role, otherwise false.
See Also:
User.isUserInRole(java.lang.String)


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.