summaryrefslogtreecommitdiff
path: root/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java')
-rw-r--r--gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java72
1 files changed, 16 insertions, 56 deletions
diff --git a/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java b/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java
index 9882ce9bb..e0cf82fb6 100644
--- a/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java
+++ b/gnu/javax/crypto/sasl/plain/PlainAuthInfoProvider.java
@@ -51,44 +51,26 @@ import javax.security.sasl.AuthenticationException;
/**
* The PLAIN mechanism authentication information provider implementation.
*/
-public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
+public class PlainAuthInfoProvider
+ implements IAuthInfoProvider, PlainRegistry
{
-
- // Constants and variables
- // -------------------------------------------------------------------------
-
private PasswordFile passwordFile = null;
- // Constructor(s)
- // -------------------------------------------------------------------------
-
// implicit 0-args constrcutor
- // Class methods
- // -------------------------------------------------------------------------
-
- // IAuthInfoProvider interface implementation
- // -------------------------------------------------------------------------
-
public void activate(Map context) throws AuthenticationException
{
try
{
if (context == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
{
String pfn = (String) context.get(PASSWORD_FILE);
if (pfn == null)
- {
- passwordFile = new PasswordFile();
- }
+ passwordFile = new PasswordFile();
else
- {
- passwordFile = new PasswordFile(pfn);
- }
+ passwordFile = new PasswordFile(pfn);
}
}
catch (IOException x)
@@ -105,10 +87,8 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
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
{
@@ -124,18 +104,13 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
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[] data = passwordFile.lookup(userName);
result.put(Registry.SASL_USERNAME, data[0]);
result.put(Registry.SASL_PASSWORD, data[1]);
@@ -148,13 +123,8 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
- else
- {
- throw new AuthenticationException("lookup()", x);
- }
+ throw (AuthenticationException) x;
+ throw new AuthenticationException("lookup()", x);
}
return result;
}
@@ -162,10 +132,7 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
public void update(Map userCredentials) throws AuthenticationException
{
if (passwordFile == null)
- {
- throw new AuthenticationException("update()",
- new IllegalStateException());
- }
+ throw new AuthenticationException("update()", new IllegalStateException());
try
{
String userName = (String) userCredentials.get(Registry.SASL_USERNAME);
@@ -177,9 +144,7 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
String shell = (String) userCredentials.get(SHELL_FIELD);
if (uid == null || gid == null || gecos == null || dir == null
|| shell == null)
- {
- passwordFile.changePasswd(userName, password);
- }
+ passwordFile.changePasswd(userName, password);
else
{
String[] attributes = new String[] { uid, gid, gecos, dir, shell };
@@ -189,13 +154,8 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
catch (Exception x)
{
if (x instanceof AuthenticationException)
- {
- throw (AuthenticationException) x;
- }
- else
- {
- throw new AuthenticationException("update()", x);
- }
+ throw (AuthenticationException) x;
+ throw new AuthenticationException("update()", x);
}
}
@@ -203,4 +163,4 @@ public class PlainAuthInfoProvider implements IAuthInfoProvider, PlainRegistry
{
throw new AuthenticationException("", new UnsupportedOperationException());
}
-} \ No newline at end of file
+}