Search in sources :

Example 1 with IntrospectAccessTokenResponse

use of io.jans.ca.common.response.IntrospectAccessTokenResponse in project jans by JanssenProject.

the class IntrospectAccessTokenTest method introspectAccessToken.

@Parameters({ "host", "opHost", "redirectUrls" })
@Test
public void introspectAccessToken(String host, String opHost, String redirectUrls) {
    ClientInterface client = Tester.newClient(host);
    RegisterSiteResponse setupResponse = SetupClientTest.setupClient(client, opHost, redirectUrls);
    final GetClientTokenParams params = new GetClientTokenParams();
    params.setOpHost(opHost);
    params.setScope(Lists.newArrayList("openid", "jans_client_api"));
    params.setClientId(setupResponse.getClientId());
    params.setClientSecret(setupResponse.getClientSecret());
    GetClientTokenResponse tokenResponse = client.getClientToken(params);
    assertNotNull(tokenResponse);
    notEmpty(tokenResponse.getAccessToken());
    IntrospectAccessTokenParams introspectParams = new IntrospectAccessTokenParams();
    introspectParams.setRpId(setupResponse.getRpId());
    introspectParams.setAccessToken(tokenResponse.getAccessToken());
    IntrospectAccessTokenResponse introspectionResponse = client.introspectAccessToken("Bearer " + tokenResponse.getAccessToken(), null, introspectParams);
    assertNotNull(introspectionResponse);
    assertTrue(introspectionResponse.isActive());
    assertNotNull(introspectionResponse.getIssuedAt());
    assertNotNull(introspectionResponse.getExpiresAt());
    assertTrue(introspectionResponse.getExpiresAt() >= introspectionResponse.getIssuedAt());
}
Also used : IntrospectAccessTokenParams(io.jans.ca.common.params.IntrospectAccessTokenParams) IntrospectAccessTokenResponse(io.jans.ca.common.response.IntrospectAccessTokenResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) GetClientTokenResponse(io.jans.ca.common.response.GetClientTokenResponse) GetClientTokenParams(io.jans.ca.common.params.GetClientTokenParams) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

ClientInterface (io.jans.ca.client.ClientInterface)1 GetClientTokenParams (io.jans.ca.common.params.GetClientTokenParams)1 IntrospectAccessTokenParams (io.jans.ca.common.params.IntrospectAccessTokenParams)1 GetClientTokenResponse (io.jans.ca.common.response.GetClientTokenResponse)1 IntrospectAccessTokenResponse (io.jans.ca.common.response.IntrospectAccessTokenResponse)1 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)1 Parameters (org.testng.annotations.Parameters)1 Test (org.testng.annotations.Test)1