Package com.github.javakeyring
Class Keyring
- java.lang.Object
-
- com.github.javakeyring.Keyring
-
- All Implemented Interfaces:
AutoCloseable
public class Keyring extends Object implements AutoCloseable
Keyring.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes resources used by the backend.static Keyringcreate()Creates an instance of Keyring using the a default backed based on operating system.static Keyringcreate(KeyringStorageType keyring)Creates an instance of Keyring with specified backend.voiddeletePassword(String service, String account)Sets password to key store (Proxy method of KeyringBackend.setPassword)KeyringStorageTypegetKeyringStorageType()StringgetPassword(String service, String account)Gets password from key store (Proxy method of KeyringBackend.getPassword).voidsetPassword(String service, String account, String password)Sets password to key store (Proxy method of KeyringBackend.setPassword)
-
-
-
Method Detail
-
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 nameaccount- 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 nameaccount- Account namepassword- 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 nameaccount- Account name- Throws:
PasswordAccessException- Thrown when an error happened while saving the password
-
close
public void close() throws ExceptionCloses resources used by the backend.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- Thrown if the backend can not be closed
-
-