Package com.caplin.permissioning
Class User
java.lang.Object
com.caplin.permissioning.Permissionable
com.caplin.permissioning.User
Represents a permissioned user that is able to log on to Caplin Trader.
Note: The default password associated with a user is the reserved value
Constants.KEYMASTER. The reserved value is not actually a password - it is an indicator that the password is
not needed here as it is verified by the Caplin Keymaster. In this case verification of the SSO keymaster token is
sufficient to determine that this user is authenticated. See the Caplin Trader Architecture document for more
information.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected SubjectMapperprotected final com.caplin.permissioning.SubjectMappingInfoFields inherited from class com.caplin.permissioning.Permissionable
name, parents, productPermissionSets -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSubjectMapping(String key, Map<String, String> map) Adds subject mappping data for use by aUser'sSubjectMapperinstance.protected voidgetAttribute(String name) Get an attribute that has been set by an earlier call tosetAttribute(String, String).Get the name of every attribute that has been set on this userGet thisUser's password.Gets the class that implements theSubjectMapperinterface for thisUser.isPermitted(String action, String requestedProduct, String permissionNameSpace) Check if theUseris authorised to perform action in that permissionNameSpace on the specified product.voidRemoves all subject mappings for thisUser, regardless of the method was used to add them.removeAttribute(String name) Removes the named attribute from this user.Removes the subject mappings identified by the passed inkey.setAttribute(String name, String value) Sets an attribute on this user.voidsetPassword(String password) Set thisUser's password.voidSets thisUser's password field to indicate that aKeyMastertoken (as opposed to a text password) should be used to authenticate this user.voidsetSubjectMapper(String subjectMapperClassName) Sets the class that implements theSubjectMapperinterface for thisUser.toString()Returns a string representation ofUser.Methods inherited from class com.caplin.permissioning.Permissionable
applyPermission, copyPermissions, deny, equals, getName, hashCode, permit, removeAllPermissions, removePermission
-
Field Details
-
attributes
-
password
-
subjectMapper
-
subjectMappingInfo
protected final com.caplin.permissioning.SubjectMappingInfo subjectMappingInfo
-
-
Method Details
-
getPassword
Get thisUser's password. If the valueConstants.KEYMASTERis returned this indicates that thisUseris authenticated using aKeyMastertoken. If any other value is returned it is the actual password text that thisUserauthenticates with theLiberator.- Returns:
- The password string.
- Throws:
IllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
setPassword
Set thisUser's password. If the valueConstants.KEYMASTERis passed as a parameter it indicates that thisUseris authenticated using aKeyMastertoken. If any other value is passed in it is the actual password text that thisUserauthenticates with in theLiberator. It is recommended that if aKeyMastertoken is used then thesetPasswordKeymaster()method is used as it is coded to provide the special (reserved) stringkeymasterto this method.Note: Only a master
PermissioningDataSourcecan set theUser's password.- Parameters:
password- The password string.- Throws:
NoTransactionInProgressException- if this method is called outside the scope of aPermissioningDataSourcetransaction.IllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
setPasswordKeymaster
Sets thisUser's password field to indicate that aKeyMastertoken (as opposed to a text password) should be used to authenticate this user.- Throws:
NoTransactionInProgressException- if this method is called outside the scope of aPermissioningDataSourcetransaction.IllegalStateException- if thisUserwas removed from thePermissioningDatasource.Note: Only a master
PermissioningDataSourcecan set theUser's password.
-
getAttribute
Get an attribute that has been set by an earlier call tosetAttribute(String, String).- Parameters:
name- The name of the attribute to set on this user.- Returns:
- The attribute value stored against this name or
nullif such an named attribute has not been set. - Throws:
IllegalStateException- if thisUserwas removed from thePermissioningDatasource.- See Also:
-
setAttribute
public String setAttribute(String name, String value) throws NoTransactionInProgressException, IllegalArgumentException Sets an attribute on this user. This can be useful, for example, for setting user-level preferences that the GUI can act upon. The internal implementation of attributes is aMap, therefore if you call this method with the samenameparameter twice, the second value overwrites the first set call.- Parameters:
name- The name of the attribute to set on this user.value- The value of the attribute to set on this user.- Returns:
- The previous value of this attribute, or
nullif this is the first time this attribute has been set. - Throws:
IllegalArgumentException- if either or both of the parameters passed to this method arenull.NoTransactionInProgressException- if this method is called outside the scope of aPermissioningDataSourcetransaction.IllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
isPermitted
public Authorization isPermitted(String action, String requestedProduct, String permissionNameSpace) Check if theUseris authorised to perform action in that permissionNameSpace on the specified product. This method checks theUsers own permissions and also any inherited permissions from recursively checked parent groups.- Parameters:
action- The action the user is attempting to perform on the specified product.requestedProduct- The item to check for action on.permissionNameSpace- The permissionNameSpace to check for the attempted action.- Returns:
- the authorisation code representing if this
Useris permitted to perform the operation described by the parameters to this method. - Throws:
IllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
addSubjectMapping
Adds subject mappping data for use by aUser'sSubjectMapperinstance. The data is stored in theUserand sent to the Auth Module where it will be applied to theSubjectMapperinstance using itsupdateMappingsmethod.- Parameters:
key- The key associated with the subject mappings.map- The subject mappings.- Throws:
NoTransactionInProgressException- if this method is called outside the scope of aPermissioningDataSourcetransaction.IllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
getAttributeNames
Get the name of every attribute that has been set on this user- Returns:
- The set of attribute names for this user.
- Throws:
IllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
removeAttribute
public String removeAttribute(String name) throws NoTransactionInProgressException, IllegalArgumentException Removes the named attribute from this user. CallinggetAttribute(java.lang.String)after this method has been called using the sameattributeNamewill returnnull. TheattributeNamewill no longer be present in the set of attribute names return bygetAttributeNames().This method cannot be used to unset a password attribute. The
setPassword(String)orsetPasswordKeymaster()methods must be used to change thisUser's password.- Parameters:
name- The name of the attribute to to be removed from thisUser's set of attrbutes.- Returns:
- The previous value of this attribute, or
nullif this attribute has not been set. - Throws:
IllegalArgumentException- if the parameter passed to this method isnullor identifies the password attribute.NoTransactionInProgressException- if this method is called outside the scope of aPermissioningDataSourcetransactionIllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
removeSubjectMappingForKey
Removes the subject mappings identified by the passed inkey. This method only removes the subject mappings if they were added usingaddSubjectMapping(String, Map).- Returns:
- The removed subject mappings, or
nullif no mappings were removed. - Throws:
NoTransactionInProgressException- if this method is called outside the scope of aPermissioningDataSourcetransactionIllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
removeAllSubjectMappings
public void removeAllSubjectMappings()Removes all subject mappings for thisUser, regardless of the method was used to add them.- Throws:
NoTransactionInProgressException- if this method is called outside the scope of aPermissioningDataSourcetransactionIllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
setSubjectMapper
Sets the class that implements theSubjectMapperinterface for thisUser. The implementation of this interface must be available to the Auth Module at the Libertor but does not need to be available to thePermissioningDataSource. If you do not set a class, then the Auth Module will use the defaultSubjectMapperto determine the subject mappings for thisUser.- Parameters:
subjectMapperClassName- The fully qualified name of the class that implements theSubjectMapperinterface.- Throws:
NoTransactionInProgressException- if this method is called outside the scope of aPermissioningDataSourcetransaction.IllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
getSubjectMapper
Gets the class that implements theSubjectMapperinterface for thisUser.- Returns:
- The fully qualified name of the class that implements the
SubjectMapperinterface. If a class was not set usingsetSubjectMapper(String), then the returned name will be for the defaultSubjectMapper. - Throws:
IllegalStateException- if thisUserwas removed from thePermissioningDatasource.
-
createSubjectMapper
protected void createSubjectMapper() -
toString
Returns a string representation ofUser.
-