Minor CleanUp
Reworked some JavaDoc comments and optimized imports.
This commit is contained in:
parent
6904ed6817
commit
061c1e9743
src/main/java/de/stklcode/jvault/connector
@ -19,7 +19,10 @@ package de.stklcode.jvault.connector;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.stklcode.jvault.connector.exception.*;
|
||||
import de.stklcode.jvault.connector.model.*;
|
||||
import de.stklcode.jvault.connector.model.AppRole;
|
||||
import de.stklcode.jvault.connector.model.AppRoleSecret;
|
||||
import de.stklcode.jvault.connector.model.AuthBackend;
|
||||
import de.stklcode.jvault.connector.model.Token;
|
||||
import de.stklcode.jvault.connector.model.response.*;
|
||||
import de.stklcode.jvault.connector.model.response.embedded.AuthMethod;
|
||||
import org.apache.http.HttpResponse;
|
||||
@ -31,11 +34,16 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.*;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,10 @@ import de.stklcode.jvault.connector.exception.VaultConnectorException;
|
||||
import de.stklcode.jvault.connector.model.*;
|
||||
import de.stklcode.jvault.connector.model.response.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Vault Connector interface.
|
||||
@ -31,6 +34,9 @@ import java.util.*;
|
||||
* @since 0.1
|
||||
*/
|
||||
public interface VaultConnector extends AutoCloseable {
|
||||
/**
|
||||
* Default sub-path for Vault secrets.
|
||||
*/
|
||||
String PATH_SECRET = "secret";
|
||||
|
||||
/**
|
||||
@ -115,7 +121,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
*
|
||||
* @param appID The App ID
|
||||
* @param userID The User ID
|
||||
* @return TRUE on success
|
||||
* @return The {@link AuthResponse}
|
||||
* @throws VaultConnectorException on error
|
||||
* @deprecated As of Vault 0.6.1 App-ID is superseded by AppRole. Consider using {@link #authAppRole} instead.
|
||||
*/
|
||||
@ -126,7 +132,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
* Authorize to Vault using AppRole method without secret ID.
|
||||
*
|
||||
* @param roleID The role ID
|
||||
* @return TRUE on success
|
||||
* @return The {@link AuthResponse}
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ -139,7 +145,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
*
|
||||
* @param roleID The role ID
|
||||
* @param secretID The secret ID
|
||||
* @return TRUE on success
|
||||
* @return The {@link AuthResponse}
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ -151,7 +157,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
* @param appID The unique App-ID
|
||||
* @param policy The policy to associate with
|
||||
* @param displayName Arbitrary name to display
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @deprecated As of Vault 0.6.1 App-ID is superseded by AppRole. Consider using {@link #createAppRole} instead.
|
||||
*/
|
||||
@ -163,7 +169,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
* Register a new AppRole role from given metamodel.
|
||||
*
|
||||
* @param role The role
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ -173,7 +179,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
* Register new AppRole role with default policy.
|
||||
*
|
||||
* @param roleName The role name
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ -186,7 +192,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
*
|
||||
* @param roleName The role name
|
||||
* @param policies The policies to associate with
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ -199,7 +205,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
*
|
||||
* @param roleName The role name
|
||||
* @param roleID A custom role ID
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ -213,7 +219,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
* @param roleName The role name
|
||||
* @param policies The policies to associate with
|
||||
* @param roleID A custom role ID
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ -226,7 +232,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
* Delete AppRole role from Vault.
|
||||
*
|
||||
* @param roleName The role anme
|
||||
* @return TRUE on succevss
|
||||
* @return {@code true} on succevss
|
||||
* @throws VaultConnectorException on error
|
||||
*/
|
||||
boolean deleteAppRole(final String roleName) throws VaultConnectorException;
|
||||
@ -256,7 +262,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
*
|
||||
* @param roleName The role name
|
||||
* @param roleID The role ID
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.4.0
|
||||
*/
|
||||
@ -345,7 +351,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
*
|
||||
* @param appID The App-ID
|
||||
* @param userID The User-ID
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @deprecated As of Vault 0.6.1 App-ID is superseded by AppRole.
|
||||
* Consider using {@link #createAppRoleSecret} instead.
|
||||
@ -360,7 +366,7 @@ public interface VaultConnector extends AutoCloseable {
|
||||
* @param policy The policy to associate with
|
||||
* @param displayName Arbitrary name to display
|
||||
* @param userID The User-ID
|
||||
* @return TRUE on success
|
||||
* @return {@code true} on success
|
||||
* @throws VaultConnectorException on error
|
||||
* @deprecated As of Vault 0.6.1 App-ID is superseded by AppRole.
|
||||
*/
|
||||
@ -471,8 +477,9 @@ public interface VaultConnector extends AutoCloseable {
|
||||
* @since 0.5.0
|
||||
*/
|
||||
default void writeSecret(final String key, final Map<String, Object> data) throws VaultConnectorException {
|
||||
if (key == null || key.isEmpty())
|
||||
if (key == null || key.isEmpty()) {
|
||||
throw new InvalidRequestException("Secret path must not be empty.");
|
||||
}
|
||||
write(PATH_SECRET + "/" + key, data);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param message The detail message
|
||||
*/
|
||||
public InvalidResponseException(final String message) {
|
||||
super(message);
|
||||
@ -49,7 +49,7 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
/**
|
||||
* Constructs a new exception with the specified cause.
|
||||
*
|
||||
* @param cause the cause
|
||||
* @param cause The cause
|
||||
*/
|
||||
public InvalidResponseException(final Throwable cause) {
|
||||
super(cause);
|
||||
@ -60,8 +60,8 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
/**
|
||||
* Constructs a new exception with the specified detail message and cause.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause
|
||||
* @param message The detail message
|
||||
* @param cause The cause
|
||||
*/
|
||||
public InvalidResponseException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
@ -74,8 +74,8 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
* <p>
|
||||
* The HTTP status code can be retrieved by {@link #getStatusCode()} later.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param statusCode status code of the HTTP response
|
||||
* @param message The detail message
|
||||
* @param statusCode Status code of the HTTP response
|
||||
* @since 0.6.2
|
||||
*/
|
||||
public InvalidResponseException(final String message, final Integer statusCode) {
|
||||
@ -89,9 +89,9 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
* <p>
|
||||
* The HTTP status code can be retrieved by {@link #getStatusCode()} later.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param statusCode status code of the HTTP response
|
||||
* @param cause the cause
|
||||
* @param message The detail message
|
||||
* @param statusCode Status code of the HTTP response
|
||||
* @param cause The cause
|
||||
* @since 0.6.2
|
||||
*/
|
||||
public InvalidResponseException(final String message, final Integer statusCode, final Throwable cause) {
|
||||
@ -103,8 +103,8 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
* <p>
|
||||
* The HTTP status code can be retrieved by {@link #getStatusCode()} later.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param statusCode status code of the HTTP response
|
||||
* @param message The detail message
|
||||
* @param statusCode Status code of the HTTP response
|
||||
* @param response HTTP response string
|
||||
* @since 0.6.2
|
||||
*/
|
||||
@ -121,10 +121,10 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
* <p>
|
||||
* The HTTP status code can be retrieved by {@link #getStatusCode()} later.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param statusCode status code of the HTTP response
|
||||
* @param message The detail message
|
||||
* @param statusCode Status code of the HTTP response
|
||||
* @param response HTTP response string
|
||||
* @param cause the cause
|
||||
* @param cause The cause
|
||||
* @since 0.6.2
|
||||
*/
|
||||
public InvalidResponseException(final String message,
|
||||
@ -139,7 +139,7 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
/**
|
||||
* Specify the HTTP status code. Can be retrieved by {@link #getStatusCode()} later.
|
||||
*
|
||||
* @param statusCode the status code
|
||||
* @param statusCode The status code
|
||||
* @return self
|
||||
* @deprecated as of 0.6.2, use constructor with status code argument instead
|
||||
*/
|
||||
@ -151,7 +151,7 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
/**
|
||||
* Specify the response string. Can be retrieved by {@link #getResponse()} later.
|
||||
*
|
||||
* @param response response text
|
||||
* @param response Response text
|
||||
* @return self
|
||||
* @deprecated use constructor with response argument instead
|
||||
*/
|
||||
@ -163,7 +163,7 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
/**
|
||||
* Retrieve the HTTP status code.
|
||||
*
|
||||
* @return the status code or {@code null} if none specified.
|
||||
* @return The status code or {@code null} if none specified.
|
||||
*/
|
||||
public Integer getStatusCode() {
|
||||
return statusCode;
|
||||
@ -172,7 +172,7 @@ public final class InvalidResponseException extends VaultConnectorException {
|
||||
/**
|
||||
* Retrieve the response text.
|
||||
*
|
||||
* @return the response text or {@code null} if none specified.
|
||||
* @return The response text or {@code null} if none specified.
|
||||
*/
|
||||
public String getResponse() {
|
||||
return response;
|
||||
|
@ -201,6 +201,7 @@ public final class HTTPVaultConnectorFactory extends VaultConnectorFactory {
|
||||
try {
|
||||
numberOfRetries = Integer.parseInt(System.getenv(ENV_VAULT_MAX_RETRIES));
|
||||
} catch (NumberFormatException ignored) {
|
||||
/* Ignore malformed values. */
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user