User: starksm
Date: 01/11/09 02:19:29
Modified: src/main/org/jboss/security/srp/jaas Tag: Branch_2_4
SRPCacheLoginModule.java SRPLoginModule.java
Log:
Clean up the logging.
Revision Changes Path
No revision
No revision
1.3.2.1 +12 -9
jbosssx/src/main/org/jboss/security/srp/jaas/SRPCacheLoginModule.java
Index: SRPCacheLoginModule.java
===================================================================
RCS file:
/cvsroot/jboss/jbosssx/src/main/org/jboss/security/srp/jaas/SRPCacheLoginModule.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- SRPCacheLoginModule.java 2001/04/11 02:04:21 1.3
+++ SRPCacheLoginModule.java 2001/11/09 10:19:28 1.3.2.1
@@ -19,8 +19,8 @@
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
+import org.jboss.security.Logger;
import org.jboss.security.auth.callback.SecurityAssociationCallback;
-import org.jboss.security.srp.PkgCategory;
import org.jboss.security.srp.SRPServerSession;
import org.jboss.security.srp.SRPServerInterface;
import org.jboss.security.srp.SRPServerInterface.SRPParameters;
@@ -37,11 +37,12 @@
information managed by the SRPSerice.
domainName,
-@author [EMAIL PROTECTED]
-@version $Revision: 1.3 $
+@author [EMAIL PROTECTED]
+@version $Revision: 1.3.2.1 $
*/
public class SRPCacheLoginModule implements LoginModule
{
+ private static Logger log = Logger.getInstance(SRPCacheLoginModule.class);
private Subject subject;
private CallbackHandler handler;
private Map sharedState;
@@ -50,7 +51,6 @@
private byte[] clientChallenge;
private SRPServerSession session;
private Principal userPrincipal;
- private boolean debug;
private boolean loginFailed;
public SRPCacheLoginModule()
@@ -74,10 +74,8 @@
this.handler = handler;
this.sharedState = sharedState;
cacheJndiName = (String) options.get("cacheJndiName");
+ log.trace("cacheJndiName="+cacheJndiName);
domainName = (String) options.get("domainName");
- String d = (String) options.get("debug");
- if( d != null )
- debug = Boolean.valueOf(d).booleanValue();
}
/** Access the user Principal object and credentials by passing a
@@ -104,6 +102,11 @@
InitialContext iniCtx = new InitialContext();
CachePolicy cache = (CachePolicy) iniCtx.lookup(cacheJndiName);
Object cacheCredential = cache.get(userPrincipal);
+ if( cacheCredential == null )
+ {
+ throw new LoginException("No SRP session found for: "+username);
+ }
+ log.trace("Found SRP cache credential: "+cacheCredential);
/** The cache object should be the SRPServerSession object used in the
authentication of the client.
*/
@@ -120,11 +123,11 @@
}
catch(NamingException e)
{
- e.printStackTrace();
+ log.error("Failed to load SRP auth cache", e);
throw new LoginException("Failed to load SRP auth cache:
"+e.toString(true));
}
- PkgCategory.debug("Login succeeded");
+ log.trace("Login succeeded");
// Put the username and the client challenge into the sharedState map
sharedState.put("javax.security.auth.login.name", username);
sharedState.put("javax.security.auth.login.password", clientChallenge);
1.2.4.1 +45 -18 jbosssx/src/main/org/jboss/security/srp/jaas/SRPLoginModule.java
Index: SRPLoginModule.java
===================================================================
RCS file:
/cvsroot/jboss/jbosssx/src/main/org/jboss/security/srp/jaas/SRPLoginModule.java,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -r1.2 -r1.2.4.1
--- SRPLoginModule.java 2001/04/04 21:46:03 1.2
+++ SRPLoginModule.java 2001/11/09 10:19:28 1.2.4.1
@@ -21,7 +21,8 @@
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
-import org.jboss.security.srp.PkgCategory;
+import org.jboss.security.Logger;
+import org.jboss.security.Util;
import org.jboss.security.srp.SRPClientSession;
import org.jboss.security.srp.SRPServerInterface;
import org.jboss.security.srp.SRPServerInterface.SRPParameters;
@@ -30,11 +31,30 @@
to authenticate a username & password in a secure fashion without
using an encrypted channel.
+The supported configuration options include:
+<ul>
+ <li>principalClassName: the fully qualified class name of the
java.security.Principal
+ implementation to use. The implementation must provide a public constructor that
+ accepts a single String argument representing the name of the principal.
+ If not specified this defaults to org.jboss.security.SimplePrincipal.
+ </li>
+
+ <li>srpServerJndiName: the JNDI name of the SRPServerInterface object to use
+ for communicating with the SRP authentication server. If both srpServerJndiName
+ and srpServerRmiUrl options are specified, the srpServerJndiName is tried before
+ srpServerRmiUrl.
+ </li>
+
+ <li>srpServerRmiUrl: the RMI protocol URL string for the location of the
+ SRPServerInterface proxy to use for communicating with the SRP authentication
server.
+ </li>
+</ul>
+
This product uses the 'Secure Remote Password' cryptographic
authentication system developed by Tom Wu ([EMAIL PROTECTED]).
-@author [EMAIL PROTECTED]
-@version $Revision: 1.2 $
+@author [EMAIL PROTECTED]
+@version $Revision: 1.2.4.1 $
*/
public class SRPLoginModule implements LoginModule
{
@@ -48,8 +68,8 @@
private String password;
private Principal userPrincipal;
private byte[] sessionKey;
- private boolean debug;
private boolean loginFailed;
+ private Logger log;
/** Creates new SRPLoginModule */
public SRPLoginModule()
@@ -67,7 +87,6 @@
srpServerJndiName: the jndi name of the SRPServerInterface implimentation
to use. This
is tried before srpServerRmiUrl.
srpServerRmiUrl: the rmi url for the SRPServerInterface implimentation to
use.
- debug: if true, print the login module progress details
*/
public void initialize(Subject subject, CallbackHandler handler, Map
sharedState, Map options)
{
@@ -75,11 +94,11 @@
this.handler = handler;
this.sharedState = sharedState;
principalClassName = (String) options.get("principalClassName");
+ if( principalClassName == null )
+ principalClassName = "org.jboss.security.SimplePrincipal";
srpServerJndiName = (String) options.get("srpServerJndiName");
srpServerRmiUrl = (String) options.get("srpServerRmiUrl");
- String o = (String) options.get("debug");
- if( o != null )
- debug = Boolean.valueOf(o).booleanValue();
+ log = Logger.getInstance(getClass());
}
/** This is where the SRP protocol exchange occurs.
@@ -111,34 +130,42 @@
SRPClientSession client = null;
try
{ // Perform the SRP login protocol
- PkgCategory.debug("Getting SRP parameters for username: "+username);
+ log.trace("Getting SRP parameters for username: "+username);
+ Util.init();
SRPParameters params = server.getSRPParameters(username);
- PkgCategory.debug("Creating SRPClientSession");
+ log.trace("N: "+Util.tob64(params.N));
+ log.trace("g: "+Util.tob64(params.g));
+ log.trace("s: "+Util.tob64(params.s));
+ byte[] hn = Util.newDigest().digest(params.N);
+ log.trace("H(N): "+Util.tob64(hn));
+ byte[] hg = Util.newDigest().digest(params.g);
+ log.trace("H(g): "+Util.tob64(hg));
+ log.trace("Creating SRPClientSession");
client = new SRPClientSession(username, password, params.s, params.N,
params.g);
- PkgCategory.debug("Generating client public key");
+ log.trace("Generating client public key");
byte[] A = client.exponential();
- PkgCategory.debug("Exchanging public keys");
+ log.trace("Exchanging public keys");
byte[] B = server.init(username, A);
- PkgCategory.debug("Generating server challenge");
+ log.trace("Generating server challenge");
M1 = client.response(B);
- PkgCategory.debug("Exchanging challenges");
+ log.trace("Exchanging challenges");
M2 = server.verify(username, M1);
sessionKey = client.getSessionKey();
}
catch(Exception e)
{
- PkgCategory.warn("Failed complete SRP login", e);
- throw new LoginException("Failed complete SRP login,
msg="+e.getMessage());
+ log.warn("Failed to complete SRP login", e);
+ throw new LoginException("Failed to complete SRP login,
msg="+e.getMessage());
}
finally
{
server = null;
}
- PkgCategory.debug("Verifying server response");
+ log.trace("Verifying server response");
if( client.verify(M2) == false )
throw new LoginException("Failed to validate server reply");
- PkgCategory.debug("Login succeeded");
+ log.trace("Login succeeded");
// Put the username and the client challenge into the sharedState map
sharedState.put("javax.security.auth.login.name", username);
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development