Search in sources :

Example 1 with X509TokenState

use of org.forgerock.openam.sts.user.invocation.X509TokenState in project OpenAM by OpenRock.

the class TokenRequestMarshallerImplTest method testX509CertificateTokenMarshalling.

@Test
public void testX509CertificateTokenMarshalling() throws Exception {
    X509Certificate certificate = getCertificate();
    ClientContext clientInfoContext = ClientContext.buildExternalClientContext(null).certificates(certificate).build();
    @SuppressWarnings("unchecked") RestTokenTransformValidatorParameters<X509Certificate[]> params = (RestTokenTransformValidatorParameters<X509Certificate[]>) tokenMarshaller.buildTokenTransformValidatorParameters(new X509TokenState().toJson(), clientInfoContext);
    assertEquals(certificate.getEncoded(), (params.getInputToken()[0].getEncoded()));
}
Also used : X509TokenState(org.forgerock.openam.sts.user.invocation.X509TokenState) RestTokenTransformValidatorParameters(org.forgerock.openam.sts.rest.token.validator.RestTokenTransformValidatorParameters) ClientContext(org.forgerock.services.context.ClientContext) X509Certificate(java.security.cert.X509Certificate) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with X509TokenState

use of org.forgerock.openam.sts.user.invocation.X509TokenState in project OpenAM by OpenRock.

the class TokenRequestMarshallerImplTest method testMissingX509CertificateTokenMarshalling.

@Test(expectedExceptions = TokenMarshalException.class)
public void testMissingX509CertificateTokenMarshalling() throws Exception {
    ClientContext clientInfoContext = ClientContext.buildExternalClientContext(null).build();
    //no certificate present in the ClientContext, and the offload header set to "" by the module above, so
    //exception should be thrown
    tokenMarshaller.buildTokenTransformValidatorParameters(new X509TokenState().toJson(), clientInfoContext);
}
Also used : X509TokenState(org.forgerock.openam.sts.user.invocation.X509TokenState) ClientContext(org.forgerock.services.context.ClientContext) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

X509TokenState (org.forgerock.openam.sts.user.invocation.X509TokenState)2 ClientContext (org.forgerock.services.context.ClientContext)2 BeforeTest (org.testng.annotations.BeforeTest)2 Test (org.testng.annotations.Test)2 X509Certificate (java.security.cert.X509Certificate)1 RestTokenTransformValidatorParameters (org.forgerock.openam.sts.rest.token.validator.RestTokenTransformValidatorParameters)1