Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CertificateType attribute to CertificateRequest #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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