|
"WEBNMS_5 API Docs" | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.adventnet.security.AuthUtil
public class AuthUtil
Provides utility methods that can be used by applications to perform authentication-related operations. This class cannot be instantiated. It has only static methods.
The following code snippet explains the role of AuthUtil in the Challenge-Handshake authentication mechanism.
String secretKey = AuthUtil.getChallenge();
boolean result = AuthUtil.isValid( "username");
String cipher = AuthUtil.encryptString("plainText", secretKey);
String plain = AuthUtil.decryptString("cipherText", secretKey);
Message Digest
String challenge = authenapi.getChallenge("userName");
String key = AuthUtil.getChallengeKey("userName" , "passWord" , challenge);
After calculating the key, using the verifyCredentials
method of AuthenticationAPI, authenticity of the user can be verified
as given below:
if(authenapi.verifyCredentials("userName",key))
System.out.println("Authenticated.");
else
System.out.println("Authentication Failed.");
AuthenticationAPI| Method Summary | |
|---|---|
static java.lang.String |
decryptString(java.lang.String cipherText,
java.lang.String key)
Method to decrypt the cipher text using the symmetric key decryption |
static java.lang.String |
encryptString(java.lang.String plainText,
java.lang.String key)
Method to encrypt the plain text using the symmetric key encryption. |
static java.lang.String |
getChallenge()
Method to get a secured random number which can be used as a shared key to encrypt and decrypt a plain and cipher respectively. |
static java.lang.String |
getChallengeKey(java.lang.String userName,
java.lang.String password,
java.lang.String challenge)
Use this method to calculate the key which is required by the Challenge Handshake mechanism to verify the user credentials . |
static boolean |
isValid(java.lang.String text)
Method to validate whether the String has any special character. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String getChallengeKey(java.lang.String userName,
java.lang.String password,
java.lang.String challenge)
throws AuthenticationException
userName - The name of the user who is to be authenticated.password - The password for the user.challenge - The challenge for the user got by the
AuthenticationAPI.getChallenge(userName).
AuthenticationException - In case of any exception while
calculating the "digest" or "key".AuthenticationAPIpublic static java.lang.String getChallenge()
public static java.lang.String encryptString(java.lang.String plainText,
java.lang.String key)
plainText - The String which is to be encrypted.key - The secret key got from the getChallenge method.
public static java.lang.String decryptString(java.lang.String cipherText,
java.lang.String key)
cipherText - which is got from encryptString method.key - The key which was used to encrypt the string.
public static boolean isValid(java.lang.String text)
text - The String to be validated for restricted special characters.
|
"WEBNMS_5 API Docs" | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||