com.sas.drugdev.remote.admin
Class UserBean

java.lang.Object
  extended by com.sas.drugdev.remote.admin.UserBean
All Implemented Interfaces:
User

public class UserBean
extends java.lang.Object
implements User

Simple bean to represent a user. This can be constructed various ways. This class allows the user to construct a User without requiring a server call.

It is the only way to create a User on the server. Construct a UserBean, then pass it into UserService.create(UserBean). If creating a user to authenticate via an external authentication provider, when setting the authentication provider, the name should be the name as it appears in the configuration file on the server.

In order to successfully create a user in SDD, you must set values for the following properties. Note that PROPERTY_PASSWORD is required even if using an external authentication provider as the provider can be changed to SDD. It is also the only means for performing write operations on the User, such as updating policies and personal information. Construct a UserBean object then call addPolicy(Policy), removePolicy(Policy) or setLastName(String) method. Then pass that bean into UserService.update(UserBean) to perform those operations on the server side.


Field Summary
static java.util.Set EDITABLE_PROPERTIES
           
static java.lang.String PROPERTY_AUTHENTICATION_PROVIDER
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_AUTHENTICATION_PROVIDER_USERID
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_CERTIFICATE
           
static java.lang.String PROPERTY_CERTIFICATEDATE
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_CITY
           
static java.lang.String PROPERTY_COMPANY
           
static java.lang.String PROPERTY_CONSENT
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_COUNTRY
           
static java.lang.String PROPERTY_CREATEDATE
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_CREATEDBY
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_DEPARTMENT
           
static java.lang.String PROPERTY_EMAILADDRESS
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_EMPLOYEEID
           
static java.lang.String PROPERTY_FAX
           
static java.lang.String PROPERTY_FIRSTNAME
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_IMAGEURL
           
static java.lang.String PROPERTY_LASTLOGIN
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_LASTMODIFIED
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_LASTNAME
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_LOGIN_ATTEMPTS
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_LOGINS
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_MIDDLENAME
           
static java.lang.String PROPERTY_MOBILE
           
static java.lang.String PROPERTY_MODIFIEDBY
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_OFFICE
           
static java.lang.String PROPERTY_PAGER
           
static java.lang.String PROPERTY_PASSWORDDATE
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_PASSWORDRESET
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_PHONE
           
static java.lang.String PROPERTY_POSTALCODE
           
static java.lang.String PROPERTY_SALUTATION
           
static java.lang.String PROPERTY_STATE
           
static java.lang.String PROPERTY_STATUS
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_STATUSDATE
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_STATUSREASON
          Should not pass to UserService.update(UserBean)
static java.lang.String PROPERTY_STREET
           
static java.lang.String PROPERTY_TITLE
           
static java.lang.String PROPERTY_USERID
          Should not pass to UserService.update(UserBean)
static java.util.Set SYSTEM_PROPERTIES
           
 
Constructor Summary
UserBean(RemoteUser remoteUser)
          Constructor that takes a RemoteUser.
UserBean(java.lang.String userId)
          Constructor that takes only a userId
 
