/** * Store credential to the store under the given alias. If given alias already contains specific credential type type the credential * replaces older one. <em>Note:</em> {@link CredentialStoreSpi} supports storing of multiple entries (credential types) per alias. * Each must be of different credential type. * @param credentialAlias to store the credential to the store * @param credential instance of {@link Credential} to store * @param <C> the class of type to which should be credential casted * @throws CredentialStoreException when the credential cannot be stored * @throws UnsupportedCredentialTypeException when the credentialType is not supported */ public <C extends Credential> void store(String credentialAlias, C credential) throws CredentialStoreException, UnsupportedCredentialTypeException { store(credentialAlias, credential, null); }
/** * Store credential to the store under the given alias. If given alias already contains specific credential type type the credential * replaces older one. <em>Note:</em> {@link CredentialStoreSpi} supports storing of multiple entries (credential types) per alias. * Each must be of different credential type. * @param credentialAlias to store the credential to the store * @param credential instance of {@link Credential} to store * @param <C> the class of type to which should be credential casted * @throws CredentialStoreException when the credential cannot be stored * @throws UnsupportedCredentialTypeException when the credentialType is not supported */ public <C extends Credential> void store(String credentialAlias, C credential) throws CredentialStoreException, UnsupportedCredentialTypeException { store(credentialAlias, credential, null); }
/** * Store credential to the store under the given alias. If given alias already contains specific credential type type the credential * replaces older one. <em>Note:</em> {@link CredentialStoreSpi} supports storing of multiple entries (credential types) per alias. * Each must be of different credential type. * @param credentialAlias to store the credential to the store * @param credential instance of {@link Credential} to store * @param <C> the class of type to which should be credential casted * @throws CredentialStoreException when the credential cannot be stored * @throws UnsupportedCredentialTypeException when the credentialType is not supported */ public <C extends Credential> void store(String credentialAlias, C credential) throws CredentialStoreException, UnsupportedCredentialTypeException { store(credentialAlias, credential, null); }
/** * Store credential to the store under the given alias. If given alias already contains specific credential type type the credential * replaces older one. <em>Note:</em> {@link CredentialStoreSpi} supports storing of multiple entries (credential types) per alias. * Each must be of different credential type. * @param credentialAlias to store the credential to the store * @param credential instance of {@link Credential} to store * @param <C> the class of type to which should be credential casted * @throws CredentialStoreException when the credential cannot be stored * @throws UnsupportedCredentialTypeException when the credentialType is not supported */ public <C extends Credential> void store(String credentialAlias, C credential) throws CredentialStoreException, UnsupportedCredentialTypeException { store(credentialAlias, credential, null); }
private static void storeSecret(CredentialStore credentialStore, String alias, String secretValue) throws CredentialStoreException { char[] secret = secretValue != null ? secretValue.toCharArray() : new char[0]; credentialStore.store(alias, createCredentialFromPassword(secret)); try { credentialStore.flush(); } catch (CredentialStoreException e) { // operation fails, remove the entry from the store, to avoid an inconsistency between // the store on the FS and in the memory credentialStore.remove(alias, PasswordCredential.class); throw e; } }
credentialStore.store(alias, retrieved); throw e;