Class HMACSignatureTest


  • public class HMACSignatureTest
    extends org.opensaml.core.xml.XMLObjectBaseTestCase
    Test to verify Signature and its marshallers and unmarshallers.
    • Field Detail

      • log

        private final org.slf4j.Logger log
        Class logger.
      • goodCredential

        private org.opensaml.security.credential.Credential goodCredential
        Credential used to sign and verify.
      • badCredential

        private org.opensaml.security.credential.Credential badCredential
        Invalid credential for verification.
      • sigBuilder

        private org.opensaml.core.xml.XMLObjectBuilder<org.opensaml.xmlsec.signature.Signature> sigBuilder
        Builder of Signature XML objects.
      • keyInfoBuilder

        private org.opensaml.core.xml.XMLObjectBuilder<org.opensaml.xmlsec.signature.KeyInfo> keyInfoBuilder
        Build of KeyInfo objects.
      • hmacOutputLength

        private Integer hmacOutputLength
        Value of HMACOutputLength element child of SignatureMethod.
      • expectedKeyName

        private String expectedKeyName
        Expected key name value in KeyInfo.
      • algoURI

        private String algoURI
        Signature algorithm URI.
    • Constructor Detail

      • HMACSignatureTest

        public HMACSignatureTest()
    • Method Detail

      • testSigningAndVerificationNoOutputLength

        public void testSigningAndVerificationNoOutputLength()
                                                      throws org.opensaml.core.xml.io.MarshallingException,
                                                             javax.xml.bind.ValidationException,
                                                             org.opensaml.xmlsec.signature.support.SignatureException
        Tests creating an enveloped signature and then verifying it.
        Throws:
        org.opensaml.core.xml.io.MarshallingException - thrown if the XMLObject tree can not be marshalled
        javax.xml.bind.ValidationException - thrown if signature validator fails to validate the signature
        org.opensaml.xmlsec.signature.support.SignatureException - ...
      • testSigningAndVerificationWithOutputLength

        public void testSigningAndVerificationWithOutputLength()
                                                        throws org.opensaml.core.xml.io.MarshallingException,
                                                               org.opensaml.xmlsec.signature.support.SignatureException
        Tests creating an enveloped signature and then verifying it.
        Throws:
        org.opensaml.core.xml.io.MarshallingException - thrown if the XMLObject tree can not be marshalled
        org.opensaml.xmlsec.signature.support.SignatureException - ...
      • testUnmarshallNoOutputLength

        public void testUnmarshallNoOutputLength()
                                          throws net.shibboleth.utilities.java.support.xml.XMLParserException,
                                                 org.opensaml.core.xml.io.UnmarshallingException
        Tests unmarshalling with SignatureMethod/HMACOutputLength not present.
        Throws:
        net.shibboleth.utilities.java.support.xml.XMLParserException - thrown if the XML can not be parsed
        org.opensaml.core.xml.io.UnmarshallingException - thrown if the DOM can not be unmarshalled
      • testUnmarshallWithOutputLength

        public void testUnmarshallWithOutputLength()
                                            throws net.shibboleth.utilities.java.support.xml.XMLParserException,
                                                   org.opensaml.core.xml.io.UnmarshallingException
        Tests unmarshalling with SignatureMethod/HMACOutputLength present.
        Throws:
        net.shibboleth.utilities.java.support.xml.XMLParserException - thrown if the XML can not be parsed
        org.opensaml.core.xml.io.UnmarshallingException - thrown if the DOM can not be unmarshalled
      • testMarshallNoOutputLength

        public void testMarshallNoOutputLength()
                                        throws org.opensaml.core.xml.io.MarshallingException
        Tests marshalling with SignatureMethod/HMACOutputLength not present.
        Throws:
        org.opensaml.core.xml.io.MarshallingException - thrown in signed object can't be marshalled
      • testMarshallWithOutputLength

        public void testMarshallWithOutputLength()
                                          throws org.opensaml.core.xml.io.MarshallingException
        Tests marshalling with SignatureMethod/HMACOutputLength present.
        Throws:
        org.opensaml.core.xml.io.MarshallingException - thrown in signed object can't be marshalled
      • getXMLObjectWithSignature

        private SignableSimpleXMLObject getXMLObjectWithSignature​(boolean useHMACOutputLength)
        Creates a XMLObject that has a Signature child element.
        Parameters:
        useHMACOutputLength - if true, set value for HMACOutputLength
        Returns:
        a XMLObject that has a Signature child element