You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by manoj sinha <ma...@yahoo.com> on 2007/02/16 15:17:32 UTC
Interceptor to Autheticate User
Hi,
Wiil appreciate if some one come with Solution!!
I am writing customized Authentication Interceptor.It Checks username & password from database by calling EJBs.
Code is Here:
public class AuthenticationInterceptor extends LoginSupport implements Interceptor {
public void destroy() {
}
public void init() {
}
public String intercept(ActionInvocation actionInvocation) throws Exception {
InitialContext jndiContext =SystemUtil.getIntialcontext();
Object ref = jndiContext.lookup("Login");
Authentication auth =null;
Encryption encrypt = new Encryption();
String encryptPassword = encrypt.encryptString(getPassword());
auth = (Authentication) new AuthenticationFactory().getAuthenticat(Constants.AUTHENTICATION_MODE);
Vector loginVector =auth.doAuthenticate(getUsername(),getPassword());
if(loginVector!=null){
if(((String)loginVector.elementAt(0)).equals("success")){
return actionInvocation.invoke();
}
return Action.ERROR;
}
return Action.INPUT;
}
}
Here LoginSupport class contains getter/setter methods.
I hace defined Interceptor Stack that is like
<interceptor name="userAuthentication" class="com.....AuthenticationInterceptor"/>
<interceptor-stack name="login">
<interceptor-ref name="userAuthentication"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
But Error is :
[[default]] Servlet.service() for servlet default threw exception
java.lang.NoClassDefFoundError: com/...../...../util/SystemUtil
at com......AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:26)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:200)
at org.apache.struts2.impl.StrutsActionProxy$1.call(StrutsActionProxy.java:27)
at org.apache.struts2.impl.StrutsActionProxy$1.call(StrutsActionProxy.java:26)
Will be Obliged if suggestion comes...
Thanks
Manoj
---------------------------------
8:00? 8:25? 8:40? Find a flick in no time
with theYahoo! Search movie showtime shortcut.
Re: Interceptor to Autheticate User
Posted by Nuwan Chandrasoma <my...@gmail.com>.
It looks like SystemUtil class is not available on the classpath.
Regards,
Nuwan.
----- Original Message -----
From: "manoj sinha" <ma...@yahoo.com>
To: <us...@struts.apache.org>
Sent: Friday, February 16, 2007 2:17 PM
Subject: Interceptor to Autheticate User
> Hi,
> Wiil appreciate if some one come with Solution!!
> I am writing customized Authentication Interceptor.It Checks username &
> password from database by calling EJBs.
> Code is Here:
> public class AuthenticationInterceptor extends LoginSupport implements
> Interceptor {
>
> public void destroy() {
> }
>
> public void init() {
> }
>
> public String intercept(ActionInvocation actionInvocation) throws
> Exception {
>
> InitialContext jndiContext =SystemUtil.getIntialcontext();
> Object ref = jndiContext.lookup("Login");
> Authentication auth =null;
> Encryption encrypt = new Encryption();
> String encryptPassword = encrypt.encryptString(getPassword());
> auth = (Authentication) new
> AuthenticationFactory().getAuthenticat(Constants.AUTHENTICATION_MODE);
> Vector loginVector
> =auth.doAuthenticate(getUsername(),getPassword());
>
>
> if(loginVector!=null){
> if(((String)loginVector.elementAt(0)).equals("success")){
> return actionInvocation.invoke();
> }
> return Action.ERROR;
> }
> return Action.INPUT;
> }
> }
>
> Here LoginSupport class contains getter/setter methods.
> I hace defined Interceptor Stack that is like
> <interceptor name="userAuthentication"
> class="com.....AuthenticationInterceptor"/>
> <interceptor-stack name="login">
> <interceptor-ref name="userAuthentication"/>
> <interceptor-ref name="defaultStack"/>
> </interceptor-stack>
> But Error is :
> [[default]] Servlet.service() for servlet default threw exception
> java.lang.NoClassDefFoundError: com/...../...../util/SystemUtil
> at
> com......AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:26)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:200)
> at
> org.apache.struts2.impl.StrutsActionProxy$1.call(StrutsActionProxy.java:27)
> at
> org.apache.struts2.impl.StrutsActionProxy$1.call(StrutsActionProxy.java:26)
> Will be Obliged if suggestion comes...
> Thanks
> Manoj
>
>
> ---------------------------------
> 8:00? 8:25? 8:40? Find a flick in no time
> with theYahoo! Search movie showtime shortcut.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org