[opencms-dev] About custom page 401 + opencms (possible solution)
Deiverson Silveira
deiverson at solutioncms.com
Tue Mar 17 15:06:22 CET 2009
Hi Guys,
I try implement solution for custom my page error 401 with autentication
opencms, but dont work, a see this, I dont understand change, the file in
opencms for put this filter.
Here is how you can create a custom 401 (Not Authorized) error response
in Tomcat. Putting a directive like this:
<error-page>
<error-code>401</error-code>
<location>/errors/401.html</location>
</error-page>
in web.xml will not work. If you put that in web.xml, it will deny all
authorization.
The thing to do is to create a filter for the resources you want to
protect. Do the conventional basic authentication in the filter.
However, here is the part which is different:
THIS QUESTION IS, WHERE I PLACE THIS CODEIN OPENCMS:
String errorFile = "/errors/401.html";
response.addHeader("WWW-Authenticate", "BASIC realm=\"" + realm
+ "\"");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
RequestDispatcher rd = request.getRequestDispatcher(errorFile);
try { rd.forward(request,response); }
So instead of letting the container generate the html for the 401
response, you always generate it using the RequestDispatcher. The
RequestDispatcher can of course be an html or jsp file.
So that is the solution to custom 401 errors in Tomcat.
Best Regards,
Deiverson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090317/bd467ea1/attachment.htm>
More information about the opencms-dev
mailing list