split lines above 120 characters
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d81fc4e5af
commit
226b6ad6c4
@ -419,7 +419,8 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SecretResponse readSecretVersion(final String mount, final String key, final Integer version) throws VaultConnectorException {
|
||||
public final SecretResponse readSecretVersion(final String mount, final String key, final Integer version)
|
||||
throws VaultConnectorException {
|
||||
requireAuth();
|
||||
/* Request HTTP response and parse secret metadata */
|
||||
Map<String, String> args = mapOfStrings("version", version);
|
||||
@ -428,7 +429,8 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final MetadataResponse readSecretMetadata(final String mount, final String key) throws VaultConnectorException {
|
||||
public final MetadataResponse readSecretMetadata(final String mount, final String key)
|
||||
throws VaultConnectorException {
|
||||
requireAuth();
|
||||
|
||||
/* Request HTTP response and parse secret metadata */
|
||||
@ -436,7 +438,10 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSecretMetadata(final String mount, final String key, final Integer maxVersions, final boolean casRequired) throws VaultConnectorException {
|
||||
public void updateSecretMetadata(final String mount,
|
||||
final String key,
|
||||
final Integer maxVersions,
|
||||
final boolean casRequired) throws VaultConnectorException {
|
||||
requireAuth();
|
||||
|
||||
Map<String, Object> payload = mapOf(
|
||||
@ -448,7 +453,10 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SecretVersionResponse writeSecretData(final String mount, final String key, final Map<String, Object> data, final Integer cas) throws VaultConnectorException {
|
||||
public final SecretVersionResponse writeSecretData(final String mount,
|
||||
final String key,
|
||||
final Map<String, Object> data,
|
||||
final Integer cas) throws VaultConnectorException {
|
||||
requireAuth();
|
||||
|
||||
if (key == null || key.isEmpty()) {
|
||||
@ -480,7 +488,8 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void write(final String key, final Map<String, Object> data, final Map<String, Object> options) throws VaultConnectorException {
|
||||
public final void write(final String key, final Map<String, Object> data, final Map<String, Object> options)
|
||||
throws VaultConnectorException {
|
||||
requireAuth();
|
||||
|
||||
if (key == null || key.isEmpty()) {
|
||||
@ -521,17 +530,20 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void deleteSecretVersions(final String mount, final String key, final int... versions) throws VaultConnectorException {
|
||||
public final void deleteSecretVersions(final String mount, final String key, final int... versions)
|
||||
throws VaultConnectorException {
|
||||
handleSecretVersions(mount, PATH_DELETE, key, versions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void undeleteSecretVersions(final String mount, final String key, final int... versions) throws VaultConnectorException {
|
||||
public final void undeleteSecretVersions(final String mount, final String key, final int... versions)
|
||||
throws VaultConnectorException {
|
||||
handleSecretVersions(mount, PATH_UNDELETE, key, versions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void destroySecretVersions(final String mount, final String key, final int... versions) throws VaultConnectorException {
|
||||
public final void destroySecretVersions(final String mount, final String key, final int... versions)
|
||||
throws VaultConnectorException {
|
||||
handleSecretVersions(mount, PATH_DESTROY, key, versions);
|
||||
}
|
||||
|
||||
@ -545,7 +557,10 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8
|
||||
*/
|
||||
private void handleSecretVersions(final String mount, final String pathPart, final String key, final int... versions) throws VaultConnectorException {
|
||||
private void handleSecretVersions(final String mount,
|
||||
final String pathPart,
|
||||
final String key,
|
||||
final int... versions) throws VaultConnectorException {
|
||||
requireAuth();
|
||||
|
||||
/* Request HTTP response and expect empty result */
|
||||
@ -698,7 +713,7 @@ public class HTTPVaultConnector implements VaultConnector {
|
||||
*/
|
||||
private static Map<String, String> mapOfStrings(Object... keyValues) {
|
||||
Map<String, String> map = new HashMap<>(keyValues.length / 2, 1);
|
||||
for (int i = 0; i < keyValues.length -1; i = i + 2) {
|
||||
for (int i = 0; i < keyValues.length - 1; i = i + 2) {
|
||||
Object key = keyValues[i];
|
||||
Object val = keyValues[i + 1];
|
||||
if (key instanceof String && val != null) {
|
||||
|
@ -422,7 +422,9 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8
|
||||
*/
|
||||
default SecretVersionResponse writeSecretData(final String mount, final String key, final Map<String, Object> data) throws VaultConnectorException {
|
||||
default SecretVersionResponse writeSecretData(final String mount,
|
||||
final String key,
|
||||
final Map<String, Object> data) throws VaultConnectorException {
|
||||
return writeSecretData(mount, key, data, null);
|
||||
}
|
||||
|
||||
@ -440,7 +442,10 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8
|
||||
*/
|
||||
SecretVersionResponse writeSecretData(final String mount, final String key, final Map<String, Object> data, final Integer cas) throws VaultConnectorException;
|
||||
SecretVersionResponse writeSecretData(final String mount,
|
||||
final String key,
|
||||
final Map<String, Object> data,
|
||||
final Integer cas) throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* Retrieve secret data from Vault.
|
||||
@ -455,7 +460,8 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8
|
||||
*/
|
||||
SecretResponse readSecretVersion(final String mount, final String key, final Integer version) throws VaultConnectorException;
|
||||
SecretResponse readSecretVersion(final String mount, final String key, final Integer version)
|
||||
throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* Retrieve secret metadata from Vault.
|
||||
@ -484,7 +490,10 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8
|
||||
*/
|
||||
void updateSecretMetadata(final String mount, final String key, final Integer maxVersions, final boolean casRequired) throws VaultConnectorException;
|
||||
void updateSecretMetadata(final String mount,
|
||||
final String key,
|
||||
final Integer maxVersions,
|
||||
final boolean casRequired) throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* List available nodes from Vault.
|
||||
@ -529,7 +538,8 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8 {@code options} parameter added
|
||||
*/
|
||||
void write(final String key, final Map<String, Object> data, final Map<String, Object> options) throws VaultConnectorException;
|
||||
void write(final String key, final Map<String, Object> data, final Map<String, Object> options)
|
||||
throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* Delete key from Vault.
|
||||
@ -576,7 +586,8 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8
|
||||
*/
|
||||
void deleteSecretVersions(final String mount, final String key, final int... versions) throws VaultConnectorException;
|
||||
void deleteSecretVersions(final String mount, final String key, final int... versions)
|
||||
throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* Undelete (restore) secret versions from Vault.
|
||||
@ -588,7 +599,8 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8
|
||||
*/
|
||||
void undeleteSecretVersions(final String mount, final String key, final int... versions) throws VaultConnectorException;
|
||||
void undeleteSecretVersions(final String mount, final String key, final int... versions)
|
||||
throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* Destroy secret versions from Vault.
|
||||
@ -600,7 +612,8 @@ public interface VaultConnector extends AutoCloseable, Serializable {
|
||||
* @throws VaultConnectorException on error
|
||||
* @since 0.8
|
||||
*/
|
||||
void destroySecretVersions(final String mount, final String key, final int... versions) throws VaultConnectorException;
|
||||
void destroySecretVersions(final String mount, final String key, final int... versions)
|
||||
throws VaultConnectorException;
|
||||
|
||||
/**
|
||||
* Revoke given lease immediately.
|
||||
|
@ -127,7 +127,8 @@ public final class RequestHelper implements Serializable {
|
||||
* @throws VaultConnectorException on connection error
|
||||
* @since 0.8
|
||||
*/
|
||||
public void postWithoutResponse(final String path, final Object payload, final String token) throws VaultConnectorException {
|
||||
public void postWithoutResponse(final String path, final Object payload, final String token)
|
||||
throws VaultConnectorException {
|
||||
if (!post(path, payload, token).isEmpty()) {
|
||||
throw new InvalidResponseException(Error.UNEXPECTED_RESPONSE);
|
||||
}
|
||||
@ -143,7 +144,8 @@ public final class RequestHelper implements Serializable {
|
||||
* @throws VaultConnectorException on connection error
|
||||
* @since 0.8 Added {@code token} parameter.
|
||||
*/
|
||||
public String put(final String path, final Map<String, String> payload, final String token) throws VaultConnectorException {
|
||||
public String put(final String path, final Map<String, String> payload, final String token)
|
||||
throws VaultConnectorException {
|
||||
// Initialize PUT.
|
||||
var req = HttpRequest.newBuilder(URI.create(baseURL + path));
|
||||
|
||||
@ -254,8 +256,8 @@ public final class RequestHelper implements Serializable {
|
||||
|
||||
if (!payload.isEmpty()) {
|
||||
uriBuilder.append("?").append(
|
||||
payload.entrySet().stream().map(
|
||||
par -> URLEncoder.encode(par.getKey(), UTF_8) + "=" + URLEncoder.encode(par.getValue(), UTF_8)
|
||||
payload.entrySet().stream().map(par ->
|
||||
URLEncoder.encode(par.getKey(), UTF_8) + "=" + URLEncoder.encode(par.getValue(), UTF_8)
|
||||
).collect(Collectors.joining("&"))
|
||||
);
|
||||
}
|
||||
@ -386,7 +388,8 @@ public final class RequestHelper implements Serializable {
|
||||
}
|
||||
|
||||
return sslContext;
|
||||
} catch (CertificateException | NoSuchAlgorithmException | KeyStoreException | IOException | KeyManagementException e) {
|
||||
} catch (CertificateException | NoSuchAlgorithmException | KeyStoreException | IOException |
|
||||
KeyManagementException e) {
|
||||
throw new TlsException(Error.INIT_SSL_CONTEXT, e);
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public final class TokenRole implements Serializable {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, allowedPolicies, allowedPoliciesGlob, disallowedPolicies, disallowedPoliciesGlob,
|
||||
orphan, renewable, pathSuffix, allowedEntityAliases, tokenBoundCidrs, tokenExplicitMaxTtl,
|
||||
orphan, renewable, pathSuffix, allowedEntityAliases, tokenBoundCidrs, tokenExplicitMaxTtl,
|
||||
tokenNoDefaultPolicy, tokenNumUses, tokenPeriod, tokenType);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class MetaSecretResponse extends SecretResponse {
|
||||
|
||||
@Override
|
||||
public final Map<String, Serializable> getData() {
|
||||
if (secret != null) {
|
||||
if (secret != null) {
|
||||
return secret.getData();
|
||||
} else {
|
||||
return Collections.emptyMap();
|
||||
@ -50,7 +50,7 @@ public class MetaSecretResponse extends SecretResponse {
|
||||
|
||||
@Override
|
||||
public final VersionMetadata getMetadata() {
|
||||
if (secret != null) {
|
||||
if (secret != null) {
|
||||
return secret.getMetadata();
|
||||
} else {
|
||||
return null;
|
||||
|
@ -37,7 +37,8 @@ import java.util.Objects;
|
||||
public final class SecretMetadata implements Serializable {
|
||||
private static final long serialVersionUID = 1684891108903409038L;
|
||||
|
||||
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSXXX");
|
||||
private static final DateTimeFormatter TIME_FORMAT =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSXXX");
|
||||
|
||||
@JsonProperty("created_time")
|
||||
private String createdTimeString;
|
||||
|
@ -36,7 +36,8 @@ import java.util.Objects;
|
||||
public final class VersionMetadata implements Serializable {
|
||||
private static final long serialVersionUID = -5286693953873839611L;
|
||||
|
||||
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSXXX");
|
||||
private static final DateTimeFormatter TIME_FORMAT =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSXXX");
|
||||
|
||||
@JsonProperty("created_time")
|
||||
private String createdTimeString;
|
||||
|
Loading…
x
Reference in New Issue
Block a user