public class KeyDB extends ObjectDB
Constructor and Description |
---|
KeyDB(DatabaseConnection databaseConnection)
Class constructor that stores the given database connection for later use.
|
Modifier and Type | Method and Description |
---|---|
void |
deletePublicData(User updatedUser)
Delete the user's public data (RSA public key, encrypted AES key, salt) from the key table
|
private byte[] |
getBytes(java.lang.String userName,
java.lang.String columnName)
Fetches the bytes in the given column of the Key table for the given user
|
byte[] |
getEncryptedAESKey(java.lang.String userName)
Return user's encrypted AES key
|
java.security.PublicKey |
getPublicKey(java.lang.String userName)
Return user's RSA public key
|
byte[] |
getSalt(java.lang.String userName)
Return the user's salt.
|
void |
storePublicData(java.lang.String username,
java.security.PublicKey publicKey,
byte[] encryptedAESKey,
byte[] salt)
Store user's public data (RSA public key, encrypted AES key and salt) in the key table
|
emptyAllTables, getDatabaseConnection
public KeyDB(DatabaseConnection databaseConnection)
databaseConnection
- public byte[] getSalt(java.lang.String userName) throws NoSuchKeysFoundForUserException, DatabaseException
userName
- NoSuchKeysFoundForUserException
DatabaseException
public byte[] getEncryptedAESKey(java.lang.String userName) throws DatabaseException, NoSuchKeysFoundForUserException
userName
- DatabaseException
NoSuchKeysFoundForUserException
public java.security.PublicKey getPublicKey(java.lang.String userName) throws DatabaseException, NoSuchKeysFoundForUserException
userName
- DatabaseException
NoSuchKeysFoundForUserException
private byte[] getBytes(java.lang.String userName, java.lang.String columnName) throws DatabaseException, NoSuchKeysFoundForUserException
userName
- columnName
- DatabaseException
NoSuchKeysFoundForUserException
public void storePublicData(java.lang.String username, java.security.PublicKey publicKey, byte[] encryptedAESKey, byte[] salt) throws UserAlreadyHasKeysException
username
- publicKey
- encryptedAESKey
- salt
- UserAlreadyHasKeysException
public void deletePublicData(User updatedUser) throws NoSuchKeysFoundForUserException
updatedUser
- NoSuchKeysFoundForUserException