|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.crypto.keystore.KeyStorePasswordManager
public final class KeyStorePasswordManager
Provides all of the keystore password functionality for the keystore.
This includes functionality of remembering how many attempts at the password, forcing the user to enter the password, remembering the password for a timeout period and other important functions. You should only use the key store password class when trying to determine if someone knows the key store password.
Method Summary | ||
---|---|---|
|
void |
challenge()
Displays the password dialog and prompts the user to enter a correct password. |
|
void |
challenge(String additionalPrompt)
Displays a custom password dialog and prompts the user to enter a correct password. |
|
void |
changePassword()
This function is called to change the KeyStore password on the device. |
|
boolean |
checkTicket(KeyStorePasswordTicket ticket)
Checks to make sure that the ticket is valid and that it is of the appropriate type. |
|
boolean |
clean()
This method is called when the user wants to clean out the keystore information requiring the entry of the password the next time they try to access anything in the keystore. |
|
byte[] |
decrypt(byte[] input,
int offset,
int length,
String label,
KeyStorePasswordTicket ticket)
Returns the byte array that is decrypted with the password. |
|
byte[] |
decrypt(byte[] input,
String label,
KeyStorePasswordTicket ticket)
Returns the byte array that is decrypted with the password. |
|
byte[] |
decrypt(int securityLevel,
long salt,
byte[] input,
int offset,
int length,
String label,
KeyStorePasswordTicket ticket)
Deprecated. Use the other decrypt method that does not take in a salt or security level. |
|
byte[] |
decrypt(int securityLevel,
long salt,
byte[] input,
String label,
KeyStorePasswordTicket ticket)
Deprecated. Use the decrypt method that does not take in the security level and salt. These parameters are encoded in the input byte[] now automatically and are not needed as parameters. |
|
byte[] |
decryptReEncrypt(int securityLevel,
byte[] ciphertext)
During a change password operation this helper function allows an easy way to change the encryption of an object from the old password to the new password. |
|
byte[] |
decryptReEncrypt(int securityLevel,
long salt,
byte[] ciphertext)
Deprecated. Use the decryptReEncrypt method that no longer requires a securityLevel and a salt. |
|
byte[] |
encrypt(int securityLevel,
byte[] input,
int offset,
int length,
String label,
KeyStorePasswordTicket ticket)
Returns the byte array that is encrypted with the password. |
|
byte[] |
encrypt(int securityLevel,
byte[] input,
String label,
KeyStorePasswordTicket ticket)
Returns the byte array that is encrypted with the password. |
|
byte[] |
encrypt(int securityLevel,
long salt,
byte[] input,
int offset,
int length,
String label,
KeyStorePasswordTicket ticket)
Deprecated. Use the encrypt method that no longer uses the salt. |
|
byte[] |
encrypt(int securityLevel,
long salt,
byte[] input,
String label,
KeyStorePasswordTicket ticket)
Deprecated. Use the encrypt method that does not take a salt. |
|
static KeyStorePasswordManager |
getInstance()
Returns an instance of the KeyStorePasswordManager. |
|
KeyStorePasswordTicket |
getTicket()
Returns a ticket if the operation to retrieve one was successful. |
|
KeyStorePasswordTicket |
getTicket(String additionalPrompt)
Returns a ticket if the operation to retrieve one was successful. |
|
KeyStorePasswordTicket |
getTicket(String additionalPrompt,
KeyStore keyStore)
Returns a ticket if the operation to retrieve one was successful. |
|
KeyStorePasswordTicket |
getTicket(String additionalPrompt,
KeyStoreData keyStoreData)
Returns a ticket if the operation to retrieve one was successful. |
|
KeyStorePasswordTicket |
getTicket(KeyStore keyStore)
Returns a ticket if the operation to retrieve one was successful. |
|
KeyStorePasswordTicket |
getTicket(KeyStoreData keyStoreData)
Returns a ticket if the operation to retrieve one was successful. |
|
byte[] |
setPassword()
Sets the password by prompting the user for it and then asking for its confirmation. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static KeyStorePasswordManager getInstance()
public void challenge() throws KeyStoreCancelException
KeyStoreCancelException
- Thrown if the user fails to enter a
valid password or cancels out of the password dialog.public void challenge(String additionalPrompt) throws KeyStoreCancelException
label
- The text label for the password dialog.
KeyStoreCancelException
- Thrown if the user fails to enter a
valid password or cancels out of the password dialog.public byte[] encrypt(int securityLevel, long salt, byte[] input, String label, KeyStorePasswordTicket ticket) throws KeyStoreCancelException
securityLevel
- The security level.salt
- The salt that is used to encrypt the password. This should be random.input
- The input byte array that is to be encrypted.label
- a label that will be shown to the user when they are prompted to encrypt their data.ticket
- A ticket denoting whether or not the developer has access to the keystore. A ticket can be retrieved
from the getTicket method in the key store or keystore data. The ticket can also be null which will most likely
prompt for a password from the user automatically (calls
getTicket
).
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public byte[] encrypt(int securityLevel, byte[] input, String label, KeyStorePasswordTicket ticket) throws KeyStoreCancelException
securityLevel
- The security level.salt
- The salt that is used to encrypt the password. This should be random.
Use the SALT_LENGTH parameter to determine how long the salt should be.input
- The input byte array that is to be encrypted.label
- a label that will be shown to the user when they are prompted to encrypt their data.ticket
- A ticket denoting whether or not the developer has access to the keystore. A ticket can be retrieved
from the getTicket method in the key store or keystore data. The ticket can also be null which will most likely
prompt for a password from the user automatically (calls
getTicket
).
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public byte[] encrypt(int securityLevel, long salt, byte[] input, int offset, int length, String label, KeyStorePasswordTicket ticket) throws KeyStoreCancelException
securityLevel
- The security level.salt
- The salt that is used to encrypt the password. This should be random.input
- The input byte array that is to be encrypted.offset
- The offset into the byte array to be encrypted.length
- The number of bytes to be encrypted.label
- a label that will be shown to the user during the prompt for their passphrase if necessary.ticket
- A ticket denoting whether or not the developer has access to the keystore. A ticket can be retrieved
from the getTicket method in the key store or keystore data. The ticket can also be null which will most likely
prompt for a password from the user automatically (essentially calls getTicket for you).
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public byte[] encrypt(int securityLevel, byte[] input, int offset, int length, String label, KeyStorePasswordTicket ticket) throws KeyStoreCancelException
securityLevel
- The security level.salt
- The salt that is used to encrypt the password. This should be random.
Use the SALT_LENGTH parameter to determine how long the salt should be.input
- The input byte array that is to be encrypted.offset
- The offset into the byte array to be encrypted.length
- The number of bytes to be encrypted.label
- a label that will be shown to the user during the prompt for their passphrase if necessary.ticket
- A ticket denoting whether or not the developer has access to the keystore. A ticket can be retrieved
from the getTicket method in the key store or keystore data. The ticket can also be null which will most likely
prompt for a password from the user automatically (essentially calls getTicket for you).
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public byte[] decrypt(int securityLevel, long salt, byte[] input, String label, KeyStorePasswordTicket ticket) throws KeyStoreCancelException, KeyStoreDecodeException
securityLevel
- The security level.salt
- The salt that is used to encrypt the password. This should be random.input
- The input byte array that is to be encrypted.label
- a string that will be shown to the user on a prompt for passphrase if necessary.ticket
- A ticket denoting whether or not the developer has access to the keystore. A ticket can be retrieved
from the getTicket method in the key store or keystore data. The ticket can also be null which will most likely
prompt for a password from the user automatically (essentially calls
getTicket for you).
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.
KeyStoreDecodeException
- if the keystore was unable to decrypt the
ciphertext given that the security level was incorrect or the password was somehow
incorrect.public byte[] decrypt(byte[] input, String label, KeyStorePasswordTicket ticket) throws KeyStoreCancelException, KeyStoreDecodeException
input
- The input byte array that is to be encrypted.label
- a string that will be shown to the user on a prompt for passphrase if necessary.ticket
- A ticket denoting whether or not the developer has access to the keystore. A ticket can be retrieved
from the getTicket method in the key store or keystore data. The ticket can also be null which will most likely
prompt for a password from the user automatically (essentially calls
getTicket for you).
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.
KeyStoreDecodeException
- if the keystore was unable to decrypt the
ciphertext given that the security level was incorrect or the password was somehow
incorrect.public byte[] decrypt(int securityLevel, long salt, byte[] input, int offset, int length, String label, KeyStorePasswordTicket ticket) throws KeyStoreCancelException, KeyStoreDecodeException
securityLevel
- The security level.salt
- The salt that is used to decrypt the password. This should be random.input
- The input byte array that is to be decrypted.offset
- The offset into the byte array to be decrypted.length
- The number of bytes to be decrypted.label
- A string that will be shown to the user when prompting for a passphrase if necessary.ticket
- A ticket denoting whether or not the developer has access to the keystore. A ticket can be retrieved
from the getTicket method in the key store or keystore data. The ticket can also be null which will most likely
prompt for a password from the user automatically (essentially calls
getTicket for you).
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.
KeyStoreDecodeException
- if the keystore was unable to decrypt the
ciphertext given that the security level was incorrect or the password was somehow
incorrect.public byte[] decrypt(byte[] input, int offset, int length, String label, KeyStorePasswordTicket ticket) throws KeyStoreCancelException, KeyStoreDecodeException
input
- The input byte array that is to be decrypted.offset
- The offset into the byte array to be decrypted.length
- The number of bytes to be decrypted.label
- A string that will be shown to the user when prompting for a passphrase if necessary.ticket
- A ticket denoting whether or not the developer has access to the keystore. A ticket can be retrieved
from the getTicket method in the key store or keystore data. The ticket can also be null which will most likely
prompt for a password from the user automatically (essentially calls
getTicket for you).
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.
KeyStoreDecodeException
- if the keystore was unable to decrypt the
ciphertext given that the security level was incorrect or the password was somehow
incorrect.public void changePassword() throws KeyStoreCancelException
This function prompts for the old password and the new password. It ensures that the old password is correct and then proceeds. If the old password is incorrect it continues to prompt until the maximum number of attempts is reached.
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public byte[] decryptReEncrypt(int securityLevel, long salt, byte[] ciphertext) throws KeyStoreDecodeException
It is important to note that this will take in a byte array that is encrypted with the old password and return a new byte array that is encrypted with the new password. Everything is seamless to the user.
securityLevel
- An integer representing the security level.salt
- The salt used to encrypt the data. Must be random. Note that the salt
is going to be the same for the old ciphertext and the new ciphertext.ciphertext
- A byte array containing the ciphertext.
InvalidKeyEncodingException
- Thrown if the key is improperly encoded.
KeyStoreDecodeException
- if the keystore was unable to decrypt the
ciphertext given that the security level was incorrect or the password was somehow
incorrect.public byte[] decryptReEncrypt(int securityLevel, byte[] ciphertext) throws KeyStoreDecodeException
It is important to note that this will take in a byte array that is encrypted with the old password and return a new byte array that is encrypted with the new password. Everything is seamless to the user.
securityLevel
- An integer representing the security level.ciphertext
- A byte array containing the ciphertext.
InvalidKeyEncodingException
- Thrown if the key is improperly encoded.
KeyStoreDecodeException
- if the keystore was unable to decrypt the
ciphertext given that the security level was incorrect or the password was somehow
incorrect.public KeyStorePasswordTicket getTicket(KeyStore keyStore) throws KeyStoreCancelException
This will typically prompt for a password and will return a key store ticket if successful. If not this method can return null.
keyStore
- A reference to the key store you are asking
for permission to access.
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public KeyStorePasswordTicket getTicket(String additionalPrompt, KeyStore keyStore) throws KeyStoreCancelException
This will typically prompt for a password and will return a key store ticket if successful. If not this method can return null.
prompt
- this string will be shown to the user so that they can
understand why the keystore is attempting to retrieve a ticket for them.
Simply pass in null or use the other constructor if you do not want to show
any application specific prompts.keyStore
- A reference to the key store you are asking
for permission to access.
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public KeyStorePasswordTicket getTicket(KeyStoreData keyStoreData) throws KeyStoreCancelException
This will typically prompt for a password and will return a key store ticket if successful. If not this method can return null.
keyStoreData
- A reference to the key store data you are asking
for permission to access.
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public KeyStorePasswordTicket getTicket(String additionalPrompt, KeyStoreData keyStoreData) throws KeyStoreCancelException
This will typically prompt for a password and will return a key store ticket if successful. If not this method can return null.
prompt
- this string will be shown to the user so that they can
understand why the keystore is attempting to retrieve a ticket for them.
Simply pass in null or use the other constructor if you do not want to show
any application specific prompts.keyStoreData
- A reference to the key store data you are asking
for permission to access.
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public KeyStorePasswordTicket getTicket() throws KeyStoreCancelException
This will typically prompt for a password and will return a key store ticket if successful. If not this method can return null.
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public KeyStorePasswordTicket getTicket(String additionalPrompt) throws KeyStoreCancelException
This will typically prompt for a password and will return a key store ticket if successful. If not this method can return null.
prompt
- a string that is appended to the dialog for clarifying what
exactly this ticket will be used for.
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public boolean checkTicket(KeyStorePasswordTicket ticket)
ticket
- The specified ticket.
public byte[] setPassword() throws KeyStoreCancelException
KeyStoreCancelException
- Thrown when the user cancels out of the simple password
dialog since they appear to not want to enter their password.public boolean clean()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.