net.sourceforge.sconman
Class User

java.lang.Object
  extended by net.sourceforge.sconman.PermissionAggregator
      extended by net.sourceforge.sconman.User

public class User
extends PermissionAggregator

User class represent actors that access a Projectand performs operations on it. In order to get a valid user, call SecurityContext.loginUser(String,String)to log in the system.

Author:
mikeshadow

Field Summary
(package private) static java.lang.String EMAIL
          First name field
(package private) static java.lang.String FIRST_NAME
          First name field
(package private) static java.lang.String LAST_NAME
          First name field
(package private) static java.lang.String LOGIN
          Login field
(package private) static java.lang.String PASSWORD
          Password field
(package private) static java.lang.String PERMISSIONS
          First name field
(package private) static java.lang.String ROLES
          First name field
static java.lang.String USER_CTYPE
          Content type associated to users
static java.lang.String USERS_CATEGORY
          Category associated to users;
 
Fields inherited from class net.sourceforge.sconman.PermissionAggregator
permissions, sctx
 
Constructor Summary
User(SecurityContext sctx, Content content)
          Main constructor
 
Method Summary
 void addRelatedContent(Content content)
          This methods adds a related content to the User
(package private)  void addRole(Role role)
          Adds a role to the user
(package private)  void addRole(java.lang.String role)
          Adds a role to the user, known its identifier
 void addRole(User actor, Role role)
          Adds a role to the user
 void addRole(User actor, java.lang.String role)
          Adds a role to the user, known its identifier
(package private)  void addRoles(java.lang.String roles)
          Adds a role list to the user, given a CSV String of role identifiers
 void changePassword(User actor, java.lang.String newPassword)
          Use this method to change password.
(package private)  java.util.List getAllPermissions()
          Returns all the user permissions
 Content getContent()
          Returns the wrapped content
 java.util.List getContentsRelatedToContent(User user, boolean visible)
          Returns all the contents who are related to this User
 java.lang.String getEmail()
          Returns the user email
 java.lang.String getFirstName()
          Returns the user first id
 java.lang.String getId()
          Returns the user's identifier
 java.lang.String getLastName()
          Returns the user last id
 java.lang.String getLogin()
          Returns the user's login
 Project getProject()
          Returns the user's project
 java.lang.String getProperty(java.lang.String name)
          Returns a user property value
 java.util.List getReferencingContents(User user, java.lang.String ctype, java.lang.String fieldName, boolean visible)
          Returns the contents of a given type that reference this User in the specified field.
 java.util.List getRelatedContents(User user, boolean visible)
          Returns all the contents related for this User
 java.util.List getRoles()
          Return the user role list
 java.lang.String getRolesAsString()
          Returns the user's role list as a String
 java.util.List getSubscriptions()
          Returns the list of subscriptions (a list of Subscription)
 boolean hasAddNewPermission(ContentType ctype)
          Checks whether the aggregator can create new contents of the given type
 boolean hasAdminProjectPermission()
          Checks that the user can manage the project (Manage Roles and Users)
 boolean hasDeletePermission(Category cat)
          Checks whether the aggregator can remove a category
 boolean hasDeletePermission(ContentType ctype)
          Checks whether the aggregator can delete that content type
 boolean hasModifyPermission(Category cat)
          Checks whether the aggregator can modify a category
 boolean hasModifyPermission(ContentType ctype)
          Checks whether the aggregator can modify that content type
(package private)  boolean hasPermission(Permission permission)
          Checks whether the user has a permission or not
 boolean hasRole(Role role)
          Checks that the user has a role
 boolean hasRole(java.lang.String role)
          Checks that the user has a role
 boolean hasViewPermission(Category cat)
          Checks whether the aggregator can view a category
 boolean hasViewPermission(ContentType ctype)
          Checks whether the aggregator can view that content type
 void remove(User actor)
          Revome the user
 void removeRelatedContent(Content relatedContent)
          Removes a related content to the User
(package private)  void removeRole(Role role)
          Removes a role from the user
(package private)  void removeRole(java.lang.String role)
          Removes a user's role
 void removeRole(User actor, Role role)
          Removes a role from the user
 void removeRole(User actor, java.lang.String role)
          Removes a role from the user, known its identifier
 void save()
          Saves the user info
 void save(User actor)
          Saves the user info
 void setEmail(java.lang.String email)
          Sets the user email
 void setFirstName(java.lang.String name)
          Sets the user first id
 void setLastName(java.lang.String lastName)
          Sets the user last id
(package private)  void setLogin(java.lang.String login)
          Sets the user login
(package private)  void setPassword(java.lang.String password)
          Sets the user password
 void setProperty(java.lang.String name, java.lang.String value)
          Sets a user property
 java.lang.String toString()
          String representation of a User object
 
