Search in sources :

Example 1 with FailedToRevokeTokenException

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

the class TppTokenConnectorTest method revokeAccessTokenInvalid.

@Test
@DisplayName("Revoke access token invalid")
void revokeAccessTokenInvalid() {
    final Request request = Request.create(Request.HttpMethod.GET, "", new HashMap<String, Collection<String>>(), null);
    final Response response = Response.builder().status(202).request(request).build();
    when(tpp.revokeToken(eq(HEADER_AUTHORIZATION))).thenReturn(response);
    Throwable throwable = assertThrows(VCertException.class, () -> classUnderTest.revokeAccessToken());
    assertThat(throwable instanceof FailedToRevokeTokenException);
}
Also used : Response(feign.Response) FailedToRevokeTokenException(com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException) RenewalRequest(com.venafi.vcert.sdk.certificate.RenewalRequest) CertificateRequest(com.venafi.vcert.sdk.certificate.CertificateRequest) Request(feign.Request) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with FailedToRevokeTokenException

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

the class TppTokenConnector method revokeAccessToken.

@Override
public int revokeAccessToken() throws VCertException {
    // "Bearer "+accessToken;
    String requestHeader = getAuthHeaderValue();
    Response response = tpp.revokeToken(requestHeader);
    if (response.status() == 200) {
        return response.status();
    } else {
        throw new FailedToRevokeTokenException(response.reason());
    }
}
Also used : ImportResponse(com.venafi.vcert.sdk.certificate.ImportResponse) CertificateSearchResponse(com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateSearchResponse) TppSshCaTemplateResponse(com.venafi.vcert.sdk.connectors.tpp.endpoint.ssh.TppSshCaTemplateResponse) CertificateRetrieveResponse(com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateRetrieveResponse) TppSshCertRequestResponse(com.venafi.vcert.sdk.connectors.tpp.endpoint.ssh.TppSshCertRequestResponse) CertificateRenewalResponse(com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateRenewalResponse) Response(feign.Response) TppSshCertRetrieveResponse(com.venafi.vcert.sdk.connectors.tpp.endpoint.ssh.TppSshCertRetrieveResponse) CertificateRequestResponse(com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateRequestResponse) CertificateRevokeResponse(com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateRevokeResponse) FailedToRevokeTokenException(com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException)

Aggregations

FailedToRevokeTokenException (com.venafi.vcert.sdk.connectors.ConnectorException.FailedToRevokeTokenException)2 Response (feign.Response)2 CertificateRequest (com.venafi.vcert.sdk.certificate.CertificateRequest)1 ImportResponse (com.venafi.vcert.sdk.certificate.ImportResponse)1 RenewalRequest (com.venafi.vcert.sdk.certificate.RenewalRequest)1 CertificateRenewalResponse (com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateRenewalResponse)1 CertificateRequestResponse (com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateRequestResponse)1 CertificateRetrieveResponse (com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateRetrieveResponse)1 CertificateRevokeResponse (com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateRevokeResponse)1 CertificateSearchResponse (com.venafi.vcert.sdk.connectors.tpp.Tpp.CertificateSearchResponse)1 TppSshCaTemplateResponse (com.venafi.vcert.sdk.connectors.tpp.endpoint.ssh.TppSshCaTemplateResponse)1 TppSshCertRequestResponse (com.venafi.vcert.sdk.connectors.tpp.endpoint.ssh.TppSshCertRequestResponse)1 TppSshCertRetrieveResponse (com.venafi.vcert.sdk.connectors.tpp.endpoint.ssh.TppSshCertRetrieveResponse)1 Request (feign.Request)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1