public class RegexSuffixSubjectMapper extends java.lang.Object implements 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).
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).
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 and Description |
|---|
RegexSuffixSubjectMapper() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
mapSubject(java.lang.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 as
RegexSuffixSubjectMapper's do not utilise data from the GlobalContext. |
java.lang.String |
toString() |
void |
updateMappings(java.lang.String identifier,
java.util.Map<java.lang.String,java.lang.String> updateMap)
You do not call this method directly; it is called when you invoke
User.addSubjectMapping(String, Map)
on a User that is using this type of SubjectMapper class. |
public java.lang.String mapSubject(java.lang.String subject)
subject passed in) is described in the description at the top of this class' documentation.mapSubject in interface SubjectMappersubject - the subject to be mappedsubject is mapped to, or null is this SubjectMapper does not map the passed in subjectpublic void setGlobalContext(GlobalContext globalContext)
RegexSuffixSubjectMapper's do not utilise data from the GlobalContext.setGlobalContext in interface SubjectMapperglobalContext - public void updateMappings(java.lang.String identifier,
java.util.Map<java.lang.String,java.lang.String> updateMap)
You do not call this method directly; it is called when you invoke User.addSubjectMapping(String, Map)
on a User that is using this type of SubjectMapper class.
updateMappings in interface SubjectMapperidentifier - the identifier used to store the updateMap 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 to mapSubject.SubjectMapper.updateMappings(String, Map)public java.lang.String toString()
toString in class java.lang.ObjectPlease send bug reports and comments to Caplin support