public static Token requestWithClientSecretJwt(final String tokenUrl, final String umaClientId, final String umaClientSecret, AuthenticationMethod authenticationMethod, SignatureAlgorithm signatureAlgorithm, String audience, UmaScopeType scopeType, String... scopeArray) throws Exception { String scope = scopeType.getValue(); if (scopeArray != null && scopeArray.length > 0) { for (String s : scopeArray) { scope = scope + " " + s; } } TokenRequest request = new TokenRequest(GrantType.CLIENT_CREDENTIALS); request.setAuthUsername(umaClientId); request.setAuthPassword(umaClientSecret); request.setScope(scope); request.setAuthenticationMethod(authenticationMethod); request.setAlgorithm(signatureAlgorithm); request.setAudience(audience); return request(tokenUrl, request); }
@Parameters({"tokenPath", "userId", "userSecret", "audience"}) @Test public void requestAccessTokenWithClientSecretJwtFail(final String tokenPath, final String userId, final String userSecret, final String audience) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + tokenPath).request(); request.header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED); TokenRequest tokenRequest = new TokenRequest(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS); tokenRequest.setUsername(userId); tokenRequest.setPassword(userSecret); tokenRequest.setScope("email read_stream manage_pages"); tokenRequest.setAuthPassword("INVALID_SECRET"); tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_JWT); tokenRequest.setAudience(audience); Response response = request .post(Entity.form(new MultivaluedHashMap<String, String>(tokenRequest.getParameters()))); String entity = response.readEntity(String.class); showResponse("requestAccessTokenWithClientSecretJwt Fail", response, entity); assertEquals(response.getStatus(), 401, "Unexpected response code."); 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); } }
tokenRequest.setAlgorithm(algorithm); tokenRequest.setKeyId(tmpKeyId); tokenRequest.setAudience(tokenUrl);
tokenRequest.setAudience(audience); tokenRequest.setUsername(userId); tokenRequest.setPassword(userSecret);
tokenRequest.setAudience(audience); tokenRequest.setUsername(userId); tokenRequest.setPassword(userSecret);
tokenRequest.setAudience(audience); tokenRequest.setUsername(userId); tokenRequest.setPassword(userSecret);
tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_JWT); tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAudience(audience);
tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setKeyId(keyId); tokenRequest.setAudience(audience); tokenRequest.setCode(authorizationCode4); tokenRequest.setRedirectUri(redirectUri);
tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAlgorithm(SignatureAlgorithm.HS384); tokenRequest.setAudience(audience);
tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAlgorithm(SignatureAlgorithm.HS512); tokenRequest.setAudience(audience);
tokenRequest.setKeyId(keyId); tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAudience(audience);
tokenRequest.setKeyId(keyId); tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAudience(audience); tokenRequest.setUsername(userId); tokenRequest.setPassword(userSecret);
tokenRequest.setKeyId(keyId); tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAudience(audience); tokenRequest.setUsername(userId); tokenRequest.setPassword(userSecret);
tokenRequest.setKeyId(keyId); tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAudience(audience);
tokenRequest.setAlgorithm(cryptoProvider.getSignatureAlgorithm(keyId)); tokenRequest.setKeyId(keyId); tokenRequest.setAudience(umaMetadata.getTokenEndpoint());
tokenRequest.setKeyId(keyId); tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAudience(audience); tokenRequest.setUsername(userId); tokenRequest.setPassword(userSecret);
public void exec() { try { TokenRequest request = new TokenRequest(grantType); request.setAuthUsername(clientId); request.setAuthPassword(clientSecret); request.setCode(code); request.setRedirectUri(redirectUri); request.setUsername(username); request.setPassword(password); request.setScope(scope); request.setAssertion(assertion); request.setRefreshToken(refreshToken); request.setAuthenticationMethod(authenticationMethod); if (authenticationMethod.equals(AuthenticationMethod.CLIENT_SECRET_JWT)) { request.setAudience(tokenEndpoint); } TokenClient client = new TokenClient(tokenEndpoint); client.setRequest(request); TokenResponse response = client.exec(); if (response.getStatus() == 200) { userInfoAction.setAccessToken(response.getAccessToken()); } showResults = true; requestString = client.getRequestAsString(); responseString = client.getResponseAsString(); } catch (Exception e) { log.error(e.getMessage(), e); } }
tokenRequest.setAlgorithm(SignatureAlgorithm.HS256); tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setAudience(tokenEndpoint);
tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setKeyId("RS384SIG_INVALID_KEYID"); tokenRequest.setAudience(tokenEndpoint);
tokenRequest.setCryptoProvider(cryptoProvider); tokenRequest.setKeyId("ES384SIG_INVALID_KEYID"); tokenRequest.setAudience(tokenEndpoint);