public class DefaultGlobalContext extends java.lang.Object implements GlobalContext
This class implements the GlobalContext
interface and is already deployed at the Permissioning Auth Module.
The methods of this class allow the Permissioning Auth Module to add data to the GlobalContext
and to remove data from the GlobalContext
. A custom
SubjectMapper
can also call one of the get()
methods of this class to retrieve data from the GlobalContext
.
You can also write a custom class that extends DefaultGlobalContext
to provide additional methods that a custom SubjectMapper
can call. If you write
a custom GlobalContext
, the class must be available on the classpath of the Permissioning Auth Module. It does not need to be deployed on the classpath of the
PermissioningDataSource
, as the PermissioningDataSource
never loads the GlobalContext
.
The document Caplin Xaqua: How To Create A Permissioning DataSource describes how to write, deploy, and configure a custom GlobalContext
, and is included in the
Permissioning DataSource kit.
Note that there is only one GlobalContext
at the Permissioning Auth Module, either the DefaultGlobalContext
or a custom GlobalContext
, and it
is shared by every PermissioningDataSource
. Therefore if you have more than one PermissioningDataSource
, make sure they do not overwrite each other's data.
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
data
|
Constructor and Description |
---|
DefaultGlobalContext()
Creates a new empty
DefaultGlobalContext . |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.String> |
get(java.lang.String identifier)
Returns the
Map of key-value pairs that are saved for the passed in identifier . |
java.lang.String |
get(java.lang.String identifier,
java.lang.String key)
Returns the value that is saved for the passed in
identifier and key . |
void |
remove(java.lang.String identifier)
Removes from the
GlobalContext , the passed in identifier and the Map of key-value pairs for that identifier . |
void |
update(java.lang.String identifier,
java.util.Map<java.lang.String,java.lang.String> data)
Saves the passed in
identifier and data , and makes the data available to the get() methods of this interface. |
protected final java.util.concurrent.ConcurrentMap<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> data
public DefaultGlobalContext()
DefaultGlobalContext
.public void update(java.lang.String identifier, java.util.Map<java.lang.String,java.lang.String> data)
Saves the passed in identifier
and data
, and makes the data available to the get()
methods of this interface.
If data has already been saved for this identifier
, the method adds the key-value pairs in data
to the saved data. If a key in data
has
already been saved for this identifier
, the new value for the key replaces the old value.
The method is called by the Permissioning Auth Module when data for the GlobalContext
is received from a
PermissioningDataSource
. A PermissioningDataSource
sends the identifier
and data
to the Permissioning Auth Module when it calls updateGlobalContext()
as part of a transaction.
update
in interface GlobalContext
identifier
- A String
that identifies the passed in data
.data
- A Map
of key-value pairs for the passed in identifier
.public java.util.Map<java.lang.String,java.lang.String> get(java.lang.String identifier)
Returns the Map
of key-value pairs that are saved for the passed in identifier
. This method is typically called by the
mapSubject()
method of a custom SubjectMapper
.
get
in interface GlobalContext
identifier
- A String
that identifies the Map
to be returned.Map
of key-value pairs for the passed in identifier
, or null
if no Map
has been saved for this identifier
.public java.lang.String get(java.lang.String identifier, java.lang.String key)
Returns the value that is saved for the passed in identifier
and key
. This method is typically called by the
mapSubject()
method of a custom SubjectMapper
.
A call to this method is equivalent to calling get(identifier)
, and then calling get(key)
on the returned
Map
of key-value pairs.
get
in interface GlobalContext
identifier
- A String
that identifies the Map
of key-value pairs.key
- A key that identifies the value to be returned.identifier
and key
, or null
if no value has been saved for this identifier
and key
.public void remove(java.lang.String identifier)
Removes from the GlobalContext
, the passed in identifier
and the Map
of key-value pairs for that identifier
. This method
is called by the Permissioning Auth Module when a PermissioningDataSource
calls
removeGlobalContextData()
as part of a transaction.
The method does not remove any data from the GlobalContext if there is no Map for this identifier.
remove
in interface GlobalContext
identifier
- A String
that identifies the Map
to be removedPlease send bug reports and comments to Caplin support