org.apache.jackrabbit.api.security.user
Interface Authorizable

All Known Subinterfaces:
Group, User

public interface Authorizable

The Authorizable is the common base interface for User and Group. It provides access to the Principals associated with an Authorizable (see below) and allow to access and modify additional properties such as e.g. full name, e-mail or address.

Please note the difference between Authorizable and Principal:
An Authorizable is repository object that is neither associated with nor depending from a particular Session and thus independant of the login mechanisms creating Sessions.
On the other hand Principals are representations of user identities. In other words: each Principal within the set associated with the Session's Subject upon login represents an identity for that user. An the set of Principals may differ between different login mechanisms.
Consequently an one-to-many relationship exists between Authorizable and Principal (see also getPrincipal() and getPrincipals()).

The interfaces derived from Authorizable are defined as follows:

See Also:
User, Group

Method Summary
 boolean addReferee(Principal principal)
          Add the given Principal to this Authorizable.
 Iterator declaredMemberOf()
           
 String getID()
          Return the implementation specific identifer for this Authorizable.
 Principal getPrincipal()
           
 PrincipalIterator getPrincipals()
           
 Value[] getProperty(String name)
          Returns the values for the properties with the specified name or null.
 Iterator getPropertyNames()
          Returns the names of properties present with this Authorizable.
 boolean hasProperty(String name)
          Tests if a the property with specified name exists.
 boolean isGroup()
           
 Iterator memberOf()
           
 void remove()
          Removes this Authorizable, if the session has sufficient permissions.
 boolean removeProperty(String name)
          Removes the property with the given name.
 boolean removeReferee(Principal principal)
          Remove the specified Principal for the referees of this Authorizable.
 void setProperty(String name, Value value)
          Set an arbitrary property to this Authorizable.
 void setProperty(String name, Value[] value)
          Set an arbitrary property to this Authorizable.
 

Method Detail

getID

String getID()
             throws RepositoryException
Return the implementation specific identifer for this Authorizable. It could e.g. be a UserID or simply the principal name.

Returns:
Name of this Authorizable.
Throws:
RepositoryException - if an error occurs.

isGroup

boolean isGroup()
Returns:
if the current Authorizable is a Group

getPrincipal

Principal getPrincipal()
                       throws RepositoryException
Returns:
a representation as Principal.
Throws:
RepositoryException - If an error occurs.

addReferee

boolean addReferee(Principal principal)
                   throws AuthorizableExistsException,
                          RepositoryException
Add the given Principal to this Authorizable. Note, that a Principal can only be refered by a single Authorizable in the Repository. If another User or Group already refers to the given Principal a AuthorizableExistsException is thrown.

Parameters:
principal -
Returns:
true if added, false if this Authorizable already represents the given Principal.
Throws:
RepositoryException
AuthorizableExistsException

removeReferee

boolean removeReferee(Principal principal)
                      throws RepositoryException
Remove the specified Principal for the referees of this Authorizable.

Parameters:
principal -
Returns:
true if principal has been referee before. False otherwise.
Throws:
RepositoryException

getPrincipals

PrincipalIterator getPrincipals()
                                throws RepositoryException
Returns:
Iterator of all Principal related to this authentication Object including the main principal, (see getPrincipal()).
Throws:
RepositoryException

declaredMemberOf

Iterator declaredMemberOf()
                          throws RepositoryException
Returns:
all Groups, this Authorizable is declared member of.
Throws:
RepositoryException

memberOf

Iterator memberOf()
                  throws RepositoryException
Returns:
all Groups, this Authorizable is member of included indirect group membership.
Throws:
RepositoryException

remove

void remove()
            throws RepositoryException
Removes this Authorizable, if the session has sufficient permissions. Note, that removing an Authorizable even if it listed as member of a Group or if still has members (this is a Group itself).

Throws:
RepositoryException - If an error occured and the Authorizable could not be removed.

getPropertyNames

Iterator getPropertyNames()
                          throws RepositoryException
Returns the names of properties present with this Authorizable.

Returns:
names of properties.
Throws:
RepositoryException - If an error occurs.
See Also:
getProperty(String), hasProperty(String)

hasProperty

boolean hasProperty(String name)
                    throws RepositoryException
Tests if a the property with specified name exists.

Parameters:
name -
Returns:
Throws:
RepositoryException
See Also:
getProperty(String)

setProperty

void setProperty(String name,
                 Value value)
                 throws RepositoryException
Set an arbitrary property to this Authorizable.

Parameters:
name -
value -
Throws:
RepositoryException - If the specified property could not be set.

setProperty

void setProperty(String name,
                 Value[] value)
                 throws RepositoryException
Set an arbitrary property to this Authorizable.

Parameters:
name -
value - multiple values
Throws:
RepositoryException - If the specified property could not be set.

getProperty

Value[] getProperty(String name)
                    throws RepositoryException
Returns the values for the properties with the specified name or null.

Parameters:
name -
Returns:
value of the property with the given name or null if no such property exists.
Throws:
RepositoryException - If an error occurs.

removeProperty

boolean removeProperty(String name)
                       throws RepositoryException
Removes the property with the given name.

Parameters:
name -
Returns:
true If the property with the specified name was successfully removed; false if no such property was present.
Throws:
RepositoryException - If an error occurs.


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