Method Summary
 void addPolicies(java.util.List policies)
          Adds the SDD policies to this user.
 void addPolicy(Policy policy)
          Adds the SDD policy to this user.
 java.lang.String getAuthenticationProvider()
          Gets the name of the authentication provider for this user.
 java.lang.String getAuthenticationProviderUserId()
          Gets the userId associated with this user that is defined in the external authentication provider.
 java.lang.String getEmailAddress()
          Get the email address of this user in SDD
 java.lang.String getFirstName()
          Get the first name of this user in SDD
 java.lang.String getLastName()
          Get the last name of this user in SDD
 boolean getPasswordReset()
          Sets whether the password should be reset.
 java.util.List getPolicies()
          Get the policies assigned to this user in SDD.
 java.util.Map getProperties()
          Get all properties of this user in SDD except policies
 java.lang.String getReason()
           
 java.lang.String getUserId()
          Get the userId of this user as defined within SDD
 boolean isActive()
          returns the active status of the user
 boolean isRetired()
          returns whether the user is retired or not
 void removePolicies(java.util.List policies)
          Removes the list of SDD policies from this user.
 void removePolicy(Policy policy)
          Removes the SDD policy from this user.
 void retire(java.lang.String reason)
          Retires the user.
 void setActive(boolean active, java.lang.String reason)
          Sets the active status of the user
 void setAuthenticationProvider(java.lang.String authenticationprovider)
          Sets the default authentication provider for this user.
 void setAuthenticationProviderUserId(java.lang.String providerUserId)
          Sets the providerUserId associated with this user as it is defined in the external authentication provider.
 void setEmailAddress(java.lang.String email)
          Sets the email address of this user.
 void setFirstName(java.lang.String firstName)
          Sets the first name of this user.
 void setLastName(java.lang.String lastName)
          Sets the last name of this user.
 void setPassword(char[] password)
          Sets the SDD password for this user.
 void setPasswordReset(boolean passwordReset)
          Set whether the user will be required to reset their password.
 void setPolicies(java.util.List policies)
          Sets the SDD policies for this user.
 void setProperties(java.util.Map properties)
          Set all the properties contained in the map.
 void setProperty(java.lang.String name, java.lang.Object value)
          Set the property with the given name to the given value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_MIDDLENAME

public static final java.lang.String PROPERTY_MIDDLENAME
See Also:
Constant Field Values

PROPERTY_SALUTATION

public static final java.lang.String PROPERTY_SALUTATION
See Also:
Constant Field Values

PROPERTY_IMAGEURL

public static final java.lang.String PROPERTY_IMAGEURL
See Also:
Constant Field Values

PROPERTY_EMPLOYEEID

public static final java.lang.String PROPERTY_EMPLOYEEID
See Also:
Constant Field Values

PROPERTY_COMPANY

public static final java.lang.String PROPERTY_COMPANY
See Also:
Constant Field Values

PROPERTY_TITLE

public static final java.lang.String PROPERTY_TITLE
See Also:
Constant Field Values

PROPERTY_DEPARTMENT

public static final java.lang.String PROPERTY_DEPARTMENT
See Also:
Constant Field Values

PROPERTY_OFFICE

public static final java.lang.String PROPERTY_OFFICE
See Also:
Constant Field Values

PROPERTY_STREET

public static final java.lang.String PROPERTY_STREET
See Also:
Constant Field Values

PROPERTY_CITY

public static final java.lang.String PROPERTY_CITY
See Also:
Constant Field Values

PROPERTY_STATE

public static final java.lang.String PROPERTY_STATE
See Also:
Constant Field Values

PROPERTY_POSTALCODE

public static final java.lang.String PROPERTY_POSTALCODE
See Also:
Constant Field Values

PROPERTY_COUNTRY

public static final java.lang.String PROPERTY_COUNTRY
See Also:
Constant Field Values

PROPERTY_PHONE

public static final java.lang.String PROPERTY_PHONE
See Also:
Constant Field Values

PROPERTY_FAX

public static final java.lang.String PROPERTY_FAX
See Also:
Constant Field Values

PROPERTY_PAGER

public static final java.lang.String PROPERTY_PAGER
See Also:
Constant Field Values

PROPERTY_MOBILE

public static final java.lang.String PROPERTY_MOBILE
See Also:
Constant Field Values

PROPERTY_CERTIFICATE

public static final java.lang.String PROPERTY_CERTIFICATE
See Also:
Constant Field Values

PROPERTY_EMAILADDRESS

public static final java.lang.String PROPERTY_EMAILADDRESS
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_FIRSTNAME

public static final java.lang.String PROPERTY_FIRSTNAME
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_LASTNAME

public static final java.lang.String PROPERTY_LASTNAME
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_AUTHENTICATION_PROVIDER

public static final java.lang.String PROPERTY_AUTHENTICATION_PROVIDER
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_AUTHENTICATION_PROVIDER_USERID

public static final java.lang.String PROPERTY_AUTHENTICATION_PROVIDER_USERID
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_USERID

