本文整理汇总了Java中org.springframework.vault.support.VaultMount类的典型用法代码示例。如果您正苦于以下问题:Java VaultMount类的具体用法?Java VaultMount怎么用?Java VaultMount使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VaultMount类属于org.springframework.vault.support包,在下文中一共展示了VaultMount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: set
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@JsonAnySetter
public void set(String name, Object value) {
if (!(value instanceof Map)) {
return;
}
Map<String, Object> map = (Map) value;
if (map.containsKey("type")) {
VaultMountBuilder builder = VaultMount.builder() //
.type((String) map.get("type")) //
.description((String) map.get("description"));// ;
if (map.containsKey("config")) {
builder.config((Map) map.get("config"));
}
VaultMount vaultMount = builder.build();
topLevelMounts.put(name, vaultMount);
}
}
示例2: mountShouldMountGenericSecret
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Test
public void mountShouldMountGenericSecret() {
if (adminOperations.getMounts().containsKey("other/")) {
adminOperations.unmount("other");
}
VaultMount mount = VaultMount.builder().type("generic") //
.config(Collections.singletonMap("default_lease_ttl", (Object) "1h")) //
.description("hello, world").build();
adminOperations.mount("other", mount);
Map<String, VaultMount> mounts = adminOperations.getMounts();
assertThat(mounts).containsKey("other/");
VaultMount secret = mounts.get("other/");
assertThat(secret.getDescription()).isEqualTo(mount.getDescription());
assertThat(secret.getConfig()).containsEntry("default_lease_ttl", 3600);
assertThat(Arrays.asList("kv", "generic")).contains(secret.getType());
}
示例3: authMountShouldMountGenericSecret
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Test
public void authMountShouldMountGenericSecret() {
if (adminOperations.getAuthMounts().containsKey("other/")) {
adminOperations.authUnmount("other");
}
VaultMount mount = VaultMount.builder().type("userpass")
.description("hello, world").build();
adminOperations.authMount("other", mount);
Map<String, VaultMount> mounts = adminOperations.getAuthMounts();
assertThat(mounts).containsKey("other/");
VaultMount secret = mounts.get("other/");
assertThat(secret.getDescription()).isEqualTo(mount.getDescription());
assertThat(secret.getType()).isEqualTo("userpass");
}
示例4: doTestWrapperTokenCreated
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
private void doTestWrapperTokenCreated(String authMountPath) {
final ClientHttpRequestFactory factory = createClientHttpRequestFactory();
final VaultTemplate template = new VaultTemplate(getVault().getEndpoint(), factory, () -> VaultToken.of(getVault().getToken()));
// Ensure approle auth enabled
template.opsForSys().authMount(authMountPath, VaultMount.create("approle"));
then(template.opsForSys().getAuthMounts()).containsKey(authMountPath + "/");
template.write("auth/" + authMountPath + "/role/testrole", CollectionsUtil.asMap(
"secret_id_ttl", "10m",
"token_num_uses", "10",
"token_ttl", "20m",
"token_max_ttl", "30m",
"secret_id_num_uses", "40"
));
Pair<String, String> credentials = getAppRoleCredentials(template, "auth/" + authMountPath + "/role/testrole");
final Pair<String, String> wrapped = VaultConnector.doRequestWrappedToken(new VaultFeatureSettings(getVault().getUrl(), authMountPath, credentials.getFirst(), credentials.getSecond()));
then(wrapped.getFirst()).isNotNull();
then(wrapped.getSecond()).isNotNull();
final CubbyholeAuthenticationOptions options = CubbyholeAuthenticationOptions.builder()
.wrapped()
.initialToken(VaultToken.of(wrapped.getFirst()))
.build();
final RestTemplate simpleTemplate = UtilKt.createRestTemplate(new VaultFeatureSettings(getVault().getUrl(), authMountPath, "", ""));
final CubbyholeAuthentication authentication = new CubbyholeAuthentication(options, simpleTemplate);
final TaskScheduler scheduler = new ConcurrentTaskScheduler();
final MyLifecycleAwareSessionManager sessionManager = new MyLifecycleAwareSessionManager(authentication, simpleTemplate, scheduler);
then(sessionManager.getSessionToken()).isNotNull();
sessionManager.renewToken();
then(sessionManager.getSessionToken()).isNotNull();
}
示例5: mount
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Override
public void mount(final String path, final VaultMount vaultMount) {
Assert.hasText(path, "Path must not be empty");
Assert.notNull(vaultMount, "VaultMount must not be null");
vaultOperations.write(String.format("sys/mounts/%s", path), vaultMount);
}
示例6: authMount
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Override
public void authMount(final String path, final VaultMount vaultMount)
throws VaultException {
Assert.hasText(path, "Path must not be empty");
Assert.notNull(vaultMount, "VaultMount must not be null");
vaultOperations.write(String.format("sys/auth/%s", path), vaultMount);
}
示例7: getMountsShouldContainSecretBackend
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Test
public void getMountsShouldContainSecretBackend() {
Map<String, VaultMount> mounts = adminOperations.getMounts();
assertThat(mounts).containsKey("secret/");
VaultMount secret = mounts.get("secret/");
assertThat(Arrays.asList("generic secret storage", "key/value secret storage"))
.contains(secret.getDescription());
assertThat(Arrays.asList("kv", "generic")).contains(secret.getType());
}
示例8: getAuthMountsShouldContainSecretBackend
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Test
public void getAuthMountsShouldContainSecretBackend() {
Map<String, VaultMount> mounts = adminOperations.getAuthMounts();
assertThat(mounts).containsKey("token/");
VaultMount secret = mounts.get("token/");
assertThat(secret.getDescription()).isEqualTo("token based credentials");
assertThat(secret.getType()).isEqualTo("token");
}
示例9: hasSecretBackend
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
/**
* Check whether a auth-backend is enabled.
*
* @param secretBackend
* @return
*/
public boolean hasSecretBackend(String secretBackend) {
Assert.hasText(secretBackend, "SecretBackend must not be empty");
Map<String, VaultMount> mounts = adminOperations.getMounts();
return mounts.containsKey(secretBackend)
|| mounts.containsKey(secretBackend + "/");
}
示例10: getMounts
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Override
public Map<String, VaultMount> getMounts() {
return requireResponse(vaultOperations.doWithSession(GET_MOUNTS));
}
示例11: getAuthMounts
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Override
public Map<String, VaultMount> getAuthMounts() throws VaultException {
return requireResponse(vaultOperations.doWithSession(GET_AUTH_MOUNTS));
}
示例12: doWithRestOperations
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Override
public Map<String, VaultMount> doWithRestOperations(RestOperations restOperations) {
ResponseEntity<VaultMountsResponse> exchange = restOperations.exchange(path,
HttpMethod.GET, null, MOUNT_TYPE_REF, Collections.emptyMap());
VaultMountsResponse body = exchange.getBody();
Assert.state(body != null, "Get mounts response must not be null");
if (body.getData() != null) {
return body.getData();
}
return body.getTopLevelMounts();
}
示例13: getTopLevelMounts
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@JsonIgnore
public Map<String, VaultMount> getTopLevelMounts() {
return topLevelMounts;
}
示例14: mountAuth
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
/**
* Mount an auth backend.
*
* @param authBackend
*/
public void mountAuth(String authBackend) {
Assert.hasText(authBackend, "AuthBackend must not be empty");
adminOperations.authMount(authBackend, VaultMount.create(authBackend));
}
示例15: mountSecret
import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
/**
* Mount an secret backend.
*
* @param secretBackend
*/
public void mountSecret(String secretBackend) {
Assert.hasText(secretBackend, "SecretBackend must not be empty");
adminOperations.mount(secretBackend, VaultMount.create(secretBackend));
}