You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by "Bhardwaj, Ashutosh" <As...@fmr.com> on 2006/11/29 11:22:56 UTC

Error in custom jaas login module

I am trying to customize the login process.
My requirement is :
*	 In request I get a user id.(no password)
*	 I check if this id exists in db, if not show an error page.
*	 if the user id exists the authenticate user in jetspeed portal
with a default password
*	 If authentication fails add the user  and then authenticate.


For doing this I have written My own login module and testing it using
the default Login Portlet that ships with jetspeed by giving an empty
password.
The code is somehat like :
========================================================================
====================================
public boolean login() throws LoginException {
		
		if (callbackHandler == null) {
			throw new LoginException("Error: no
CallbackHandler available "
					+ "to garner authentication
information from the user");
		}
		try {
			// Setup default callback handlers.
			
			Callback[] callbacks = new Callback[] {
					new NameCallback("Username: ")
					};
			
			callbackHandler.handle(callbacks);
			username = ((NameCallback)
callbacks[0]).getName();
			refreshProxy();
			
			success = ums.authenticate(this.username,
this.username);
			System.out.println("sucees is :"+success);
			
			if(!success){
				FCEmployee emp =
getUserObject(this.username);
				if(emp!=null){
					ums.addUser(this.username,
this.username);
					success =
ums.authenticate(this.username, this.username);
									
				}
				
			}
			callbacks[0] = null;
			//callbacks[1] = null;
			if (!success) {
				throw new FailedLoginException(
						"Authentication failed:
Password does not match");
			}
			System.out.println("just before returning");

			return (true);
		} catch (LoginException ex) {
			throw ex;
		} catch (Exception ex) {
			ex.printStackTrace();
			success = false;
			throw new LoginException(ex.getMessage());
		}
	}

========================================================================
=================================

Now as expected it prints : just before returning , but after that

Nov 29, 2006 3:50:08 PM org.apache.catalina.realm.JAASRealm authenticate
WARNING: Login exception authenticating username g370978
javax.security.auth.login.LoginException: Login Failure: all modules
ignored
        at
javax.security.auth.login.LoginContext.invoke(LoginContext.java:779)
        at
javax.security.auth.login.LoginContext.access$000(LoginContext.java:129)
        at
javax.security.auth.login.LoginContext$4.run(LoginContext.java:610)
        at java.security.AccessController.doPrivileged(Native Method)
        at
javax.security.auth.login.LoginContext.invokeModule(LoginContext.java:60
7)
        at
javax.security.auth.login.LoginContext.login(LoginContext.java:535)
        at
org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:316)
        at
org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAut
henticator.java:229)
        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticator
Base.java:446)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:102)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
20)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:137)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:104)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:118)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:102)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
20)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:109)
        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:104)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
20)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
        at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:79
9)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11Protocol.java:705)
        at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:57
7)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:683)
        at java.lang.Thread.run(Thread.java:534)


What is the probable issue?

regards,
ashutosh bhardwaj


Re: Error in custom jaas login module

Posted by David Sean Taylor <da...@bluesunrise.com>.
Bhardwaj, Ashutosh wrote:
> I am trying to customize the login process.
> My requirement is :
> *	 In request I get a user id.(no password)
> *	 I check if this id exists in db, if not show an error page.
> *	 if the user id exists the authenticate user in jetspeed portal
> with a default password
> *	 If authentication fails add the user  and then authenticate.
> 
> 
> For doing this I have written My own login module and testing it using
> the default Login Portlet that ships with jetspeed by giving an empty
> password.
> The code is somehat like :
> ========================================================================
> ====================================
> public boolean login() throws LoginException {
> 		
> 		if (callbackHandler == null) {
> 			throw new LoginException("Error: no
> CallbackHandler available "
> 					+ "to garner authentication
> information from the user");
> 		}
> 		try {
> 			// Setup default callback handlers.
> 			
> 			Callback[] callbacks = new Callback[] {
> 					new NameCallback("Username: ")
> 					};
> 			
> 			callbackHandler.handle(callbacks);
> 			username = ((NameCallback)
> callbacks[0]).getName();
> 			refreshProxy();
> 			
> 			success = ums.authenticate(this.username,
> this.username);

Is "ums" the Jetspeed User Manager or your own User Manager?
I am assuming its your own User Manager.
Are you aware that Jetspeed also has a Login Module, and that all Login 
Modules are called during the authentication process?
Most likely the Jetspeed Login Module is failing.
If you do NOT want to use the Jetspeed Login Module, then you will need 
to disable it by removing the login.conf from the security jar.

This will not fully integrate your security system into Jetspeed, but 
lets see how far that gets you...


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org