Writing a TokenValidatorModule Class
Writing Oracle Security Token Service Module Classes 4-7
Development highlights: Writing a TokenIssuanceModule class 1.
Implement the public void initMap optionsthrows TokenProcessingException method.
The init method is called when the issuer module is initialized. The init method is passed a map contain the parameters defined in the issuance template.
2.
Implement the public TokenResult issueTokenContext context throws TokenProcessingException method.
This method is called when a custom outgoing token must be created.
a.
Create, within the issue method, the token using the attributes in the issuance template and the attributes passed in the TokenContext. Attributes
in the TokenContext are accessed in the following way:
List attributes = Listcontext.getOtherProperties.getTPEConstants.TOKEN_ATTRIBUTES;
String emailAddress = null; HashMap attributes = HashMapcontext.getOtherProperties.getSTS_TOKEN_
ATTRIBUTES; Object valueObj = attributes.getmail; valuesObj will be a list if
mail has more than 1 value; ifattributes = null
attrIter = attributes.iterator; ifattrIter = null{
HashMap attributes = HashMapcontext.getOtherProperties.getSTS_TOKEN_ ATTRIBUTES;
Object valueObj = attributes.getmail; valuesObj will be a list if mail has more than 1 value.
MapString, Object attribute = attrIter.next; String attributeName = Stringattribute.getTPEConstants.SAML_ATTRIBUTE_
NAME; ifmail.equalsattributeName{
{Object valuesObj = attribute.getTPEConstants.SAML_ATTRIBUTE_VALUES; ifvaluesObj instanceof List { Iterator iter =
ListvaluesObj.iterator; whileiter.hasNext {Object valueObj = iter.next; ifvalueObj instanceof String
} }else ifvaluesObj instanceof String
Unknown macro: { emailAddress = StringvaluesObj; } }
b.
Create a result object and set the bytes of the token and the Document Object Model DOM representation of the token only if the DOM representation
was created during the processing in this class:
token.setTokenDocumentnull;-- if you have a doc object that can be reuse.d set it here
token.setTokenBytestokenBytes; TokenResult result = new TokenResultImpl0, TokenResult.SUCCESS, token;
c.
Set the key identifier information into the token properties, as follows: Map resultMap = new HashMap;
resultMap.putSTS_KEY_IDENTIFIER_VALUE, emailAddress; resultMap.putSTS_KEY_IDENTIFIER_VALUE_TYPE, EmailAddress;
result.setTokenPropertiesresultMap;