Package com.github.javakeyring
Class Keyring
java.lang.Object
com.github.javakeyring.Keyring
- All Implemented Interfaces:
AutoCloseable
Keyring.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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)getPassword(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 Details
-
create
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
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
-
getPassword
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
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
Closes resources used by the backend.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception- Thrown if the backend can not be closed
-