public class KeyChain extends Object
To contstruct a KeyChain, you need to pass in an InputStream to the store and it will initialize the KeyStore from the InputStream. You can add and remove entries any time once you have an instance of KeyChain. To persist the KeyChain and reflect any changes, you need to call store method with an OutputStream.
Modifier and Type | Field and Description |
---|---|
private static Logger |
LOG |
private char[] |
masterPassword |
private KeyStore |
store |
Constructor and Description |
---|
KeyChain(char[] masterPassword,
InputStream inputStream)
Creates an instance of KeyChain and initializes the store
from the InputStream.
|
Modifier and Type | Method and Description |
---|---|
void |
addPassword(String user,
String server,
char[] password)
Adds a password to the KeyChain for a given account/user and server.
|
String |
getPassword(String user,
String server)
Fetches the password for a given account/user and server.
|
static void |
main(String[] args) |
void |
removePassword(String user,
String server)
Removes a password for a given account/user and server.
|
void |
store(OutputStream ostream)
Persists the KeyChain to an OutputStream
|
private char[] masterPassword
public KeyChain(char[] masterPassword, InputStream inputStream) throws IOException
masterPassword
- inputStream
- IOException
public String getPassword(String user, String server)
user
- server
- null
if no password could be obtained, the password
otherwisepublic void addPassword(String user, String server, char[] password)
user
- server
- password
- public void removePassword(String user, String server)
user
- server
- public void store(OutputStream ostream) throws IOException
ostream
- IOException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses