Class Keyring

java.lang.Object
com.github.javakeyring.Keyring
All Implemented Interfaces:
AutoCloseable

public class Keyring extends Object implements AutoCloseable
Keyring.
  • Method Details

    • create

      public static Keyring create() throws BackendNotSupportedException
      Creates an instance of Keyring using the a default backed based on operating system.
      Returns:
      a functional Keyring or a BackendNotSupportedException is thrown.
      Throws:
      BackendNotSupportedException - if the default backend for the operating system is unsupported.
    • create

      public static Keyring create(KeyringStorageType keyring) throws BackendNotSupportedException
      Creates an instance of Keyring with specified backend.
      Parameters:
      keyring - desired backend.
      Returns:
      a functional Keyring or a BackendNotSupportedException is thrown.
      Throws:
      BackendNotSupportedException - if the default backend for the operating system is unsupported.
    • getKeyringStorageType

      public KeyringStorageType getKeyringStorageType()
    • getPassword

      public String getPassword(String service, String account) throws PasswordAccessException
      Gets password from key store (Proxy method of KeyringBackend.getPassword).
      Parameters:
      service - Service name
      account - Account name
      Returns:
      Password related to specified service and account
      Throws:
      PasswordAccessException - Thrown when an error happened while getting password
    • setPassword

      public void setPassword(String service, String account, String password) throws PasswordAccessException
      Sets password to key store (Proxy method of KeyringBackend.setPassword)
      Parameters:
      service - Service name
      account - Account name
      password - Password
      Throws:
      PasswordAccessException - Thrown when an error happened while saving the password
    • deletePassword

      public void deletePassword(String service, String account) throws PasswordAccessException
      Sets password to key store (Proxy method of KeyringBackend.setPassword)
      Parameters:
      service - Service name
      account - Account name
      Throws:
      PasswordAccessException - Thrown when an error happened while saving the password
    • close

      public void close() throws Exception
      Closes resources used by the backend.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception - Thrown if the backend can not be closed