logo       

roller/src/org/roller/presentation/filters RequestFilter.java,1.10,1.11: msg#00075

java.roller.cvs

Subject: roller/src/org/roller/presentation/filters RequestFilter.java,1.10,1.11

Update of /cvsroot/roller/roller/src/org/roller/presentation/filters
In directory sc8-pr-cvs1:/tmp/cvs-serv26686/src/org/roller/presentation/filters

Modified Files:
RequestFilter.java
Log Message:
page not found should result in 404

Index: RequestFilter.java
===================================================================
RCS file:
/cvsroot/roller/roller/src/org/roller/presentation/filters/RequestFilter.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** RequestFilter.java 3 Sep 2003 21:21:14 -0000 1.10
--- RequestFilter.java 17 Sep 2003 01:41:04 -0000 1.11
***************
*** 5,9 ****
--- 5,11 ----
import org.apache.commons.logging.LogFactory;
import org.roller.RollerException;
+ import org.roller.model.Roller;
import org.roller.presentation.RequestUtil;
+ import org.roller.presentation.RollerContext;
import org.roller.presentation.RollerRequest;
import org.roller.util.Utilities;
***************
*** 40,47 ****

/**
! * doFilter
! *
! * As the first & last filter in the chain, it is necessary that
RequestFilter
! * releases its Roller resources before it returns.
*/
public void doFilter(
--- 42,47 ----

/**
! * As the first and last filter in the chain, it is necessary that
! * RequestFilter releases its Roller resources before it returns.
*/
public void doFilter(
***************
*** 51,163 ****
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res;
! RollerRequest rreq = null;
! try
! {
! rreq = RollerRequest.getRollerRequest(
! request, mFilterConfig.getServletContext());
! }
! catch (RollerException e)
! {
! // An error initializing the request is considered to be a 404
! mLogger.debug("RollerRequest threw Exception", e);
! ((HttpServletResponse)res).sendError(
! HttpServletResponse.SC_NOT_FOUND);
! releaseRoller(rreq);
! return;
! }
!
! // Get the relevant cookies for the "remember me" feature
! Cookie rememberMe = RequestUtil.getCookie(request,
"rememberMe");
! Cookie passCookie = RequestUtil.getCookie(request, "password");
! String password =
! (passCookie != null)
! ? URLDecoder.decode(passCookie.getValue(), "UTF-8") :
null;
!
! // Detect if authentication has failed - indicated by the
error=true
! // parameter from the <form-error-page> in web.xml
! // StringUtils.equals is a convenience method from commons-lang
that handles
! // nulls gracefully.
! boolean authFailed =
! StringUtils.equals(request.getParameter("error"),
"true");
!
! // MR: I use login.jsp?error=true, but I know others use
loginerror.jsp
! if (!authFailed) // doublecheck
! {
! authFailed =
(request.getRequestURL().indexOf("loginerror.jsp") != -1);
! }
!
! // Check to see if the user is logging out, if so, remove the
! // rememberMe cookie and password cookie.
! if ((authFailed ||
!
(request.getRequestURL().indexOf("logout-redirect") != -1)) &&
! (rememberMe != null))
! {
! if (mLogger.isDebugEnabled())
! {
! mLogger.debug("deleting rememberMe-related
cookies");
! }
!
! response =
! RequestUtil.deleteCookie(response,
!
RequestUtil.getCookie(request,
!
"rememberMe"));
! response = RequestUtil.deleteCookie(response,
passCookie);
! }
!
! // Check to see if the user is logging in. If so, check to see
! // if they have enabled rememberMe functionality.
! // Only attempt to authenticate when "login" is requested
! if ((request.getRequestURL().indexOf("login.jsp") != -1))
! {
! // Check to see if we should automatically login the
user
! // container is routing user to login page, check for
remember me cookie
! Cookie userCookie = RequestUtil.getCookie(request,
"username");
!
! if (rememberMe!=null && password!=null &&
userCookie!=null)
! {
! String username =
! (passCookie != null)
! ? URLDecoder.decode(userCookie.getValue(), "UTF-8") :
null;
!
! String authURL = (String)
! mFilterConfig.getServletContext().getAttribute("authURL");
!
! // authenticate user without displaying login
page
! String route =
! request.getContextPath() + authURL +
"?j_username=" + username +
! "&j_password=" +
Utilities.decodeString(password);
!
! if (mLogger.isDebugEnabled())
! {
! mLogger.debug("I remember you '" +
username +
! "',
authenticating...");
! }

! releaseRoller(rreq);
!
response.sendRedirect(response.encodeRedirectURL(route));
!
! return;
! }
! }


- try
- {
chain.doFilter(req, res);
}
finally
{
! releaseRoller(rreq);
! }
! }
!
! /**
! * @param rreq
! */
! private void releaseRoller(RollerRequest rreq)
! {
! if (rreq != null)
! {
! rreq.releaseRoller();
}
}
--- 51,153 ----
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res;
! Roller roller = RollerContext.getRoller( request );

! try
! {
! RollerRequest rreq = null;
! try
! {
! rreq = RollerRequest.getRollerRequest(
! request, mFilterConfig.getServletContext());

! }
! catch (RollerException e)
! {
! // An error initializing the request is considered to be a 404
! mLogger.debug("RollerRequest threw Exception", e);
! ((HttpServletResponse)res).sendError(
! HttpServletResponse.SC_NOT_FOUND);
! return;
! }
!
! // Get the relevant cookies for the "remember me" feature
! Cookie rememberMe = RequestUtil.getCookie(request,
"rememberMe");
! Cookie passCookie = RequestUtil.getCookie(request, "password");
! String password =
! (passCookie != null)
! ? URLDecoder.decode(passCookie.getValue(), "UTF-8") :
null;
!
! // Detect if authentication has failed - indicated by the
error=true
! // parameter from the <form-error-page> in web.xml.
! // StringUtils.equals is a convenience method from commons-lang
that
! // handles nulls gracefully.
! boolean authFailed =
! StringUtils.equals(request.getParameter("error"),
"true");
!
! // MR: I use login.jsp?error=true, but others use loginerror.jsp
! if (!authFailed) // doublecheck
! {
! authFailed =
! (request.getRequestURL().indexOf("loginerror.jsp") != -1);
! }
!
! // Check to see if the user is logging out, if so, remove the
! // rememberMe cookie and password cookie.
! if ((authFailed ||
!
(request.getRequestURL().indexOf("logout-redirect") != -1))
! && (rememberMe != null))
! {
! if (mLogger.isDebugEnabled())
! {
! mLogger.debug("deleting rememberMe-related
cookies");
! }
!
! response =
! RequestUtil.deleteCookie(response,
! RequestUtil.getCookie(request,"rememberMe"));
! response = RequestUtil.deleteCookie(response,
passCookie);
! }
!
! // Check to see if the user is logging in. If so, check to see
! // if they have enabled rememberMe functionality.
! // Only attempt to authenticate when "login" is requested
! if ((request.getRequestURL().indexOf("login.jsp") != -1))
! {
! // Check to see if we should automatically login the
user
! // container is routing user to login page, check for
remember
! // me cookie
! Cookie userCookie = RequestUtil.getCookie(request,
"username");
!
! if (rememberMe!=null && password!=null &&
userCookie!=null)
! {
! String username = (passCookie != null)
! ? URLDecoder.decode(userCookie.getValue(),"UTF-8") :
null;
!
! String authURL = (String)
!
mFilterConfig.getServletContext().getAttribute("authURL");
!
! // authenticate user without displaying login
page
! String route =
! request.getContextPath() + authURL
! + "?j_username=" + username
! + "&j_password=" + Utilities.decodeString(password);
!
! if (mLogger.isDebugEnabled())
! {
! mLogger.debug("I remember you '" +
username +
! "',
authenticating...");
! }
!
!
response.sendRedirect(response.encodeRedirectURL(route));
! return;
! }
! }


chain.doFilter(req, res);
+
}
finally
{
! roller.release();
}
}




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise