use of org.apache.cxf.rs.security.oauth2.grants.code.PlainCodeVerifier in project cxf by apache.
the class PublicClientTest method testAuthorizationCodeGrantNoRedirectURI.
@org.junit.Test
public void testAuthorizationCodeGrantNoRedirectURI() throws Exception {
URL busFile = PublicClientTest.class.getResource("publicclient.xml");
String address = "https://localhost:" + port + "/services/";
WebClient client = WebClient.create(address, OAuth2TestUtils.setupProviders(), "alice", "security", busFile.toString());
// Save the Cookie for the second request...
WebClient.getConfig(client).getRequestContext().put(org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
// Get Authorization Code
try {
// Get Authorization Code
AuthorizationCodeParameters parameters = new AuthorizationCodeParameters();
parameters.setConsumerId("fredPublic");
String codeVerifier = Base64UrlUtility.encode(CryptoUtils.generateSecureRandomBytes(32));
CodeVerifierTransformer transformer = new PlainCodeVerifier();
parameters.setCodeChallenge(transformer.transformCodeVerifier(codeVerifier));
parameters.setCodeChallengeMethod(transformer.getChallengeMethod());
parameters.setResponseType(OAuthConstants.CODE_RESPONSE_TYPE);
parameters.setPath("authorize/");
OAuth2TestUtils.getLocation(client, parameters);
fail("Failure expected on a missing (registered) redirectURI");
} catch (Exception ex) {
// expected
}
}
Aggregations