Class DefaultSignServiceContext
java.lang.Object
se.swedenconnect.signservice.context.DefaultSignServiceContext
- All Implemented Interfaces:
Serializable
,SignServiceContext
Default implementation of the
SignServiceContext
interface.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultSignServiceContext
deserialize
(String encoding) Deserializes an encoding to aDefaultSignServiceContext
object.<T extends Serializable>
TGets a named data element from the context.<T extends Serializable>
TGets a named data element having a given type from the context.getId()
Gets the unique ID for the current operation.<T extends Serializable>
voidStores a data element in the context.<T extends Serializable>
voidRemoves the named element from the context.Serializes the context to its string representation/encoding.
-
Constructor Details
-
DefaultSignServiceContext
Constructor.- Parameters:
id
- the context ID
-
-
Method Details
-
getId
Gets the unique ID for the current operation. This ID should be included in all logs (process- and audit logs).- Specified by:
getId
in interfaceSignServiceContext
- Returns:
- the unique ID for the operation
-
put
Stores a data element in the context.- Specified by:
put
in interfaceSignServiceContext
- Type Parameters:
T
- the type of the element- Parameters:
name
- the unique name of the elementdata
- the element to store
-
get
Gets a named data element from the context.- Specified by:
get
in interfaceSignServiceContext
- Type Parameters:
T
- the type of the element- Parameters:
name
- the unique name of the element- Returns:
- the element, or null if no matching element is available
-
get
@Nonnull public <T extends Serializable> T get(@Nonnull String name, @Nonnull Class<T> type) throws ClassCastException Gets a named data element having a given type from the context.- Specified by:
get
in interfaceSignServiceContext
- Type Parameters:
T
- the type of the element- Parameters:
name
- the unique name of the elementtype
- the type of the element- Returns:
- the element, or null if no matching element is available
- Throws:
ClassCastException
- if the element exists but is not of the given type
-
remove
Removes the named element from the context.The rationale behind this method is that a module that writes a large data element to the context should be able to remove it when it os no longer needed. In this way, storing the context is cheaper.
- Specified by:
remove
in interfaceSignServiceContext
- Type Parameters:
T
- the type of the element- Parameters:
name
- the unique name of the element
-
serialize
Serializes the context to its string representation/encoding.- Specified by:
serialize
in interfaceSignServiceContext
- Returns:
- the string encoding of the context object
-
deserialize
Deserializes an encoding to aDefaultSignServiceContext
object.- Parameters:
encoding
- the string encoding- Returns:
- a DefaultSignServiceContext object
-