SMSLib 3.5.3

org.smslib.crypto
Class KeyManager

java.lang.Object
  extended by org.smslib.crypto.KeyManager

public class KeyManager
extends java.lang.Object

The KeyManager class handles the association of a number (originator or recipient) with a cryptographic key.


Method Summary
 byte[] decrypt(java.lang.String mobileNumber, byte[] message)
          Decrypts the specified message with the encryption key already associated with the specified mobile number.
 byte[] encrypt(java.lang.String mobileNumber, byte[] message)
          Encrypts the specified message with the encryption key already associated with the specified mobile number.
static KeyManager getInstance()
           
 AKey getKey(java.lang.String mobileNumber)
          Returns the encryption key of the specified mobile number.
 void registerKey(java.lang.String mobileNumber, AKey key)
          Associates a mobile number with an encryption key.
 void unregisterAllKeys()
          Removes all associations of mobile numbers and encryption keys.
 AKey unregisterKey(java.lang.String mobileNumber)
          Removes the association of a mobile number with a key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static KeyManager getInstance()

registerKey

public void registerKey(java.lang.String mobileNumber,
                        AKey key)
Associates a mobile number with an encryption key.

Parameters:
mobileNumber - The mobile number which will be associated with the encryption key.
key - The encryption key.
See Also:
AKey, registerKey(String, AKey), unregisterAllKeys()

unregisterKey

public AKey unregisterKey(java.lang.String mobileNumber)
Removes the association of a mobile number with a key.

Parameters:
mobileNumber - The mobile number which will be removed from the key associations.
Returns:
The encryption key which was associated with the specific mobile number.
See Also:
AKey, registerKey(String, AKey)

unregisterAllKeys

public void unregisterAllKeys()
Removes all associations of mobile numbers and encryption keys.


getKey

public AKey getKey(java.lang.String mobileNumber)
Returns the encryption key of the specified mobile number. Returns null if there is no association.

Parameters:
mobileNumber - The mobile number to look for.
Returns:
The encryption key, null if no key was previously associated.

encrypt

public byte[] encrypt(java.lang.String mobileNumber,
                      byte[] message)
               throws SMSLibException,
                      java.security.InvalidKeyException,
                      javax.crypto.IllegalBlockSizeException,
                      javax.crypto.BadPaddingException,
                      javax.crypto.NoSuchPaddingException,
                      java.security.NoSuchAlgorithmException
Encrypts the specified message with the encryption key already associated with the specified mobile number.

Parameters:
mobileNumber - The mobile number which the message will be send to / received from.
message - The decrypted message.
Returns:
The encrypted message.
Throws:
SMSLibException
java.security.InvalidKeyException
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException
javax.crypto.NoSuchPaddingException
java.security.NoSuchAlgorithmException

decrypt

public byte[] decrypt(java.lang.String mobileNumber,
                      byte[] message)
               throws SMSLibException,
                      java.security.InvalidKeyException,
                      javax.crypto.IllegalBlockSizeException,
                      javax.crypto.BadPaddingException,
                      javax.crypto.NoSuchPaddingException,
                      java.security.NoSuchAlgorithmException
Decrypts the specified message with the encryption key already associated with the specified mobile number.

Parameters:
mobileNumber - The mobile number which the message received from.
message - The encrypted message.
Returns:
The decrypted message.
Throws:
SMSLibException
java.security.InvalidKeyException
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException
javax.crypto.NoSuchPaddingException
java.security.NoSuchAlgorithmException

SMSLib 3.5.3

(c) 2002-2011, http://smslib.org