java.security.interfaces.DSAKey#com.sun.org.apache.xml.internal.security.signature.XMLSignatureException源码实例Demo

下面列出了java.security.interfaces.DSAKey#com.sun.org.apache.xml.internal.security.signature.XMLSignatureException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: RetrievalMethod.java
/**
 * 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);
    }
}
 
/**
 * 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);
}
 
源代码3 项目: TencentKona-8   文件: IntegrityHmac.java
/**
 * 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);
    }
}
 
源代码4 项目: jdk1.8-source-analysis   文件: SignatureECDSA.java
/** @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);
    }
}
 
源代码5 项目: TencentKona-8   文件: SignatureDSA.java
/**
 * @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();
}
 
源代码6 项目: jdk1.8-source-analysis   文件: SignatureBaseRSA.java
/** @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);
    }
}
 
源代码7 项目: TencentKona-8   文件: SignatureECDSA.java
/** @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);
    }
}
 
源代码8 项目: jdk1.8-source-analysis   文件: SignatureDSA.java
/**
 * @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();
}
 
源代码9 项目: jdk1.8-source-analysis   文件: SignatureDSA.java
/**
 * @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();
}
 
源代码10 项目: dragonwell8_jdk   文件: SignatureAlgorithm.java
/**
 * 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);
}
 
源代码11 项目: TencentKona-8   文件: SignatureDSA.java
/**
 * @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();
}
 
源代码12 项目: TencentKona-8   文件: RetrievalMethod.java
/**
 * 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);
    }
}
 
源代码13 项目: jdk1.8-source-analysis   文件: Transforms.java
/**
 * 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);
    }
}
 
/**
 * 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);
}
 
源代码15 项目: TencentKona-8   文件: IntegrityHmac.java
/**
 * 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);
    }
}
 
源代码16 项目: TencentKona-8   文件: SignatureBaseRSA.java
/** @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);
    }
}
 
源代码17 项目: TencentKona-8   文件: SignatureDSA.java
/**
 * @inheritDoc
 */
protected void engineSetParameter(AlgorithmParameterSpec params)
    throws XMLSignatureException {
    try {
        this.signatureAlgorithm.setParameter(params);
    } catch (InvalidAlgorithmParameterException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
源代码18 项目: TencentKona-8   文件: IntegrityHmac.java
/**
 * 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);
    }
}
 
源代码19 项目: jdk1.8-source-analysis   文件: SignatureECDSA.java
/** @inheritDoc */
protected void engineUpdate(byte input) throws XMLSignatureException {
    try {
        this.signatureAlgorithm.update(input);
    } catch (SignatureException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
源代码20 项目: TencentKona-8   文件: SignatureBaseRSA.java
/** @inheritDoc */
protected byte[] engineSign() throws XMLSignatureException {
    try {
        return this.signatureAlgorithm.sign();
    } catch (SignatureException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
源代码21 项目: dragonwell8_jdk   文件: SignatureDSA.java
/**
 * @inheritDoc
 */
protected void engineUpdate(byte input) throws XMLSignatureException {
    try {
        this.signatureAlgorithm.update(input);
    } catch (SignatureException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
源代码22 项目: dragonwell8_jdk   文件: IntegrityHmac.java
/**
 * 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);
    }
}
 
源代码23 项目: dragonwell8_jdk   文件: Transforms.java
/**
 * 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);
    }
}
 
源代码24 项目: dragonwell8_jdk   文件: MessageDigestAlgorithm.java
/**
 * 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);
}
 
源代码25 项目: jdk1.8-source-analysis   文件: SignatureBaseRSA.java
/** @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);
    }
}
 
源代码26 项目: TencentKona-8   文件: SignerOutputStream.java
/** @inheritDoc */
public void write(byte[] arg0)  {
    try {
        sa.update(arg0);
    } catch (XMLSignatureException e) {
        throw new RuntimeException("" + e);
    }
}
 
源代码27 项目: TencentKona-8   文件: SignatureECDSA.java
/** @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);
    }
}
 
源代码28 项目: jdk1.8-source-analysis   文件: SignatureDSA.java
/**
 * @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();
}
 
源代码29 项目: dragonwell8_jdk   文件: SignatureBaseRSA.java
/** @inheritDoc */
protected void engineUpdate(byte input) throws XMLSignatureException {
    try {
        this.signatureAlgorithm.update(input);
    } catch (SignatureException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
 
源代码30 项目: TencentKona-8   文件: SignatureBaseRSA.java
/** @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);
    }
}