You can use the NetServices setCredentials function in ActionScript to authenticate Flash users to a JRun 4 server and authorize them to access EJBs once they have been authenticated. When a user cannot be authenticated, the NetServices onStatus function provides details on the client.
All of the gateway adapters support authentication, but only the EJB adapter supports authorization. Once a user has been authenticated, the user's role is associated with any EJBs the user may access, and the security permissions established in EJB deployment descriptors (ejb-jar.xml) are enforced. Only users in specified roles are allowed to access the EJB methods. An error occurs when the credentials provided through the setCredentials function do not map to a user in a specified role.
The following sections show examples of ActionScript for setting credentials and security settings.
The following example shows ActionScript code that passes a username and password from a Flash application to a JRun server:
gatewayConnection = NetServices.createGatewayConnection();
gatewayConnection.setCredentials("Flash", "Flashpass");
The following example shows entries for the user named Flash and a role, FlashRole, to which the user belongs, using the default security implementation (jrun-users.xml file) for a JRun server:
<user>
<user-name>Flash</user-name> <password>Flashpass</password> </user> <role> <role-name>FlashRole</role-name> <user-name>Flash</user-name> </role>
The following example shows entries for the FlashRole role and corresponding EJB method permissions in an ejb-jar.xml file:
<assembly-descriptor>
<security-role>
<role-name>FlashRole</role-name>
</security-role>
<method-permission>
<role-name>FlashRole</role-name>
<method>
<ejb-name>SampleLoanBean</ejb-name>
<method-name>calculate</method-name>
</method>
</method-permission>
</assembly-descriptor>
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx/Using_Flash_Remoting_MX/usingFRJ2EE9.htm