pt.digitalis.dif.controller.security.objects
Class DIFUserImpl

java.lang.Object
  extended by pt.digitalis.dif.controller.security.objects.DIFUserImpl
All Implemented Interfaces:
Cloneable, IDIFClonableUser, IDIFInternalUser, IDIFUser, IUserAuthorization

public class DIFUserImpl
extends Object
implements IDIFClonableUser, Cloneable

Default implementation VALIDATE: Check the Cloneable usage good/bad practice!

Author:
Rodrigo Gon�alves rgoncalves@digitalis.pt, Pedro Viegas pviegas@digitalis.pt
Created on:
Dec 3, 2007

Constructor Summary
DIFUserImpl()
          Default constructor
DIFUserImpl(IDIFUser user, String password)
          Constructor from a IDIFUser object
 
Method Summary
 void addTempGroup(String groupId)
          Adds the temporary group.
 boolean canAccess(Entity resourceType, String resourceId)
          Checks if the user can access a given resource.
 boolean canAccess(IStage stage)
          Checks if the user can access a given stage.
 void cleanCache()
          Clears any existing cache
protected  Object clone()
           
 IDIFClonableUser cloneUser()
           
 boolean containsAttribute(String id)
          Searches for a given attribute
 boolean containsParameter(String id)
          Searches for a given parameter
 boolean equals(Object obj)
           
 Object getAttribute(String id)
          Gets the user attribute.
 pt.digitalis.utils.common.collections.CaseInsensitiveHashMap<Object> getAttributes()
          Gets the user attribute list.
 List<String> getAttributesToRemove()
          Inspector for the 'attributesToRemove' attribute.
 String getEmail()
          Returns the user e-mail address.
 Set<String> getGroupIDs()
          Retrieves the list of group ids associated with this user
 Map<String,IDIFGroup> getGroups()
          Retrieves the list of groups associated with this user
 String getID()
          Returns the user id.
 String getName()
          Returns the user full name.
 String getNick()
          Returns the user's nick name.
 Object getParameter(String id)
          Gets a user parameter.
 Map<String,Object> getParameters()
          Gets the user parameter list.
 String getPassword()
           
 IDIFGroup getProfile()
          Retrieves the user profile or default group
 String getProfileID()
          Retrieves the user profile or default group ID
 int hashCode()
           
 void initializeAttributes(Map<String,Object> attrs)
           
 boolean isDefault()
          A default user is a user that is created by the default configuration of the application.
 boolean isEnabled()
          A disabled user will not be able to log on
 void refresh()
          Refreshes the current user from the persistent layer
 void removeAttribute(String id)
          Removes the user attribute.
 void removeParameter(String id)
          Removes the user parameter.
 void removeTempGroup(String groupId)
          Removes the temporary group.
 void setAttribute(String id, Object attribute)
          Sets the user attribute.
 void setAttributes(Map<String,Object> attributes)
          Sets the attributes.
 void setDefault(boolean isDefault)
          Sets the user as a default user.
 void setEmail(String email)
          Sets the user e-mail address.
 void setEnabled(boolean enabled)
           
 void setID(String id)
          Sets the user id.
 void setName(String name)
          Sets the user full name.
 void setNick(String nick)
          Sets the user nick name.
 void setParameter(String id, Object parameter)
          Sets the user parameters.
 void setParameters(Map<String,Object> parameters)
          Sets the parameters.
 void setPassword(String password)
          Sets the user password.
 void setProfileID(String profileGroupID)
          Sets the profile ID or default group of the user
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DIFUserImpl

public DIFUserImpl()
Default constructor


DIFUserImpl

public DIFUserImpl(IDIFUser user,
                   String password)
            throws IdentityManagerException
Constructor from a IDIFUser object

Parameters:
user - the IDIFUser to use as a base for the new user to create
password - the password to set
Throws:
IdentityManagerException - if the profile can't be accessed
Method Detail

addTempGroup

public void addTempGroup(String groupId)
Description copied from interface: IDIFUser
Adds the temporary group. This user group has the session life expectancy

Specified by:
addTempGroup in interface IDIFUser
Parameters:
groupId - the group id
See Also:
IDIFUser.addTempGroup(java.lang.String)

canAccess

public boolean canAccess(Entity resourceType,
                         String resourceId)
Description copied from interface: IUserAuthorization
Checks if the user can access a given resource.

Specified by:
canAccess in interface IUserAuthorization
Parameters:
resourceType - the resource (entity) type.
resourceId - the id of the resource to check access
Returns:
T if the user can access the resource, F otherwise
See Also:
IUserAuthorization.canAccess(pt.digitalis.dif.dem.Entity, java.lang.String)

canAccess

public boolean canAccess(IStage stage)
Description copied from interface: IUserAuthorization
Checks if the user can access a given stage. Will parse the DEM for inherited grants

Specified by:
canAccess in interface IUserAuthorization
Parameters:
stage - the stage to check
Returns:
T if the user can access the stage, F otherwise
See Also:
IUserAuthorization.canAccess(pt.digitalis.dif.dem.interfaces.IStage)

