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());
}
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());
}
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;
}
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();
}
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());
}
Aggregations