-
Notifications
You must be signed in to change notification settings - Fork 224
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 new Pki::issue method that takes an IssueOptions object #211
Open
kb
wants to merge
1
commit into
BetterCloud:master
Choose a base branch
from
digits:pki-issue-api-options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
src/main/java/com/bettercloud/vault/api/pki/IssueOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.bettercloud.vault.api.pki; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Value class for options to be passed to the PKI issue API. | ||
*/ | ||
public class IssueOptions { | ||
|
||
private List<String> altNames; | ||
private List<String> ipSans; | ||
private List<String> uriSans; | ||
private List<String> otherSans; | ||
private String ttl; | ||
private CredentialFormat credentialFormat; | ||
private PrivateKeyFormat privateKeyFormat; | ||
private Boolean excludeCnFromSans; | ||
private String csr; | ||
|
||
public IssueOptions altNames(List<String> altNames) { | ||
this.altNames = altNames; | ||
return this; | ||
} | ||
|
||
public IssueOptions ipSans(List<String> ipSans) { | ||
this.ipSans = ipSans; | ||
return this; | ||
} | ||
|
||
public IssueOptions uriSans(List<String> uriSans) { | ||
this.uriSans = uriSans; | ||
return this; | ||
} | ||
|
||
public IssueOptions otherSans(List<String> otherSans) { | ||
this.otherSans = otherSans; | ||
return this; | ||
} | ||
|
||
public IssueOptions ttl(String ttl) { | ||
this.ttl = ttl; | ||
return this; | ||
} | ||
|
||
public IssueOptions credentialFormat(CredentialFormat format) { | ||
this.credentialFormat = format; | ||
return this; | ||
} | ||
|
||
public IssueOptions privateKeyFormat(PrivateKeyFormat privateKeyFormat) { | ||
this.privateKeyFormat = privateKeyFormat; | ||
return this; | ||
} | ||
|
||
public IssueOptions excludeCnFromSans(Boolean excludeCnFromSans) { | ||
this.excludeCnFromSans = excludeCnFromSans; | ||
return this; | ||
} | ||
|
||
public IssueOptions csr(String csr) { | ||
this.csr = csr; | ||
return this; | ||
} | ||
|
||
public List<String> getAltNames() { | ||
return altNames; | ||
} | ||
|
||
public List<String> getIpSans() { return ipSans; } | ||
|
||
public List<String> getUriSans() { | ||
return uriSans; | ||
} | ||
|
||
public List<String> getOtherSans() { | ||
return otherSans; | ||
} | ||
|
||
public String getTtl() { | ||
return ttl; | ||
} | ||
|
||
public CredentialFormat getCredentialFormat() { return credentialFormat; } | ||
|
||
public PrivateKeyFormat getPrivateKeyFormat() { | ||
return privateKeyFormat; | ||
} | ||
|
||
public Boolean isExcludeCnFromSans() { | ||
return excludeCnFromSans; | ||
} | ||
|
||
public String getCsr() { | ||
return csr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/bettercloud/vault/api/pki/PrivateKeyFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.bettercloud.vault.api.pki; | ||
|
||
/** | ||
* <p>Possible format options for private keys issued by the PKI backend.</p> | ||
*/ | ||
public enum PrivateKeyFormat { | ||
DER, | ||
PEM, | ||
PKCS8; | ||
|
||
public static PrivateKeyFormat fromString(final String text) { | ||
if (text != null) { | ||
for (final PrivateKeyFormat format : PrivateKeyFormat.values()) { | ||
if (text.equalsIgnoreCase(format.toString())) { | ||
return format; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString() { return super.toString().toLowerCase(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,12 @@ | |
import com.bettercloud.vault.response.LogicalResponse; | ||
import com.bettercloud.vault.vault.VaultTestUtils; | ||
import com.bettercloud.vault.vault.mock.MockVault; | ||
import java.util.Collections; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated change that fixes checkstyle rule failure |
||
import java.util.Optional; | ||
import org.eclipse.jetty.server.Server; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.Optional; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TransitApiTest { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change that fixes checkstyle rule failure