Search in sources :

Example 1 with MissingCredentialsException

use of com.venafi.vcert.sdk.connectors.ConnectorException.MissingCredentialsException in project vcert-java by Venafi.

the class TppConnector method authenticate.

public void authenticate(Authentication auth) throws VCertException {
    if (auth == null)
        throw new MissingCredentialsException();
    AuthorizeResponse response = tpp.authorize(new AuthorizeRequest(auth.user(), auth.password()));
    apiKey = response.apiKey();
    bestBeforeEnd = response.validUntil();
}
Also used : MissingCredentialsException(com.venafi.vcert.sdk.connectors.ConnectorException.MissingCredentialsException)

Example 2 with MissingCredentialsException

use of com.venafi.vcert.sdk.connectors.ConnectorException.MissingCredentialsException 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)2 BadRequest (feign.FeignException.BadRequest)1 Unauthorized (feign.FeignException.Unauthorized)1