Search in sources :

Example 1 with BadRequest

use of feign.FeignException.BadRequest in project vcert-java by Venafi.

the class TppTokenConnector method authenticate.

@Override
public void authenticate(Authentication auth) throws VCertException {
    if (isEmptyCredentials(auth))
        throw new MissingCredentialsException();
    try {
        AuthorizeTokenRequest authRequest = new AuthorizeTokenRequest(auth.user(), auth.password(), auth.clientId(), auth.scope(), auth.state(), auth.redirectUri());
        AuthorizeTokenResponse response = tpp.authorizeToken(authRequest);
        tokenInfo = new TokenInfo(response.accessToken(), response.refreshToken(), response.expire(), response.tokenType(), response.scope(), response.identity(), response.refreshUntil(), true, null);
        this.credentials = auth;
        this.credentials.accessToken(tokenInfo.accessToken());
        this.credentials.refreshToken(tokenInfo.refreshToken());
    } catch (Unauthorized | BadRequest e) {
        tokenInfo = new TokenInfo(null, null, -1, null, null, null, -1, false, e.getMessage() + " " + new String(e.content()));
    }
}
Also used : BadRequest(feign.FeignException.BadRequest) Unauthorized(feign.FeignException.Unauthorized) MissingCredentialsException(com.venafi.vcert.sdk.connectors.ConnectorException.MissingCredentialsException)

Aggregations

MissingCredentialsException (com.venafi.vcert.sdk.connectors.ConnectorException.MissingCredentialsException)1 BadRequest (feign.FeignException.BadRequest)1 Unauthorized (feign.FeignException.Unauthorized)1