use of io.jans.ca.common.response.GetClientTokenResponse 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.response.GetClientTokenResponse in project jans by JanssenProject.
the class GetTokensByCodeTest method refreshToken.
public static GetClientTokenResponse refreshToken(GetTokensByCodeResponse2 resp, ClientInterface client, RegisterSiteResponse site) {
notEmpty(resp.getRefreshToken());
// refresh token
final GetAccessTokenByRefreshTokenParams refreshParams = new GetAccessTokenByRefreshTokenParams();
refreshParams.setRpId(site.getRpId());
refreshParams.setScope(Lists.newArrayList("openid", "jans_client_api"));
refreshParams.setRefreshToken(resp.getRefreshToken());
GetClientTokenResponse refreshResponse = client.getAccessTokenByRefreshToken(Tester.getAuthorization(site), null, refreshParams);
assertNotNull(refreshResponse);
notEmpty(refreshResponse.getAccessToken());
notEmpty(refreshResponse.getRefreshToken());
return refreshResponse;
}
use of io.jans.ca.common.response.GetClientTokenResponse 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());
}
use of io.jans.ca.common.response.GetClientTokenResponse in project jans by JanssenProject.
the class AccessTokenAsJwtTest method getClientToken.
@Parameters({ "host", "opHost", "redirectUrls", "postLogoutRedirectUrls" })
@Test
public void getClientToken(String host, String opHost, String redirectUrls, String postLogoutRedirectUrls) throws InvalidJwtException {
final RegisterSiteParams params = new RegisterSiteParams();
params.setOpHost(opHost);
params.setRedirectUris(Lists.newArrayList(redirectUrls.split(" ")));
params.setPostLogoutRedirectUris(Lists.newArrayList(postLogoutRedirectUrls.split(" ")));
params.setScope(Lists.newArrayList("openid", "uma_protection", "profile"));
params.setAccessTokenAsJwt(true);
params.setGrantTypes(Lists.newArrayList(GrantType.AUTHORIZATION_CODE.getValue(), GrantType.CLIENT_CREDENTIALS.getValue()));
final RegisterSiteResponse resp = Tester.newClient(host).registerSite(params);
assertResponse(resp);
final GetClientTokenParams tokenParams = new GetClientTokenParams();
tokenParams.setOpHost(opHost);
tokenParams.setScope(Lists.newArrayList("openid"));
tokenParams.setClientId(resp.getClientId());
tokenParams.setClientSecret(resp.getClientSecret());
GetClientTokenResponse tokenResponse = Tester.newClient(host).getClientToken(tokenParams);
assertNotNull(tokenResponse);
notEmpty(tokenResponse.getAccessToken());
final Jwt parse = Jwt.parse(tokenResponse.getAccessToken());
assertNotNull(parse);
System.out.println("access token as JWT: " + tokenResponse.getAccessToken() + ", claims: " + parse.getClaims());
}
Aggregations