use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.
the class CheckAccessTokenTest method test.
@Parameters({ "host", "redirectUrls", "userId", "userSecret", "opHost" })
@Test
public void test(String host, String redirectUrls, String userId, String userSecret, String opHost) {
ClientInterface client = Tester.newClient(host);
String nonce = CoreUtils.secureRandomString();
String state = CoreUtils.secureRandomString();
RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
GetTokensByCodeResponse2 response = GetTokensByCodeTest.tokenByCode(client, site, opHost, userId, userSecret, site.getClientId(), redirectUrls, nonce, state);
final CheckAccessTokenParams params = new CheckAccessTokenParams();
params.setAccessToken(response.getAccessToken());
params.setIdToken(response.getIdToken());
params.setRpId(site.getRpId());
final CheckAccessTokenResponse checkR = client.checkAccessToken(Tester.getAuthorization(site), null, params);
assertNotNull(checkR);
assertTrue(checkR.isActive());
assertNotNull(checkR.getExpiresAt());
assertNotNull(checkR.getIssuedAt());
}
use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.
the class DifferentAuthServerTest method getUserInfo_withDifferentAuthServer.
@Parameters({ "host", "opHost", "authServer", "redirectUrls", "clientId", "clientSecret", "userId", "userSecret" })
@Test
public void getUserInfo_withDifferentAuthServer(String host, String opHost, String authServer, String redirectUrls, String clientId, String clientSecret, String userId, String userSecret) {
ClientInterface client = Tester.newClient(host);
RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
RegisterSiteResponse authServerResp = RegisterSiteTest.registerSite(client, authServer, redirectUrls);
final GetTokensByCodeResponse2 tokens = requestTokens(client, opHost, site, authServerResp, userId, userSecret, site.getClientId(), redirectUrls);
GetUserInfoParams params = new GetUserInfoParams();
params.setRpId(site.getRpId());
params.setAccessToken(tokens.getAccessToken());
params.setIdToken(tokens.getIdToken());
final JsonNode resp = client.getUserInfo(Tester.getAuthorization(authServerResp), authServerResp.getRpId(), params);
assertNotNull(resp);
assertNotNull(resp.get("sub"));
}
use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.
the class GetIssuerTest method hostnameInputTest.
@Parameters({ "host", "opHost", "hostnameWebfingerInput" })
@Test
public void hostnameInputTest(String host, String opHost, String hostnameWebfingerInput) {
ClientInterface client = Tester.newClient(host);
final GetIssuerParams params = new GetIssuerParams();
params.setResource(hostnameWebfingerInput);
params.setOpHost(opHost);
final GetIssuerResponse resp = client.getIssuer(params);
assertNotNull(resp);
assertEquals(resp.getSubject(), hostnameWebfingerInput);
resp.getLinks().forEach((link) -> {
assertEquals(link.getHref(), opHost);
});
}
use of io.jans.ca.client.ClientInterface in project jans by JanssenProject.
the class GetIssuerTest method emailInputTest.
@Parameters({ "host", "opHost", "emailWebfingerInput" })
@Test(enabled = false)
public void emailInputTest(String host, String opHost, String emailWebfingerInput) {
ClientInterface client = Tester.newClient(host);
final GetIssuerParams params = new GetIssuerParams();
params.setResource(emailWebfingerInput);
params.setOpHost(opHost);
final GetIssuerResponse resp = client.getIssuer(params);
assertNotNull(resp);
assertEquals(resp.getSubject(), emailWebfingerInput);
resp.getLinks().forEach((link) -> {
assertEquals(link.getHref(), opHost);
});
}
use of io.jans.ca.client.ClientInterface 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());
}
Aggregations