public class SignatureHeaderBlock extends SecurityHeaderBlockImpl
| Modifier and Type | Field and Description |
|---|---|
static String |
SignatureSpecNS |
static String |
SignatureSpecNSprefix |
static String |
TAG_SIGNATURE |
delegateElementATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE| Constructor and Description |
|---|
SignatureHeaderBlock(Document doc,
String signatureMethodURI)
This creates a new
ds:Signature Element and adds an empty
ds:SignedInfo. |
SignatureHeaderBlock(SOAPElement elem)
parse and create the Signature element
|
SignatureHeaderBlock(org.apache.xml.security.signature.XMLSignature signature)
constructor that takes Apache Signature
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSignedInfoReference(String referenceURI,
org.apache.xml.security.transforms.Transforms transforms)
Adds a Reference with just the URI and the transforms.
|
void |
addSignedInfoReference(String referenceURI,
org.apache.xml.security.transforms.Transforms trans,
String digestURI)
Adds a Reference with URI, transforms and Digest algorithm URI
|
void |
addSignedInfoReference(String referenceURI,
org.apache.xml.security.transforms.Transforms trans,
String digestURI,
String referenceId,
String referenceType)
Add a Reference with full parameters to this Signature
|
void |
appendObject(SOAPElement object)
Method appendObject.
|
boolean |
checkSignatureValue(Key pk)
Verifies if the signature is valid by redigesting all References,
comparing those against the stored DigestValues and then checking to see
if the Signatures match on the SignedInfo.
|
boolean |
checkSignatureValue(X509Certificate cert)
Extracts the public key from the certificate and verifies if the
signature is valid by re-digesting all References, comparing those
against the stored DigestValues and then checking to see if the
Signatures match on the SignedInfo.
|
static SecurityHeaderBlock |
fromSoapElement(SOAPElement element) |
SOAPElement |
getAsSoapElement()
Method to return the Signature as a SOAPElement
|
org.apache.xml.security.signature.SignedInfo |
getDSSignedInfo() |
String |
getId()
Method getId
|
SOAPElement |
getKeyInfo()
Returns the KeyInfo child.
|
KeyInfoHeaderBlock |
getKeyInfoHeaderBlock()
Returns the KeyInfo as a HeaderBlock.
|
int |
getObjectCount()
Returns the number of all
ds:Object elements. |
SOAPElement |
getObjectItem(int index)
Returns the
index |
org.apache.xml.security.signature.XMLSignature |
getSignature()
return the Apache XML Signature corresponding to this Block
|
byte[] |
getSignatureValue()
Method getSignatureValue
|
SOAPElement |
getSignedInfo()
Returns the completely parsed
SignedInfo object. |
void |
saveChanges()
This method should be called when changes are made inside an object
through its reference obtained from any of the get methods of this
class.
|
void |
setApacheResourceResolver(org.apache.xml.security.utils.resolver.ResourceResolverSpi resolver) |
void |
setBaseURI(String uri)
Method setBaseURI : BaseURI needed by Apache KeyInfo Ctor
|
void |
setDocument(Document doc)
setDocument.
|
void |
setId(String id)
Method setId
|
void |
sign(Key signingKey)
Digests all References in the SignedInfo, calculates the signature
value and sets it in the SignatureValue Element.
|
addAttribute, addChildElement, addChildElement, addChildElement, addChildElement, addChildElement, addNamespaceDeclaration, addTextNode, appendChild, cloneNode, compareDocumentPosition, detachNode, equals, fromSoapElement, getAllAttributes, getAllAttributesAsQNames, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getAttributeValue, getBaseURI, getChildElements, getChildElements, getChildNodes, getElementName, getElementsByTagName, getElementsByTagNameNS, getEncodingStyle, getFeature, getFirstChild, getLastChild, getLocalName, getNamespacePrefixes, getNamespaceURI, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPrefix, getPreviousSibling, getSchemaTypeInfo, getSoapFactory, getTagName, getTextContent, getUserData, getValue, getVisibleNamespacePrefixes, hasAttribute, hasAttributeNS, hasAttributes, hasChildNodes, insertBefore, isBSP, isBSP, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, recycleNode, removeAttribute, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, removeContents, removeNamespaceDeclaration, replaceChild, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setEncodingStyle, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setParentElement, setPrefix, setSOAPElement, setTextContent, setUserData, setValue, setWsuIdAttraddAttribute, addChildElement, createQName, getAttributeValue, getChildElements, getElementQName, removeAttribute, setElementQNameclone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddAttribute, addChildElement, createQName, getAttributeValue, getChildElements, getElementQName, removeAttribute, setElementQNamepublic static final String SignatureSpecNS
public static final String SignatureSpecNSprefix
public static final String TAG_SIGNATURE
public SignatureHeaderBlock(SOAPElement elem) throws XWSSecurityException
elem - the element representing an XML Signature
NOTE : this constructor assumes a fully initialized XML Signature
No modifications are allowed on the signature, We can only get existing
values. For example appendObject() would throw an Exception. If
a KeyInfo was not present in the signature, then calling getKeyInfo()
will not append a KeyInfo child to the signature.XWSSecurityExceptionpublic SignatureHeaderBlock(org.apache.xml.security.signature.XMLSignature signature)
throws XWSSecurityException
signature - the XMLSignature from XML DSIG
NOTE : No modifications are allowed on the signature,
if a SIGN operation has already been performed on the argument
signature. We can only get existing values.
For example appendObject() would throw an Exception. If
a KeyInfo was not present in the signature, then calling getKeyInfo()
will not append a KeyInfo child to the signature.XWSSecurityExceptionpublic SignatureHeaderBlock(Document doc, String signatureMethodURI) throws XWSSecurityException
ds:Signature Element and adds an empty
ds:SignedInfo.
The ds:SignedInfo is initialized with the specified
Signature algorithm and Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS
which is RECOMMENDED by the spec. This method's main use is for creating
a new signature.doc - The OwnerDocument of signaturesignatureMethodURI - signature algorithm to use.XWSSecurityExceptionpublic org.apache.xml.security.signature.XMLSignature getSignature()
public void sign(Key signingKey) throws XWSSecurityException
signingKey - the PrivateKey or
SecretKey that is used to sign.XWSSecurityExceptionpublic SOAPElement getSignedInfo() throws XWSSecurityException
SignedInfo object.XWSSecurityExceptionpublic org.apache.xml.security.signature.SignedInfo getDSSignedInfo()
public SOAPElement getKeyInfo() throws XWSSecurityException
XWSSecurityExceptionpublic KeyInfoHeaderBlock getKeyInfoHeaderBlock() throws XWSSecurityException
XWSSecurityExceptionpublic byte[] getSignatureValue()
throws XWSSecurityException
XWSSecurityExceptionpublic void addSignedInfoReference(String referenceURI, org.apache.xml.security.transforms.Transforms transforms) throws XWSSecurityException
referenceURI - URI according to the XML Signature specification.transforms - List of transformations to be applied.XWSSecurityExceptionpublic void addSignedInfoReference(String referenceURI, org.apache.xml.security.transforms.Transforms trans, String digestURI) throws XWSSecurityException
referenceURI - URI according to the XML Signature specification.trans - List of transformations to be applied.digestURI - URI of the digest algorithm to be used.XWSSecurityExceptionpublic void addSignedInfoReference(String referenceURI, org.apache.xml.security.transforms.Transforms trans, String digestURI, String referenceId, String referenceType) throws XWSSecurityException
referenceURI - URI of the resource to be signed.Can be null in which
case the dereferencing is application specific. Can be "" in which it's
the parent node (or parent document?). There can only be one "" in each
signature.trans - Optional list of transformations to be done before digestingdigestURI - Mandatory URI of the digesting algorithm to use.referenceId - Optional id attribute for this ReferencereferenceType - Optional mimetype for the URIXWSSecurityExceptionpublic boolean checkSignatureValue(X509Certificate cert) throws XWSSecurityException
cert - Certificate that contains the public key part of the keypair
that was used to sign.XWSSecurityExceptionpublic boolean checkSignatureValue(Key pk) throws XWSSecurityException
pk - PublicKey part of the keypair or
SecretKey that was used to signXWSSecurityExceptionpublic void appendObject(SOAPElement object) throws XWSSecurityException
XWSSecurityExceptionpublic SOAPElement getObjectItem(int index) throws XWSSecurityException
indexth ds:Object child of the
signature or null if no such ds:Object element exists.index - indexth ds:Object child of the
signature or null if no such ds:Object element exists.
1 is the lowest index (not 0)XWSSecurityExceptionpublic int getObjectCount()
ds:Object elements.ds:Object elements.public void setId(String id)
public String getId()
getId in interface SecurityHeaderBlockgetId in class SecurityHeaderBlockImplpublic void setBaseURI(String uri)
uri - URI to be used as context for all relative URIs.public SOAPElement getAsSoapElement() throws XWSSecurityException
getAsSoapElement in interface SecurityHeaderBlockgetAsSoapElement in class SecurityHeaderBlockImplXWSSecurityException - If owner soap document is not set.setDocument(Document)public void setDocument(Document doc)
doc - The owner Document of this Signaturepublic void saveChanges()
public void setApacheResourceResolver(org.apache.xml.security.utils.resolver.ResourceResolverSpi resolver)
public static SecurityHeaderBlock fromSoapElement(SOAPElement element) throws XWSSecurityException
XWSSecurityExceptionCopyright © 2005–2018 Oracle Corporation. All rights reserved.