public static final java.lang.String PROPERTY_USERID
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_PASSWORDRESET

public static final java.lang.String PROPERTY_PASSWORDRESET
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_CREATEDATE

public static final java.lang.String PROPERTY_CREATEDATE
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_CREATEDBY

public static final java.lang.String PROPERTY_CREATEDBY
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_LASTMODIFIED

public static final java.lang.String PROPERTY_LASTMODIFIED
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_MODIFIEDBY

public static final java.lang.String PROPERTY_MODIFIEDBY
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_PASSWORDDATE

public static final java.lang.String PROPERTY_PASSWORDDATE
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_CERTIFICATEDATE

public static final java.lang.String PROPERTY_CERTIFICATEDATE
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_STATUSDATE

public static final java.lang.String PROPERTY_STATUSDATE
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_CONSENT

public static final java.lang.String PROPERTY_CONSENT
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_LOGIN_ATTEMPTS

public static final java.lang.String PROPERTY_LOGIN_ATTEMPTS
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_LOGINS

public static final java.lang.String PROPERTY_LOGINS
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_LASTLOGIN

public static final java.lang.String PROPERTY_LASTLOGIN
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_STATUS

public static final java.lang.String PROPERTY_STATUS
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

PROPERTY_STATUSREASON

public static final java.lang.String PROPERTY_STATUSREASON
Should not pass to UserService.update(UserBean)

See Also:
Constant Field Values

SYSTEM_PROPERTIES

public static final java.util.Set SYSTEM_PROPERTIES

EDITABLE_PROPERTIES

public static final java.util.Set EDITABLE_PROPERTIES
Constructor Detail

UserBean

public UserBean(java.lang.String userId)
Constructor that takes only a userId

Parameters:
userId - userId with which to populate the UserBean

UserBean

public UserBean(RemoteUser remoteUser)
Constructor that takes a RemoteUser. This is useful for updating users. If a UserBean is constructed using a remote user, then checking is done on the server when a user is updated to ensure that it hasn't been modified since it was retrieved. All the properties from the remote user are copied into the properties of this bean.

Parameters:
remoteUser - remoteUser with which to populate the UserBean
Method Detail

getEmailAddress

public java.lang.String getEmailAddress()
Description copied from interface: User
Get the email address of this user in SDD

Specified by:
getEmailAddress in interface User
Returns:
The email address of this user within SDD

setEmailAddress

public void setEmailAddress(java.lang.String email)
                     throws InvalidEmailException
Sets the email address of this user. Required to successfully create a user on the server. The email address is not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
email - email address of this user
Throws:
InvalidEmailException - if email address is not valid

getFirstName

public java.lang.String getFirstName()
Description copied from interface: User
Get the first name of this user in SDD

Specified by:
getFirstName in interface User
Returns:
The first name of this user within SDD

setFirstName

public void setFirstName(java.lang.String firstName)
Sets the first name of this user. Required to successfully create a user on the server. The first name is not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
firstName - First name of this user

getLastName

public java.lang.String getLastName()
Description copied from interface: User
Get the last name of this user in SDD

Specified by:
getLastName in interface User
Returns:
The last name of this user within SDD

setLastName

public void setLastName(java.lang.String lastName)
Sets the last name of this user. Required to successfully create a user on the server. The last name is not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
lastName - Last name of this user

getUserId

public java.lang.String getUserId()
Description copied from interface: User
Get the userId of this user as defined within SDD

Specified by:
getUserId in interface User
Returns:
The userId of this user within SDD

getReason

public java.lang.String getReason()

getPolicies

public java.util.List getPolicies()
Description copied from interface: User
Get the policies assigned to this user in SDD. Returns an empty List if user has no policies.

Specified by:
getPolicies in interface User
Returns:
List of Policy objects

setPassword

public void setPassword(char[] password)
Sets the SDD password for this user. Required to successfully create a user on the server. The password is not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
password - char[] of this user's password

setPolicies

public void setPolicies(java.util.List policies)
Sets the SDD policies for this user. Passing null will set the user with no policies. The policies are not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
policies - List of SDD Policys to set on the user