cleanCache

public void cleanCache()
Description copied from interface: IDIFUser
Clears any existing cache

Specified by:
cleanCache in interface IDIFUser
See Also:
IDIFUser.cleanCache()

clone

protected Object clone()
                throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException
See Also:
Object.clone()

cloneUser

public IDIFClonableUser cloneUser()
Specified by:
cloneUser in interface IDIFClonableUser
Returns:
a clone of the current user
See Also:
IDIFClonableUser.cloneUser()

containsAttribute

public boolean containsAttribute(String id)
Description copied from interface: IDIFUser
Searches for a given attribute

Specified by:
containsAttribute in interface IDIFUser
Parameters:
id - the id of the attribute to search
Returns:
T if the attribute is present
See Also:
IDIFUser.containsAttribute(java.lang.String)

containsParameter

public boolean containsParameter(String id)
Description copied from interface: IDIFUser
Searches for a given parameter

Specified by:
containsParameter in interface IDIFUser
Parameters:
id - the id of the parameter to search
Returns:
T if the parameter is present
See Also:
IDIFUser.containsParameter(java.lang.String)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

getAttribute

public Object getAttribute(String id)
Description copied from interface: IDIFUser
Gets the user attribute.

Specified by:
getAttribute in interface IDIFUser
Parameters:
id - the id of the attribute
Returns:
the user attribute
See Also:
IDIFUser.getAttribute(java.lang.String)

getAttributes

public pt.digitalis.utils.common.collections.CaseInsensitiveHashMap<Object> getAttributes()
Description copied from interface: IDIFUser
Gets the user attribute list.

Specified by:
getAttributes in interface IDIFUser
Returns:
the user attribute list
See Also:
IDIFUser.getAttributes()

getAttributesToRemove

public List<String> getAttributesToRemove()
Description copied from interface: IDIFUser
Inspector for the 'attributesToRemove' attribute.

Specified by:
getAttributesToRemove in interface IDIFUser
Returns:
the attributesToRemove value
See Also:
IDIFUser.getAttributesToRemove()

getEmail

public String getEmail()
Description copied from interface: IDIFUser
Returns the user e-mail address.

Specified by:
getEmail in interface IDIFUser
Returns:
the user e-mail
See Also:
IDIFUser.getEmail()

getGroupIDs

public Set<String> getGroupIDs()
                        throws IdentityManagerException
Description copied from interface: IDIFUser
Retrieves the list of group ids associated with this user

Specified by:
getGroupIDs in interface IDIFUser
Returns:
the groups
Throws:
IdentityManagerException - if the users can't be found on the identity manager
See Also:
IDIFUser.getGroupIDs()

getGroups

public Map<String,IDIFGroup> getGroups()
                                throws IdentityManagerException
Description copied from interface: IDIFUser
Retrieves the list of groups associated with this user

Specified by:
getGroups in interface IDIFUser
Returns:
the groups
Throws:
IdentityManagerException - if the groups can't be found on the identity manager
See Also:
IDIFUser.getGroups()

getID

public String getID()
Description copied from interface: IDIFUser
Returns the user id.

Specified by:
getID in interface IDIFUser
Returns:
the user id
See Also:
IDIFUser.getID()

getName

public String getName()
Description copied from interface: IDIFUser
Returns the user full name.

Specified by:
getName in interface IDIFUser
Returns:
the user's full name
See Also:
IDIFUser.getName()

getNick

public String getNick()
Description copied from interface: IDIFUser
Returns the user's nick name.

Specified by:
getNick in interface IDIFUser
Returns:
the user's nick name
See Also:
IDIFUser.getNick()

getParameter

public Object getParameter(String id)
Description copied from interface: IDIFUser
Gets a user parameter.

Specified by:
getParameter in interface IDIFUser
Parameters:
id - the id of the parameter
Returns:
the user parameter
See Also:
IDIFUser.getParameter(String)

getParameters

public Map<String,Object> getParameters()
Description copied from interface: IDIFUser
Gets the user parameter list.

Specified by:
getParameters in interface IDIFUser
Returns:
the user parameter list
See Also:
IDIFUser.getParameters()

getPassword

public String getPassword()
Specified by:
getPassword in interface IDIFInternalUser
Returns:
the user password

getProfile

public IDIFGroup getProfile()
                     throws IdentityManagerException
Description copied from interface: IDIFUser
Retrieves the user profile or default group

Specified by:
getProfile in interface IDIFUser
Returns:
the profile group
Throws:
IdentityManagerException - if the profile can't be found on the identity manager
See Also:
IDIFUser.getProfile()

getProfileID

public String getProfileID()
Description copied from interface: IDIFUser
Retrieves the user profile or default group ID

Specified by:
getProfileID in interface IDIFUser
Returns:
the profile group
See Also:
IDIFUser.getProfileID()

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

initializeAttributes

