use of com.venafi.vcert.sdk.connectors.tpp.endpoint.ssh.TppSshCertRetrieveRequest in project vcert-java by Venafi.
the class TppConnectorUtils method convertToTppSshCertRetReq.
public static TppSshCertRetrieveRequest convertToTppSshCertRetReq(SshCertificateRequest sshCertificateRequest) throws VCertException {
TppSshCertRetrieveRequest tppSshCertRetrieveRequest = new TppSshCertRetrieveRequest();
tppSshCertRetrieveRequest.dn(isNotBlank(sshCertificateRequest.pickupID()) ? sshCertificateRequest.pickupID() : null);
tppSshCertRetrieveRequest.guid(isNotBlank(sshCertificateRequest.guid()) ? sshCertificateRequest.guid() : null);
tppSshCertRetrieveRequest.privateKeyPassphrase(isNotBlank(sshCertificateRequest.privateKeyPassphrase()) ? sshCertificateRequest.privateKeyPassphrase() : null);
return tppSshCertRetrieveRequest;
}
use of com.venafi.vcert.sdk.connectors.tpp.endpoint.ssh.TppSshCertRetrieveRequest in project vcert-java by Venafi.
the class AbstractTppConnector method retrieveTppSshCertificate.
protected SshCertRetrieveDetails retrieveTppSshCertificate(SshCertificateRequest sshCertificateRequest) throws VCertException {
TppSshCertRetrieveResponse tppSshCertRetrieveResponse = null;
TppSshCertRetrieveRequest tppSshCertRetrieveRequest = TppConnectorUtils.convertToTppSshCertRetReq(sshCertificateRequest);
// TODO move this retry logic to feign client
Instant startTime = Instant.now();
while (true) {
tppSshCertRetrieveResponse = tppAPI.retrieveSshCertificate(tppSshCertRetrieveRequest);
// if the certificate was returned(Issued)
if (StringUtils.isNotBlank(tppSshCertRetrieveResponse.certificateData())) {
break;
}
// if the certificate request was rejected
if (tppSshCertRetrieveResponse.response().success() && tppSshCertRetrieveResponse.processingDetails().status().equals("Rejected"))
throw new CertificateRejectedException(sshCertificateRequest.pickupID(), tppSshCertRetrieveResponse.processingDetails().statusDescription());
// if the certificate is pending to be issued
if (ZERO.equals(sshCertificateRequest.timeout())) {
throw new CertificatePendingException(sshCertificateRequest.pickupID(), tppSshCertRetrieveResponse.processingDetails().statusDescription());
}
// if the timeout was reached
if (Instant.now().isAfter(startTime.plus(sshCertificateRequest.timeout()))) {
throw new RetrieveCertificateTimeoutException(sshCertificateRequest.pickupID());
}
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
// Restore interrupted state...
Thread.currentThread().interrupt();
throw new AttemptToRetryException(e);
}
}
return TppConnectorUtils.convertToSshCertRetrieveDetails(tppSshCertRetrieveResponse);
}
Aggregations