this servlet run but not exactly....

G

gbattine

Hi guys,
i'm a problem and i don't find a solution from 10 days....please help
me.
I have to give access security to my jsf application because each page
shows private information. I have a login page and a visit bean that
store the session's information,like current user and current locale.
I've developed a filter that when a page is loaded try to retrieve user
from Visit Object,if it's not found go to login page.
What's my problem?
After i developed my filter my application don't go well,because after
i logged in my application try to open next page but it loads for
infinite time....and while i try to load a page without log in i read
the messagge "indirizzamento a Login.jsf...." but it loads for infinite
time.
It seems the filter acts but not exactly......
Can you help me?
I post you the important code.
This is the important code of mu AuthenticationBean

User newUser=new User(loginName,password,teamName,tipo);
Visit visit = new Visit();
visit.setUser(newUser);
visit.setAuthenticationBean(this);
setVisit(visit);
FacesContext facesContext = getFacesContext();
getApplication().createValueBinding("#{sessionScope.visit}").setValue(facesContext,
visit);

this is my Visit Object

package giu;

import javax.faces.context.FacesContext;
import java.util.Locale;
import javax.faces.model.SelectItem;
import javax.faces.application.Application;
import java.util.*;

import java.io.Serializable;

public class Visit implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
private User user;
private AuthenticationBean authenticationBean;

public Visit()
{
}

public User getUser()
{
return user;
}

public void setUser(User user)
{
this.user = user;
}



public AuthenticationBean getAuthenticationBean()
{
return authenticationBean;
}

public void setAuthenticationBean(AuthenticationBean
authenticationBean)
{
this.authenticationBean = authenticationBean;
}

and this is my filter

package giu;

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;

public class AuthorizationFilter implements Filter
{
FilterConfig config = null;
ServletContext servletContext = null;

public AuthorizationFilter()
{
}

public void init(FilterConfig filterConfig) throws ServletException
{
config = filterConfig;
servletContext = config.getServletContext();
}

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException,
ServletException
{
Utils.log(servletContext, "Inside the filter");

HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;
HttpSession session = httpRequest.getSession();

String requestPath = httpRequest.getPathInfo();
Visit visit = (Visit)session.getAttribute("visit");
if (visit == null)
{
session.setAttribute("originalTreeId", httpRequest.getPathInfo());
Utils.log(servletContext, "redirecting to " +
httpRequest.getContextPath() +
"/faces/Login.jsf");
httpResponse.sendRedirect(httpRequest.getContextPath() +
"/faces/Login.jsf");
}
else
{
session.removeAttribute("originalTreeId");
String role = visit.getUser().getRole();
/*
if ((role.equals("utente") && requestPath.indexOf("protected") >
0))
{
String text = Utils.getDisplayString("ptrackResources",
"PathNotFound",
new Object[] { requestPath },
request.getLocale());
httpResponse.sendError(HttpServletResponse.SC_NOT_FOUND,
text);
}
else*/
{
chain.doFilter(request, response);
}
}
Utils.log(servletContext, "Exiting the filter");
}

public void destroy()
{
}
}


with its declaration in web.xml

<filter>
<filter-name>AuthorizationFilter</filter-name>
<filter-class>giu.AuthorizationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthorizationFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>AuthorizationFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>

Please help me.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top