VeriCheck.jws Sample

This topic inludes the source code for the VeriCheck.jws Sample.

Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/security/roleBased/

Sample Source Code


01 /** 
02  <p>The VeriCheck web service demonstrates the use of one-way SSL and basic authentication.
03  * Processing begins when a client invokes the VeriCheck
04  * web service through the checkForSufficientBalance method. VeriCheck then calls 
05  * the Bank web service to see if the specified checking account has sufficient 
06  * balance to cover the specified amount. When the Bank web service has completed 
07  * its results, it calls back the VeriCheck service via the callback onResultComplete.  
08  * Finally, the VeriCheck service calls back the original client through the callback 
09  * onCheckDone.</p>
10  *
11  * The Bank web service is restricted to users granted the BankUsers role.   
12  
13  <p><b>web.xml</b> associates particular users with groups. The user weblogic
14  * is declared as a member of the BankUsers group. This allows weblogic to pass the 
15  * servlet security gate when it invokes the Bank's method doesAccountHaveSufficientBalance.
16  */ 
17 
18 package security.roleBased; 
19 
20 import async.HelloWorldAsyncControl;
21 
22 /**
23  * @common:target-namespace namespace="http://workshop.bea.com/VeriCheck"
24  */
25 public class VeriCheck implements com.bea.jws.WebService
26 
27     /**
28      * @common:control
29      */
30     private security.roleBased.BankControl bankControl;
31 
32     public Callback callback;
33 
34     public interface Callback
35     {
36         /**
37          * @jws:conversation phase="finish"
38          */
39         public String onCheckDone(String checkingAccountID, String resultMessage);
40     }
41     
42     /**
43      <p>The VeriCheck web service takes requests for check verification from merchants.
44      
45      <p>The checking account number and the amount on the check are passed to the Bank
46      * web service.  The Bank web service returns a message saying whether or not there is 
47      * enough money in the account to cover the check.
48      
49      <p>Enter any String for the <b>checkingAccountID</b> parameter.
50      
51      <p>Enter any integer for the <b>amount</b> parameter.
52      
53      * @common:operation
54      * @jws:conversation phase="start"
55      * @jws:message-buffer enable="true"
56      */
57     public void checkForSufficientBalance(String checkingAccountID, int amount)
58     {  
59         /*
60          * Use the username and passwords assigned to the VeriCheck web service by the Bank.
61          * These allow VeriCheck to pass the Bank's security gate.
62          * 'weblogic' has been granted the role BankUser.
63          */ 
64         bankControl.setUsername("weblogic");
65         bankControl.setPassword("weblogic");
66         bankControl.doesAccountHaveSufficientBalance(checkingAccountID, amount);
67     }
68 
69     public void bankControl_onResultComplete(java.lang.String accountID, java.lang.String resultMessage)
70     {
71         callback.onCheckDone(accountID, resultMessage);
72     }
73