Class HMACSignatureTest
- java.lang.Object
-
- org.opensaml.core.OpenSAMLInitBaseTestCase
-
- org.opensaml.core.xml.XMLObjectBaseTestCase
-
- org.opensaml.xmlsec.signature.support.HMACSignatureTest
-
public class HMACSignatureTest extends XMLObjectBaseTestCase
Test to verifySignatureand its marshallers and unmarshallers.
-
-
Field Summary
Fields Modifier and Type Field Description private StringalgoURISignature algorithm URI.private CredentialbadCredentialInvalid credential for verification.private StringexpectedKeyNameExpected key name value in KeyInfo.private CredentialgoodCredentialCredential used to sign and verify.private IntegerhmacOutputLengthValue of HMACOutputLength element child of SignatureMethod.private XMLObjectBuilder<KeyInfo>keyInfoBuilderBuild of KeyInfo objects.private org.slf4j.LoggerlogClass logger.private XMLObjectBuilder<Signature>sigBuilderBuilder of Signature XML objects.private SignableSimpleXMLObjectBuildersxoBuilderBuilder of mock XML objects.-
Fields inherited from class org.opensaml.core.xml.XMLObjectBaseTestCase
builderFactory, marshallerFactory, parserPool, simpleXMLObjectQName, unmarshallerFactory
-
-
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
-
Methods inherited from class org.opensaml.core.OpenSAMLInitBaseTestCase
initOpenSAML
-
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
Class logger.
-
goodCredential
private Credential goodCredential
Credential used to sign and verify.
-
badCredential
private Credential badCredential
Invalid credential for verification.
-
sxoBuilder
private SignableSimpleXMLObjectBuilder sxoBuilder
Builder of mock XML objects.
-
sigBuilder
private XMLObjectBuilder<Signature> sigBuilder
Builder of Signature XML objects.
-
keyInfoBuilder
private XMLObjectBuilder<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 MarshallingException, javax.xml.bind.ValidationException, SignatureExceptionTests creating an enveloped signature and then verifying it.- Throws:
MarshallingException- thrown if the XMLObject tree can not be marshalledjavax.xml.bind.ValidationException- thrown if signature validator fails to validate the signatureSignatureException- ...
-
testSigningAndVerificationWithOutputLength
public void testSigningAndVerificationWithOutputLength() throws MarshallingException, SignatureExceptionTests creating an enveloped signature and then verifying it.- Throws:
MarshallingException- thrown if the XMLObject tree can not be marshalledSignatureException- ...
-
testUnmarshallNoOutputLength
public void testUnmarshallNoOutputLength() throws XMLParserException, UnmarshallingExceptionTests unmarshalling with SignatureMethod/HMACOutputLength not present.- Throws:
XMLParserException- thrown if the XML can not be parsedUnmarshallingException- thrown if the DOM can not be unmarshalled
-
testUnmarshallWithOutputLength
public void testUnmarshallWithOutputLength() throws XMLParserException, UnmarshallingExceptionTests unmarshalling with SignatureMethod/HMACOutputLength present.- Throws:
XMLParserException- thrown if the XML can not be parsedUnmarshallingException- thrown if the DOM can not be unmarshalled
-
testMarshallNoOutputLength
public void testMarshallNoOutputLength() throws MarshallingExceptionTests marshalling with SignatureMethod/HMACOutputLength not present.- Throws:
MarshallingException- thrown in signed object can't be marshalled
-
testMarshallWithOutputLength
public void testMarshallWithOutputLength() throws MarshallingExceptionTests marshalling with SignatureMethod/HMACOutputLength present.- Throws:
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
-
-