Java Code Examples for org.springframework.vault.support.VaultResponse#getData()
The following examples show how to use
org.springframework.vault.support.VaultResponse#getData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubbyholeAuthentication.java From spring-vault with Apache License 2.0 | 6 votes |
private static VaultToken getToken(CubbyholeAuthenticationOptions options, VaultResponse response, String url) { if (options.isWrappedToken()) { VaultResponse responseToUse = options.getUnwrappingEndpoints().unwrap(response); Assert.state(responseToUse.getAuth() != null, "Auth field must not be null"); return LoginTokenUtil.from(responseToUse.getAuth()); } Map<String, Object> data = response.getData(); if (data == null || data.isEmpty()) { throw new VaultLoginException( String.format("Cannot retrieve Token from Cubbyhole: Response at %s does not contain a token", options.getPath())); } if (data.size() == 1) { String token = (String) data.get(data.keySet().iterator().next()); return VaultToken.of(token); } throw new VaultLoginException(String .format("Cannot retrieve Token from Cubbyhole: Response at %s does not contain an unique token", url)); }
Example 2
Source File: VaultPropertySource.java From spring-vault with Apache License 2.0 | 6 votes |
/** * Hook method to obtain properties from Vault. * @param path the path, must not be empty or {@literal null}. * @return the resulting {@link Map} or {@literal null} if properties were not found. * @throws VaultException on problems retrieving properties */ @Nullable protected Map<String, Object> doGetProperties(String path) throws VaultException { VaultResponse vaultResponse; if (this.keyValueDelegate.isVersioned(path)) { vaultResponse = this.keyValueDelegate.getSecret(path); } else { vaultResponse = this.source.read(path); } if (vaultResponse == null || vaultResponse.getData() == null) { if (logger.isDebugEnabled()) { logger.debug(String.format("No properties found at %s", path)); } return null; } return flattenMap(vaultResponse.getData()); }
Example 3
Source File: KeyValueDelegate.java From spring-vault with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static void unwrapDataResponse(@Nullable VaultResponse response) { if (response == null || response.getData() == null || !response.getData().containsKey("data")) { return; } Map<String, Object> nested = new LinkedHashMap<>((Map) response.getRequiredData().get("data")); response.setData(nested); }
Example 4
Source File: KeyValueDelegate.java From spring-vault with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private MountInfo doGetMountInfo(String path) { VaultResponse response = this.operations.read(String.format("sys/internal/ui/mounts/%s", path)); if (response == null || response.getData() == null) { return MountInfo.unavailable(); } Map<String, Object> data = response.getData(); return MountInfo.from((String) data.get("path"), (Map) data.get("options")); }
Example 5
Source File: SecretDocument.java From spring-vault with Apache License 2.0 | 2 votes |
/** * Factory method to create a {@link SecretDocument} from an {@code id} and * {@link VaultResponse}. * @param id must not be {@literal null}. * @param vaultResponse must not be {@literal null}. * @return the {@link SecretDocument}. */ @SuppressWarnings("ConstantConditions") public static SecretDocument from(@Nullable String id, VaultResponse vaultResponse) { return new SecretDocument(id, vaultResponse.getData()); }