/** * Check whether credential store has an entry associated with the given credential alias of specified credential type. * @param credentialAlias alias to check existence * @param credentialType to check existence in the credential store * @param <C> the class of type to which should be credential casted * @return true in case key exist in store * @throws CredentialStoreException when there is a problem with credential store * @throws UnsupportedCredentialTypeException when the credentialType is not supported */ public <C extends Credential> boolean exists(String credentialAlias, Class<C> credentialType) throws CredentialStoreException, UnsupportedCredentialTypeException { return spi.exists(credentialAlias, credentialType); }
/** * Initialize Credential Store service with given attributes. * This procedure should set {@link CredentialStoreSpi#initialized} after successful initialization. * * @param attributes attributes to used to pass information to Credential Store service * @param protectionParameter the protection parameter to use when accessing the store * @throws CredentialStoreException if initialization fails due to any reason */ public void initialize(Map<String, String> attributes, ProtectionParameter protectionParameter) throws CredentialStoreException { initialize(attributes, protectionParameter, null); }
/** * Get a {@code CredentialStore} instance. The returned CredentialStore object will implement the given algorithm. * * @param algorithm the name of the algorithm * @return a {@code CredentialStore} instance * @throws NoSuchAlgorithmException if the given algorithm has no available implementations */ public static CredentialStore getInstance(String algorithm) throws NoSuchAlgorithmException { return getInstance(algorithm, INSTALLED_PROVIDERS); }
/** * Retrieve credential stored in the store under the key and of the credential type * @param credentialAlias to find the credential in the store * @param credentialType - credential type to retrieve from under the credentialAlias from the store * @param <C> the class of type to which should be credential casted * @return instance of {@link Credential} stored in the store * @throws CredentialStoreException - if credentialAlias credentialType combination doesn't exist or credentialAlias cannot be retrieved * @throws UnsupportedCredentialTypeException when the credentialType is not supported */ public <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType) throws CredentialStoreException, UnsupportedCredentialTypeException { return retrieve(credentialAlias, credentialType, null, null, null); }
/** * Flush the contents of this credential store to storage. This method may be a no-op on credential stores * without backing storage or which do not buffer changes. * * @throws CredentialStoreException if flushing the store fails for some reason */ public void flush() throws CredentialStoreException { if (isModifiable()) { spi.flush(); } else { throw log.nonModifiableCredentialStore("flush"); } }
/** * Remove the credentialType with from given alias matching the given criteria from the store. * * @param credentialAlias alias to remove credential(s) from * @param credentialType credential type to match (must not be {@code null}) * @param credentialAlgorithm the algorithm name to match, or {@code null} to match any * @param parameterSpec the parameters to match, or {@code null} to match any * @throws CredentialStoreException if credential removal fails */ public void remove(String credentialAlias, Class<? extends Credential> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec) throws CredentialStoreException { if (isModifiable()) { spi.remove(credentialAlias, credentialType, credentialAlgorithm, parameterSpec); } else { throw log.nonModifiableCredentialStore("remove"); } }
/** * Remove the credentialType with from given alias matching the given criteria from the store. * * @param credentialAlias alias to remove credential(s) from * @param credentialType credential type to match (must not be {@code null}) * @param credentialAlgorithm the algorithm name to match, or {@code null} to match any * @throws CredentialStoreException if credential removal fails */ public void remove(String credentialAlias, Class<? extends Credential> credentialType, String credentialAlgorithm) throws CredentialStoreException { remove(credentialAlias, credentialType, credentialAlgorithm, 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); }
/** * Check whether credential store service has an entry associated with the given credential alias of specified * credential type. The default implementation simply attempts to retrieve the credential without a protection * parameter, and returns {@code true} if any credential was returned. Credential stores which use a protection * parameter should override this method. * * @param credentialAlias key to check existence * @param credentialType to class of credential to look for * @return {@code true} in case key exist in store otherwise {@code false} * @throws CredentialStoreException when there is a problem with credential store */ public boolean exists(String credentialAlias, Class<? extends Credential> credentialType) throws CredentialStoreException { return retrieve(credentialAlias, credentialType, null, null, null) != null; }
/** * Creates new {@code CredentialStorePermission} * @param name of new {@code CredentialStorePermission} * @param actions have to be {@code null} */ public CredentialStorePermission(final String name, final String actions) { this(name); requireEmptyActions(actions); }
/** * Checks whether underlying credential store is initialized. * @return {@code true} in case of initialization passed successfully, {@code false} otherwise. */ public boolean isInitialized() { return spi.isInitialized(); }
/** * Check if credential store supports modification of actual store * @return true in case of modification of store is supported */ public boolean isModifiable() { return spi.isModifiable(); }
/** * Initialize Credential Store service with given attributes. * This procedure should set {@link CredentialStoreSpi#initialized} after successful initialization. * * @param attributes attributes to used to pass information to Credential Store service * @param protectionParameter the protection parameter to use when accessing the store * @param providers providers to be injected into SPI implementation to get custom object instances of various type from * @throws CredentialStoreException if initialization fails due to any reason */ public void initialize(Map<String, String> attributes, ProtectionParameter protectionParameter, Provider[] providers) throws CredentialStoreException { spi.initialize(attributes, protectionParameter, providers); }
/** * Returns {@code Set<String>} stored in this store. * * @return {@code Set<String>} of all keys stored in this store * @throws UnsupportedOperationException when this method is not supported by the underlying credential store * @throws CredentialStoreException if there is any problem with internal store */ public Set<String> getAliases() throws UnsupportedOperationException, CredentialStoreException { return spi.getAliases(); }
public CredentialStorePermission withName(final String name) { return forName(name); }
/** * Retrieve credential stored in the store under the key and of the credential type. * * @param credentialAlias to find the credential in the store * @param credentialType credential type to retrieve from under the credentialAlias from the store * @param credentialAlgorithm the credential algorithm to match, or {@code null} to match any * @param <C> the class of type to which should be credential casted * @return instance of {@link Credential} stored in the store * @throws CredentialStoreException if credentialAlias credentialType combination doesn't exist or credentialAlias cannot be retrieved */ public <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm) throws CredentialStoreException { return retrieve(credentialAlias, credentialType, credentialAlgorithm, null, null); }
/** * Initialize Credential Store service with given attributes. * This procedure should set {@link CredentialStoreSpi#initialized} after successful initialization. * * @param attributes attributes to used to pass information to Credential Store service * @throws CredentialStoreException if initialization fails due to any reason */ public void initialize(Map<String, String> attributes) throws CredentialStoreException { initialize(attributes, null); }
/** * Remove the credentialType with from given alias matching the given criteria from the store. * * @param credentialAlias alias to remove credential(s) from * @param credentialType credential type to match (must not be {@code null}) * @throws CredentialStoreException if credential removal fails */ public void remove(String credentialAlias, Class<? extends Credential> credentialType) throws CredentialStoreException { remove(credentialAlias, credentialType, null, null); }
/** * Retrieve credential stored in the store under the key and of the credential type. * * @param credentialAlias to find the credential in the store * @param credentialType credential type to retrieve from under the credentialAlias from the store * @param credentialAlgorithm the credential algorithm to match, or {@code null} to match any * @param parameterSpec the parameter specification to match, or {@code null} to match any * @param protectionParameter the protection parameter to use, or {@code null} to use none * @param <C> the class of type to which should be credential casted * @return instance of {@link Credential} stored in the store * @throws CredentialStoreException if credentialAlias credentialType combination doesn't exist or credentialAlias cannot be retrieved */ public <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec, ProtectionParameter protectionParameter) throws CredentialStoreException { return spi.retrieve(credentialAlias, credentialType, credentialAlgorithm, parameterSpec, protectionParameter); }
/** * Retrieve credential stored in the store under the key and of the credential type. * * @param credentialAlias to find the credential in the store * @param credentialType credential type to retrieve from under the credentialAlias from the store * @param credentialAlgorithm the credential algorithm to match, or {@code null} to match any * @param parameterSpec the parameter specification to match, or {@code null} to match any * @param <C> the class of type to which should be credential casted * @return instance of {@link Credential} stored in the store * @throws CredentialStoreException if credentialAlias credentialType combination doesn't exist or credentialAlias cannot be retrieved */ public <C extends Credential> C retrieve(String credentialAlias, Class<C> credentialType, String credentialAlgorithm, AlgorithmParameterSpec parameterSpec) throws CredentialStoreException { return retrieve(credentialAlias, credentialType, credentialAlgorithm, parameterSpec, null); }