Package org.apache.wss4j.common.token
Class SecurityTokenReference
java.lang.Object
org.apache.wss4j.common.token.SecurityTokenReference
Security Token Reference.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.SecurityTokenReference(Element elem, BSPEnforcer bspEnforcer) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTokenType(String tokenType) Add a wsse11:TokenType attribute to this SecurityTokenReferencevoidAdd the WSSE Namespace to this STR.voidAdd the WSU Namespace to this STR.booleanMethod containsKeyIdentifier.booleanMethod containsReferencebooleanMethod containsX509DatabooleanMethod containsX509IssuerSerialbooleanGet the DOM element.get the first child element.getID()Get the idgetKeyIdentifier(Crypto crypto) Gets the KeyIdentifier.Gets the Reference.byte[]Get the wsse11:TokenType attribute of this SecurityTokenReferencegetX509IssuerSerial(Crypto crypto) Gets the certificate identified with X509 issuerSerial data.getX509SKIAlias(Crypto crypto) inthashCode()voidset the id.voidsetKeyIdentifier(String valueType, String keyIdVal) voidsetKeyIdentifier(String valueType, String keyIdVal, boolean base64) voidSets the KeyIdentifier Element as a X509 certificate.voidsetKeyIdentifierEncKeySHA1(String value) voidsetKeyIdentifierSKI(X509Certificate cert, Crypto crypto) Sets the KeyIdentifier Element as a X509 Subject-Key-Identifier (SKI).voidSets the KeyIdentifier Element as a Thumbprint.voidsetReference(Reference ref) set the reference.voidsetUnknownElement(Element unknownElement) Set an unknown element.toString()return the string representation.
-
Field Details
-
SECURITY_TOKEN_REFERENCE
- See Also:
-
STR_QNAME
-
SKI_URI
- See Also:
-
THUMB_URI
- See Also:
-
ENC_KEY_SHA1_URI
- See Also:
-
X509_V3_TYPE
- See Also:
-
-
Constructor Details
-
SecurityTokenReference
Constructor.- Parameters:
elem- A SecurityTokenReference elementbspEnforcer- a BSPEnforcer instance to enforce BSP rules- Throws:
WSSecurityException
-
SecurityTokenReference
Constructor.- Parameters:
doc- The Document
-
-
Method Details
-
addWSSENamespace
public void addWSSENamespace()Add the WSSE Namespace to this STR. The namespace is not added by default for efficiency purposes. -
addWSUNamespace
public void addWSUNamespace()Add the WSU Namespace to this STR. The namespace is not added by default for efficiency purposes. -
addTokenType
Add a wsse11:TokenType attribute to this SecurityTokenReference- Parameters:
tokenType- the wsse11:TokenType attribute to add
-
getTokenType
Get the wsse11:TokenType attribute of this SecurityTokenReference- Returns:
- the value of the wsse11:TokenType attribute
-
setReference
set the reference.- Parameters:
ref-
-
getReference
Gets the Reference.- Returns:
- the
Referenceelement contained in this SecurityTokenReference - Throws:
WSSecurityException
-
setKeyIdentifier
Sets the KeyIdentifier 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 certificate to be inserted as key identifier- Throws:
WSSecurityException
-
setKeyIdentifierSKI
Sets the KeyIdentifier Element as a X509 Subject-Key-Identifier (SKI). Takes a X509 certificate, gets the SKI data, converts it into base 64 and inserts it into awsse:KeyIdentifierelement, which is placed in thewsse:SecurityTokenReferenceelement.- Parameters:
cert- is the X509 certificate to get the SKIcrypto- is the Crypto implementation. Used to read SKI info bytes from certificate- Throws:
WSSecurityException
-
setKeyIdentifierThumb
Sets the KeyIdentifier 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 certificate to get the thumbprint- Throws:
WSSecurityException
-
setKeyIdentifierEncKeySHA1
- Throws:
WSSecurityException
-
setKeyIdentifier
- Throws:
WSSecurityException
-
setKeyIdentifier
public void setKeyIdentifier(String valueType, String keyIdVal, boolean base64) throws WSSecurityException - Throws:
WSSecurityException
-
getFirstElement
get the first child element.- Returns:
- the first
Elementchild node
-
getKeyIdentifier
Gets the KeyIdentifier.- Returns:
- the the X509 certificate or zero if a unknown key identifier type was detected.
- Throws:
WSSecurityException
-
getKeyIdentifierValue
-
getKeyIdentifierValueType
-
getKeyIdentifierEncodingType
-
getX509SKIAlias
- Throws:
WSSecurityException
-
getSKIBytes
public byte[] getSKIBytes() -
setUnknownElement
Set an unknown element.- Parameters:
unknownElement- the org.w3c.dom.Element to put into this SecurityTokenReference
-
getX509IssuerSerial
Gets the certificate identified with X509 issuerSerial data.- Returns:
- a certificate array or null if nothing found
- Throws:
WSSecurityException
-
containsReference
public boolean containsReference()Method containsReference- Returns:
- true if the
SecurityTokenReferencecontains awsse:Referenceelement
-
containsX509IssuerSerial
public boolean containsX509IssuerSerial()Method containsX509IssuerSerial- Returns:
- true if the
SecurityTokenReferencecontains ads:IssuerSerialelement
-
containsX509Data
public boolean containsX509Data()Method containsX509Data- Returns:
- true if the
SecurityTokenReferencecontains ads:X509Dataelement
-
containsKeyIdentifier
public boolean containsKeyIdentifier()Method containsKeyIdentifier.- Returns:
- true if the
SecurityTokenReferencecontains awsse:KeyIdentifierelement
-
getElement
Get the DOM element.- Returns:
- the DOM element
-
setID
set the id.- Parameters:
id-
-
getID
Get the id- Returns:
- the wsu ID of the element
-
toString
return the string representation. -
hashCode
public int hashCode() -
equals
-