org.apache.cocoon.auth
Class StandardUser

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

public class StandardUser
extends Object
implements User, Serializable

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

Version:
$Id: StandardUser.html 1304258 2012-03-23 10:09:27Z 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.
 
Constructor Summary
StandardUser()
          Create a new user object.
StandardUser(String userId)
          Create a new user object.
 
Method Summary
 Object getAttribute(String key)
          Get information about the user.
 Iterator getAttributeNames()
          Return all available names.
 String getId()
          Return the unique id of this user.
 boolean isUserInRole(String role)
          Check if the user is in a given role.
 void removeAttribute(String key)
          Remove an information about the user.
 void setAttribute(String key, Object value)
          Set an information about the user.
 
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()
Description copied from interface: User
Return the unique id of this user.

Specified by:
getId in interface User
Returns:
The identifier.
See Also:
User.getId()

setAttribute

public void setAttribute(String key,
                         Object value)
Description copied from interface: User
Set an information about the user. For session replication the value of the attribute should be Serializable.

Specified by:
setAttribute in interface User
Parameters:
key - The key identifying the information.
value - The value of the information.
See Also:
User.setAttribute(java.lang.String, java.lang.Object)

removeAttribute

public void removeAttribute(String key)
Description copied from interface: User
Remove an information about the user.

Specified by:
removeAttribute in interface User
Parameters:
key - The key identifying the information.
See Also:
User.removeAttribute(java.lang.String)

getAttribute

public Object getAttribute(String key)
Description copied from interface: User
Get information about the user.

Specified by:
getAttribute in interface User
Parameters:
key - The key identifying the information.
Returns:
The value or null.
See Also:
User.getAttribute(java.lang.String)

getAttributeNames

public Iterator getAttributeNames()
Description copied from interface: User
Return all available names.

Specified by:
getAttributeNames in interface User
Returns:
An Iterator for the names (Strings).
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 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-2010 The Apache Software Foundation. All Rights Reserved.