Class SecurityTokenReference
java.lang.Object
org.apache.ws.security.message.token.SecurityTokenReference
Security Token Reference.
- Author:
- Davanum Srinivas (dims@yahoo.com).
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanMethod containsKeyIdentifier.booleanMethod containsReferencebooleanMethod containsX509DatabooleanMethod containsX509IssuerSerialget the dom element.get the first child element.getKeyIdentifier(Crypto crypto) Gets the KeyIdentifer.Gets the Reference.byte[]getTokenElement(Document doc, WSDocInfo docInfo) Gets the signing token element, which maybe aBinarySecurityTokenor a SAML token.getX509IssuerSerial(Crypto crypto) Gets the certificate identified with X509 issuerSerial data.getX509IssuerSerialAlias(Crypto crypto) Gets the alias name of the certificate identified with X509 issuerSerial data.getX509SKIAlias(Crypto crypto) intMethod length.intMethod lengthKeyIdentifier.intMethod lengthReference.intMethod lengthX509Data.intMethod lengthX509IssuerSerial.voidset the id.voidSets the KeyIdentifer Element as a X509 certificate.voidsetKeyIdentifierSKI(X509Certificate cert, Crypto crypto) Sets the KeyIdentifer Element as a X509 Subject-Key-Identifier (SKI).voidSets the KeyIdentifer Element as a Thumbprint.voidsetReference(Reference ref) set the reference.voidsetSAMLKeyIdentifier(String keyIdVal) voidsetX509IssuerSerial(org.apache.xml.security.keys.content.X509Data ref) Sets the X509 IssuerSerial data.toString()return the string representation.
-
Field Details
-
SECURITY_TOKEN_REFERENCE
- See Also:
-
KEY_NAME
- See Also:
-
SKI_URI
- See Also:
-
THUMB_URI
- See Also:
-
SAML_ID_URI
- See Also:
-
element
-
-
Constructor Details
-
SecurityTokenReference
Constructor.- Parameters:
elem- TODO- Throws:
WSSecurityException
-
SecurityTokenReference
-
-
Method Details
-
setReference
-
getReference
Gets the Reference.- Returns:
- the
Referenceelement contained in this SecurityTokeneReference - Throws:
WSSecurityException
-
getTokenElement
Gets the signing token element, which maybe aBinarySecurityTokenor a SAML token. The method gets the URI attribute of theReferencecontained in theSecurityTokenReferenceand tries to find the referenced Element in the document.- Parameters:
doc- the document that contains the binary security token element. This could be different from the document that contains the SecurityTokenReference (STR). See STRTransform.derefenceBST() method- Returns:
- Element containing the signing token, must be a BinarySecurityToken
- Throws:
WSSecurityException- When either noReferenceelement, or the found reference contains no URI, or the referenced signing not found.
-
setKeyIdentifier
Sets the KeyIdentifer Element as a X509 certificate. Takes a X509 certificate, converts its data into base 64 and inserts it into awsse:KeyIdentifierelement, which is placed in thewsse:SecurityTokenReferenceelement.- Parameters:
cert- is the X509 certficate to be inserted as key identifier- Throws:
WSSecurityException
-
setKeyIdentifierSKI
Sets the KeyIdentifer Element as a X509 Subject-Key-Identifier (SKI). Takes a X509 certificate, gets it SKI data, converts into base 64 and inserts it into awsse:KeyIdentifierelement, which is placed in thewsse:SecurityTokenReferenceelement.- Parameters:
cert- is the X509 certficate to get the SKIcrypto- is the Crypto implementation. Used to read SKI info bytes from certificate- Throws:
WSSecurityException
-
setKeyIdentifierThumb
Sets the KeyIdentifer Element as a Thumbprint. Takes a X509 certificate, computes its thumbprint using SHA-1, converts into base 64 and inserts it into awsse:KeyIdentifierelement, which is placed in thewsse:SecurityTokenReferenceelement.- Parameters:
cert- is the X509 certficate to get the thumbprint- Throws:
WSSecurityException
-
setSAMLKeyIdentifier
- Throws:
WSSecurityException
-
getKeyIdentifier
Gets the KeyIdentifer.- Returns:
- the the X509 certficate or zero if a unknown key identifier type was detected.
- Throws:
WSSecurityException
-
getX509SKIAlias
- Throws:
WSSecurityException
-
getSKIBytes
public byte[] getSKIBytes() -
setX509IssuerSerial
public void setX509IssuerSerial(org.apache.xml.security.keys.content.X509Data ref) Sets the X509 IssuerSerial data.- Parameters:
ref- theXMLX509IssuerSerialto put into this SecurityTokenReference
-
getX509IssuerSerial
Gets the certificate identified with X509 issuerSerial data. This method first tries to get the embedded certificate. If this fails it checks if the certificate is in the keystore.- Returns:
- a certificate array or null if nothing found
- Throws:
WSSecurityException
-
getX509IssuerSerialAlias
Gets the alias name of the certificate identified with X509 issuerSerial data. The keystore identifies the certificate and the key with this alias name.- Returns:
- the alias name for the certificate or null if nothing found
- Throws:
WSSecurityException
-
getFirstElement
-
containsReference
public boolean containsReference()Method containsReference- Returns:
- true if the
SecurtityTokenReferencecontains awsse:Referenceelement
-
lengthReference
public int lengthReference()Method lengthReference.- Returns:
- number of
wsse:Referenceelements in theSecurtityTokenReference
-
containsX509IssuerSerial
public boolean containsX509IssuerSerial()Method containsX509IssuerSerial- Returns:
- true if the
SecurtityTokenReferencecontains ads:IssuerSerialelement
-
containsX509Data
public boolean containsX509Data()Method containsX509Data- Returns:
- true if the
SecurtityTokenReferencecontains ads:X509Dataelement
-
lengthX509IssuerSerial
public int lengthX509IssuerSerial()Method lengthX509IssuerSerial.- Returns:
- number of
ds:IssuerSerialelements in theSecurtityTokenReference
-
lengthX509Data
public int lengthX509Data()Method lengthX509Data.- Returns:
- number of
ds:IssuerSerialelements in theSecurtityTokenReference
-
containsKeyIdentifier
public boolean containsKeyIdentifier()Method containsKeyIdentifier.- Returns:
- true if the
SecurtityTokenReferencecontains awsse:KeyIdentifierelement
-
lengthKeyIdentifier
public int lengthKeyIdentifier()Method lengthKeyIdentifier.- Returns:
- number of
wsse:KeyIdentifierelements in theSecurtityTokenReference
-
length
-
getElement
-
setID
-
toString
-