Class User
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
Modifier and TypeFieldDescriptionprotected String
protected SubjectMapper
protected final com.caplin.permissioning.SubjectMappingInfo
Fields inherited from class com.caplin.permissioning.Permissionable
name, parents, productPermissionSets
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSubjectMapping
(String key, Map<String, String> map) Adds subject mappping data for use by aUser
'sSubjectMapper
instance.protected void
getAttribute
(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 theSubjectMapper
interface for thisUser
.isPermitted
(String action, String requestedProduct, String permissionNameSpace) Check if theUser
is authorised to perform action in that permissionNameSpace on the specified product.void
Removes 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.void
setPassword
(String password) Set thisUser
's password.void
Sets thisUser
's password field to indicate that aKeyMaster
token (as opposed to a text password) should be used to authenticate this user.void
setSubjectMapper
(String subjectMapperClassName) Sets the class that implements theSubjectMapper
interface 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.KEYMASTER
is returned this indicates that thisUser
is authenticated using aKeyMaster
token. If any other value is returned it is the actual password text that thisUser
authenticates with theLiberator
.- Returns:
- The password string.
- Throws:
IllegalStateException
- if thisUser
was removed from thePermissioningDatasource
.
-
setPassword
Set thisUser
's password. If the valueConstants.KEYMASTER
is passed as a parameter it indicates that thisUser
is authenticated using aKeyMaster
token. If any other value is passed in it is the actual password text that thisUser
authenticates with in theLiberator
. It is recommended that if aKeyMaster
token is used then thesetPasswordKeymaster()
method is used as it is coded to provide the special (reserved) stringkeymaster
to this method.Note: Only a master
PermissioningDataSource
can set theUser
's password.- Parameters:
password
- The password string.- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transaction.IllegalStateException
- if thisUser
was removed from thePermissioningDatasource
.
-
setPasswordKeymaster
Sets thisUser
's password field to indicate that aKeyMaster
token (as opposed to a text password) should be used to authenticate this user.- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transaction.IllegalStateException
- if thisUser
was removed from thePermissioningDatasource
.Note: Only a master
PermissioningDataSource
can 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
null
if such an named attribute has not been set. - Throws:
IllegalStateException
- if thisUser
was 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 samename
parameter 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
null
if 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 aPermissioningDataSource
transaction.IllegalStateException
- if thisUser
was removed from thePermissioningDatasource
.
-
isPermitted
public Authorization isPermitted(String action, String requestedProduct, String permissionNameSpace) Check if theUser
is authorised to perform action in that permissionNameSpace on the specified product. This method checks theUser
s 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
User
is permitted to perform the operation described by the parameters to this method. - Throws:
IllegalStateException
- if thisUser
was removed from thePermissioningDatasource
.
-
addSubjectMapping
Adds subject mappping data for use by a
User
'sSubjectMapper
instance. The data is stored in theUser
and sent to the Auth Module where it will be applied to theSubjectMapper
instance using itsupdateMappings
method.- Parameters:
key
- The key associated with the subject mappings.map
- The subject mappings.- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transaction.IllegalStateException
- if thisUser
was 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 thisUser
was 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 sameattributeName
will returnnull
. TheattributeName
will 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
null
if this attribute has not been set. - Throws:
IllegalArgumentException
- if the parameter passed to this method isnull
or identifies the password attribute.NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transactionIllegalStateException
- if thisUser
was 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
null
if no mappings were removed. - Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transactionIllegalStateException
- if thisUser
was 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 aPermissioningDataSource
transactionIllegalStateException
- if thisUser
was removed from thePermissioningDatasource
.
-
setSubjectMapper
Sets the class that implements theSubjectMapper
interface 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 defaultSubjectMapper
to determine the subject mappings for thisUser
.- Parameters:
subjectMapperClassName
- The fully qualified name of the class that implements theSubjectMapper
interface.- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transaction.IllegalStateException
- if thisUser
was removed from thePermissioningDatasource
.
-
getSubjectMapper
Gets the class that implements theSubjectMapper
interface for thisUser
.- Returns:
- The fully qualified name of the class that implements the
SubjectMapper
interface. If a class was not set usingsetSubjectMapper(String)
, then the returned name will be for the defaultSubjectMapper
. - Throws:
IllegalStateException
- if thisUser
was removed from thePermissioningDatasource
.
-
createSubjectMapper
protected void createSubjectMapper() -
toString
Returns a string representation ofUser
.
-