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();
}
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()));
}
}
Aggregations