Search in sources :

Example 1 with GetAuthorizationUrlParams

use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.

the class GoogleTest method getAuthorizationUrl.

private static String getAuthorizationUrl(ClientInterface client, RegisterSiteResponse site) {
    final GetAuthorizationUrlParams params = new GetAuthorizationUrlParams();
    params.setRpId(site.getRpId());
    final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, params);
    assertNotNull(resp);
    notEmpty(resp.getAuthorizationUrl());
    System.out.println("Authorization url: " + resp.getAuthorizationUrl());
    return resp.getAuthorizationUrl();
}
Also used : GetAuthorizationUrlResponse(io.jans.ca.common.response.GetAuthorizationUrlResponse) GetAuthorizationUrlParams(io.jans.ca.common.params.GetAuthorizationUrlParams)

Example 2 with GetAuthorizationUrlParams

use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.

the class GetRequestUriTest method test.

@Parameters({ "host", "redirectUrls", "opHost" })
@Test
public void test(String host, String redirectUrls, String opHost) {
    ClientInterface client = Tester.newClient(host);
    // client registration
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls);
    // jwks generation
    JsonNode jwks = client.getRpJwks();
    // update jwks in OP
    UpdateSiteParams updateSiteParams = new UpdateSiteParams();
    updateSiteParams.setRpId(site.getRpId());
    updateSiteParams.setJwks(jwks.asText());
    updateSiteParams.setRequestObjectSigningAlg("RS256");
    client.updateSite(Tester.getAuthorization(site), null, updateSiteParams);
    // Request uri
    GetRequestObjectUriParams getRequestUriParams = new GetRequestObjectUriParams();
    getRequestUriParams.setRpId(site.getRpId());
    getRequestUriParams.setRpHostUrl("http://localhost" + ":" + SetUpTest.SUPPORT.getLocalPort());
    GetRequestObjectUriResponse getRequestUriResponse = client.getRequestObjectUri(Tester.getAuthorization(site), null, getRequestUriParams);
    assertNotNull(getRequestUriResponse.getRequestUri());
    // Get Request object
    String requestObjectId = getRequestUriResponse.getRequestUri().substring(getRequestUriResponse.getRequestUri().lastIndexOf('/') + 1);
    String requestObject = client.getRequestObject(requestObjectId);
    assertNotNull(requestObject);
    Map<String, String> paramsMap = new HashMap<>();
    paramsMap.put("request", requestObject);
    final GetAuthorizationUrlParams commandParams = new GetAuthorizationUrlParams();
    commandParams.setRpId(site.getRpId());
    commandParams.setParams(paramsMap);
    final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, commandParams);
    assertNotNull(resp);
    TestUtils.notEmpty(resp.getAuthorizationUrl());
}
Also used : GetAuthorizationUrlResponse(io.jans.ca.common.response.GetAuthorizationUrlResponse) HashMap(java.util.HashMap) JsonNode(com.fasterxml.jackson.databind.JsonNode) ClientInterface(io.jans.ca.client.ClientInterface) UpdateSiteParams(io.jans.ca.common.params.UpdateSiteParams) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) GetRequestObjectUriResponse(io.jans.ca.common.response.GetRequestObjectUriResponse) GetRequestObjectUriParams(io.jans.ca.common.params.GetRequestObjectUriParams) GetAuthorizationUrlParams(io.jans.ca.common.params.GetAuthorizationUrlParams) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 3 with GetAuthorizationUrlParams

use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.

the class GetAuthorizationUrlTest method testWithCustomStateParameter.

