Using Flash Remoting with JRun security
139
You can use the following ActionScript code to get the value of the LoanInfo bean’s
MonthlyPayment
property, or handle a fault condition:
function calculateReturnComplex_Result (re:ResultEvent):Void
{
payOutput.text = re.result.monthlyPayment;
}
function calculateReturnComplex_Fault (fe:FaultEvent):Void
{
mx.remoting.debug.NetDebug.trace({level:"None", message:"There was a
problem" + fe.fault.faultstring});
}
For detailed information about the ActionScript result-handling hierarchy and result-handling
strategies, see
Chapter 2, “Handling service results and errors,” on page 43
.
Using Flash Remoting with JRun security
You can use the
setCredentials()
method of the Connection class in ActionScript to
authenticate Flash users to a JRun 4 server and authorize them to access EJBs after they are
authenticated. When a user cannot be authenticated, the default fault handling method on the
client can provide details.
All of the gateway adapters support authentication, but only the EJB adapter supports
authorization. After a user is 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()
method do not map to a user in a
specified role.
The following sections show examples of ActionScript for setting credentials and security settings.
Looking at the ActionScript authentication code
The following example shows ActionScript code that passes a user name and password from a
Flash application to a JRun server:
var con1:Connection = new Connection();
con1.connect("http://examples.macromedia.com/flashservices/gateway/");
con1.setCredentials("Flash", "Flashpass");
Looking at the JRun security settings
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>