use of org.xdi.oxauth.client.AuthorizationRequest in project oxAuth by GluuFederation.
the class ResponseTypesRestrictionEmbeddedTest method responseTypesCodeIdTokenStep4.
/**
* Authorization request with the other Response types combination should
* fail.
*/
@Test(dependsOnMethods = "omittedResponseTypesStep3b", dataProvider = "responseTypesCodeIdTokenStep4DataProvider")
public void responseTypesCodeIdTokenStep4(final String authorizePath, final String userId, final String userSecret, final String redirectUri, final List<ResponseType> responseTypes) throws Exception {
List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
String nonce = UUID.randomUUID().toString();
AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId1, scopes, redirectUri, nonce);
authorizationRequest.setState("af0ifjsldkj");
authorizationRequest.getPrompts().add(Prompt.NONE);
authorizationRequest.setAuthUsername(userId);
authorizationRequest.setAuthPassword(userSecret);
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
request.header("Accept", MediaType.TEXT_PLAIN);
Response response = request.get();
String entity = response.readEntity(String.class);
showResponse("responseTypesCodeIdTokenStep4", response, entity);
if (response.getStatus() == 400) {
assertNotNull(entity, "Unexpected result: " + entity);
try {
JSONObject jsonObj = new JSONObject(entity);
assertTrue(jsonObj.has("error"), "The error type is null");
assertTrue(jsonObj.has("error_description"), "The error description is null");
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage() + "\nResponse was: " + entity);
}
} else {
fail("Unexpected response code: " + response.getStatus());
}
}
use of org.xdi.oxauth.client.AuthorizationRequest in project oxAuth by GluuFederation.
the class ResponseTypesRestrictionEmbeddedTest method responseTypesTokenIdTokenStep4.
/**
* Authorization request with the other Response types combination should
* fail.
*/
@Test(dependsOnMethods = "responseTypesTokenIdTokenStep3", dataProvider = "responseTypesTokenIdTokenStep4DataProvider")
public void responseTypesTokenIdTokenStep4(final String authorizePath, final String userId, final String userSecret, final String redirectUri, final List<ResponseType> responseTypes) throws Exception {
List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
String nonce = UUID.randomUUID().toString();
AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId3, scopes, redirectUri, nonce);
authorizationRequest.setState("af0ifjsldkj");
authorizationRequest.getPrompts().add(Prompt.NONE);
authorizationRequest.setAuthUsername(userId);
authorizationRequest.setAuthPassword(userSecret);
Builder request = ResteasyClientBuilder.newClient().target(url.toString() + authorizePath + "?" + authorizationRequest.getQueryString()).request();
request.header("Authorization", "Basic " + authorizationRequest.getEncodedCredentials());
request.header("Accept", MediaType.TEXT_PLAIN);
Response response = request.get();
String entity = response.readEntity(String.class);
showResponse("responseTypesTokenIdTokenStep4", response, entity);
if (response.getStatus() == 400) {
assertNotNull(entity, "Unexpected result: " + entity);
try {
JSONObject jsonObj = new JSONObject(entity);
assertTrue(jsonObj.has("error"), "The error type is null");
assertTrue(jsonObj.has("error_description"), "The error description is null");
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage() + "\nResponse was: " + entity);
}
} else {
fail("Unexpected response code: " + response.getStatus());
}
}
use of org.xdi.oxauth.client.AuthorizationRequest in project oxTrust by GluuFederation.
the class OpenIdClient method getRedirectionUrl.
/**
* {@InheritDoc}
*/
public String getRedirectionUrl(final WebContext context) {
init();
final String state = RandomStringUtils.randomAlphanumeric(10);
final String nonce = RandomStringUtils.randomAlphanumeric(10);
final AuthorizationRequest authorizationRequest = new AuthorizationRequest(Arrays.asList(ResponseType.CODE), this.clientId, this.appConfiguration.getOpenIdScopes(), this.appConfiguration.getOpenIdRedirectUrl(), null);
authorizationRequest.setState(state);
authorizationRequest.setNonce(nonce);
context.setSessionAttribute(getName() + STATE_PARAMETER, state);
final String redirectionUrl = this.openIdConfiguration.getAuthorizationEndpoint() + "?" + authorizationRequest.getQueryString();
logger.debug("oxAuth redirection Url: '{}'", redirectionUrl);
return redirectionUrl;
}
Aggregations