import javax.security.sasl.AuthenticationException;
/**
- * <p>The SRP mechanism authentication information provider implementation.</p>
+ * The SRP mechanism authentication information provider implementation.
*/
-public class SRPAuthInfoProvider implements IAuthInfoProvider
+public class SRPAuthInfoProvider
+ implements IAuthInfoProvider
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private PasswordFile passwordFile = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-args constrcutor
- // Class methods
- // -------------------------------------------------------------------------
-
- // Instance methods
- // -------------------------------------------------------------------------
-
- // IAuthInfoProvider interface implementation ------------------------------
-
public void activate(Map context) throws AuthenticationException
{
try
{
if (context == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
{
passwordFile = (PasswordFile) context.get(SRPRegistry.PASSWORD_DB);
{
String pfn = (String) context.get(SRPRegistry.PASSWORD_FILE);
if (pfn == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
- {
- passwordFile = new PasswordFile(pfn);
- }
+ passwordFile = new PasswordFile(pfn);
}
}
}
public boolean contains(String userName) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("contains()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("contains()",
+ new IllegalStateException());
boolean result = false;
try
{
public Map lookup(Map userID) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("lookup()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("lookup()", new IllegalStateException());
Map result = new HashMap();
try
{
String userName = (String) userID.get(Registry.SASL_USERNAME);
if (userName == null)
- {
- throw new NoSuchUserException("");
- }
+ throw new NoSuchUserException("");
String mdName = (String) userID.get(SRPRegistry.MD_NAME_FIELD);
-
String[] data = passwordFile.lookup(userName, mdName);
result.put(SRPRegistry.USER_VERIFIER_FIELD, data[0]);
result.put(SRPRegistry.SALT_FIELD, data[1]);
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
+ throw (AuthenticationException) x;
throw new AuthenticationException("lookup()", x);
}
return result;
{
if (passwordFile == null)
throw new AuthenticationException("update()", new IllegalStateException());
-
try
{
String userName = (String) userCredentials.get(Registry.SASL_USERNAME);
String salt = (String) userCredentials.get(SRPRegistry.SALT_FIELD);
String config = (String) userCredentials.get(SRPRegistry.CONFIG_NDX_FIELD);
if (salt == null || config == null)
- {
- passwordFile.changePasswd(userName, password);
- }
+ passwordFile.changePasswd(userName, password);
else
- {
- passwordFile.add(userName, password, Util.fromBase64(salt), config);
- }
+ passwordFile.add(userName, password, Util.fromBase64(salt), config);
}
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
+ throw (AuthenticationException) x;
throw new AuthenticationException("update()", x);
}
}
public Map getConfiguration(String mode) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("getConfiguration()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("getConfiguration()",
+ new IllegalStateException());
Map result = new HashMap();
try
{
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
+ throw (AuthenticationException) x;
throw new AuthenticationException("getConfiguration()", x);
}
return result;
}
-}
\ No newline at end of file
+}