dev@glassfish.java.net

Providing login access to user created in admin-realm

From: Deepak Gothe <Deepak.Gothe_at_Sun.COM>
Date: Thu, 24 Jan 2008 18:20:39 +0530

Hi,
   I have a question regarding providing access to a user created in
admin-realm using Glassfish admin console. Following are the steps that
i performed..

1. Create a user with user id as "deepak" and Group List as "group1" in
admin-realm using the admin console

2. Add the following in the web.xml

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>SecureResource</web-resource-name>
            <url-pattern>/authorized</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
            <role-name>*</role-name>
        </auth-constraint>
        <user-data-constraint>
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
   
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>admin-realm</realm-name>
        <form-login-config>
            <form-login-page>/login.jsp</form-login-page>
            <form-error-page>/error.jsp</form-error-page>
        </form-login-config>
    </login-config>
   
    <security-role>
        <role-name>deepak</role-name>
    </security-role>

3. Add the following in the sun-web.xml

    <security-role-mapping>
        <role-name>deepak</role-name>
        <group-name>group1</group-name>
    </security-role-mapping>


login.jsp is the form that use j_security_check. After the above changes
I can login as user "deepak". Now if I create a new user say "user1" in
the group "group2" and want that user to login, I need to modify both
web.xml and sun-web.xml. This is not desirable. Once i deploy the
webapp, any user that is created should be able to login. Is there a way
to achieve this. This is needed to implement "isUserInRole"
functionality in OpenPortal Portlet Container Driver.

Thanks in advance,
Deepak