Document Information
Preface
Part I Introduction
1. Overview
2. Using the Tutorial Examples
Part II The Web Tier
3. Getting Started with Web Applications
4. JavaServer Faces Technology
5. Introduction to Facelets
6. Expression Language
7. Using JavaServer Faces Technology in Web Pages
8. Using Converters, Listeners, and Validators
9. Developing with JavaServer Faces Technology
10. JavaServer Faces Technology: Advanced Concepts
11. Using Ajax with JavaServer Faces Technology
12. Composite Components: Advanced Topics and Example
13. Creating Custom UI Components and Other Custom Objects
14. Configuring JavaServer Faces Applications
15. Java Servlet Technology
16. Uploading Files with Java Servlet Technology
17. Internationalizing and Localizing Web Applications
Part III Web Services
18. Introduction to Web Services
19. Building Web Services with JAX-WS
20. Building RESTful Web Services with JAX-RS
21. JAX-RS: Advanced Topics and Example
Part IV Enterprise Beans
22. Enterprise Beans
23. Getting Started with Enterprise Beans
24. Running the Enterprise Bean Examples
25. A Message-Driven Bean Example
26. Using the Embedded Enterprise Bean Container
27. Using Asynchronous Method Invocation in Session Beans
Part V Contexts and Dependency Injection for the Java EE Platform
28. Introduction to Contexts and Dependency Injection for the Java EE Platform
29. Running the Basic Contexts and Dependency Injection Examples
30. Contexts and Dependency Injection for the Java EE Platform: Advanced Topics
31. Running the Advanced Contexts and Dependency Injection Examples
Part VI Persistence
32. Introduction to the Java Persistence API
33. Running the Persistence Examples
34. The Java Persistence Query Language
35. Using the Criteria API to Create Queries
36. Creating and Using String-Based Criteria Queries
37. Controlling Concurrent Access to Entity Data with Locking
38. Using a Second-Level Cache with Java Persistence API Applications
Part VII Security
39. Introduction to Security in the Java EE Platform
40. Getting Started Securing Web Applications
41. Getting Started Securing Enterprise Applications
42. Java EE Security: Advanced Topics
Working with Digital Certificates
Creating a Server Certificate
To Use keytool to Create a Server Certificate
Adding Users to the Certificate Realm
Using a Different Server Certificate with the GlassFish Server
To Specify a Different Server Certificate
Authentication Mechanisms
Client Authentication
Mutual Authentication
Enabling Mutual Authentication over SSL
Creating a Client Certificate for Mutual Authentication
Using Form-Based Login in JavaServer Faces Web Applications
Using j_security_check in JavaServer Faces Forms
Using a Managed Bean for Authentication in JavaServer Faces Applications
Using the JDBC Realm for User Authentication
To Configure a JDBC Authentication Realm
Securing HTTP Resources
Securing Application Clients
Using Login Modules
Using Programmatic Login
Securing Enterprise Information Systems Applications
Container-Managed Sign-On
Component-Managed Sign-On
Configuring Resource Adapter Security
To Map an Application Principal to EIS Principals
Further Information about Security
Part VIII Java EE Supporting Technologies
43. Introduction to Java EE Supporting Technologies
44. Transactions
45. Resources and Resource Adapters
46. The Resource Adapter Example
47. Java Message Service Concepts
48. Java Message Service Examples
49. Bean Validation: Advanced Topics
50. Using Java EE Interceptors
Part IX Case Studies
51. Duke's Bookstore Case Study Example
52. Duke's Tutoring Case Study Example
53. Duke's Forest Case Study Example
Index
|
|
The Java EE 6 Tutorial
|
 |
Configuring Security Using Deployment Descriptors
The recommended way to configure security in the Java EE 6 platform is
with annotations. If you wish to override the security settings at deployment time,
you can use security elements in the web.xml deployment descriptor to do so.
This section describes how to use the deployment descriptor to specify basic authentication
and to override default principal-to-role mapping.
Specifying Security for Basic Authentication in the Deployment Descriptor
The elements of the deployment descriptor that add basic authentication to an example
tell the server or browser to perform the following tasks:
Send a standard login dialog to collect user name and password data
Verify that the user is authorized to access the application
If authorized, display the servlet to the user
The following sample code shows the security elements for a deployment descriptor that
could be used in the example of basic authentication found in the tut-install/examples/security/hello2_basicauth/
directory:
<security-constraint>
<display-name>SecurityConstraint</display-name>
<web-resource-collection>
<web-resource-name>WRCollection</web-resource-name>
<url-pattern>/greeting</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>TutorialUser</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>file</realm-name>
</login-config>
<security-role>
<role-name>TutorialUser</role-name>
</security-role>This deployment descriptor specifies that the request URI /greeting can be accessed
only by users who have entered their user names and passwords and have
been authorized to access this URL because they have been verified to be
in the role TutorialUser. The user name and password data will be sent
over a protected transport in order to keep it from being read in
transit.
Specifying Non-Default Principal-to-Role Mapping in the Deployment Descriptor
To map a role name permitted by the application or module to
principals (users) and groups defined on the server, use the security-role-mapping element in the
runtime deployment descriptor file (glassfish-application.xml, glassfish-web.xml, or glassfish-ejb-jar.xml). The entry needs to declare
a mapping between a security role used in the application and one or
more groups or principals defined for the applicable realm of the GlassFish
Server. An example for the glassfish-web.xml file is shown below:
<glassfish-web-app>
<security-role-mapping>
<role-name>DIRECTOR</role-name>
<principal-name>schwartz</principal-name>
</security-role-mapping>
<security-role-mapping>
<role-name>DEPT-ADMIN</role-name>
<group-name>dept-admins</group-name>
</security-role-mapping>
</glassfish-web-app>The role name can be mapped to either a specific principal (user),
a group, or both. The principal or group names referenced must be valid
principals or groups in the current default realm of the GlassFish Server. The
role-name in this example must exactly match the role-name in the security-role element
of the corresponding web.xml file or the role name defined in the
@DeclareRoles and/or @RolesAllowed annotations.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices
|