Methods inherited from class net.sourceforge.sconman.PermissionAggregator
addAddNewPermission, addAdminProjectPermission, addDeletePermission, addModifyPermission, addModifyPermission, addPermission, addPermission, addPermissions, addViewPermission, addViewPermission, getPermissions, getPermissionsAsString, hasPermission, removeAddNewPermission, removeAdminProjectPermission, removeAllPermissions, removeAllPermissions, removeDeletePermission, removeModifyPermission, removeModifyPermission, removePermission, removePermission, removeViewPermission, removeViewPermission
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

USER_CTYPE

public static final java.lang.String USER_CTYPE
Content type associated to users

See Also:
Constant Field Values

USERS_CATEGORY

public static final java.lang.String USERS_CATEGORY
Category associated to users;

See Also:
Constant Field Values

LOGIN

static final java.lang.String LOGIN
Login field

See Also:
Constant Field Values

PASSWORD

static final java.lang.String PASSWORD
Password field

See Also:
Constant Field Values

FIRST_NAME

static final java.lang.String FIRST_NAME
First name field

See Also:
Constant Field Values

LAST_NAME

static final java.lang.String LAST_NAME
First name field

See Also:
Constant Field Values

EMAIL

static final java.lang.String EMAIL
First name field

See Also:
Constant Field Values

ROLES

static final java.lang.String ROLES
First name field

See Also:
Constant Field Values

PERMISSIONS

static final java.lang.String PERMISSIONS
First name field

See Also:
Constant Field Values
Constructor Detail

User

User(SecurityContext sctx,
     Content content)
Main constructor

Parameters:
sctx - The parent scurity context
id - The user identifier
Method Detail

toString

public java.lang.String toString()
String representation of a User object

Overrides:
toString in class java.lang.Object
Returns:
A String representation

getProject

public Project getProject()
Returns the user's project

Returns:

getContent

public Content getContent()
Returns the wrapped content

Returns:

getId

public java.lang.String getId()
Returns the user's identifier

Returns:
The String that identifies the user

setLogin

void setLogin(java.lang.String login)
Sets the user login

Parameters:
login -

setPassword

void setPassword(java.lang.String password)
Sets the user password

Parameters:
password -

setFirstName

public void setFirstName(java.lang.String name)
Sets the user first id

Parameters:
firstName -

getLogin

public java.lang.String getLogin()
Returns the user's login

Returns:

getFirstName

public java.lang.String getFirstName()
Returns the user first id

Returns:
The user first id

getLastName

public java.lang.String getLastName()
Returns the user last id

Returns:
The user last id

setLastName

public void setLastName(java.lang.String lastName)
Sets the user last id

Parameters:
lastName - The last id to set

getEmail

public java.lang.String getEmail()
Returns the user email

Returns:
The user email address

setEmail

public void setEmail(java.lang.String email)
Sets the user email

Parameters:
email - The new user email address

addRole

void addRole(Role role)
Adds a role to the user

Parameters:
role - The role to add

addRole

void addRole(java.lang.String role)
Adds a role to the user, known its identifier

Parameters:
role - The role identifier

addRoles

void addRoles(java.lang.String roles)
Adds a role list to the user, given a CSV String of role identifiers

Parameters:
roles - A CSV String of role identifiers

addRole

public void addRole(User actor,
                    java.lang.String role)
             throws SCMSecurityException
Adds a role to the user, known its identifier

Parameters:
actor - The User who adds the Role
role - The role identifier
Throws:
SCMSecurityException

addRole

public void addRole(User actor,
                    Role role)
             throws SCMSecurityException
Adds a role to the user

Parameters:
actor - The User who adds the Role
role - The role to add
Throws:
SCMSecurityException

removeRole

void removeRole(Role role)
Removes a role from the user

Parameters:
role - The role to remove

removeRole

void removeRole(java.lang.String role)
Removes a user's role

Parameters:
role - The role identifier

removeRole

public void removeRole(User actor,
                       Role role)
                throws SCMSecurityException
Removes a role from the user

Parameters:
actor - The User who removes the Role
role - The role to remove
Throws:
SCMSecurityException

removeRole

public void removeRole(User actor,
                       java.lang.String role)
                throws SCMSecurityException
Removes a role from the user, known its identifier

Parameters:
actor - The User who removes the Role
role - The role identifier
Throws:
SCMSecurityException

hasRole

public boolean hasRole(java.lang.String role)
Checks that the user has a role

Parameters:
role - The role identifier
Returns:
True if the user has the specified role

hasRole

public boolean hasRole(Role role)
Checks that the user has a role

Parameters:
role - The role
Returns:
True if the user has the specified role

getRoles

public java.util.List getRoles()
Return the user role list

Returns:
An unmodifiable list with the user roles

getAllPermissions

java.util.List getAllPermissions()
Returns all the user permissions

Returns:

hasPermission

