Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit c3e5f8f

Browse files
Merge branch 'master' into SonarCloud-Duplications
2 parents 2f85ef6 + 193c1f9 commit c3e5f8f

14 files changed

Lines changed: 83 additions & 74 deletions

File tree

File renamed without changes.
File renamed without changes.

.github/images/Venafi_logo.png

4.55 KB
Loading

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Venafi](Venafi_logo.png)
1+
[![Venafi](.github/images/Venafi_logo.png)](https://www.venafi.com/)
22
[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
33
![Community Supported](https://img.shields.io/badge/Support%20Level-Community-brightgreen)
44
![Compatible with TPP 17.3+ & Cloud](https://img.shields.io/badge/Compatibility-TPP%2017.3+%20%26%20Cloud-f9a90c)

Venafi_logo.png

-8.26 KB
Binary file not shown.

src/main/java/com/venafi/vcert/sdk/certificate/KeySize.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public enum KeySize {
2424
}
2525
}
2626

27-
public static KeySize from(String key) {
27+
public static KeySize from(Integer key) {
2828
return LOOKUP.get(key);
2929
}
3030

src/main/java/com/venafi/vcert/sdk/connectors/cloud/CloudConnector.java

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,32 +118,30 @@ public void authenticate(Authentication auth) throws VCertException {
118118

119119
@Override
120120
public ZoneConfiguration readZoneConfiguration(String zone) throws VCertException {
121-
121+
122122
String valies[] = StringUtils.split(zone, "\\");
123123
String appName = valies[0];
124124
String citAlias = valies[1];
125-
125+
126126
CertificateIssuingTemplate cit = null;
127-
String zoneId = null;
128-
if((appName != null && appName != "") && (citAlias != null && citAlias != "")) {
129-
130-
cit = cloud.certificateIssuingTemplateByAppNameAndCitAlias(appName, citAlias, auth.apiKey());
131-
132-
}else {
133-
throw new ZoneFormatException("The parameters: appName, citAlias or both are empty");
134-
}
135-
136-
//get application id.
137-
Application app = cloud.applicationByName(appName, auth.apiKey());
138-
String appId = app.id();
139127

140-
ZoneConfiguration zoneConfig = cit.toZoneConfig();
141-
zoneConfig.policy(cit.toPolicy());
142-
zoneConfig.zoneId(zone);
143-
zoneConfig.applicationId(appId);
144-
zoneConfig.certificateIssuingTemplateId(cit.id());
128+
if((appName != null && !appName.equals("")) && (citAlias != null && !citAlias.equals(""))) {
129+
cit = cloud.certificateIssuingTemplateByAppNameAndCitAlias(appName, citAlias, auth.apiKey());
130+
} else {
131+
throw new ZoneFormatException("The parameters: appName, citAlias or both are empty");
132+
}
133+
134+
//get application id.
135+
Application app = cloud.applicationByName(appName, auth.apiKey());
136+
String appId = app.id();
137+
138+
ZoneConfiguration zoneConfig = cit.toZoneConfig();
139+
zoneConfig.policy(cit.toPolicy());
140+
zoneConfig.zoneId(zone);
141+
zoneConfig.applicationId(appId);
142+
zoneConfig.certificateIssuingTemplateId(cit.id());
145143

146-
return zoneConfig;
144+
return zoneConfig;
147145
}
148146

149147
@Override
@@ -307,11 +305,20 @@ private void setIdentifiersUsingThumbprint(CertificateRequest request) throws VC
307305

308306
private String getCertificateIdFromPickupId(CertificateRequest request) throws VCertException {
309307
CertificateStatus certificateStatus = null;
308+
309+
if (user == null || user.company() == null) {
310+
throw new UserNotAuthenticatedException("Must be authenticated to retrieve certificate");
311+
}
310312

311313
Instant startTime = Instant.now();
312314
while (true) {
313315

314316
certificateStatus = getCertificateStatus(request.pickupId());
317+
318+
if(certificateStatus == null) {
319+
throw new FailedToRetrieveCertificateStatusException(request.pickupId());
320+
}
321+
315322
if ("ISSUED".equals(certificateStatus.status())) {
316323
break;
317324
} else if ("FAILED".equals(certificateStatus.status())) {
@@ -330,18 +337,12 @@ private String getCertificateIdFromPickupId(CertificateRequest request) throws V
330337
try {
331338
TimeUnit.SECONDS.sleep(2);
332339
} catch (InterruptedException e) {
340+
// Restore interrupted state...
341+
Thread.currentThread().interrupt();
333342
throw new AttemptToRetryException(e);
334343
}
335344
}
336-
337-
if (user == null || user.company() == null) {
338-
throw new UserNotAuthenticatedException("Must be authenticated to retrieve certificate");
339-
}
340-
341-
if(certificateStatus == null) {
342-
throw new FailedToRetrieveCertificateStatusException(request.pickupId());
343-
}
344-
345+
345346
return certificateStatus.certificateIds().get(0);
346347
}
347348

@@ -397,6 +398,8 @@ private PEMCollection retrieveCertificateAsPemCollectionFromCSRProvided(Certific
397398
try {
398399
TimeUnit.SECONDS.sleep(2);
399400
} catch (InterruptedException e) {
401+
// Restore interrupted state...
402+
Thread.currentThread().interrupt();
400403
throw new AttemptToRetryException(e);
401404
}
402405
}

src/main/java/com/venafi/vcert/sdk/connectors/cloud/CloudConnectorUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.venafi.vcert.sdk.connectors.cloud.domain.CloudZone;
1717
import com.venafi.vcert.sdk.connectors.cloud.domain.UserDetails;
1818
import com.venafi.vcert.sdk.connectors.cloud.endpoint.*;
19+
import com.venafi.vcert.sdk.connectors.cloud.endpoint.CAAccount.ProductOption;
1920
import com.venafi.vcert.sdk.policy.api.domain.CloudPolicy;
2021
import com.venafi.vcert.sdk.policy.domain.PolicySpecification;
2122

@@ -224,7 +225,7 @@ private static String getProductName(CAAccount caAccount, CertificateIssuingTemp
224225
return caAccount.productOptions().stream()
225226
.filter(p -> p.id().equals(cit.certificateAuthorityProductOptionId))
226227
.findFirst()
227-
.get()
228+
.orElse(new ProductOption())
228229
.productName();
229230
}
230231

src/main/java/com/venafi/vcert/sdk/connectors/tpp/AbstractTppConnector.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,16 @@ public abstract class AbstractTppConnector {
4242

4343
// TODO can be enum
4444
@SuppressWarnings("serial")
45-
protected static final Map<String, Integer> revocationReasons = new HashMap<String, Integer>() {
46-
{
47-
put("", 0); // NoReason
48-
put("none", 0); //
49-
put("key-compromise", 1); // UserKeyCompromised
50-
put("ca-compromise", 2); // CAKeyCompromised
51-
put("affiliation-changed", 3); // UserChangedAffiliation
52-
put("superseded", 4); // CertificateSuperseded
53-
put("cessation-of-operation", 5); // OriginalUseNoLongerValid
54-
}
55-
};
45+
protected static final Map<String, Integer> revocationReasons = new HashMap<String, Integer>();
46+
static {
47+
revocationReasons.put("", 0); // NoReason
48+
revocationReasons.put("none", 0); //
49+
revocationReasons.put("key-compromise", 1); // UserKeyCompromised
50+
revocationReasons.put("ca-compromise", 2); // CAKeyCompromised
51+
revocationReasons.put("affiliation-changed", 3); // UserChangedAffiliation
52+
revocationReasons.put("superseded", 4); // CertificateSuperseded
53+
revocationReasons.put("cessation-of-operation", 5); // OriginalUseNoLongerValid
54+
}
5655

5756
protected final Tpp tpp;
5857

@@ -173,6 +172,8 @@ protected SshCertRetrieveDetails retrieveTppSshCertificate(SshCertificateRequest
173172
try {
174173
TimeUnit.SECONDS.sleep(2);
175174
} catch (InterruptedException e) {
175+
// Restore interrupted state...
176+
Thread.currentThread().interrupt();
176177
throw new AttemptToRetryException(e);
177178
}
178179
}

src/main/java/com/venafi/vcert/sdk/connectors/tpp/TppConnector.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,11 @@ public PEMCollection retrieveCertificate(CertificateRequest request) throws VCer
342342
throw new RetrieveCertificateTimeoutException(request.pickupId());
343343

344344
try {
345-
TimeUnit.SECONDS.sleep(2);
345+
TimeUnit.SECONDS.sleep(2);
346346
} catch (InterruptedException e) {
347-
throw new AttemptToRetryException(e);
347+
// Restore interrupted state...
348+
Thread.currentThread().interrupt();
349+
throw new AttemptToRetryException(e);
348350
}
349351
}
350352
}

0 commit comments

Comments
 (0)