com.sun.org.apache.xml.internal.security.signature.XMLSignature Java Examples
The following examples show how to use
com.sun.org.apache.xml.internal.security.signature.XMLSignature.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignatureAlgorithm.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Constructor SignatureAlgorithm * * @param element * @param baseURI * @param secureValidation * @throws XMLSecurityException */ public SignatureAlgorithm( Element element, String baseURI, boolean secureValidation ) throws XMLSecurityException { super(element, baseURI); algorithmURI = this.getURI(); Attr attr = element.getAttributeNodeNS(null, "Id"); if (attr != null) { element.setIdAttributeNode(attr, true); } if (secureValidation && (XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(algorithmURI) || XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(algorithmURI))) { Object exArgs[] = { algorithmURI }; throw new XMLSecurityException("signature.signatureAlgorithm", exArgs); } signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI); signatureAlgorithm.engineGetContextFromElement(this.constructionElement); }
Example #2
Source File: TruncateHMAC.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void generate_hmac_sha1_40() throws Exception { System.out.println("Generating "); Document doc = dbf.newDocumentBuilder().newDocument(); XMLSignature sig = new XMLSignature (doc, null, XMLSignature.ALGO_ID_MAC_HMAC_SHA1, 40, Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS); try { sig.sign(getSecretKey("secret".getBytes("ASCII"))); System.out.println("FAILED"); atLeastOneFailed = true; } catch (XMLSignatureException xse) { System.out.println(xse.getMessage()); System.out.println("PASSED"); } }
Example #3
Source File: TruncateHMAC.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void generate_hmac_sha1_40() throws Exception { System.out.println("Generating "); Document doc = dbf.newDocumentBuilder().newDocument(); XMLSignature sig = new XMLSignature (doc, null, XMLSignature.ALGO_ID_MAC_HMAC_SHA1, 40, Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS); try { sig.sign(getSecretKey("secret".getBytes("ASCII"))); System.out.println("FAILED"); atLeastOneFailed = true; } catch (XMLSignatureException xse) { System.out.println(xse.getMessage()); System.out.println("PASSED"); } }
Example #4
Source File: TruncateHMAC.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static void generate_hmac_sha1_40() throws Exception { System.out.println("Generating "); Document doc = dbf.newDocumentBuilder().newDocument(); XMLSignature sig = new XMLSignature (doc, null, XMLSignature.ALGO_ID_MAC_HMAC_SHA1, 40, Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS); try { sig.sign(getSecretKey("secret".getBytes("ASCII"))); System.out.println("FAILED"); atLeastOneFailed = true; } catch (XMLSignatureException xse) { System.out.println(xse.getMessage()); System.out.println("PASSED"); } }
Example #5
Source File: SignatureAlgorithm.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Constructor SignatureAlgorithm * * @param element * @param baseURI * @param secureValidation * @throws XMLSecurityException */ public SignatureAlgorithm( Element element, String baseURI, boolean secureValidation ) throws XMLSecurityException { super(element, baseURI); algorithmURI = this.getURI(); Attr attr = element.getAttributeNodeNS(null, "Id"); if (attr != null) { element.setIdAttributeNode(attr, true); } if (secureValidation && (XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(algorithmURI) || XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(algorithmURI))) { Object exArgs[] = { algorithmURI }; throw new XMLSecurityException("signature.signatureAlgorithm", exArgs); } signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI); signatureAlgorithm.engineGetContextFromElement(this.constructionElement); }
Example #6
Source File: TruncateHMAC.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void generate_hmac_sha1_40() throws Exception { System.out.println("Generating "); Document doc = dbf.newDocumentBuilder().newDocument(); XMLSignature sig = new XMLSignature (doc, null, XMLSignature.ALGO_ID_MAC_HMAC_SHA1, 40, Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS); try { sig.sign(getSecretKey("secret".getBytes("ASCII"))); System.out.println("FAILED"); atLeastOneFailed = true; } catch (XMLSignatureException xse) { System.out.println(xse.getMessage()); System.out.println("PASSED"); } }
Example #7
Source File: SignatureAlgorithm.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Constructor SignatureAlgorithm * * @param element * @param baseURI * @param secureValidation * @throws XMLSecurityException */ public SignatureAlgorithm( Element element, String baseURI, boolean secureValidation ) throws XMLSecurityException { super(element, baseURI); algorithmURI = this.getURI(); Attr attr = element.getAttributeNodeNS(null, "Id"); if (attr != null) { element.setIdAttributeNode(attr, true); } if (secureValidation && (XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(algorithmURI) || XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(algorithmURI))) { Object exArgs[] = { algorithmURI }; throw new XMLSecurityException("signature.signatureAlgorithm", exArgs); } signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI); signatureAlgorithm.engineGetContextFromElement(this.constructionElement); }
Example #8
Source File: TruncateHMAC.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void validate(String data, boolean pass) throws Exception { System.out.println("Validating " + data); File file = new File(DIR, data); Document doc = dbf.newDocumentBuilder().parse(file); NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature"); if (nl.getLength() == 0) { throw new Exception("Couldn't find signature Element"); } Element sigElement = (Element) nl.item(0); XMLSignature signature = new XMLSignature (sigElement, file.toURI().toString()); SecretKey sk = signature.createSecretKey("secret".getBytes("ASCII")); try { System.out.println ("Validation status: " + signature.checkSignatureValue(sk)); if (!pass) { System.out.println("FAILED"); atLeastOneFailed = true; } else { System.out.println("PASSED"); } } catch (XMLSignatureException xse) { System.out.println(xse.getMessage()); if (!pass) { System.out.println("PASSED"); } else { System.out.println("FAILED"); atLeastOneFailed = true; } } }
Example #9
Source File: TruncateHMAC.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void validate(String data, boolean pass) throws Exception { System.out.println("Validating " + data); File file = new File(DIR, data); Document doc = dbf.newDocumentBuilder().parse(file); NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature"); if (nl.getLength() == 0) { throw new Exception("Couldn't find signature Element"); } Element sigElement = (Element) nl.item(0); XMLSignature signature = new XMLSignature (sigElement, file.toURI().toString()); SecretKey sk = signature.createSecretKey("secret".getBytes("ASCII")); try { System.out.println ("Validation status: " + signature.checkSignatureValue(sk)); if (!pass) { System.out.println("FAILED"); atLeastOneFailed = true; } else { System.out.println("PASSED"); } } catch (XMLSignatureException xse) { System.out.println(xse.getMessage()); if (!pass) { System.out.println("PASSED"); } else { System.out.println("FAILED"); atLeastOneFailed = true; } } }
Example #10
Source File: TruncateHMAC.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void validate(String data, boolean pass) throws Exception { System.out.println("Validating " + data); File file = new File(DIR, data); Document doc = dbf.newDocumentBuilder().parse(file); NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature"); if (nl.getLength() == 0) { throw new Exception("Couldn't find signature Element"); } Element sigElement = (Element) nl.item(0); XMLSignature signature = new XMLSignature (sigElement, file.toURI().toString()); SecretKey sk = signature.createSecretKey("secret".getBytes("ASCII")); try { System.out.println ("Validation status: " + signature.checkSignatureValue(sk)); if (!pass) { System.out.println("FAILED"); atLeastOneFailed = true; } else { System.out.println("PASSED"); } } catch (XMLSignatureException xse) { System.out.println(xse.getMessage()); if (!pass) { System.out.println("PASSED"); } else { System.out.println("FAILED"); atLeastOneFailed = true; } } }
Example #11
Source File: TruncateHMAC.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void validate(String data, boolean pass) throws Exception { System.out.println("Validating " + data); File file = new File(DIR, data); Document doc = dbf.newDocumentBuilder().parse(file); NodeList nl = doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature"); if (nl.getLength() == 0) { throw new Exception("Couldn't find signature Element"); } Element sigElement = (Element) nl.item(0); XMLSignature signature = new XMLSignature (sigElement, file.toURI().toString()); SecretKey sk = signature.createSecretKey("secret".getBytes("ASCII")); try { System.out.println ("Validation status: " + signature.checkSignatureValue(sk)); if (!pass) { System.out.println("FAILED"); atLeastOneFailed = true; } else { System.out.println("PASSED"); } } catch (XMLSignatureException xse) { System.out.println(xse.getMessage()); if (!pass) { System.out.println("PASSED"); } else { System.out.println("FAILED"); atLeastOneFailed = true; } } }
Example #12
Source File: SignatureAlgorithm.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put(SignatureDSA.URI, SignatureDSA.class); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #13
Source File: SignatureBaseRSA.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1; }
Example #14
Source File: SignatureECDSA.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1; }
Example #15
Source File: SignatureBaseRSA.java From hottub with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384; }
Example #16
Source File: SignatureDSA.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256; }
Example #17
Source File: SignatureBaseRSA.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384; }
Example #18
Source File: SignatureBaseRSA.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512; }
Example #19
Source File: SignatureBaseRSA.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256; }
Example #20
Source File: SignatureECDSA.java From hottub with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512; }
Example #21
Source File: SignatureAlgorithm.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put(SignatureDSA.URI, SignatureDSA.class); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #22
Source File: SignatureBaseRSA.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160; }
Example #23
Source File: SignatureBaseRSA.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160; }
Example #24
Source File: SignatureDSA.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256; }
Example #25
Source File: SignatureBaseRSA.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5; }
Example #26
Source File: SignatureBaseRSA.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5; }
Example #27
Source File: SignatureAlgorithm.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * This method registers the default algorithms. */ public static void registerDefaultAlgorithms() { algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5, SignatureBaseRSA.SignatureRSAMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160, SignatureBaseRSA.SignatureRSARIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class ); algorithmHash.put( XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class ); }
Example #28
Source File: SignatureECDSA.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512; }
Example #29
Source File: SignatureBaseRSA.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512; }
Example #30
Source File: SignatureECDSA.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public String engineGetURI() { return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512; }