public void initializeAttributes(Map<String,Object> attrs)
Specified by:
initializeAttributes in interface IDIFUser
Parameters:
attrs - the new attributes to set
See Also:
IDIFUser.initializeAttributes(java.util.Map)

isDefault

public boolean isDefault()
Description copied from interface: IDIFUser
A default user is a user that is created by the default configuration of the application. As such it cannot be deleted. Only disabled.

Specified by:
isDefault in interface IDIFUser
Returns:
T if the user is a default user
See Also:
IDIFUser.isDefault()

isEnabled

public boolean isEnabled()
Description copied from interface: IDIFUser
A disabled user will not be able to log on

Specified by:
isEnabled in interface IDIFUser
Returns:
T if the user is enabled
See Also:
IDIFUser.isEnabled()

refresh

public void refresh()
Description copied from interface: IDIFUser
Refreshes the current user from the persistent layer

Specified by:
refresh in interface IDIFUser
See Also:
IDIFUser.refresh()

removeAttribute

public void removeAttribute(String id)
Description copied from interface: IDIFUser
Removes the user attribute.

Specified by:
removeAttribute in interface IDIFUser
Parameters:
id - the id of the attribute
See Also:
IDIFUser.removeAttribute(java.lang.String)

removeParameter

public void removeParameter(String id)
Description copied from interface: IDIFUser
Removes the user parameter.

Specified by:
removeParameter in interface IDIFUser
Parameters:
id - the id of the parameter
See Also:
IDIFUser.removeParameter(java.lang.String)

removeTempGroup

public void removeTempGroup(String groupId)
Description copied from interface: IDIFUser
Removes the temporary group.

Specified by:
removeTempGroup in interface IDIFUser
Parameters:
groupId - the group id
See Also:
IDIFUser.removeTempGroup(java.lang.String)

setAttribute

public void setAttribute(String id,
                         Object attribute)
                  throws InternalFrameworkException
Description copied from interface: IDIFUser
Sets the user attribute.

Specified by:
setAttribute in interface IDIFUser
Parameters:
id - the id of the attribute
attribute - the attribute to set
Throws:
InternalFrameworkException - if the attribute can't be set
See Also:
IDIFUser.setAttribute(java.lang.String, java.lang.Object)

setAttributes

public void setAttributes(Map<String,Object> attributes)
                   throws InternalFrameworkException
Description copied from interface: IDIFUser
Sets the attributes.

Specified by:
setAttributes in interface IDIFUser
Parameters:
attributes - the attributes to set
Throws:
InternalFrameworkException - if the attribute can't be set
See Also:
IDIFUser.setAttributes(java.util.Map)

setDefault

public void setDefault(boolean isDefault)
Description copied from interface: IDIFUser
Sets the user as a default user.

Specified by:
setDefault in interface IDIFUser
See Also:
IDIFUser.setDefault(boolean)

setEmail

public void setEmail(String email)
Description copied from interface: IDIFUser
Sets the user e-mail address.

Specified by:
setEmail in interface IDIFUser
Parameters:
email - the email to set
See Also:
IDIFUser.setEmail(java.lang.String)

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface IDIFUser
Parameters:
enabled - the enabled to set
See Also:
IDIFUser.setEnabled(boolean)

setID

public void setID(String id)
Description copied from interface: IDIFUser
Sets the user id.

Specified by:
setID in interface IDIFUser
Parameters:
id - the id to set
See Also:
IDIFUser.setID(java.lang.String)

setName

public void setName(String name)
Description copied from interface: IDIFUser
Sets the user full name.

Specified by:
setName in interface IDIFUser
Parameters:
name - the name to set
See Also:
IDIFUser.setName(java.lang.String)

setNick

public void setNick(String nick)
Description copied from interface: IDIFUser
Sets the user nick name.

Specified by:
setNick in interface IDIFUser
Parameters:
nick - the nick name to set
See Also:
IDIFUser.setNick(java.lang.String)

setParameter

public void setParameter(String id,
                         Object parameter)
Description copied from interface: IDIFUser
Sets the user parameters.

Specified by:
setParameter in interface IDIFUser
Parameters:
id - the id of the parameter
parameter - the parameter to set
See Also:
IDIFUser.setParameter(java.lang.String, java.lang.Object)

setParameters

public void setParameters(Map<String,Object> parameters)
Description copied from interface: IDIFUser
Sets the parameters.

Specified by:
setParameters in interface IDIFUser
Parameters:
parameters - the parameters to set
See Also:
IDIFUser.setParameters(java.util.Map)

setPassword

public void setPassword(String password)
Description copied from interface: IDIFUser
Sets the user password.

Specified by:
setPassword in interface IDIFUser
Parameters:
password - the password to set
See Also:
IDIFUser.setPassword(java.lang.String)

setProfileID

public void setProfileID(String profileGroupID)
Description copied from interface: IDIFUser
Sets the profile ID or default group of the user

Specified by:
setProfileID in interface IDIFUser
Parameters:
profileGroupID - the group to set as the profile
See Also:
IDIFUser.setProfileID(java.lang.String)

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.