Search in sources :

Example 1 with RpGetRptResponse

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()));
}
Also used : RpGetRptParams(io.jans.ca.common.params.RpGetRptParams) RsCheckAccessResponse(io.jans.ca.common.response.RsCheckAccessResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) RpGetRptResponse(io.jans.ca.common.response.RpGetRptResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 2 with RpGetRptResponse

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));
    });
}
Also used : CorrectRptIntrospectionResponse(io.jans.ca.common.introspection.CorrectRptIntrospectionResponse) IntrospectRptParams(io.jans.ca.common.params.IntrospectRptParams) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) RpGetRptResponse(io.jans.ca.common.response.RpGetRptResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 3 with RpGetRptResponse

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;
}
Also used : RpGetRptParams(io.jans.ca.common.params.RpGetRptParams) RsCheckAccessResponse(io.jans.ca.common.response.RsCheckAccessResponse) RpGetRptResponse(io.jans.ca.common.response.RpGetRptResponse)

Example 4 with RpGetRptResponse

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);
}
Also used : ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) RpGetRptResponse(io.jans.ca.common.response.RpGetRptResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 5 with RpGetRptResponse

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"));
}
Also used : Jwt(io.jans.as.model.jwt.Jwt) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteParams(io.jans.ca.common.params.RegisterSiteParams) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) RpGetRptResponse(io.jans.ca.common.response.RpGetRptResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

RpGetRptResponse (io.jans.ca.common.response.RpGetRptResponse)9 ClientInterface (io.jans.ca.client.ClientInterface)7 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)7 Parameters (org.testng.annotations.Parameters)7 Test (org.testng.annotations.Test)7 RpGetRptParams (io.jans.ca.common.params.RpGetRptParams)4 RsCheckAccessResponse (io.jans.ca.common.response.RsCheckAccessResponse)4 CorrectRptIntrospectionResponse (io.jans.ca.common.introspection.CorrectRptIntrospectionResponse)3 IntrospectRptParams (io.jans.ca.common.params.IntrospectRptParams)2 Jwt (io.jans.as.model.jwt.Jwt)1 UmaMetadata (io.jans.as.model.uma.UmaMetadata)1 UmaTokenResponse (io.jans.as.model.uma.UmaTokenResponse)1 RegisterSiteParams (io.jans.ca.common.params.RegisterSiteParams)1 HttpException (io.jans.ca.server.HttpException)1 RegisterSiteTest (io.jans.ca.server.RegisterSiteTest)1 RsCheckAccessTest (io.jans.ca.server.RsCheckAccessTest)1 RsProtectTest (io.jans.ca.server.RsProtectTest)1 IOException (java.io.IOException)1 Builder (javax.ws.rs.client.Invocation.Builder)1 Form (javax.ws.rs.core.Form)1