Java Reference
In-Depth Information
<web-resource-name>Administration</web-resource-name>
<url-pattern>/faces/
administration/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
3. Associate each role with a user group in the glassfish-web.xml file. In
the realm, each user is associated with a user group. However, the URL pat-
terns are associated with roles. So, you need to tell the server which group
a role belongs to. In GlassFish, this is possible through the <security-
role-mapping> element. The following code shows the complete contents
of the glassfish-web.xml file with the role-group combination:
<glassfish-web-app error-url=""
httpservlet-security-provider="AuthModule1">
<security-role-mapping>
<role-name>admin</role-name>
<group-name>administrator</group-name>
</security-role-mapping>
<class-loader delegate="true"/>
</glassfish-web-app>
4. Declare the realm and authentication types to be used by our application
in web.xml . The following code demonstrates how to declare the
MyJDBCRealm we created in the preceding step. The authentication type we
have chosen is DIGEST . It transmits the password in an encrypted form.
<login-config>
<auth-method>DIGEST</auth-method>
<realm-name>MyJDBCRealm</realm-name>
</login-config>
Once you complete these configurations, candidates can access the registration
forms without any problem. But, if they try to connect to an admin form, a window
similar to the following window will be displayed:
Search WWH ::




Custom Search