public abstract class GenericSecurityTokenFactory
extends java.lang.Object
This API is used for the creation of security tokens.
The following code snippets demonstrate how to use this API to create security tokens:
GenericSecurityTokenFactory gstFactory = GenericSecurityTokenFactory.getInstance(); UsernameToken unt = gstFactory.getFullUsernameToken(username,password);
GenericSecurityTokenFactory gstFactory = GenericSecurityTokenFactory.getInstance() 1. Create the valueType javax.xml.namespace.QName valueType = new QName("", "http://myToken") 2. Get a unique ID String uniqueID = gstFactory.createUniqueId() 3. Build the custom element org.w3c.dom.Element customElement = buildmyTokenElement(uniqueId) 4. Create the security token GenericSecurityToken myToken = gstFactory.getToken(customElement, valueType)
Constructor and Description |
---|
GenericSecurityTokenFactory() |
Modifier and Type | Method and Description |
---|---|
abstract java.lang.String |
createUniqueId()
Create a Unique ID that can be put into a custom token so that it can be referred to properly
when being individually signed or encrypted.
|
abstract SecurityToken |
getConsumerTokenFromSharedState(java.util.Map sharedState,
javax.xml.namespace.QName valueType)
Get a consumed token from the shared state.
|
abstract UsernameToken |
getFullUsernameToken(java.lang.String username)
Create a fully-populated UsernameToken with a username and no password.
|
abstract UsernameToken |
getFullUsernameToken(java.lang.String username,
char[] password)
Create a fully-populated UsernameToken with a username and password.
|
abstract UsernameToken |
getFullUsernameToken(java.lang.String username,
char[] password,
boolean useTimestamp)
Create a fully-populated UsernameToken with a username, password, and timestamp.
|
abstract SecurityToken |
getGeneratorTokenFromSharedState(java.util.Map sharedState,
javax.xml.namespace.QName valueType)
Get a generated token from the shared state.
|
static GenericSecurityTokenFactory |
getInstance()
Retrieves an instance of the GenericSecurityTokenFactory
|
abstract BinarySecurityToken |
getSimpleBinarySecurityToken(java.lang.Class tokenClass,
byte[] binary)
Create a sparse BinarySecurityToken (no XML) for use with binary
security token generators (like LTPA).
|
abstract UsernameToken |
getSimpleUsernameToken(java.lang.String username)
Create a sparse UsernameToken (no XML) with a username and password to pass
to the UNTGenerateLoginModule.
|
abstract UsernameToken |
getSimpleUsernameToken(java.lang.String username,
char[] password)
Create a sparse UsernameToken (no XML) with a username to pass to the UNTGenerateLoginModule.
|
abstract X509Token |
getSimpleX509PrivateToken(java.security.cert.X509Certificate certificate,
java.security.Key privateKey)
Create a sparse X509Token (no XML) that contains a private key.
|
abstract X509Token |
getSimpleX509PublicToken(java.security.cert.X509Certificate certificate)
Create a sparse X509Token (no XML) that contains just a public certificate.
|
abstract X509Token |
getSimpleX509Token(java.security.cert.X509Certificate certificate,
java.security.Key privateKey)
Create a sparse X509Token (no XML).
|
abstract GenericSecurityToken |
getToken()
Create an unpupulated GenericSecurityToken.
|
abstract GenericSecurityToken |
getToken(org.w3c.dom.Element element,
javax.xml.namespace.QName valueType)
Create a custom GenericSecurityToken from a org.w3c.dom element
|
abstract GenericSecurityToken |
getToken(java.io.InputStream is,
javax.xml.namespace.QName valueType)
Create a custom GenericSecurityToken from an XML fragment given as a String
|
abstract GenericSecurityToken |
getToken(org.apache.axiom.om.OMElement element,
javax.xml.namespace.QName valueType)
Create a custom GenericSecurityToken from an OMElement
|
abstract GenericSecurityToken |
getToken(com.ibm.wsspi.wssecurity.wssapi.OMStructure xml,
javax.xml.namespace.QName valueType) |
abstract GenericSecurityToken |
getToken(java.lang.String xmlFragment,
javax.xml.namespace.QName valueType)
Create a custom GenericSecurityToken from an XML fragment given as a String
|
abstract void |
putAuthenticatedTokenToSharedState(java.util.Map sharedState,
SecurityToken token)
Put a token that has been authenticated by a login module into the shared state.
|
abstract void |
putConsumerTokenToSharedState(java.util.Map sharedState,
SecurityToken token)
Put a consumed token on the shared state.
|
abstract void |
putGeneratorTokenToSharedState(java.util.Map sharedState,
SecurityToken token)
Put a generated token on the shared state.
|
public static GenericSecurityTokenFactory getInstance() throws WSSException
WSSException
- if the illegal access occurs or if the WSSFactory instance is not generated.public abstract GenericSecurityToken getToken(com.ibm.wsspi.wssecurity.wssapi.OMStructure xml, javax.xml.namespace.QName valueType)
public abstract GenericSecurityToken getToken()
GenericSecurityToken
public abstract GenericSecurityToken getToken(org.apache.axiom.om.OMElement element, javax.xml.namespace.QName valueType)
element
- axiom representation of the custom elementvalueType
- the token's value typeGenericSecurityToken
public abstract GenericSecurityToken getToken(org.w3c.dom.Element element, javax.xml.namespace.QName valueType) throws java.lang.Exception
element
- w3c.dom representation of the custom elementvalueType
- the token's value typeGenericSecurityToken
java.lang.Exception
public abstract GenericSecurityToken getToken(java.lang.String xmlFragment, javax.xml.namespace.QName valueType) throws java.lang.Exception
xmlFragment
- token represented as a well-formed XML fragmentvalueType
- the token's value typeGenericSecurityToken
java.lang.Exception
public abstract GenericSecurityToken getToken(java.io.InputStream is, javax.xml.namespace.QName valueType) throws java.lang.Exception
is
- an inputStream corresponding to a serialized XML element. The programmer is
responsible for closing of the stream accordingly.valueType
- the token's value typeGenericSecurityToken
java.lang.Exception
public abstract UsernameToken getFullUsernameToken(java.lang.String username) throws javax.security.auth.login.LoginException
username
- username for the UsernameToken elementUsernameToken
javax.security.auth.login.LoginException
public abstract UsernameToken getFullUsernameToken(java.lang.String username, char[] password) throws javax.security.auth.login.LoginException
username
- username for the UsernameToken elementpassword
- password for the UsernameToken elementUsernameToken
javax.security.auth.login.LoginException
public abstract UsernameToken getFullUsernameToken(java.lang.String username, char[] password, boolean useTimestamp) throws javax.security.auth.login.LoginException
username
- username for the UsernameToken elementpassword
- password for the UsernameToken element. Null for no password.useTimestamp
- true=add timestamp, false=no timestampUsernameToken
javax.security.auth.login.LoginException
public abstract java.lang.String createUniqueId()
public abstract SecurityToken getGeneratorTokenFromSharedState(java.util.Map sharedState, javax.xml.namespace.QName valueType)
com.ibm.wsspi.wssecurity.core.Constants.WSSECURITY_TOKEN_TO_BE_INSERTED
property on the shared state.sharedState
- JAAS login module shared state MapvalueType
- Value type of the desired tokenpublic abstract SecurityToken getConsumerTokenFromSharedState(java.util.Map sharedState, javax.xml.namespace.QName valueType)
com.ibm.wsspi.wssecurity.core.Constants.WSSECURITY_TOKEN_PROCESSED
property on the shared state.sharedState
- JAAS login module shared state MapvalueType
- Value type of the desired tokenpublic abstract void putGeneratorTokenToSharedState(java.util.Map sharedState, SecurityToken token)
com.ibm.wsspi.wssecurity.core.Constants.WSSECURITY_TOKEN_TO_BE_INSERTED
property in the shared state.sharedState
- JAAS login module shared state Maptoken
- Token to insertpublic abstract void putConsumerTokenToSharedState(java.util.Map sharedState, SecurityToken token)
com.ibm.wsspi.wssecurity.core.Constants.WSSECURITY_TOKEN_TO_BE_INSERTED
property in the shared state.sharedState
- JAAS login module shared state MapToken
- Token to insertpublic abstract UsernameToken getSimpleUsernameToken(java.lang.String username)
username
- username for the UsernameToken elementpassword
- password for the UsernameToken element. Null for no password.UsernameToken
public abstract UsernameToken getSimpleUsernameToken(java.lang.String username, char[] password)
username
- username for the UsernameToken elementUsernameToken
public abstract X509Token getSimpleX509PublicToken(java.security.cert.X509Certificate certificate)
certificate
- public certificate for the tokenX509Token
public abstract X509Token getSimpleX509PrivateToken(java.security.cert.X509Certificate certificate, java.security.Key privateKey) throws WSSException
certificate
- public certificate for the token (may be null)privateKey
- private key for the tokenX509Token
WSSException
- if the privateKey is nullpublic abstract X509Token getSimpleX509Token(java.security.cert.X509Certificate certificate, java.security.Key privateKey)
certificate
- public certificate for the token (may be null)privateKey
- private key for the token (may be null)X509Token
public abstract BinarySecurityToken getSimpleBinarySecurityToken(java.lang.Class tokenClass, byte[] binary) throws WSSException
tokenClass
- class name to instantiate for the tokenbinary
- unencoded token bytes for the tokenBinarySecurityToken
WSSException
- if the tokenClass is not a recognized built-in class that
extends BinarySecurityTokenpublic abstract void putAuthenticatedTokenToSharedState(java.util.Map sharedState, SecurityToken token)
sharedState
- JAAS login module shared state Maptoken
- token that has been authenticated