org.apache.cocoon.auth
Interface User


public interface User

This object represents the current user. Each user must have a unique identifier (per SecurityHandler). For session replication, the implementation should be Serializable.

Version:
$Id: User.java 587757 2007-10-24 02:52:49Z vgritsenko $

Field Summary
static String ATTRIBUTE_PRINCIPAL
          If the security handler provides a Principal object, it should be stored into an attribute with the following name.
 
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.
 

Field Detail

ATTRIBUTE_PRINCIPAL

public static final String ATTRIBUTE_PRINCIPAL
If the security handler provides a Principal object, it should be stored into an attribute with the following name.

Method Detail

getId

public String getId()
Return the unique id of this user.

Returns:
The identifier.

setAttribute

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

Parameters:
key - The key identifying the information.
value - The value of the information.

removeAttribute

public void removeAttribute(String key)
Remove an information about the user.

Parameters:
key - The key identifying the information.

getAttribute

public Object getAttribute(String key)
Get information about the user.

Parameters:
key - The key identifying the information.
Returns:
The value or null.

getAttributeNames

public Iterator getAttributeNames()
Return all available names.

Returns:
An Iterator for the names (Strings).

isUserInRole

public boolean isUserInRole(String role)
Check if the user is in a given role. This method can't check for a role handled by the servlet engine, it only handles independently specified roles. Therefore, it is advisable to not call this method directly, but use the provided methods from the ApplicationUtil instead.

Parameters:
role - The role to test.
Returns:
Returns true if the user has the role, otherwise false.


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