|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
package com.sun.org.apache.xml.internal.security.signature; |
|
|
|
import java.io.IOException; |
|
import java.io.OutputStream; |
|
import java.security.Key; |
|
import java.security.PublicKey; |
|
import java.security.cert.X509Certificate; |
|
import java.util.Base64; |
|
|
|
import javax.crypto.SecretKey; |
|
|
|
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm; |
|
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; |
|
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer; |
|
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException; |
|
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; |
|
import com.sun.org.apache.xml.internal.security.keys.KeyInfo; |
|
import com.sun.org.apache.xml.internal.security.keys.content.X509Data; |
|
import com.sun.org.apache.xml.internal.security.transforms.Transforms; |
|
import com.sun.org.apache.xml.internal.security.utils.Constants; |
|
import com.sun.org.apache.xml.internal.security.utils.I18n; |
|
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; |
|
import com.sun.org.apache.xml.internal.security.utils.SignerOutputStream; |
|
import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream; |
|
import com.sun.org.apache.xml.internal.security.utils.XMLUtils; |
|
import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver; |
|
import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverSpi; |
|
import org.w3c.dom.Attr; |
|
import org.w3c.dom.Document; |
|
import org.w3c.dom.Element; |
|
import org.w3c.dom.Node; |
|
import org.w3c.dom.Text; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public final class XMLSignature extends SignatureElementProxy { |
|
|
|
|
|
public static final String ALGO_ID_MAC_HMAC_SHA1 = |
|
Constants.SignatureSpecNS + "hmac-sha1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_DSA = |
|
Constants.SignatureSpecNS + "dsa-sha1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_DSA_SHA256 = |
|
Constants.SignatureSpec11NS + "dsa-sha256"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA = |
|
Constants.SignatureSpecNS + "rsa-sha1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA1 = |
|
Constants.SignatureSpecNS + "rsa-sha1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5 = |
|
Constants.MoreAlgorithmsSpecNS + "rsa-md5"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_RIPEMD160 = |
|
Constants.MoreAlgorithmsSpecNS + "rsa-ripemd160"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA224 = |
|
Constants.MoreAlgorithmsSpecNS + "rsa-sha224"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA256 = |
|
Constants.MoreAlgorithmsSpecNS + "rsa-sha256"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA384 = |
|
Constants.MoreAlgorithmsSpecNS + "rsa-sha384"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA512 = |
|
Constants.MoreAlgorithmsSpecNS + "rsa-sha512"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA1_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha1-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA224_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha224-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA256_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha256-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA384_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha384-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA512_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha512-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA3_224_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha3-224-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA3_256_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha3-256-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA3_384_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha3-384-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_RSA_SHA3_512_MGF1 = |
|
Constants.XML_DSIG_NS_MORE_07_05 + "sha3-512-rsa-MGF1"; |
|
|
|
|
|
public static final String ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5 = |
|
Constants.MoreAlgorithmsSpecNS + "hmac-md5"; |
|
|
|
|
|
public static final String ALGO_ID_MAC_HMAC_RIPEMD160 = |
|
Constants.MoreAlgorithmsSpecNS + "hmac-ripemd160"; |
|
|
|
|
|
public static final String ALGO_ID_MAC_HMAC_SHA224 = |
|
Constants.MoreAlgorithmsSpecNS + "hmac-sha224"; |
|
|
|
|
|
public static final String ALGO_ID_MAC_HMAC_SHA256 = |
|
Constants.MoreAlgorithmsSpecNS + "hmac-sha256"; |
|
|
|
|
|
public static final String ALGO_ID_MAC_HMAC_SHA384 = |
|
Constants.MoreAlgorithmsSpecNS + "hmac-sha384"; |
|
|
|
|
|
public static final String ALGO_ID_MAC_HMAC_SHA512 = |
|
Constants.MoreAlgorithmsSpecNS + "hmac-sha512"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_ECDSA_SHA1 = |
|
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_ECDSA_SHA224 = |
|
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_ECDSA_SHA256 = |
|
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_ECDSA_SHA384 = |
|
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_ECDSA_SHA512 = |
|
"http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512"; |
|
|
|
|
|
public static final String ALGO_ID_SIGNATURE_ECDSA_RIPEMD160 = |
|
"http://www.w3.org/2007/05/xmldsig-more#ecdsa-ripemd160"; |
|
|
|
private static final com.sun.org.slf4j.internal.Logger LOG = |
|
com.sun.org.slf4j.internal.LoggerFactory.getLogger(XMLSignature.class); |
|
|
|
|
|
private SignedInfo signedInfo; |
|
|
|
|
|
private KeyInfo keyInfo; |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
private boolean followManifestsDuringValidation = false; |
|
|
|
private Element signatureValueElement; |
|
|
|
private static final int MODE_SIGN = 0; |
|
private static final int MODE_VERIFY = 1; |
|
private int state = MODE_SIGN; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLSignature(Document doc, String baseURI, String signatureMethodURI) |
|
throws XMLSecurityException { |
|
this(doc, baseURI, signatureMethodURI, 0, Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLSignature(Document doc, String baseURI, String signatureMethodURI, |
|
int hmacOutputLength) throws XMLSecurityException { |
|
this( |
|
doc, baseURI, signatureMethodURI, hmacOutputLength, |
|
Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLSignature( |
|
Document doc, |
|
String baseURI, |
|
String signatureMethodURI, |
|
String canonicalizationMethodURI |
|
) throws XMLSecurityException { |
|
this(doc, baseURI, signatureMethodURI, 0, canonicalizationMethodURI); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLSignature( |
|
Document doc, |
|
String baseURI, |
|
String signatureMethodURI, |
|
int hmacOutputLength, |
|
String canonicalizationMethodURI |
|
) throws XMLSecurityException { |
|
super(doc); |
|
|
|
String xmlnsDsPrefix = getDefaultPrefix(Constants.SignatureSpecNS); |
|
if (xmlnsDsPrefix == null || xmlnsDsPrefix.length() == 0) { |
|
getElement().setAttributeNS( |
|
Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS |
|
); |
|
} else { |
|
getElement().setAttributeNS( |
|
Constants.NamespaceSpecNS, "xmlns:" + xmlnsDsPrefix, Constants.SignatureSpecNS |
|
); |
|
} |
|
addReturnToSelf(); |
|
|
|
this.baseURI = baseURI; |
|
this.signedInfo = |
|
new SignedInfo( |
|
getDocument(), signatureMethodURI, hmacOutputLength, canonicalizationMethodURI |
|
); |
|
|
|
appendSelf(this.signedInfo); |
|
addReturnToSelf(); |
|
|
|
|
|
signatureValueElement = |
|
XMLUtils.createElementInSignatureSpace(getDocument(), Constants._TAG_SIGNATUREVALUE); |
|
|
|
appendSelf(signatureValueElement); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLSignature( |
|
Document doc, |
|
String baseURI, |
|
Element SignatureMethodElem, |
|
Element CanonicalizationMethodElem |
|
) throws XMLSecurityException { |
|
super(doc); |
|
|
|
String xmlnsDsPrefix = getDefaultPrefix(Constants.SignatureSpecNS); |
|
if (xmlnsDsPrefix == null || xmlnsDsPrefix.length() == 0) { |
|
getElement().setAttributeNS( |
|
Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS |
|
); |
|
} else { |
|
getElement().setAttributeNS( |
|
Constants.NamespaceSpecNS, "xmlns:" + xmlnsDsPrefix, Constants.SignatureSpecNS |
|
); |
|
} |
|
addReturnToSelf(); |
|
|
|
this.baseURI = baseURI; |
|
this.signedInfo = |
|
new SignedInfo(getDocument(), SignatureMethodElem, CanonicalizationMethodElem); |
|
|
|
appendSelf(this.signedInfo); |
|
addReturnToSelf(); |
|
|
|
|
|
signatureValueElement = |
|
XMLUtils.createElementInSignatureSpace(getDocument(), Constants._TAG_SIGNATUREVALUE); |
|
|
|
appendSelf(signatureValueElement); |
|
addReturnToSelf(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLSignature(Element element, String baseURI) |
|
throws XMLSignatureException, XMLSecurityException { |
|
this(element, baseURI, true); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XMLSignature(Element element, String baseURI, boolean secureValidation) |
|
throws XMLSignatureException, XMLSecurityException { |
|
super(element, baseURI); |
|
|
|
|
|
Element signedInfoElem = XMLUtils.getNextElement(element.getFirstChild()); |
|
|
|
|
|
if (signedInfoElem == null) { |
|
Object exArgs[] = { Constants._TAG_SIGNEDINFO, Constants._TAG_SIGNATURE }; |
|
throw new XMLSignatureException("xml.WrongContent", exArgs); |
|
} |
|
|
|
|
|
this.signedInfo = new SignedInfo(signedInfoElem, baseURI, secureValidation); |
|
|
|
signedInfoElem = XMLUtils.getNextElement(element.getFirstChild()); |
|
|
|
|
|
this.signatureValueElement = |
|
XMLUtils.getNextElement(signedInfoElem.getNextSibling()); |
|
|
|
|
|
if (signatureValueElement == null) { |
|
Object exArgs[] = { Constants._TAG_SIGNATUREVALUE, Constants._TAG_SIGNATURE }; |
|
throw new XMLSignatureException("xml.WrongContent", exArgs); |
|
} |
|
Attr signatureValueAttr = signatureValueElement.getAttributeNodeNS(null, "Id"); |
|
if (signatureValueAttr != null) { |
|
signatureValueElement.setIdAttributeNode(signatureValueAttr, true); |
|
} |
|
|
|
|
|
Element keyInfoElem = |
|
XMLUtils.getNextElement(signatureValueElement.getNextSibling()); |
|
|
|
|
|
if (keyInfoElem != null |
|
&& Constants.SignatureSpecNS.equals(keyInfoElem.getNamespaceURI()) |
|
&& Constants._TAG_KEYINFO.equals(keyInfoElem.getLocalName())) { |
|
this.keyInfo = new KeyInfo(keyInfoElem, baseURI); |
|
this.keyInfo.setSecureValidation(secureValidation); |
|
} |
|
|
|
|
|
Element objectElem = |
|
XMLUtils.getNextElement(signatureValueElement.getNextSibling()); |
|
while (objectElem != null) { |
|
Attr objectAttr = objectElem.getAttributeNodeNS(null, "Id"); |
|
if (objectAttr != null) { |
|
objectElem.setIdAttributeNode(objectAttr, true); |
|
} |
|
|
|
Node firstChild = objectElem.getFirstChild(); |
|
|
|
while (firstChild != null) { |
|
if (firstChild.getNodeType() == Node.ELEMENT_NODE) { |
|
Element childElem = (Element)firstChild; |
|
String tag = childElem.getLocalName(); |
|
if ("Manifest".equals(tag)) { |
|
new Manifest(childElem, baseURI); |
|
} else if ("SignatureProperties".equals(tag)) { |
|
new SignatureProperties(childElem, baseURI); |
|
} |
|
} |
|
firstChild = firstChild.getNextSibling(); |
|
} |
|
|
|
objectElem = XMLUtils.getNextElement(objectElem.getNextSibling()); |
|
} |
|
|
|
this.state = MODE_VERIFY; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void setId(String id) { |
|
if (id != null) { |
|
setLocalIdAttribute(Constants._ATT_ID, id); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public String getId() { |
|
return getLocalAttribute(Constants._ATT_ID); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public SignedInfo getSignedInfo() { |
|
return this.signedInfo; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public byte[] getSignatureValue() throws XMLSignatureException { |
|
String content = XMLUtils.getFullTextChildrenFromElement(signatureValueElement); |
|
return Base64.getMimeDecoder().decode(content); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
private void setSignatureValueElement(byte[] bytes) { |
|
|
|
while (signatureValueElement.hasChildNodes()) { |
|
signatureValueElement.removeChild(signatureValueElement.getFirstChild()); |
|
} |
|
|
|
String base64codedValue = Base64.getMimeEncoder().encodeToString(bytes); |
|
|
|
if (base64codedValue.length() > 76 && !XMLUtils.ignoreLineBreaks()) { |
|
base64codedValue = "\n" + base64codedValue + "\n"; |
|
} |
|
|
|
Text t = createText(base64codedValue); |
|
signatureValueElement.appendChild(t); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public KeyInfo getKeyInfo() { |
|
|
|
if (this.state == MODE_SIGN && this.keyInfo == null) { |
|
|
|
|
|
this.keyInfo = new KeyInfo(getDocument()); |
|
|
|
|
|
Element keyInfoElement = this.keyInfo.getElement(); |
|
Element firstObject = |
|
XMLUtils.selectDsNode( |
|
getElement().getFirstChild(), Constants._TAG_OBJECT, 0 |
|
); |
|
|
|
if (firstObject != null) { |
|
|
|
getElement().insertBefore(keyInfoElement, firstObject); |
|
XMLUtils.addReturnBeforeChild(getElement(), firstObject); |
|
} else { |
|
|
|
appendSelf(keyInfoElement); |
|
addReturnToSelf(); |
|
} |
|
} |
|
|
|
return this.keyInfo; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void appendObject(ObjectContainer object) throws XMLSignatureException { |
|
//try { |
|
//if (this.state != MODE_SIGN) { |
|
// throw new XMLSignatureException( |
|
// "signature.operationOnlyBeforeSign"); |
|
//} |
|
|
|
appendSelf(object); |
|
addReturnToSelf(); |
|
//} catch (XMLSecurityException ex) { |
|
// throw new XMLSignatureException(ex); |
|
//} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public ObjectContainer getObjectItem(int i) { |
|
Element objElem = |
|
XMLUtils.selectDsNode( |
|
getFirstChild(), Constants._TAG_OBJECT, i |
|
); |
|
|
|
try { |
|
return new ObjectContainer(objElem, this.baseURI); |
|
} catch (XMLSecurityException ex) { |
|
return null; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int getObjectLength() { |
|
return this.length(Constants.SignatureSpecNS, Constants._TAG_OBJECT); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void sign(Key signingKey) throws XMLSignatureException { |
|
|
|
if (signingKey instanceof PublicKey) { |
|
throw new IllegalArgumentException( |
|
I18n.translate("algorithms.operationOnlyVerification") |
|
); |
|
} |
|
|
|
|
|
SignedInfo si = this.getSignedInfo(); |
|
SignatureAlgorithm sa = si.getSignatureAlgorithm(); |
|
try (SignerOutputStream output = new SignerOutputStream(sa); |
|
OutputStream so = new UnsyncBufferedOutputStream(output)) { |
|
|
|
|
|
si.generateDigestValues(); |
|
|
|
|
|
sa.initSign(signingKey); |
|
|
|
|
|
si.signInOctetStream(so); |
|
|
|
|
|
this.setSignatureValueElement(sa.sign()); |
|
} catch (XMLSignatureException ex) { |
|
throw ex; |
|
} catch (CanonicalizationException ex) { |
|
throw new XMLSignatureException(ex); |
|
} catch (InvalidCanonicalizerException ex) { |
|
throw new XMLSignatureException(ex); |
|
} catch (XMLSecurityException ex) { |
|
throw new XMLSignatureException(ex); |
|
} catch (IOException ex) { |
|
throw new XMLSignatureException(ex); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addResourceResolver(ResourceResolver resolver) { |
|
this.getSignedInfo().addResourceResolver(resolver); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addResourceResolver(ResourceResolverSpi resolver) { |
|
this.getSignedInfo().addResourceResolver(resolver); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean checkSignatureValue(X509Certificate cert) |
|
throws XMLSignatureException { |
|
|
|
if (cert != null) { |
|
|
|
return this.checkSignatureValue(cert.getPublicKey()); |
|
} |
|
|
|
Object exArgs[] = { "Didn't get a certificate" }; |
|
throw new XMLSignatureException("empty", exArgs); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean checkSignatureValue(Key pk) throws XMLSignatureException { |
|
//COMMENT: pk suggests it can only be a public key? |
|
|
|
if (pk == null) { |
|
Object exArgs[] = { "Didn't get a key" }; |
|
throw new XMLSignatureException("empty", exArgs); |
|
} |
|
// all references inside the signedinfo need to be dereferenced and |
|
// digested again to see if the outcome matches the stored value in the |
|
// SignedInfo. |
|
// If followManifestsDuringValidation is true it will do the same for |
|
|
|
try { |
|
SignedInfo si = this.getSignedInfo(); |
|
//create a SignatureAlgorithms from the SignatureMethod inside |
|
|
|
SignatureAlgorithm sa = si.getSignatureAlgorithm(); |
|
LOG.debug("signatureMethodURI = {}", sa.getAlgorithmURI()); |
|
LOG.debug("jceSigAlgorithm = {}", sa.getJCEAlgorithmString()); |
|
LOG.debug("jceSigProvider = {}", sa.getJCEProviderName()); |
|
LOG.debug("PublicKey = {}", pk); |
|
|
|
byte sigBytes[] = null; |
|
try (SignerOutputStream so = new SignerOutputStream(sa); |
|
OutputStream bos = new UnsyncBufferedOutputStream(so)) { |
|
|
|
sa.initVerify(pk); |
|
|
|
|
|
si.signInOctetStream(bos); |
|
|
|
sigBytes = this.getSignatureValue(); |
|
} catch (IOException ex) { |
|
LOG.debug(ex.getMessage(), ex); |
|
// Impossible... |
|
} catch (XMLSecurityException ex) { |
|
throw ex; |
|
} |
|
|
|
// have SignatureAlgorithm sign the input bytes and compare them to |
|
|
|
if (!sa.verify(sigBytes)) { |
|
LOG.warn("Signature verification failed."); |
|
return false; |
|
} |
|
|
|
return si.verify(this.followManifestsDuringValidation); |
|
} catch (XMLSignatureException ex) { |
|
throw ex; |
|
} catch (XMLSecurityException ex) { |
|
throw new XMLSignatureException(ex); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addDocument( |
|
String referenceURI, |
|
Transforms trans, |
|
String digestURI, |
|
String referenceId, |
|
String referenceType |
|
) throws XMLSignatureException { |
|
this.signedInfo.addDocument( |
|
this.baseURI, referenceURI, trans, digestURI, referenceId, referenceType |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addDocument( |
|
String referenceURI, |
|
Transforms trans, |
|
String digestURI |
|
) throws XMLSignatureException { |
|
this.signedInfo.addDocument(this.baseURI, referenceURI, trans, digestURI, null, null); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addDocument(String referenceURI, Transforms trans) |
|
throws XMLSignatureException { |
|
this.signedInfo.addDocument( |
|
this.baseURI, referenceURI, trans, Constants.ALGO_ID_DIGEST_SHA1, null, null |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addDocument(String referenceURI) throws XMLSignatureException { |
|
this.signedInfo.addDocument( |
|
this.baseURI, referenceURI, null, Constants.ALGO_ID_DIGEST_SHA1, null, null |
|
); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addKeyInfo(X509Certificate cert) throws XMLSecurityException { |
|
X509Data x509data = new X509Data(getDocument()); |
|
|
|
x509data.addCertificate(cert); |
|
this.getKeyInfo().add(x509data); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void addKeyInfo(PublicKey pk) { |
|
this.getKeyInfo().add(pk); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public SecretKey createSecretKey(byte[] secretKeyBytes) { |
|
return this.getSignedInfo().createSecretKey(secretKeyBytes); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void setFollowNestedManifests(boolean followManifests) { |
|
this.followManifestsDuringValidation = followManifests; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public String getBaseLocalName() { |
|
return Constants._TAG_SIGNATURE; |
|
} |
|
} |