当前位置: 首页>>代码示例>>Java>>正文


Java VaultMount类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:26,代码来源:VaultSysTemplate.java

示例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());
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:23,代码来源:VaultSysTemplateIntegrationTests.java

示例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");
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:21,代码来源:VaultSysTemplateIntegrationTests.java

示例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();
}
 
开发者ID:JetBrains,项目名称:teamcity-hashicorp-vault-plugin,代码行数:40,代码来源:VaultConnectorTest.java

示例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);
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:9,代码来源:VaultSysTemplate.java

示例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);
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:10,代码来源:VaultSysTemplate.java

示例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());
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:13,代码来源:VaultSysTemplateIntegrationTests.java

示例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");
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:12,代码来源:VaultSysTemplateIntegrationTests.java

示例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 + "/");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-vault,代码行数:14,代码来源:PrepareVault.java

示例10: getMounts

import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Override
public Map<String, VaultMount> getMounts() {
	return requireResponse(vaultOperations.doWithSession(GET_MOUNTS));
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:5,代码来源:VaultSysTemplate.java

示例11: getAuthMounts

import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@Override
public Map<String, VaultMount> getAuthMounts() throws VaultException {
	return requireResponse(vaultOperations.doWithSession(GET_AUTH_MOUNTS));
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:5,代码来源:VaultSysTemplate.java

示例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();
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:17,代码来源:VaultSysTemplate.java

示例13: getTopLevelMounts

import org.springframework.vault.support.VaultMount; //导入依赖的package包/类
@JsonIgnore
public Map<String, VaultMount> getTopLevelMounts() {
	return topLevelMounts;
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:5,代码来源:VaultSysTemplate.java

示例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));
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:12,代码来源:PrepareVault.java

示例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));
}
 
开发者ID:spring-projects,项目名称:spring-vault,代码行数:12,代码来源:PrepareVault.java


注:本文中的org.springframework.vault.support.VaultMount类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。