users@glassfish.java.net

Re: realm security with the hello world duke program...

From: <glassfish_at_javadesktop.org>
Date: Mon, 19 May 2008 06:19:13 PDT

> i am trying to play around with realm security,
>
> my web.xml looks like:
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5"
> xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="h
> ttp://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
> <session-config>
> <session-timeout>
> 30
> </session-timeout>
> </session-config>
> <welcome-file-list>
> <welcome-file>
> index.jsp
> </welcome-file>
> </welcome-file-list>
> <security-constraint>
> <web-resource-collection>
> <web-resource-name>hello</web-resource-name>
> <url-pattern>/*</url-pattern>
> <http-method>GET</http-method>
> </web-resource-collection>
> <auth-constraint>
> <role-name>users</role-name>
> </auth-constraint>
> </security-constraint>
> <login-config>
> <auth-method>BASIC</auth-method>
> <realm-name>myTest</realm-name>
> </login-config>
> <security-role>
> <role-name>USERS</role-name>
> <group-name>Users</group-name>
> </security-role>
> </web-app>
>
> security is not working though... i know i have
> something wrong...

The above web.xml file appears to have an invalid role definition (security-role should not contain a group-name lement). In the latter parts of this thread, the other examples of web.xml appears to be invalid in other ways (e.g. elements must be in proper order as defined by

<!ELEMENT web-app (icon?, display-name?, description?, distributable?,
context-param*, filter*, filter-mapping*, listener*, servlet*,
servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?,
error-page*, taglib*, resource-env-ref*, resource-ref*, security-constraint*,
login-config?, security-role*, env-entry*, ejb-ref*, ejb-local-ref*)>

It might be a good idea to get the program properly configured with the default realm, before you throw in the other variable of a custme realm, as failures in realm intialization can be difficult to distinguish form web.xml config problems.
 
Ron
[Message sent by forum member 'monzillo' (monzillo)]

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