Class JCEKSPasswordAliasStore

  • All Implemented Interfaces:
    PasswordAliasStore
    Direct Known Subclasses:
    JCEKSDomainPasswordAliasStore

    public class JCEKSPasswordAliasStore
    extends Object
    implements PasswordAliasStore
    Provides the PasswordAliasStore behavior using a JCEKS keystore.

    The keystore is actually managed by the PasswordAdapter, to which this implementation currently delegates its work.

    Note that this service is currently per-lookup. This is so that each use of the alias store gets the current on-disk information. Ideally we can change this when we can use Java 7 features, including the WatchService feature.

    This class's methods are not synchronized because the PasswordAdapter's methods are. If this implementation changes so that it no longer delegates to those synchronized PasswordAdapter methods, then make sure that the implementation is thread-safe.

    Note that the domain-scoped password alias store service class extends this class. As a service, that class will be instantiated using the no-args constructor. So the actual initialization of the class occurs in the init method. The domain-scoped service class invokes the init method itself. Any code that needs to create some other alias store can use the newInstance method to provide the location of the alias store file and the password.

    Author:
    tjquinn
    • Constructor Detail

      • JCEKSPasswordAliasStore

        public JCEKSPasswordAliasStore()
    • Method Detail

      • init

        protected final void init​(String pathToAliasStore,
                                  char[] storePassword)
      • put

        public void put​(String alias,
                        char[] password)
        Description copied from interface: PasswordAliasStore
        Insert a new alias with the specified password, or assigns a new password to an existing alias.
        Specified by:
        put in interface PasswordAliasStore
        Parameters:
        alias - the alias to create or reassign
        password - the password to be associated with the alias
      • putAll

        public void putAll​(PasswordAliasStore otherStore)
        Description copied from interface: PasswordAliasStore
        Adds all alias/password pairs from the specified store to this store.
        Specified by:
        putAll in interface PasswordAliasStore
        Parameters:
        otherStore - the alias store from which to get entries
      • remove

        public void remove​(String alias)
        Description copied from interface: PasswordAliasStore
        Removes the specified alias (and the associated password) from the password alias store.
        Specified by:
        remove in interface PasswordAliasStore
        Parameters:
        alias - the alias to be removed
      • containsKey

        public boolean containsKey​(String alias)
        Description copied from interface: PasswordAliasStore
        Reports whether the store contains the specified alias.
        Specified by:
        containsKey in interface PasswordAliasStore
        Parameters:
        alias - the alias to check for
        Returns:
        true if the alias appears in the store; false otherwise
      • get

        public char[] get​(String alias)
        Description copied from interface: PasswordAliasStore
        Returns the password associated with the specified alias.
        Specified by:
        get in interface PasswordAliasStore
        Parameters:
        alias - the alias of interest
        Returns:
        the password for that alias, if the store contains the alias; null otherwise