Jul 08 2008
LiveCycle Data Services and Java EE container managed security
Disease
You want to authenticate via a Flex application and still leverage Java EE container managed security.
Prescription
With LiveCycle ES Data Services you can authenticate users using the Flex application and you can pass these credentials on to the back-end where they will be verified by the container. The server-side Flex Session give you access to the Principal object. Through the use of roles you can authorize users to invoke LiveCycle ES Data Services endpoints or avoid users invoking specific LiveCycle ES Data Services assembler methods.
Following steps explain how to set this up on Tomcat 5.5.
- Download the source of this sample from Adobe share and import the Flex project
- Configure container managed security in Tomcat.
- Follow the steps in $LCDSHOME/resources/security/tomcat/readme.txt (download LiveCycle ES Data Services)
- Create a LiveCycle ES Data Services project in Eclipse (Dr. FLex & Dr. LiveCycle)
- In your project, create a context.xml under META-INF/
|
<Context> |
- In your project, edit services-config.xml in WEB-INF/flex, the <security> tag should point to the following login command:
|
<security> </security> |
- To pass on the credentials captured in your Flex application to your back-end you can use (see main.mxml in the code sample):
|
personDS.setCredentials(username.text, password.text); |
personDS is a LiveCycle ES Data Services Data Management endpoint
- The container will only allow you to access the LiveCycle ES Data Services endpoint when these credentials are valid.
- To obtain the Principal in the LiveCycle ES Data Services assembler you execute (see PersonAssember in the code sample). For more info on assemblers, go to Dr Flex & Dr. LiveCycle or consult the LiveCycle Data Services Developer Guide.
| Principal principal = FlexContext.getUserPrincipal(); |
Tips to stay healthy :
You can extend this further by leveraging the integration between LiveCycle ES Data Services and Java EE security by protecting resources via roles to allow only specific users to invoke Data Services endpoints.
Embedding the following in your LiveCycle ES Data Services data-management-config.xml file, you can avoid users not having the correct role to invoke this endpoint (see sample code):
|
<destination id="persons"> <adapter ref="java-dao" /> …. |
Where is sample code for PersonAssembler?