aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/service/credentialsstorage
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2010-07-12 14:59:01 +0000
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2010-07-12 14:59:01 +0000
commit04cac3354cde9cbbf72cd91cef559a02d0143b20 (patch)
tree1febf0158fee5ec0cf7db649599d2cc8456c9519 /src/net/java/sip/communicator/service/credentialsstorage
parenta16201daf3842b3abae0f876a6f43429fbee145c (diff)
downloadjitsi-04cac3354cde9cbbf72cd91cef559a02d0143b20.zip
jitsi-04cac3354cde9cbbf72cd91cef559a02d0143b20.tar.gz
jitsi-04cac3354cde9cbbf72cd91cef559a02d0143b20.tar.bz2
Merges branches/gsoc10/passwdstrg@7435 which represents the work of Dmitri Melnikov on the "Password storage" GSoC 2010 project into trunk.
Diffstat (limited to 'src/net/java/sip/communicator/service/credentialsstorage')
-rw-r--r--src/net/java/sip/communicator/service/credentialsstorage/CredentialsStorageService.java71
-rw-r--r--src/net/java/sip/communicator/service/credentialsstorage/CryptoException.java51
2 files changed, 122 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/service/credentialsstorage/CredentialsStorageService.java b/src/net/java/sip/communicator/service/credentialsstorage/CredentialsStorageService.java
new file mode 100644
index 0000000..abc5712
--- /dev/null
+++ b/src/net/java/sip/communicator/service/credentialsstorage/CredentialsStorageService.java
@@ -0,0 +1,71 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.credentialsstorage;
+
+/**
+ * Loads and saves user credentials from/to the persistent storage
+ * (configuration file in the default implementation).
+ *
+ * @author Dmitri Melnikov
+ */
+public interface CredentialsStorageService
+{
+ /**
+ * Store the password for the account that starts with the given prefix.
+ *
+ * @param accountPrefix
+ * @param password
+ */
+ public void storePassword(String accountPrefix, String password);
+
+ /**
+ * Load the password for the account that starts with the given prefix.
+ *
+ * @param accountPrefix
+ * @return
+ */
+ public String loadPassword(String accountPrefix);
+
+ /**
+ * Remove the password for the account that starts with the given prefix.
+ *
+ * @param accountPrefix
+ */
+ public void removePassword(String accountPrefix);
+
+ /**
+ * Checks if master password was set by the user and
+ * it is used to encrypt saved account passwords.
+ *
+ * @return true if used, false if not
+ */
+ public boolean isUsingMasterPassword();
+
+ /**
+ * Changes the old master password to the new one.
+ * For all saved account passwords it decrypts them with the old MP and then
+ * encrypts them with the new MP.
+ * @param oldPassword
+ * @param newPassword
+ * @return true if MP was changed successfully, false otherwise
+ */
+ public boolean changeMasterPassword(String oldPassword, String newPassword);
+
+ /**
+ * Verifies the correctness of the master password.
+ * @param master
+ * @return true if the password is correct, false otherwise
+ */
+ public boolean verifyMasterPassword(String master);
+
+ /**
+ * Checks if the account password that starts with the given prefix is saved in encrypted form.
+ *
+ * @return true if saved, false if not
+ */
+ public boolean isStoredEncrypted(String accountPrefix);
+}
diff --git a/src/net/java/sip/communicator/service/credentialsstorage/CryptoException.java b/src/net/java/sip/communicator/service/credentialsstorage/CryptoException.java
new file mode 100644
index 0000000..b8923f1
--- /dev/null
+++ b/src/net/java/sip/communicator/service/credentialsstorage/CryptoException.java
@@ -0,0 +1,51 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.credentialsstorage;
+
+/**
+ * Exception thrown by the Crypto encrypt/decrypt interface methods.
+ *
+ * @author Dmitri Melnikov
+ */
+public class CryptoException
+ extends Exception
+{
+ private static final long serialVersionUID = -5424208764356198091L;
+
+ /**
+ * Set when encryption fails.
+ */
+ public static final int ENCRYPTION_ERROR = 1;
+
+ /**
+ * Set when decryption fails.
+ */
+ public static final int DECRYPTION_ERROR = 2;
+
+ /**
+ * Set when a decryption fail is caused by the wrong key.
+ */
+ public static final int WRONG_KEY = 3;
+
+ /**
+ * The error code of this exception.
+ */
+ private final int errorCode;
+
+ public CryptoException(int code, Exception ex) {
+ super(ex);
+ this.errorCode = code;
+ }
+
+ /**
+ * @return the error code for the exception.
+ */
+ public int getErrorCode()
+ {
+ return errorCode;
+ }
+}