RE: [newbie] Container Managed Security - preventing direct accessto .jsp

2004-12-15 Thread Robert Taylor
That is exactly how I want to do it. 
In fact, if you look at my original message I describe what you recommend
almost exactly. 

Anyhow, I finally created a VERY simple security example web app with
the following web.xml:


http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
version="2.4">

   Simple Security Example
   Simple Security Example

   
index.jsp


403
/403.jsp



  Example Security Constraint
  
 Protected Area
 /secure/*
  
  





And it work! Yeeeha!

Thanks for the help and discussion Ben.

/robert

> -Original Message-
> From: Ben Souther [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 14, 2004 10:35 PM
> To: Tomcat Users List
> Subject: RE: [newbie] Container Managed Security - preventing direct
> accessto .jsp
> 
> 
> > It appears that there is no standard way to do this even though
> > it's implied in the spec.
> 
> I don't know how standard this is but it works.
> The trick is in the auth-constraint node (note the commented out
> role-name).
> Since it is exclusive. Not declaring a role-name for the protected
> resource denies access to everyone.
> 
> You then catch the 403 error with an error page mapping and you're good
> to go.  
> 
> The JSPs can still be accessed from the request dispatcher so you can 
> reach them through the MVC pattern.
> 
> I suppose a simpler solution would be simply to create a
> servelet-mapping with a url pattern of *.jsp and map it to an error
> servlet.
> 
> If you want to test this out quickly grab the  SimpleMVC.war from
> http://simple.souther.us and replace the web.xml file with this one.
> You'd have to create your own no-jsp-4-u.html page.
> 
> Hope it helps
> -Ben
> 
> 
> 
> 
> http://java.sun.com/xml/ns/j2ee";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
> version="2.4">
>   
>
>   
> ControllerServlet 
>   
>   
>   
> us.souther.simple.mvc.ControllerServlet
>   
> 
>   
> ControllerServlet
> /simple-mvc
>   
>  
>   
> 
>   
> off-limits
>   
>   
>   *.jsp
>   
> 
> 
>   
> 
>   
>  
>   
> 403
> /no-jsp-4-u.html
>   
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: [newbie] Container Managed Security - preventing direct accessto .jsp

2004-12-15 Thread Ben Souther
Thanks for the help and discussion Ben.
> 
> /robert

Yep, they look the same.
Glad to help, even if I've done nothing more than validate your
assumptions ;)



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [newbie] Container Managed Security - preventing direct accessto .jsp

2004-12-14 Thread Robert Taylor
Yes. That would be an alternative approach.
However, I want to use CMS (Container Managed Security) to protect direct 
access to .jsp pages.
This should be possible as per the Servlet specification.

/robert

> -Original Message-
> From: Ben Souther [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 14, 2004 1:16 PM
> To: Tomcat Users List
> Subject: RE: [newbie] Container Managed Security - preventing direct
> accessto .jsp
> 
> 
> Filters are portable.
> 
> 
> 
> On Tue, 2004-12-14 at 12:32, Robert Taylor wrote:
> > Ping...
> > 
> > Please let me know if this questions is just too obvious
> > and I'll gladly RTFM...even more. And yes, I know this list
> > is not here just to serve _my_ interests.
> > 
> > It just seems like a common idiom to provide a portable mechanism
> > for protecting direct access to .jsp so as to enforce access through
> > some controller. I have in the past placed .jsp files "behind" WEB-INF,
> > but I don't believe that is portable and would like to use CMS to achieve
> > this.
> > 
> > Thanks again.
> > 
> > /robert
> > 
> > 
> > > -Original Message-
> > > From: Robert Taylor [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, December 13, 2004 8:59 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [newbie] Container Managed Security - preventing direct access
> > > to .jsp
> > > 
> > > 
> > > Greetings, 
> > > 
> > > I'm new to Tomcat and this mailing list, and have a question
> > > regarding configuring Tomcat to simply disallow access to .jsp pages
> > > which I have been protected via the  in my web app
> > > web.xml file.
> > > 
> > > >From what I understand, the following should do the trick and cause
> > > a 403 error to be sent to the browser by the container. I would like
> > > to trap that error code and display a user friendly page (I chose any page
> > > so I would know it's working).
> > > 
> > > I've simply modified the Tomcat jsp-examples web app. Here's a snippet
> > > of the necessary artifacts in the web.xml file.
> > > 
> > > 
> > > 
> > > 
> > > 403
> > > /dates/date.jsp
> > > 
> > > 
> > > 
> > >   Example Security Constraint
> > >   
> > >  Protected Area
> > >  /security/protected/*
> > >   
> > > 
> > > 
> > > 
> > > I believe the constraint is working, but I don't think the 
> > >  is "catching" the 403 status code. This is probably
> > > because a 403 status code is not returned, but rather a 200 (I verified
> > > this by looking at the response headers).
> > > 
> > > Anyhow, the content of the returned page is below within the :
> > > 
> > > 
> > > 
> > > You are logged in as remote user null in session 
> > > D97EE937BEC953A7E82E42B3956AED86
> > > 
> > > No user principal could be identified.
> > > 
> > > To check whether your username has been granted a particular role, enter 
> > > it here:
> > > 
> > > 
> > > If you have configured this app for form-based authentication, you can 
> > > log off by 
> > > clicking here. This should cause you to be returned to the logon page 
> > > after the 
> > > redirect that is performed.
> > > 
> > > 
> > > I'm sure this has happened to someone else, I just cannot find where.
> > > I googled and didn't come up with much. I searched the archives using
> > > "You are logged in as remote user null in session" and no matches were
> > > found.
> > > 
> > > Any help would be greatly appreciated.
> > > 
> > > /robert
> > > 
> > > 
> > >  
> > > 
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > > 
> > 
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]