users@glassfish.java.net

Re: Protecting Access to Pages Based on User Login?

From: <glassfish_at_javadesktop.org>
Date: Fri, 20 Mar 2009 12:20:06 PDT

Hi,
There are a few steps to do this:

I am assuming you are using NetBeans:

1) Project -> Configuration Files-> web.xml
2) Select the security tab

a) Login configuration: I would select Basic as a start.
b) Security roles: Add a role (if you have one role, you can name it "user" if you want)
c) Security constraints:
c.1) Name: A name for the constraint. Anything you want really.
c.2) Web resource name: A name for the area you are restricting access to.
c.3) URL pattern: Which URLs are you restricting access to. (ex, /users/secure/* or if you are using visual jsf /faces/users/secure/*)
c.4) Enable constraints and add the role you created earlier as an allowed role.

Last step is Security role mapping:
1) Project -> Configuration files -> sun-web.xml
2) Security
3) Add Security Role mapping
a) Give the role a name (same name as in 2.a above)
b) Add the group name that should be assuming this role (depends on what you use in your file realm).

Hope this helps.
[Message sent by forum member 'hedgy102' (hedgy102)]

http://forums.java.net/jive/thread.jspa?messageID=338213