@Parameters({ "host", "opHost", "redirectUrls", "postLogoutRedirectUrl", "logoutUrl", "paramRedirectUrl", "state" })
@Test
public void testWithCustomStateParameter(String host, String opHost, String redirectUrls, String postLogoutRedirectUrl, String logoutUrl, String paramRedirectUrl, String state) throws IOException {
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls, postLogoutRedirectUrl, logoutUrl, false);
    final GetAuthorizationUrlParams commandParams = new GetAuthorizationUrlParams();
    commandParams.setRpId(site.getRpId());
    commandParams.setRedirectUri(paramRedirectUrl);
    commandParams.setState(state);
    final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, commandParams);
    assertNotNull(resp);
    notEmpty(resp.getAuthorizationUrl());
    assertTrue(resp.getAuthorizationUrl().contains(paramRedirectUrl));
    Map<String, String> parameters = CoreUtils.splitQuery(resp.getAuthorizationUrl());
    assertTrue(StringUtils.isNotBlank(parameters.get("state")));
    assertEquals(parameters.get("state"), state);
}
Also used : GetAuthorizationUrlResponse(io.jans.ca.common.response.GetAuthorizationUrlResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) GetAuthorizationUrlParams(io.jans.ca.common.params.GetAuthorizationUrlParams) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 4 with GetAuthorizationUrlParams

use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.

the class GetAuthorizationUrlTest method testWithParameterAuthorizationUrl.

@Parameters({ "host", "opHost", "redirectUrls", "postLogoutRedirectUrl", "logoutUrl", "paramRedirectUrl" })
@Test
public void testWithParameterAuthorizationUrl(String host, String opHost, String redirectUrls, String postLogoutRedirectUrl, String logoutUrl, String paramRedirectUrl) {
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrls, postLogoutRedirectUrl, logoutUrl, false);
    final GetAuthorizationUrlParams commandParams = new GetAuthorizationUrlParams();
    commandParams.setRpId(site.getRpId());
    commandParams.setRedirectUri(paramRedirectUrl);
    final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, commandParams);
    assertNotNull(resp);
    notEmpty(resp.getAuthorizationUrl());
    assertTrue(resp.getAuthorizationUrl().contains(paramRedirectUrl));
}
Also used : GetAuthorizationUrlResponse(io.jans.ca.common.response.GetAuthorizationUrlResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) GetAuthorizationUrlParams(io.jans.ca.common.params.GetAuthorizationUrlParams) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 5 with GetAuthorizationUrlParams

use of io.jans.ca.common.params.GetAuthorizationUrlParams in project jans by JanssenProject.

the class StressTest method test.

@Parameters({ "host", "redirectUrl", "opHost" })
@Test(invocationCount = 10, threadPoolSize = 10, enabled = true)
public void test(String host, String redirectUrl, String opHost) {
    ClientInterface client = Tester.newClient(host);
    final RegisterSiteResponse site = RegisterSiteTest.registerSite(client, opHost, redirectUrl);
    final GetAuthorizationUrlParams params = new GetAuthorizationUrlParams();
    params.setRpId(site.getRpId());
    final GetAuthorizationUrlResponse resp = client.getAuthorizationUrl(Tester.getAuthorization(site), null, params);
    assertNotNull(resp);
    notEmpty(resp.getAuthorizationUrl());
    assertTrue(resp.getAuthorizationUrl().contains("acr_values"));
}
Also used : GetAuthorizationUrlResponse(io.jans.ca.common.response.GetAuthorizationUrlResponse) ClientInterface(io.jans.ca.client.ClientInterface) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) GetAuthorizationUrlParams(io.jans.ca.common.params.GetAuthorizationUrlParams) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) RegisterSiteTest(io.jans.ca.server.RegisterSiteTest)

Aggregations

GetAuthorizationUrlParams (io.jans.ca.common.params.GetAuthorizationUrlParams)9 GetAuthorizationUrlResponse (io.jans.ca.common.response.GetAuthorizationUrlResponse)9 ClientInterface (io.jans.ca.client.ClientInterface)8 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)8 Parameters (org.testng.annotations.Parameters)8 Test (org.testng.annotations.Test)8 HashMap (java.util.HashMap)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 GetRequestObjectUriParams (io.jans.ca.common.params.GetRequestObjectUriParams)1 UpdateSiteParams (io.jans.ca.common.params.UpdateSiteParams)1 GetRequestObjectUriResponse (io.jans.ca.common.response.GetRequestObjectUriResponse)1 RegisterSiteTest (io.jans.ca.server.RegisterSiteTest)1