Class DOMSignatureMethod

    • Constructor Detail

      • DOMSignatureMethod

        DOMSignatureMethod​(java.security.spec.AlgorithmParameterSpec params)
                    throws java.security.InvalidAlgorithmParameterException
        Creates a DOMSignatureMethod.
        Parameters:
        params - the algorithm-specific params (may be null)
        Throws:
        java.security.InvalidAlgorithmParameterException - if the parameters are not appropriate for this signature method
      • DOMSignatureMethod

        DOMSignatureMethod​(org.w3c.dom.Element smElem)
                    throws javax.xml.crypto.MarshalException
        Creates a DOMSignatureMethod from an element. This ctor invokes the unmarshalParams method to unmarshal any algorithm-specific input parameters.
        Parameters:
        smElem - a SignatureMethod element
        Throws:
        javax.xml.crypto.MarshalException
    • Method Detail

      • postSignFormat

        abstract byte[] postSignFormat​(java.security.Key key,
                                       byte[] sig)
                                throws java.io.IOException
        Returns the signature bytes with any additional formatting necessary for the signature algorithm used. For RSA signatures, no changes are required, and this method should simply return back sig. For DSA and ECDSA, this method should return the signature in the IEEE P1363 format, the concatenation of r and s.
        Parameters:
        key - the key used to sign
        sig - the signature returned by Signature.sign()
        Returns:
        the formatted signature
        Throws:
        java.io.IOException
      • preVerifyFormat

        abstract byte[] preVerifyFormat​(java.security.Key key,
                                        byte[] sig)
                                 throws java.io.IOException
        Returns the signature bytes with any conversions that are necessary before the signature can be verified. For RSA signatures, no changes are required, and this method should simply return back sig. For DSA and ECDSA, this method should return the signature in the DER-encoded ASN.1 format.
        Parameters:
        key - the key used to sign
        sig - the signature
        Returns:
        the formatted signature
        Throws:
        java.io.IOException
      • unmarshal

        static javax.xml.crypto.dsig.SignatureMethod unmarshal​(org.w3c.dom.Element smElem)
                                                        throws javax.xml.crypto.MarshalException
        Throws:
        javax.xml.crypto.MarshalException
      • getParameterSpec

        public final java.security.spec.AlgorithmParameterSpec getParameterSpec()
      • getSignature

        java.security.Signature getSignature​(java.security.Provider p)
                                      throws java.security.NoSuchAlgorithmException
        Returns an instance of Signature from the specified Provider. The algorithm is specified by the getJCAAlgorithm() method.
        Parameters:
        p - the Provider to use
        Returns:
        an instance of Signature implementing the algorithm specified by getJCAAlgorithm()
        Throws:
        java.security.NoSuchAlgorithmException - if the Provider does not support the signature algorithm
      • verify

        boolean verify​(java.security.Key key,
                       javax.xml.crypto.dsig.SignedInfo si,
                       byte[] sig,
                       javax.xml.crypto.dsig.XMLValidateContext context)
                throws java.security.InvalidKeyException,
                       java.security.SignatureException,
                       javax.xml.crypto.dsig.XMLSignatureException
        Description copied from class: AbstractDOMSignatureMethod
        Verifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.
        Specified by:
        verify in class AbstractDOMSignatureMethod
        Parameters:
        key - the verification key
        si - the SignedInfo
        sig - the signature bytes to be verified
        context - the XMLValidateContext
        Returns:
        true if the signature verified successfully, false if not
        Throws:
        java.security.InvalidKeyException - if the key is improperly encoded, of the wrong type, or parameters are missing, etc
        java.security.SignatureException - if an unexpected error occurs, such as the passed in signature is improperly encoded
        javax.xml.crypto.dsig.XMLSignatureException - if an unexpected error occurs
      • sign

        byte[] sign​(java.security.Key key,
                    javax.xml.crypto.dsig.SignedInfo si,
                    javax.xml.crypto.dsig.XMLSignContext context)
             throws java.security.InvalidKeyException,
                    javax.xml.crypto.dsig.XMLSignatureException
        Description copied from class: AbstractDOMSignatureMethod
        Signs the bytes with the specified key, using the underlying Signature or Mac algorithm.
        Specified by:
        sign in class AbstractDOMSignatureMethod
        Parameters:
        key - the signing key
        si - the SignedInfo
        context - the XMLSignContext
        Returns:
        the signature
        Throws:
        java.security.InvalidKeyException - if the key is improperly encoded, of the wrong type, or parameters are missing, etc
        javax.xml.crypto.dsig.XMLSignatureException - if an unexpected error occurs