addPolicy

public void addPolicy(Policy policy)
Adds the SDD policy to this user. If this user already has the policy, no action is taken. The policy is not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
policy - SDD Policy to add to the user

addPolicies

public void addPolicies(java.util.List policies)
Adds the SDD policies to this user. Only policies that the user does not have will be added. These policies are not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
policies - List of SDD Policys to add to the user

removePolicy

public void removePolicy(Policy policy)
Removes the SDD policy from this user. If the user does not have the policy, the users's policies are unchanged. The policy is not removed until you call UserService.update(UserBean).

Parameters:
policy - SDD Policy to remove from the user

removePolicies

public void removePolicies(java.util.List policies)
Removes the list of SDD policies from this user. If the user has any of the policies in the specified list, they are removed. Otherwise, they are ignored. These policies are not removed until you call UserService.update(UserBean).

Parameters:
policies - List of SDD Policys to remove from the user

setAuthenticationProvider

public void setAuthenticationProvider(java.lang.String authenticationprovider)
Sets the default authentication provider for this user. If not called, the default is SDD. The name of the provider as it is configured on the server should be passed here. The authentication provider is not set until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
authenticationprovider -

getAuthenticationProvider

public java.lang.String getAuthenticationProvider()
Description copied from interface: User
Gets the name of the authentication provider for this user. Default is sdd, otherwise will be the name of an external authentication provider.

Specified by:
getAuthenticationProvider in interface User
Returns:
name of authentication provider

getAuthenticationProviderUserId

public java.lang.String getAuthenticationProviderUserId()
Description copied from interface: User
Gets the userId associated with this user that is defined in the external authentication provider. If the authentication provider is sdd or if no provider userId has been specified, this will return null.

Specified by:
getAuthenticationProviderUserId in interface User
Returns:
userId as defined in external authentication provider

setAuthenticationProviderUserId

public void setAuthenticationProviderUserId(java.lang.String providerUserId)
Sets the providerUserId associated with this user as it is defined in the external authentication provider. If not set, the sdd userId is used. If the current authentication provider is sdd, this value is ignored. Otherwise, the providerUserId is used to authenticate against the external authenication provider. The authentication provider userId is not set until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
providerUserId - userId as defined in external authentication provider

setProperties

public void setProperties(java.util.Map properties)
Set all the properties contained in the map. These properties are added to the existing properties. Any properties that are already set on this user are replaced with those passed in. If any of the system properties are being set, they are ignored. These properties are not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
properties - map of properties with a String key and a String value

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Set the property with the given name to the given value. If it is a system property it is ignored. The property is not saved until you call UserService.update(UserBean) or UserService.create(UserBean).

Parameters:
name - name of the property to set
value - value of the property to set

getProperties

public java.util.Map getProperties()
Description copied from interface: User
Get all properties of this user in SDD except policies

Specified by:
getProperties in interface User
Returns:
An unmodifiable map of properties with a String key and String value

getPasswordReset

public boolean getPasswordReset()
Description copied from interface: User
Sets whether the password should be reset. Default is true. Determines if this user's password needs to be reset

Specified by:
getPasswordReset in interface User
Returns:
True if the user's password needs to be reset, otherwise false

setPasswordReset

public void setPasswordReset(boolean passwordReset)
Set whether the user will be required to reset their password. Default for new users is true.

Parameters:
passwordReset - true to require the user to reset their password, otherwise false

retire

public void retire(java.lang.String reason)
Retires the user. WARNING: Retiring an account is an irreversible act.

Parameters:
reason - reason for updating user status

setActive

public void setActive(boolean active,
                      java.lang.String reason)
Sets the active status of the user

Parameters:
active - true for active, false for inactive
reason - reason for updating user status

isActive

public boolean isActive()
returns the active status of the user

Specified by:
isActive in interface User
Returns:
true if active, false if inactive

isRetired

public boolean isRetired()
returns whether the user is retired or not

Specified by:
isRetired in interface User
Returns:
true if retired, false if not