Search in sources :

Example 1 with RsCheckAccessResponse

use of io.jans.ca.common.response.RsCheckAccessResponse in project jans by JanssenProject.

the class RsCheckAccessTest method checkAccess.

public static RsCheckAccessResponse checkAccess(ClientInterface client, RegisterSiteResponse site, List<String> scopeList) {
    final RsCheckAccessParams params = new RsCheckAccessParams();
    params.setRpId(site.getRpId());
    params.setHttpMethod("GET");
    params.setPath("/ws/phone");
    params.setRpt("dummy");
    params.setScopes(scopeList);
    final RsCheckAccessResponse response = client.umaRsCheckAccess(Tester.getAuthorization(site), null, params);
    assertNotNull(response);
    assertTrue(StringUtils.isNotBlank(response.getAccess()));
    return response;
}
Also used : RsCheckAccessParams(io.jans.ca.common.params.RsCheckAccessParams) RsCheckAccessResponse(io.jans.ca.common.response.RsCheckAccessResponse)

Example 2 with RsCheckAccessResponse

use of io.jans.ca.common.response.RsCheckAccessResponse in project jans by JanssenProject.

the class UmaGetClaimsGatheringUrlTest method test.

@Parameters({ "host", "opHost", "paramRedirectUrl", "rsProtect" })
@Test
public void test(String host, String opHost, String paramRedirectUrl, String rsProtect) throws IOException {
    ClientInterface client = Tester.newClient(host);
    RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, paramRedirectUrl);
    RsProtectTest.protectResources(client, site, UmaFullTest.resourceList(rsProtect).getResources());
    final RsCheckAccessResponse checkAccess = RsCheckAccessTest.checkAccess(client, site, null);
    final RpGetClaimsGatheringUrlParams params = new RpGetClaimsGatheringUrlParams();
    params.setRpId(site.getRpId());
    params.setTicket(checkAccess.getTicket());
    params.setClaimsRedirectUri(paramRedirectUrl);
    final RpGetClaimsGatheringUrlResponse response = client.umaRpGetClaimsGatheringUrl(Tester.getAuthorization(site), null, params);
    Map<String, String> parameters = CoreUtils.splitQuery(response.getUrl());
    assertTrue(StringUtils.isNotBlank(parameters.get("client_id")));
    assertTrue(StringUtils.isNotBlank(parameters.get("ticket")));
    assertTrue(StringUtils.isNotBlank(parameters.get("state")));
    assertTrue(StringUtils.isNotBlank(response.getState()));
    assertEquals(paramRedirectUrl, parameters.get("claims_redirect_uri"));
}
Also used : RpGetClaimsGatheringUrlParams(io.jans.ca.common.params.RpGetClaimsGatheringUrlParams) RpGetClaimsGatheringUrlResponse(io.jans.ca.common.response.RpGetClaimsGatheringUrlResponse) RsCheckAccessResponse(io.jans.ca.common.response.RsCheckAccessResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 3 with RsCheckAccessResponse

use of io.jans.ca.common.response.RsCheckAccessResponse in project jans by JanssenProject.

the class UmaGetClaimsGatheringUrlTest method test_withState.

@Parameters({ "host", "opHost", "paramRedirectUrl", "rsProtect", "state" })
@Test
public void test_withState(String host, String opHost, String paramRedirectUrl, String rsProtect, String state) throws IOException {
    ClientInterface client = Tester.newClient(host);
    RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, paramRedirectUrl);
    RsProtectTest.protectResources(client, site, UmaFullTest.resourceList(rsProtect).getResources());
    final RsCheckAccessResponse checkAccess = RsCheckAccessTest.checkAccess(client, site, null);
    final RpGetClaimsGatheringUrlParams params = new RpGetClaimsGatheringUrlParams();
    params.setRpId(site.getRpId());
    params.setTicket(checkAccess.getTicket());
    params.setClaimsRedirectUri(paramRedirectUrl);
    params.setState(state);
    final RpGetClaimsGatheringUrlResponse response = client.umaRpGetClaimsGatheringUrl(Tester.getAuthorization(site), null, params);
    Map<String, String> parameters = CoreUtils.splitQuery(response.getUrl());
    assertTrue(StringUtils.isNotBlank(parameters.get("client_id")));
    assertTrue(StringUtils.isNotBlank(parameters.get("ticket")));
    assertTrue(StringUtils.isNotBlank(parameters.get("state")));
    assertTrue(StringUtils.isNotBlank(response.getState()));
    assertEquals(paramRedirectUrl, parameters.get("claims_redirect_uri"));
    assertEquals(response.getState(), state);
}
Also used : RpGetClaimsGatheringUrlParams(io.jans.ca.common.params.RpGetClaimsGatheringUrlParams) RpGetClaimsGatheringUrlResponse(io.jans.ca.common.response.RpGetClaimsGatheringUrlResponse) RsCheckAccessResponse(io.jans.ca.common.response.RsCheckAccessResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 4 with RsCheckAccessResponse

use of io.jans.ca.common.response.RsCheckAccessResponse in project jans by JanssenProject.

the class RsProtectTest method protectWithScopeExpressionSeconds.

@Parameters({ "host", "redirectUrls", "opHost", "rsProtectScopeExpressionSecond" })
@Test
public void protectWithScopeExpressionSeconds(String host, String redirectUrls, String opHost, String rsProtectScopeExpressionSecond) throws IOException {
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    protectResources(client, site, UmaFullTest.resourceList(rsProtectScopeExpressionSecond).getResources());
    final RsCheckAccessParams params = new RsCheckAccessParams();
    params.setRpId(site.getRpId());
    params.setHttpMethod("GET");
    params.setPath("/GetAll");
    params.setRpt("");
    final RsCheckAccessResponse response = client.umaRsCheckAccess(Tester.getAuthorization(site), null, params);
    assertNotNull(response);
    assertTrue(StringUtils.isNotBlank(response.getAccess()));
}
Also used : RsCheckAccessParams(io.jans.ca.common.params.RsCheckAccessParams) RsCheckAccessResponse(io.jans.ca.common.response.RsCheckAccessResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 5 with RsCheckAccessResponse

use of io.jans.ca.common.response.RsCheckAccessResponse 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)

Aggregations

RsCheckAccessResponse (io.jans.ca.common.response.RsCheckAccessResponse)10 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 RpGetRptResponse (io.jans.ca.common.response.RpGetRptResponse)4 RpGetClaimsGatheringUrlParams (io.jans.ca.common.params.RpGetClaimsGatheringUrlParams)3 RpGetClaimsGatheringUrlResponse (io.jans.ca.common.response.RpGetClaimsGatheringUrlResponse)3 RsCheckAccessParams (io.jans.ca.common.params.RsCheckAccessParams)2 CorrectRptIntrospectionResponse (io.jans.ca.common.introspection.CorrectRptIntrospectionResponse)1 CorrectUmaPermission (io.jans.ca.common.introspection.CorrectUmaPermission)1 IOpResponse (io.jans.ca.common.response.IOpResponse)1 PatProvider (io.jans.ca.rs.protect.resteasy.PatProvider)1 ResourceRegistrar (io.jans.ca.rs.protect.resteasy.ResourceRegistrar)1 RptPreProcessInterceptor (io.jans.ca.rs.protect.resteasy.RptPreProcessInterceptor)1 ServiceProvider (io.jans.ca.rs.protect.resteasy.ServiceProvider)1 HttpException (io.jans.ca.server.HttpException)1 RegisterSiteTest (io.jans.ca.server.RegisterSiteTest)1 RsCheckAccessTest (io.jans.ca.server.RsCheckAccessTest)1