Search in sources :

Example 1 with ResourceOwnerPasswordCredentialsGrant

use of com.nimbusds.oauth2.sdk.ResourceOwnerPasswordCredentialsGrant 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);
    }
}
Also used : Secret(com.nimbusds.oauth2.sdk.auth.Secret) ClientCredentialsGrant(com.nimbusds.oauth2.sdk.ClientCredentialsGrant) TokenRequest(com.nimbusds.oauth2.sdk.TokenRequest) ResourceOwnerPasswordCredentialsGrant(com.nimbusds.oauth2.sdk.ResourceOwnerPasswordCredentialsGrant) ClientID(com.nimbusds.oauth2.sdk.id.ClientID) URISyntaxException(java.net.URISyntaxException) AuthorizationGrant(com.nimbusds.oauth2.sdk.AuthorizationGrant) ClientAuthentication(com.nimbusds.oauth2.sdk.auth.ClientAuthentication) URI(java.net.URI) ClientSecretBasic(com.nimbusds.oauth2.sdk.auth.ClientSecretBasic)

Aggregations

AuthorizationGrant (com.nimbusds.oauth2.sdk.AuthorizationGrant)1 ClientCredentialsGrant (com.nimbusds.oauth2.sdk.ClientCredentialsGrant)1 ResourceOwnerPasswordCredentialsGrant (com.nimbusds.oauth2.sdk.ResourceOwnerPasswordCredentialsGrant)1 TokenRequest (com.nimbusds.oauth2.sdk.TokenRequest)1 ClientAuthentication (com.nimbusds.oauth2.sdk.auth.ClientAuthentication)1 ClientSecretBasic (com.nimbusds.oauth2.sdk.auth.ClientSecretBasic)1 Secret (com.nimbusds.oauth2.sdk.auth.Secret)1 ClientID (com.nimbusds.oauth2.sdk.id.ClientID)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1