use of io.jans.ca.common.response.RpGetRptResponse in project jans by JanssenProject.
the class UmaFullTest method test.
@Parameters({ "host", "redirectUrls", "opHost", "rsProtect" })
@Test
public void test(String host, String redirectUrls, String opHost, String rsProtect) throws Exception {
ClientInterface client = Tester.newClient(host);
RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
RsProtectTest.protectResources(client, site, UmaFullTest.resourceList(rsProtect).getResources());
final RsCheckAccessResponse checkAccess = RsCheckAccessTest.checkAccess(client, site, null);
final RpGetRptParams params = new RpGetRptParams();
params.setRpId(site.getRpId());
params.setTicket(checkAccess.getTicket());
final RpGetRptResponse response = client.umaRpGetRpt(Tester.getAuthorization(site), null, params);
assertNotNull(response);
assertTrue(StringUtils.isNotBlank(response.getRpt()));
assertTrue(StringUtils.isNotBlank(response.getPct()));
}
use of io.jans.ca.common.response.RpGetRptResponse in project jans by JanssenProject.
the class UmaSpontaneousScopeTest method init.
@Parameters({ "host", "opHost", "paramRedirectUrl", "userId", "userSecret", "rsProtectWithSpontaneousScope" })
@Test
public void init(String host, String opHost, String paramRedirectUrl, String userId, String userSecret, String rsProtectWithSpontaneousScope) throws Exception {
List<String> scopes = Lists.newArrayList("openid", "uma_protection", "profile", "address", "email", "phone", "user_name", "jans_client_api");
List<String> responseTypes = Lists.newArrayList("code", "id_token", "token");
// register client
ClientInterface client = Tester.newClient(host);
final RegisterSiteResponse registerResponse = RegisterSiteTest.registerSite(client, opHost, paramRedirectUrl, scopes, responseTypes, true, null);
// UMA RP - Get RPT
// Spontaneous Scope Regress: ^/user/.+$
RpGetRptResponse response = RpGetRptTest.requestRpt(client, registerResponse, rsProtectWithSpontaneousScope);
// UMA Introspect RPT
IntrospectRptParams params = new IntrospectRptParams();
params.setRpId(registerResponse.getRpId());
params.setRpt(response.getRpt());
final CorrectRptIntrospectionResponse rptIntrospectionResponse = client.introspectRpt(Tester.getAuthorization(registerResponse), null, params);
rptIntrospectionResponse.getPermissions().forEach(permission -> {
assertTrue(permission.getScopes().contains(USER_2_SCOPE));
});
}
use of io.jans.ca.common.response.RpGetRptResponse in project jans by JanssenProject.
the class RpGetRptTest method requestRpt.
public static RpGetRptResponse requestRpt(ClientInterface client, RegisterSiteResponse site, String rsProtect) throws IOException {
RsProtectTest.protectResources(client, site, UmaFullTest.resourceList(rsProtect).getResources());
final RsCheckAccessResponse checkAccess = RsCheckAccessTest.checkAccess(client, site, null);
final RpGetRptParams params = new RpGetRptParams();
params.setRpId(site.getRpId());
params.setTicket(checkAccess.getTicket());
final RpGetRptResponse response = client.umaRpGetRpt(Tester.getAuthorization(site), null, params);
assertNotNull(response);
assertTrue(StringUtils.isNotBlank(response.getRpt()));
assertTrue(StringUtils.isNotBlank(response.getPct()));
return response;
}
use of io.jans.ca.common.response.RpGetRptResponse in project jans by JanssenProject.
the class RpGetRptTest method simple.
@Parameters({ "host", "opHost", "redirectUrls", "rsProtect" })
@Test
public void simple(String host, String opHost, String redirectUrls, String rsProtect) throws IOException {
ClientInterface client = Tester.newClient(host);
RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
final RpGetRptResponse response = requestRpt(client, site, rsProtect);
assertNotNull(response);
}
use of io.jans.ca.common.response.RpGetRptResponse in project jans by JanssenProject.
the class RpGetRptTest method rptAsJwt.
@Parameters({ "host", "opHost", "redirectUrls", "rsProtect" })
@Test
public void rptAsJwt(String host, String opHost, String redirectUrls, String rsProtect) throws IOException, InvalidJwtException {
ClientInterface client = Tester.newClient(host);
final RegisterSiteParams params = new RegisterSiteParams();
params.setOpHost(opHost);
params.setRedirectUris(Lists.newArrayList(redirectUrls.split(" ")));
params.setPostLogoutRedirectUris(Lists.newArrayList(redirectUrls.split(" ")));
params.setClientFrontchannelLogoutUri(redirectUrls.split(" ")[0]);
params.setScope(Lists.newArrayList("openid", "uma_protection", "profile", "jans_client_api"));
params.setRptAsJwt(true);
params.setGrantTypes(Lists.newArrayList(GrantType.AUTHORIZATION_CODE.getValue(), GrantType.OXAUTH_UMA_TICKET.getValue(), GrantType.CLIENT_CREDENTIALS.getValue()));
final RegisterSiteResponse site = client.registerSite(params);
assertNotNull(site);
assertTrue(!Strings.isNullOrEmpty(site.getRpId()));
final RpGetRptResponse response = requestRpt(client, site, rsProtect);
assertNotNull(response);
Jwt jwt = Jwt.parse(response.getRpt());
assertNotNull(jwt);
assertEquals(site.getClientId(), jwt.getClaims().getClaimAsString("client_id"));
assertTrue(jwt.getClaims().getClaimAsString("permissions").contains("resource_id"));
}
Aggregations