use of com.nimbusds.oauth2.sdk.ClientCredentialsGrant in project iaf by ibissource.
the class OAuthAccessTokenManager method createRequest.
private TokenRequest createRequest(Credentials credentials) throws HttpAuthenticationException {
AuthorizationGrant grant;
if (useClientCredentialsGrant) {
grant = new ClientCredentialsGrant();
} else {
String username = credentials.getUserPrincipal().getName();
Secret password = new Secret(credentials.getPassword());
grant = new ResourceOwnerPasswordCredentialsGrant(username, password);
}
// The credentials to authenticate the client at the token endpoint
ClientID clientID = new ClientID(client_cf.getUsername());
Secret clientSecret = new Secret(client_cf.getPassword());
ClientAuthentication clientAuth = new ClientSecretBasic(clientID, clientSecret);
try {
URI _tokenEndpoint = new URI(tokenEndpoint);
return new TokenRequest(_tokenEndpoint, clientAuth, grant, scope);
} catch (URISyntaxException e) {
throw new HttpAuthenticationException("illegal token endpoint", e);
}
}
Aggregations