use of org.wildfly.security.credential.store.CredentialStore.ProtectionParameter in project fuse-karaf by jboss-fuse.
the class CredentialStoreHelper method credentialStoreFromEnvironment.
/**
* Creates the credential store specified by the configuration in environment variables.
*
* @return the credential store
* @throws GeneralSecurityException
* @throws IOException
*/
public static CredentialStore credentialStoreFromEnvironment() throws GeneralSecurityException, IOException {
final String credentialStoreAlgorithm = Optional.ofNullable(getenv(CREDENTIAL_STORE_ALGORITHM_ENV)).orElse(Defaults.CREDENTIAL_STORE_ALGORITHM);
final Provider provider = ProviderHelper.provider(Optional.ofNullable(getenv(CREDENTIAL_STORE_PROVIDER_ENV)).orElse(ProviderHelper.WILDFLY_PROVIDER));
final CredentialStore credentialStore = CredentialStore.getInstance(credentialStoreAlgorithm, provider);
final Map<String, String> attributes = defaultCredentialStoreAttributesFor(credentialStoreAlgorithm);
attributes.putAll(attributesFromEnvironment(CREDENTIAL_STORE_ATTR_ENV_PREFIX));
final ProtectionParameter protectionParameter = createProtectionParameterFromEnvironment();
credentialStore.initialize(attributes, protectionParameter);
return credentialStore;
}
Aggregations