boolean hasPermission(Permission permission)
Checks whether the user has a permission or not

Overrides:
hasPermission in class PermissionAggregator
Parameters:
permission - The permission to check
Returns:
True if the user has the permission

getRolesAsString

public java.lang.String getRolesAsString()
Returns the user's role list as a String

Returns:
A CSV String of role identifiers

save

public void save()
          throws SCMStorageException
Saves the user info

Parameters:
actor - The user that saves
Throws:
SCMSecurityException - If the actor cannot save the user
SCMStorageException

save

public void save(User actor)
          throws SCMStorageException,
                 SCMSecurityException
Saves the user info

Parameters:
actor - The user that saves
Throws:
SCMSecurityException - If the actor cannot save the user
SCMStorageException

changePassword

public void changePassword(User actor,
                           java.lang.String newPassword)
                    throws SCMSecurityException
Use this method to change password. Users can only modify their own passwords

Parameters:
actor -
newPassword -
Throws:
SCMSecurityException

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Sets a user property

Parameters:
name - The property name
value - The property value

getProperty

public java.lang.String getProperty(java.lang.String name)
Returns a user property value

Parameters:
name - The property name
Returns:
The property value

remove

public void remove(User actor)
            throws SCMException
Revome the user

Parameters:
actor - User that removes the user
Throws:
SCMException

getSubscriptions

public java.util.List getSubscriptions()
                                throws SCMStorageException
Returns the list of subscriptions (a list of Subscription)

Returns:
Throws:
SCMStorageException

addRelatedContent

public void addRelatedContent(Content content)
                       throws SCMStorageException
This methods adds a related content to the User

Parameters:
content -
Throws:
SCMStorageException

removeRelatedContent

public void removeRelatedContent(Content relatedContent)
                          throws SCMStorageException
Removes a related content to the User

Parameters:
relatedContent -
Throws:
SCMStorageException

getReferencingContents

public java.util.List getReferencingContents(User user,
                                             java.lang.String ctype,
                                             java.lang.String fieldName,
                                             boolean visible)
                                      throws java.io.IOException,
                                             SCMException
Returns the contents of a given type that reference this User in the specified field.

Parameters:
ctype - The type of the requested contents
fieldName - The field id that references this content's type
visible - True to filter non visible contents
Returns:
The results
Throws:
java.io.IOException - If there's an IO problem
SCMException

getRelatedContents

public java.util.List getRelatedContents(User user,
                                         boolean visible)
                                  throws SCMStorageException,
                                         SCMSecurityException
Returns all the contents related for this User

Parameters:
user - The user who requests the related contents
Returns:
Throws:
SCMStorageException
SCMSecurityException

getContentsRelatedToContent

public java.util.List getContentsRelatedToContent(User user,
                                                  boolean visible)
                                           throws SCMStorageException,
                                                  SCMSecurityException
Returns all the contents who are related to this User

Parameters:
user - The user who requests the related contents
Returns:
Throws:
SCMStorageException
SCMSecurityException

hasAddNewPermission

public boolean hasAddNewPermission(ContentType ctype)
Description copied from class: PermissionAggregator
Checks whether the aggregator can create new contents of the given type

Overrides:
hasAddNewPermission in class PermissionAggregator

hasAdminProjectPermission

public boolean hasAdminProjectPermission()
Description copied from class: PermissionAggregator
Checks that the user can manage the project (Manage Roles and Users)

Overrides:
hasAdminProjectPermission in class PermissionAggregator
Returns:

hasDeletePermission

public boolean hasDeletePermission(Category cat)
Description copied from class: PermissionAggregator
Checks whether the aggregator can remove a category

Overrides:
hasDeletePermission in class PermissionAggregator
Returns:

hasDeletePermission

public boolean hasDeletePermission(ContentType ctype)
Description copied from class: PermissionAggregator
Checks whether the aggregator can delete that content type

Overrides:
hasDeletePermission in class PermissionAggregator

hasModifyPermission

public boolean hasModifyPermission(Category cat)
Description copied from class: PermissionAggregator
Checks whether the aggregator can modify a category

Overrides:
hasModifyPermission in class PermissionAggregator
Returns:

hasModifyPermission

public boolean hasModifyPermission(ContentType ctype)
Description copied from class: PermissionAggregator
Checks whether the aggregator can modify that content type

Overrides:
hasModifyPermission in class PermissionAggregator

hasViewPermission

public boolean hasViewPermission(Category cat)
Description copied from class: PermissionAggregator
Checks whether the aggregator can view a category

Overrides:
hasViewPermission in class PermissionAggregator
Returns:

hasViewPermission

public boolean hasViewPermission(ContentType ctype)
Description copied from class: PermissionAggregator
Checks whether the aggregator can view that content type

Overrides:
hasViewPermission in class PermissionAggregator


Copyright null null. All Rights Reserved.