Skip to content

Commit

Permalink
Add CertificateType attribute to CertificateRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Oehmke authored and heoehmke committed Feb 3, 2023
1 parent 41bde09 commit 5013770
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class CertificateRequest {
private String issuerHint;
private Collection<CustomField> customFields;
private DataFormat dataFormat;
private CertificateType certificateType;

public CertificateRequest() {
this.dnsNames = emptyList();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.venafi.vcert.sdk.certificate;


import lombok.Getter;

public enum CertificateType {
Auto("Auto"),
CodeSigning("Code Signing: X.509 Code Signing Certificate"),
Device("Device: X.509 Device Certificate"),
Server("Server: X.509 Server Certificate"),
User("User: X.509 User Certificate");

public static CertificateType from(String value) {
switch (value.toLowerCase()) {
case "auto":
return Auto;
case "code signing: x.509 code signing certificate":
return CodeSigning;
case "device: x.509 device certificate":
return Device;
case "server: x.509 server certificate":
return Server;
case "user: x.509 user certificate":
return User;
default:
throw new IllegalArgumentException(String.format("unknown certificate type: %s", value));
}
}

@Getter
private final String value;

CertificateType(String value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public static class CertificateRequestsPayload {
private String ellipticCurve;
private boolean disableAutomaticRenewal;
private String origin;

private String certificateType;
@SerializedName("CustomFields")
private ArrayList<CustomFieldRequest> customFields;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,11 @@ protected CertificateRequestsPayload prepareRequest(CertificateRequest request,
break;
}
}



if (request.certificateType() != null) {
payload.certificateType(request.certificateType().value());
}

//support for validity hours begins
VCertUtils.addExpirationDateAttribute(request, payload);
//support for validity hours ends
Expand Down

0 comments on commit 5013770

Please sign in to comment.