List of usage examples for org.springframework.http ResponseEntity toString
@Override
public String toString()
From source file:org.springframework.cloud.vault.util.PrepareVault.java
/** * Mount an secret backend./*from w w w.jav a 2s .co m*/ * * @param secretBackend */ public void mountSecret(String secretBackend) { Assert.hasText(secretBackend, "SecretBackend must not be empty"); Map<String, String> parameters = parameters(vaultProperties); parameters.put("type", secretBackend); Map<String, String> requestEntity = Collections.singletonMap("type", secretBackend); HttpEntity<Map<String, String>> entity = new HttpEntity<>(requestEntity, authenticatedHeaders()); ResponseEntity<String> responseEntity = restTemplate.exchange(MOUNT_SECRET_URL_TEMPLATE, HttpMethod.POST, entity, String.class, parameters); if (!responseEntity.getStatusCode().is2xxSuccessful()) { throw new IllegalStateException("Cannot create mount secret backend: " + responseEntity.toString()); } responseEntity.getBody(); }
From source file:org.springframework.cloud.vault.util.PrepareVault.java
private boolean hasMount(String urlTemplate, String type) { Map<String, String> parameters = parameters(vaultProperties); HttpEntity<Map<String, String>> entity = new HttpEntity<>(authenticatedHeaders()); ResponseEntity<Map<String, Object>> responseEntity = restTemplate.exchange(urlTemplate, HttpMethod.GET, entity, MAP_OF_MAPS_TYPE, parameters); if (!responseEntity.getStatusCode().is2xxSuccessful()) { throw new IllegalStateException("Cannot enumerate mounts: " + responseEntity.toString()); }//from ww w. j a v a2 s .c o m Map<String, Object> body = responseEntity.getBody(); for (Entry<String, Object> entry : body.entrySet()) { if (entry.getValue() instanceof Map) { Map<String, Object> nested = (Map<String, Object>) entry.getValue(); if (entry.getKey().contains(type) && type.equals(nested.get("type"))) { return true; } } } return false; }