/** * <p> * Executes the call to the REST Service requesting the authorization and * processes the response. * </p> * <p> * The client uses an extension grant type by specifying the grant type * using an absolute URI (defined by the authorization server) as the value * of the grant_type parameter of the token endpoint, and by adding any * additional parameters necessary. * </p> * * @param grantTypeUri Absolute URI. * @param assertion Assertion grant type. * @param clientId The client identifier. * @param clientSecret The client secret. * @return The token response. */ public TokenResponse execExtensionGrant(String grantTypeUri, String assertion, String clientId, String clientSecret) { GrantType grantType = GrantType.fromString(grantTypeUri); setRequest(new TokenRequest(grantType)); getRequest().setAssertion(assertion); getRequest().setAuthUsername(clientId); getRequest().setAuthPassword(clientSecret); return exec(); }
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); } }