com.sun.org.apache.xml.internal.security.signature.XMLSignatureException Java Examples
The following examples show how to use
com.sun.org.apache.xml.internal.security.signature.XMLSignatureException.
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: SignatureECDSA.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** @inheritDoc */ protected void engineInitSign(Key privateKey, SecureRandom secureRandom) throws XMLSignatureException { if (!(privateKey instanceof PrivateKey)) { String supplied = privateKey.getClass().getName(); String needed = PrivateKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom); } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } }
Example #2
Source File: SignatureECDSA.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** @inheritDoc */ protected void engineInitSign(Key privateKey, SecureRandom secureRandom) throws XMLSignatureException { if (!(privateKey instanceof PrivateKey)) { String supplied = privateKey.getClass().getName(); String needed = PrivateKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom); } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } }
Example #3
Source File: RetrievalMethod.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Method getTransforms * * @throws XMLSecurityException * @return the transformations */ public Transforms getTransforms() throws XMLSecurityException { try { Element transformsElem = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0); if (transformsElem != null) { return new Transforms(transformsElem, this.baseURI); } return null; } catch (XMLSignatureException ex) { throw new XMLSecurityException("empty", ex); } }
Example #4
Source File: SignatureAlgorithm.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Registers implementing class of the Transform algorithm with algorithmURI * * @param algorithmURI algorithmURI URI representation of <code>SignatureAlgorithm</code>. * @param implementingClass <code>implementingClass</code> the implementing class of * {@link SignatureAlgorithmSpi} * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered * @throws XMLSignatureException * @throws SecurityException if a security manager is installed and the * caller does not have permission to register the signature algorithm */ public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass) throws AlgorithmAlreadyRegisteredException, ClassNotFoundException, XMLSignatureException { JavaUtils.checkRegisterPermission(); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass); } // are we already registered? Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI); if (registeredClass != null) { Object exArgs[] = { algorithmURI, registeredClass }; throw new AlgorithmAlreadyRegisteredException( "algorithm.alreadyRegistered", exArgs ); } algorithmHash.put(algorithmURI, implementingClass); }
Example #5
Source File: IntegrityHmac.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Method engineInitSign * * @param secretKey * @throws XMLSignatureException */ protected void engineInitSign(Key secretKey) throws XMLSignatureException { if (!(secretKey instanceof SecretKey)) { String supplied = secretKey.getClass().getName(); String needed = SecretKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.macAlgorithm.init(secretKey); } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } }
Example #6
Source File: RetrievalMethod.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Method getTransforms * * @throws XMLSecurityException * @return the transformations */ public Transforms getTransforms() throws XMLSecurityException { try { Element transformsElem = XMLUtils.selectDsNode( this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0); if (transformsElem != null) { return new Transforms(transformsElem, this.baseURI); } return null; } catch (XMLSignatureException ex) { throw new XMLSecurityException("empty", ex); } }
Example #7
Source File: SignatureBaseRSA.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** @inheritDoc */ protected void engineInitSign(Key privateKey, SecureRandom secureRandom) throws XMLSignatureException { if (!(privateKey instanceof PrivateKey)) { String supplied = privateKey.getClass().getName(); String needed = PrivateKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom); } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } }
Example #8
Source File: SignatureDSA.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * @inheritDoc */ protected void engineInitSign(Key privateKey, SecureRandom secureRandom) throws XMLSignatureException { if (!(privateKey instanceof PrivateKey)) { String supplied = privateKey.getClass().getName(); String needed = PrivateKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom); } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } size = ((DSAKey)privateKey).getParams().getQ().bitLength(); }
Example #9
Source File: SignatureDSA.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * @inheritDoc */ protected void engineInitSign(Key privateKey) throws XMLSignatureException { if (!(privateKey instanceof PrivateKey)) { String supplied = privateKey.getClass().getName(); String needed = PrivateKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initSign((PrivateKey) privateKey); } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } size = ((DSAKey)privateKey).getParams().getQ().bitLength(); }
Example #10
Source File: SignatureDSA.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * @inheritDoc */ protected void engineInitSign(Key privateKey, SecureRandom secureRandom) throws XMLSignatureException { if (!(privateKey instanceof PrivateKey)) { String supplied = privateKey.getClass().getName(); String needed = PrivateKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom); } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } size = ((DSAKey)privateKey).getParams().getQ().bitLength(); }
Example #11
Source File: SignatureDSA.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * @inheritDoc */ protected void engineInitSign(Key privateKey) throws XMLSignatureException { if (!(privateKey instanceof PrivateKey)) { String supplied = privateKey.getClass().getName(); String needed = PrivateKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initSign((PrivateKey) privateKey); } catch (InvalidKeyException ex) { throw new XMLSignatureException("empty", ex); } size = ((DSAKey)privateKey).getParams().getQ().bitLength(); }
Example #12
Source File: SignatureAlgorithm.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Registers implementing class of the Transform algorithm with algorithmURI * * @param algorithmURI algorithmURI URI representation of <code>SignatureAlgorithm</code>. * @param implementingClass <code>implementingClass</code> the implementing class of * {@link SignatureAlgorithmSpi} * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered * @throws XMLSignatureException * @throws SecurityException if a security manager is installed and the * caller does not have permission to register the signature algorithm */ public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass) throws AlgorithmAlreadyRegisteredException, ClassNotFoundException, XMLSignatureException { JavaUtils.checkRegisterPermission(); if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass); } // are we already registered? Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI); if (registeredClass != null) { Object exArgs[] = { algorithmURI, registeredClass }; throw new AlgorithmAlreadyRegisteredException( "algorithm.alreadyRegistered", exArgs ); } algorithmHash.put(algorithmURI, implementingClass); }
Example #13
Source File: IntegrityHmac.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Proxy method for {@link java.security.Signature#update(byte[])} * which is executed on the internal {@link java.security.Signature} object. * * @param input * @throws XMLSignatureException */ protected void engineUpdate(byte[] input) throws XMLSignatureException { try { this.macAlgorithm.update(input); } catch (IllegalStateException ex) { throw new XMLSignatureException("empty", ex); } }
Example #14
Source File: SignatureBaseRSA.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** @inheritDoc */ protected void engineUpdate(byte input) throws XMLSignatureException { try { this.signatureAlgorithm.update(input); } catch (SignatureException ex) { throw new XMLSignatureException("empty", ex); } }
Example #15
Source File: SignatureDSA.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * @inheritDoc */ protected void engineInitVerify(Key publicKey) throws XMLSignatureException { if (!(publicKey instanceof PublicKey)) { String supplied = publicKey.getClass().getName(); String needed = PublicKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initVerify((PublicKey) publicKey); } catch (InvalidKeyException ex) { // reinstantiate Signature object to work around bug in JDK // see: http://bugs.sun.com/view_bug.do?bug_id=4953555 Signature sig = this.signatureAlgorithm; try { this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm()); } catch (Exception e) { // this shouldn't occur, but if it does, restore previous // Signature if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e); } this.signatureAlgorithm = sig; } throw new XMLSignatureException("empty", ex); } size = ((DSAKey)publicKey).getParams().getQ().bitLength(); }
Example #16
Source File: IntegrityHmac.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Proxy method for {@link java.security.Signature#update(byte[])} * which is executed on the internal {@link java.security.Signature} object. * * @param input * @throws XMLSignatureException */ protected void engineUpdate(byte[] input) throws XMLSignatureException { try { this.macAlgorithm.update(input); } catch (IllegalStateException ex) { throw new XMLSignatureException("empty", ex); } }
Example #17
Source File: SignatureBaseRSA.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** @inheritDoc */ protected byte[] engineSign() throws XMLSignatureException { try { return this.signatureAlgorithm.sign(); } catch (SignatureException ex) { throw new XMLSignatureException("empty", ex); } }
Example #18
Source File: SignerOutputStream.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** @inheritDoc */ public void write(int arg0) { try { sa.update((byte)arg0); } catch (XMLSignatureException e) { throw new RuntimeException("" + e); } }
Example #19
Source File: TruncateHMAC.java From dragonwell8_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 #20
Source File: IntegrityHmac.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Proxy method for {@link java.security.Signature#update(byte[])} * which is executed on the internal {@link java.security.Signature} object. * * @param input * @throws XMLSignatureException */ protected void engineUpdate(byte[] input) throws XMLSignatureException { try { this.macAlgorithm.update(input); } catch (IllegalStateException ex) { throw new XMLSignatureException("empty", ex); } }
Example #21
Source File: SignatureBaseRSA.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** @inheritDoc */ protected void engineInitVerify(Key publicKey) throws XMLSignatureException { if (!(publicKey instanceof PublicKey)) { String supplied = publicKey.getClass().getName(); String needed = PublicKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initVerify((PublicKey) publicKey); } catch (InvalidKeyException ex) { // reinstantiate Signature object to work around bug in JDK // see: http://bugs.sun.com/view_bug.do?bug_id=4953555 Signature sig = this.signatureAlgorithm; try { this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm()); } catch (Exception e) { // this shouldn't occur, but if it does, restore previous // Signature if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e); } this.signatureAlgorithm = sig; } throw new XMLSignatureException("empty", ex); } }
Example #22
Source File: Transforms.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Constructs {@link Transforms} from {@link Element} which is * <code>Transforms</code> Element * * @param element is <code>Transforms</code> element * @param BaseURI the URI where the XML instance was stored * @throws DOMException * @throws InvalidTransformException * @throws TransformationException * @throws XMLSecurityException * @throws XMLSignatureException */ public Transforms(Element element, String BaseURI) throws DOMException, XMLSignatureException, InvalidTransformException, TransformationException, XMLSecurityException { super(element, BaseURI); int numberOfTransformElems = this.getLength(); if (numberOfTransformElems == 0) { // At least one Transform element must be present. Bad. Object exArgs[] = { Constants._TAG_TRANSFORM, Constants._TAG_TRANSFORMS }; throw new TransformationException("xml.WrongContent", exArgs); } }
Example #23
Source File: SignatureDSA.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * @inheritDoc */ protected void engineUpdate(byte input) throws XMLSignatureException { try { this.signatureAlgorithm.update(input); } catch (SignatureException ex) { throw new XMLSignatureException("empty", ex); } }
Example #24
Source File: SignatureDSA.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * @inheritDoc */ protected void engineInitVerify(Key publicKey) throws XMLSignatureException { if (!(publicKey instanceof PublicKey)) { String supplied = publicKey.getClass().getName(); String needed = PublicKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initVerify((PublicKey) publicKey); } catch (InvalidKeyException ex) { // reinstantiate Signature object to work around bug in JDK // see: http://bugs.sun.com/view_bug.do?bug_id=4953555 Signature sig = this.signatureAlgorithm; try { this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm()); } catch (Exception e) { // this shouldn't occur, but if it does, restore previous // Signature if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e); } this.signatureAlgorithm = sig; } throw new XMLSignatureException("empty", ex); } size = ((DSAKey)publicKey).getParams().getQ().bitLength(); }
Example #25
Source File: SignatureECDSA.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** @inheritDoc */ protected void engineInitVerify(Key publicKey) throws XMLSignatureException { if (!(publicKey instanceof PublicKey)) { String supplied = publicKey.getClass().getName(); String needed = PublicKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.signatureAlgorithm.initVerify((PublicKey) publicKey); } catch (InvalidKeyException ex) { // reinstantiate Signature object to work around bug in JDK // see: http://bugs.sun.com/view_bug.do?bug_id=4953555 Signature sig = this.signatureAlgorithm; try { this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm()); } catch (Exception e) { // this shouldn't occur, but if it does, restore previous // Signature if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e); } this.signatureAlgorithm = sig; } throw new XMLSignatureException("empty", ex); } }
Example #26
Source File: SignerOutputStream.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** @inheritDoc */ public void write(byte[] arg0) { try { sa.update(arg0); } catch (XMLSignatureException e) { throw new RuntimeException("" + e); } }
Example #27
Source File: IntegrityHmac.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Proxy method for {@link java.security.Signature#initVerify(java.security.PublicKey)} * which is executed on the internal {@link java.security.Signature} object. * * @param secretKey * @throws XMLSignatureException */ protected void engineInitVerify(Key secretKey) throws XMLSignatureException { if (!(secretKey instanceof SecretKey)) { String supplied = secretKey.getClass().getName(); String needed = SecretKey.class.getName(); Object exArgs[] = { supplied, needed }; throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs); } try { this.macAlgorithm.init(secretKey); } catch (InvalidKeyException ex) { // reinstantiate Mac object to work around bug in JDK // see: http://bugs.sun.com/view_bug.do?bug_id=4953555 Mac mac = this.macAlgorithm; try { this.macAlgorithm = Mac.getInstance(macAlgorithm.getAlgorithm()); } catch (Exception e) { // this shouldn't occur, but if it does, restore previous Mac if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Mac:" + e); } this.macAlgorithm = mac; } throw new XMLSignatureException("empty", ex); } }
Example #28
Source File: Transforms.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructs {@link Transforms} from {@link Element} which is * <code>Transforms</code> Element * * @param element is <code>Transforms</code> element * @param BaseURI the URI where the XML instance was stored * @throws DOMException * @throws InvalidTransformException * @throws TransformationException * @throws XMLSecurityException * @throws XMLSignatureException */ public Transforms(Element element, String BaseURI) throws DOMException, XMLSignatureException, InvalidTransformException, TransformationException, XMLSecurityException { super(element, BaseURI); int numberOfTransformElems = this.getLength(); if (numberOfTransformElems == 0) { // At least one Transform element must be present. Bad. Object exArgs[] = { Constants._TAG_TRANSFORM, Constants._TAG_TRANSFORMS }; throw new TransformationException("xml.WrongContent", exArgs); } }
Example #29
Source File: MessageDigestAlgorithm.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Constructor for the brave who pass their own message digest algorithms and the * corresponding URI. * @param doc * @param algorithmURI */ private MessageDigestAlgorithm(Document doc, String algorithmURI) throws XMLSignatureException { super(doc, algorithmURI); algorithm = getDigestInstance(algorithmURI); }
Example #30
Source File: SignatureBaseRSA.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** @inheritDoc */ protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException { try { this.signatureAlgorithm.update(buf, offset, len); } catch (SignatureException ex) { throw new XMLSignatureException("empty", ex); } }