Class DOMHMACSignatureMethod

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String DOM_SIGNATURE_PROVIDER  
      private javax.crypto.Mac hmac  
      (package private) static java.lang.String HMAC_RIPEMD160  
      (package private) static java.lang.String HMAC_SHA224  
      (package private) static java.lang.String HMAC_SHA256  
      (package private) static java.lang.String HMAC_SHA384  
      (package private) static java.lang.String HMAC_SHA512  
      private static org.slf4j.Logger LOG  
      private int outputLength  
      private boolean outputLengthSet  
      private javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params  
      • Fields inherited from interface javax.xml.crypto.dsig.SignatureMethod

        DSA_SHA1, DSA_SHA256, ECDSA_SHA1, ECDSA_SHA224, ECDSA_SHA256, ECDSA_SHA384, ECDSA_SHA512, HMAC_SHA1, RSA_SHA1, RSA_SHA224, RSA_SHA256, RSA_SHA384, RSA_SHA512, SHA1_RSA_MGF1, SHA224_RSA_MGF1, SHA256_RSA_MGF1, SHA384_RSA_MGF1, SHA512_RSA_MGF1
    • Constructor Summary

      Constructors 
      Constructor Description
      DOMHMACSignatureMethod​(java.security.spec.AlgorithmParameterSpec params)
      Creates a DOMHMACSignatureMethod with the specified params
      DOMHMACSignatureMethod​(org.w3c.dom.Element smElem)
      Creates a DOMHMACSignatureMethod from an element.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void checkParams​(javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params)
      Checks if the specified parameters are valid for this algorithm.
      (package private) AbstractDOMSignatureMethod.Type getAlgorithmType()
      Returns the type of signature algorithm.
      (package private) abstract int getDigestLength()
      Returns the output length of the hash/digest.
      java.security.spec.AlgorithmParameterSpec getParameterSpec()  
      (package private) void marshalParams​(org.w3c.dom.Element parent, java.lang.String prefix)
      Marshals the algorithm-specific parameters to an Element and appends it to the specified parent element.
      (package private) boolean paramsEqual​(java.security.spec.AlgorithmParameterSpec spec)
      Returns true if parameters are equal; false otherwise.
      (package private) byte[] sign​(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, javax.xml.crypto.dsig.XMLSignContext context)
      Signs the bytes with the specified key, using the underlying Signature or Mac algorithm.
      (package private) javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec unmarshalParams​(org.w3c.dom.Element paramsElem)
      Unmarshals SignatureMethodParameterSpec from the specified Element.
      (package private) boolean verify​(java.security.Key key, javax.xml.crypto.dsig.SignedInfo si, byte[] sig, javax.xml.crypto.dsig.XMLValidateContext context)
      Verifies the passed-in signature with the specified key, using the underlying Signature or Mac algorithm.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.xml.crypto.AlgorithmMethod

        getAlgorithm
      • Methods inherited from interface javax.xml.crypto.XMLStructure

        isFeatureSupported
    • Field Detail

      • DOM_SIGNATURE_PROVIDER

        private static final java.lang.String DOM_SIGNATURE_PROVIDER
        See Also:
        Constant Field Values
      • LOG

        private static final org.slf4j.Logger LOG
      • hmac

        private javax.crypto.Mac hmac
      • outputLength

        private int outputLength
      • outputLengthSet

        private boolean outputLengthSet
      • params

        private javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params
    • Constructor Detail

      • DOMHMACSignatureMethod

        DOMHMACSignatureMethod​(java.security.spec.AlgorithmParameterSpec params)
                        throws java.security.InvalidAlgorithmParameterException
        Creates a DOMHMACSignatureMethod with the specified params
        Parameters:
        params - algorithm-specific parameters (may be null)
        Throws:
        java.security.InvalidAlgorithmParameterException - if params are inappropriate
      • DOMHMACSignatureMethod

        DOMHMACSignatureMethod​(org.w3c.dom.Element smElem)
                        throws javax.xml.crypto.MarshalException
        Creates a DOMHMACSignatureMethod from an element.
        Parameters:
        smElem - a SignatureMethod element
        Throws:
        javax.xml.crypto.MarshalException
    • Method Detail

      • checkParams

        void checkParams​(javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec params)
                  throws java.security.InvalidAlgorithmParameterException
        Description copied from class: AbstractDOMSignatureMethod
        Checks if the specified parameters are valid for this algorithm. By default, this method throws an exception if parameters are specified since most SignatureMethod algorithms do not have parameters. Subclasses should override it if they have parameters.
        Overrides:
        checkParams in class AbstractDOMSignatureMethod
        Parameters:
        params - the algorithm-specific params (may be null)
        Throws:
        java.security.InvalidAlgorithmParameterException - if the parameters are not appropriate for this signature method
      • getParameterSpec

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

        javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec unmarshalParams​(org.w3c.dom.Element paramsElem)
                                                                         throws javax.xml.crypto.MarshalException
        Description copied from class: AbstractDOMSignatureMethod
        Unmarshals SignatureMethodParameterSpec from the specified Element. By default, this method throws an exception since most SignatureMethod algorithms do not have parameters. Subclasses should override it if they have parameters.
        Overrides:
        unmarshalParams in class AbstractDOMSignatureMethod
        Parameters:
        paramsElem - the Element holding the input params
        Returns:
        the algorithm-specific SignatureMethodParameterSpec
        Throws:
        javax.xml.crypto.MarshalException - if the parameters cannot be unmarshalled
      • marshalParams

        void marshalParams​(org.w3c.dom.Element parent,
                           java.lang.String prefix)
                    throws javax.xml.crypto.MarshalException
        Description copied from class: AbstractDOMSignatureMethod
        Marshals the algorithm-specific parameters to an Element and appends it to the specified parent element. By default, this method throws an exception since most SignatureMethod algorithms do not have parameters. Subclasses should override it if they have parameters.
        Overrides:
        marshalParams in class AbstractDOMSignatureMethod
        Parameters:
        parent - the parent element to append the parameters to
        prefix - the algorithm parameters prefix to use
        Throws:
        javax.xml.crypto.MarshalException - if the parameters cannot be marshalled
      • 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
      • paramsEqual

        boolean paramsEqual​(java.security.spec.AlgorithmParameterSpec spec)
        Description copied from class: AbstractDOMSignatureMethod
        Returns true if parameters are equal; false otherwise. Subclasses should override this method to compare algorithm-specific parameters.
        Overrides:
        paramsEqual in class AbstractDOMSignatureMethod
      • getDigestLength

        abstract int getDigestLength()
        Returns the output length of the hash/digest.