Class RegexSuffixSubjectMapper
- All Implemented Interfaces:
SubjectMapper
This implementation of the SubjectMapper
interface maps subjects in the same manner as the default SubjectMapper
(see the section on Mapping Logic, below),
but unlike the default SubjectMapper
it permits multiple mappings to be added to it.
To use this SubjectMapper
you must call User.setSubjectMapper
, passing in the String value
com.caplin.permissioning.RegexSuffixSubjectMapper
(this class' fully qualified name).
Data Passed to RegexSuffixSubjectMapper
To pass mapping data to instances of this class you must use the User.addSubjectMapping
method, just as you would for any other custom
SubjectMapper
implementation.
The subject mappings that are passed into the mapper will have been aggregated by their identifier when they are added on the User
. Subsequently, for a given identifier,
the mappings for keys passed in earlier to User.addSubjectMapping
are overwritten by mappings with duplicate keys that are passed in later.
The identifier is not used for mapping purposes: it is only used for the purpose of identifying mappings for the sake of overwriting older mappings with newer mappings and
removal of mappings by key (which can be performed by calling methods on the User
).
Mapping Logic
The mapSubject(String)
method maps an RTTP subject if the subject
passed to it matches one of the patterns (one of the keys) in the maps
that have been passed to updateMappings
(which receives the data that is passed in to User.addSubjectMapping
). If a match is found, the value that the
matching pattern maps to in the stored mappings is appended to the passed in subject
to produce the subject that it is mapped to. If no matching pattern is found, this
SubjectMapper
returns null
to indicate the passed in subject
is not mapped.
When mapSubject
is called, the order that the mappings are checked against the passed in subject
is not predictable. You should not
count on the order that you add the mappings to be the order that they are checked for a match.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionmapSubject
(String subject) You do not call this method directly; it is called in the Permissioning Auth Module to map objects each time a new RTTP object is requested or contributed to.void
setGlobalContext
(GlobalContext globalContext) This method is a no-op asRegexSuffixSubjectMapper
's do not utilise data from theGlobalContext
.toString()
void
updateMappings
(String identifier, Map<String, String> updateMap) You do not call this method directly; it is called when you invokeUser.addSubjectMapping(String, Map)
on aUser
that is using this type ofSubjectMapper
class.
-
Constructor Details
-
RegexSuffixSubjectMapper
public RegexSuffixSubjectMapper()
-
-
Method Details
-
mapSubject
You do not call this method directly; it is called in the Permissioning Auth Module to map objects each time a new RTTP object is requested or contributed to. The behaviour of this method (how it maps thesubject
passed in) is described in the description at the top of this class' documentation.- Specified by:
mapSubject
in interfaceSubjectMapper
- Parameters:
subject
- the subject to be mapped- Returns:
- the subject that the passed in
subject
is mapped to, or null is thisSubjectMapper
does not map the passed insubject
-
setGlobalContext
This method is a no-op asRegexSuffixSubjectMapper
's do not utilise data from theGlobalContext
.- Specified by:
setGlobalContext
in interfaceSubjectMapper
- Parameters:
globalContext
-
-
updateMappings
You do not call this method directly; it is called when you invoke
User.addSubjectMapping(String, Map)
on aUser
that is using this type ofSubjectMapper
class.- Specified by:
updateMappings
in interfaceSubjectMapper
- Parameters:
identifier
- the identifier used to store theupdateMap
mappings .updateMap
- The keys from the mappings will be used to create regexp patterns and the values they map to will be used as the mapped subjects' suffixes when a regexp matches the subject passed in tomapSubject
.- See Also:
-
toString
-