Class HMACSignatureTest
- java.lang.Object
-
- org.opensaml.core.OpenSAMLInitBaseTestCase
-
- org.opensaml.core.xml.XMLObjectBaseTestCase
-
- org.opensaml.xmlsec.signature.support.HMACSignatureTest
-
public class HMACSignatureTest extends org.opensaml.core.xml.XMLObjectBaseTestCaseTest to verifySignatureand its marshallers and unmarshallers.
-
-
Field Summary
Fields Modifier and Type Field Description private StringalgoURISignature algorithm URI.private org.opensaml.security.credential.CredentialbadCredentialInvalid credential for verification.private StringexpectedKeyNameExpected key name value in KeyInfo.private org.opensaml.security.credential.CredentialgoodCredentialCredential used to sign and verify.private IntegerhmacOutputLengthValue of HMACOutputLength element child of SignatureMethod.private org.opensaml.core.xml.XMLObjectBuilder<org.opensaml.xmlsec.signature.KeyInfo>keyInfoBuilderBuild of KeyInfo objects.private org.slf4j.LoggerlogClass logger.private org.opensaml.core.xml.XMLObjectBuilder<org.opensaml.xmlsec.signature.Signature>sigBuilderBuilder of Signature XML objects.private SignableSimpleXMLObjectBuildersxoBuilderBuilder of mock XML objects.
-
Constructor Summary
Constructors Constructor Description HMACSignatureTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private SignableSimpleXMLObjectgetXMLObjectWithSignature(boolean useHMACOutputLength)Creates a XMLObject that has a Signature child element.protected voidsetUp()voidtestMarshallNoOutputLength()Tests marshalling with SignatureMethod/HMACOutputLength not present.voidtestMarshallWithOutputLength()Tests marshalling with SignatureMethod/HMACOutputLength present.voidtestSigningAndVerificationNoOutputLength()Tests creating an enveloped signature and then verifying it.voidtestSigningAndVerificationWithOutputLength()Tests creating an enveloped signature and then verifying it.voidtestUnmarshallNoOutputLength()Tests unmarshalling with SignatureMethod/HMACOutputLength not present.voidtestUnmarshallWithOutputLength()Tests unmarshalling with SignatureMethod/HMACOutputLength present.-
Methods inherited from class org.opensaml.core.xml.XMLObjectBaseTestCase
assertXMLEquals, assertXMLEquals, buildXMLObject, getBuilder, getMarshaller, getMarshaller, getUnmarshaller, getUnmarshaller, getUnmarshaller, initXMLObjectSupport, parseXMLDocument, printXML, printXML, unmarshallElement, unmarshallElement
-
-
-
-
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.
-
sxoBuilder
private SignableSimpleXMLObjectBuilder sxoBuilder
Builder of mock XML objects.
-
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.
-
-
Method Detail
-
setUp
@BeforeMethod protected void setUp() throws Exception
- Throws:
Exception
-
testSigningAndVerificationNoOutputLength
public void testSigningAndVerificationNoOutputLength() throws org.opensaml.core.xml.io.MarshallingException, javax.xml.bind.ValidationException, org.opensaml.xmlsec.signature.support.SignatureExceptionTests creating an enveloped signature and then verifying it.- Throws:
org.opensaml.core.xml.io.MarshallingException- thrown if the XMLObject tree can not be marshalledjavax.xml.bind.ValidationException- thrown if signature validator fails to validate the signatureorg.opensaml.xmlsec.signature.support.SignatureException- ...
-
testSigningAndVerificationWithOutputLength
public void testSigningAndVerificationWithOutputLength() throws org.opensaml.core.xml.io.MarshallingException, org.opensaml.xmlsec.signature.support.SignatureExceptionTests creating an enveloped signature and then verifying it.- Throws:
org.opensaml.core.xml.io.MarshallingException- thrown if the XMLObject tree can not be marshalledorg.opensaml.xmlsec.signature.support.SignatureException- ...
-
testUnmarshallNoOutputLength
public void testUnmarshallNoOutputLength() throws net.shibboleth.utilities.java.support.xml.XMLParserException, org.opensaml.core.xml.io.UnmarshallingExceptionTests unmarshalling with SignatureMethod/HMACOutputLength not present.- Throws:
net.shibboleth.utilities.java.support.xml.XMLParserException- thrown if the XML can not be parsedorg.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.UnmarshallingExceptionTests unmarshalling with SignatureMethod/HMACOutputLength present.- Throws:
net.shibboleth.utilities.java.support.xml.XMLParserException- thrown if the XML can not be parsedorg.opensaml.core.xml.io.UnmarshallingException- thrown if the DOM can not be unmarshalled
-
testMarshallNoOutputLength
public void testMarshallNoOutputLength() throws org.opensaml.core.xml.io.MarshallingExceptionTests 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.MarshallingExceptionTests 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
-
-