Search in sources :

Example 1 with GetClientTokenParams

use of io.jans.ca.common.params.GetClientTokenParams in project jans by JanssenProject.

the class GetClientTokenTest method getClientToken.

@Parameters({ "host", "opHost" })
@Test
public void getClientToken(String host, String opHost) {
    final GetClientTokenParams params = new GetClientTokenParams();
    params.setOpHost(opHost);
    params.setScope(Lists.newArrayList("openid"));
    params.setClientId(Tester.getSetupClient().getClientId());
    params.setClientSecret(Tester.getSetupClient().getClientSecret());
    GetClientTokenResponse resp = Tester.newClient(host).getClientToken(params);
    assertNotNull(resp);
    notEmpty(resp.getAccessToken());
}
Also used : GetClientTokenResponse(io.jans.ca.common.response.GetClientTokenResponse) GetClientTokenParams(io.jans.ca.common.params.GetClientTokenParams) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 2 with GetClientTokenParams

use of io.jans.ca.common.params.GetClientTokenParams 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)

Example 3 with GetClientTokenParams

use of io.jans.ca.common.params.GetClientTokenParams in project jans by JanssenProject.

the class Tester method getAuthorization.

public static String getAuthorization() {
    Preconditions.checkNotNull(SETUP_CLIENT);
    if (Strings.isNullOrEmpty(AUTHORIZATION)) {
        final GetClientTokenParams params = new GetClientTokenParams();
        params.setOpHost(OP_HOST);
        params.setScope(Lists.newArrayList("openid"));
        params.setClientId(Tester.getSetupClient().getClientId());
        params.setClientSecret(Tester.getSetupClient().getClientSecret());
        GetClientTokenResponse resp = Tester.newClient(HOST).getClientToken(params);
        assertNotNull(resp);
        assertTrue(!Strings.isNullOrEmpty(resp.getAccessToken()));
        AUTHORIZATION = "Bearer " + resp.getAccessToken();
    }
    return AUTHORIZATION;
}
Also used : GetClientTokenResponse(io.jans.ca.common.response.GetClientTokenResponse) GetClientTokenParams(io.jans.ca.common.params.GetClientTokenParams)

Example 4 with GetClientTokenParams

use of io.jans.ca.common.params.GetClientTokenParams in project jans by JanssenProject.

the class Tester method getAuthorization.

public static String getAuthorization(RegisterSiteResponse site) {
    final GetClientTokenParams params = new GetClientTokenParams();
    params.setScope(Lists.newArrayList("openid", "jans_client_api"));
    params.setOpHost(site.getOpHost());
    params.setClientId(site.getClientId());
    params.setClientSecret(site.getClientSecret());
    GetClientTokenResponse resp = Tester.newClient(HOST).getClientToken(params);
    assertNotNull(resp);
    assertTrue(!Strings.isNullOrEmpty(resp.getAccessToken()));
    return "Bearer " + resp.getAccessToken();
}
Also used : GetClientTokenResponse(io.jans.ca.common.response.GetClientTokenResponse) GetClientTokenParams(io.jans.ca.common.params.GetClientTokenParams)

Example 5 with GetClientTokenParams

use of io.jans.ca.common.params.GetClientTokenParams in project jans by JanssenProject.

the class GetClientTokenTest method getClientToken_withOpConfigurationEndpoint.

@Parameters({ "host", "opConfigurationEndpoint" })
@Test
public void getClientToken_withOpConfigurationEndpoint(String host, String opConfigurationEndpoint) {
    final GetClientTokenParams params = new GetClientTokenParams();
    params.setOpConfigurationEndpoint(opConfigurationEndpoint);
    params.setScope(Lists.newArrayList("openid"));
    params.setClientId(Tester.getSetupClient().getClientId());
    params.setClientSecret(Tester.getSetupClient().getClientSecret());
    GetClientTokenResponse resp = Tester.newClient(host).getClientToken(params);
    assertNotNull(resp);
    notEmpty(resp.getAccessToken());
}
Also used : 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

GetClientTokenParams (io.jans.ca.common.params.GetClientTokenParams)6 GetClientTokenResponse (io.jans.ca.common.response.GetClientTokenResponse)6 Parameters (org.testng.annotations.Parameters)4 Test (org.testng.annotations.Test)4 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)2 Jwt (io.jans.as.model.jwt.Jwt)1 ClientInterface (io.jans.ca.client.ClientInterface)1 IntrospectAccessTokenParams (io.jans.ca.common.params.IntrospectAccessTokenParams)1 RegisterSiteParams (io.jans.ca.common.params.RegisterSiteParams)1 IntrospectAccessTokenResponse (io.jans.ca.common.response.IntrospectAccessTokenResponse)1