info.magnolia.cms.security
Class MgnlUser

java.lang.Object
  extended by info.magnolia.cms.security.AbstractUser
      extended by info.magnolia.cms.security.MgnlUser
All Implemented Interfaces:
User, Serializable, Principal

public class MgnlUser
extends AbstractUser
implements User, Serializable

User for 4.5 instance In difference from old MgnlUser, this class operates directly on JCR session and with JCR nodes/properties as our hierarchy managers are not available at the login time. Also in difference from MgnlUser, this class doesn't keep around instance of the user node! TODO: Test performance impact of such change.

Version:
$Id$
Author:
had
See Also:
Serialized Form

Constructor Summary
MgnlUser(String name, String realm, Collection<String> groups, Collection<String> roles, Map<String,String> properties)
           
MgnlUser(String name, String realm, Collection<String> groups, Collection<String> roles, Map<String,String> properties, String path, String uuid)
           
 
Method Summary
 void addGroup(String groupName)
          Adds this user to a group.
 void addRole(String roleName)
          Adds a role to this user.
protected  String decodePassword(String encodedPassword)
          Deprecated. 
 Collection<String> getAllGroups()
          Get all groups to which this user belongs to, collected recursively including.
 Collection<String> getAllRoles()
          Get all roles assigned to this user, collected recursively including groups/subgroups.
 int getFailedLoginAttempts()
           
 Collection<String> getGroups()
          Get groups that are directly assigned to the user.
 String getIdentifier()
          Gets user identifier.
 String getLanguage()
           
 String getName()
           
 String getPassword()
           
 String getPath()
           
 String getProperty(String propertyName)
          Gets an arbitrary property from this user.
 String getRealm()
           
 Calendar getReleaseTime()
           
 Collection<String> getRoles()
          Get roles that are directly assigned to the user.
 Content getUserNode()
          Deprecated. since 4.5, use UserManager.updateLastAccessTimestamp(User) instead
 String getUuid()
          Deprecated. since 4.5.1, use getIdentifier() instead
 boolean hasRole(String roleName)
          Is this user in a specified role?
 boolean inGroup(String groupName)
          Is this user in a specified group?
 boolean isEnabled()
          Returns false if the user was explicitly disabled.
 void removeGroup(String groupName)
          Remove a group.
 void removeRole(String roleName)
          Remove a role.
 void setEnabled(boolean enabled)
          Deprecated. since 4.5, use UserManager.setProperty(User, String, Value) instead
 void setLastAccess()
          Deprecated. since 4.5, use UserManager.updateLastAccessTimestamp(User) instead
 void setPath(String path)
          Deprecated. 
 void setProperty(String propertyName, String value)
          Deprecated. since 4.5, use UserManager instead
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.security.Principal
equals, hashCode
 

Constructor Detail

MgnlUser

public MgnlUser(String name,
                String realm,
                Collection<String> groups,
                Collection<String> roles,
                Map<String,String> properties)

MgnlUser

public MgnlUser(String name,
                String realm,
                Collection<String> groups,
                Collection<String> roles,
                Map<String,String> properties,
                String path,
                String uuid)
Method Detail

inGroup

public boolean inGroup(String groupName)
Is this user in a specified group?

Specified by:
inGroup in interface User
Parameters:
groupName - the name of the group
Returns:
true if in group

removeGroup

public void removeGroup(String groupName)
                 throws UnsupportedOperationException
Remove a group. Implementation is optional

Specified by:
removeGroup in interface User
Parameters:
groupName -
Throws:
UnsupportedOperationException

addGroup

public void addGroup(String groupName)
              throws UnsupportedOperationException
Adds this user to a group. Implementation is optional

Specified by:
addGroup in interface User
Parameters:
groupName -
Throws:
UnsupportedOperationException

isEnabled

public boolean isEnabled()
Description copied from interface: User
Returns false if the user was explicitly disabled. Implementations should return true by default if the status is unknown.

Specified by:
isEnabled in interface User

setEnabled

@Deprecated
public void setEnabled(boolean enabled)
Deprecated. since 4.5, use UserManager.setProperty(User, String, Value) instead

This methods sets flag just on the bean. It does not update persisted user data. Use manager to update user data.

Specified by:
setEnabled in interface User

hasRole

public boolean hasRole(String roleName)
Is this user in a specified role?

Specified by:
hasRole in interface User
Parameters:
roleName - the name of the role
Returns:
true if in role

removeRole

public void removeRole(String roleName)
                throws UnsupportedOperationException
Description copied from interface: User
Remove a role. Implementation is optional

Specified by:
removeRole in interface User
Throws:
UnsupportedOperationException

addRole

public void addRole(String roleName)
             throws UnsupportedOperationException
Description copied from interface: User
Adds a role to this user. Implementation is optional

Specified by:
addRole in interface User
Parameters:
roleName - the name of the role
Throws:
UnsupportedOperationException

getFailedLoginAttempts

public int getFailedLoginAttempts()

getReleaseTime

public Calendar getReleaseTime()

getName

public String getName()
Specified by:
getName in interface User
Specified by:
getName in interface Principal

getPassword

public String getPassword()
Specified by:
getPassword in interface User

decodePassword

@Deprecated
protected String decodePassword(String encodedPassword)
Deprecated. 


getLanguage

public String getLanguage()
Specified by:
getLanguage in interface User

getProperty

public String getProperty(String propertyName)
Description copied from interface: User
Gets an arbitrary property from this user.

Specified by:
getProperty in interface User

getGroups

public Collection<String> getGroups()
Description copied from interface: User
Get groups that are directly assigned to the user.

Specified by:
getGroups in interface User

getAllGroups

public Collection<String> getAllGroups()
Description copied from interface: User
Get all groups to which this user belongs to, collected recursively including.

Specified by:
getAllGroups in interface User

getRoles

public Collection<String> getRoles()
Description copied from interface: User
Get roles that are directly assigned to the user.

Specified by:
getRoles in interface User

getAllRoles

public Collection<String> getAllRoles()
Description copied from interface: User
Get all roles assigned to this user, collected recursively including groups/subgroups.

Specified by:
getAllRoles in interface User

getPath

public String getPath()

setPath

@Deprecated
public void setPath(String path)
Deprecated. 


getRealm

public String getRealm()

setLastAccess

@Deprecated
public void setLastAccess()
Deprecated. since 4.5, use UserManager.updateLastAccessTimestamp(User) instead

Update the "last access" timestamp.


getUserNode

@Deprecated
public Content getUserNode()
Deprecated. since 4.5, use UserManager.updateLastAccessTimestamp(User) instead

Not every user needs to have a node behind. Use manager to obtain nodes


setProperty

@Deprecated
public void setProperty(String propertyName,
                                   String value)
Deprecated. since 4.5, use UserManager instead

Description copied from interface: User
Sets an arbitrary property for this user. Values are currently Strings; we'd need some kind of abstract encoding mechanism to allow other types if needed.

Specified by:
setProperty in interface User

getIdentifier

public String getIdentifier()
Description copied from interface: User
Gets user identifier.

Specified by:
getIdentifier in interface User

getUuid

@Deprecated
public String getUuid()
Deprecated. since 4.5.1, use getIdentifier() instead


toString

public String toString()
Specified by:
toString in interface Principal
Overrides:
toString in class Object


Copyright © 2003-2013 Magnolia International Ltd.. All Rights Reserved.