You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2007/12/03 16:23:41 UTC

svn commit: r600563 - in /incubator/tuscany/java/sca/demos/secure-bigbank: secure-bigbank-account/ secure-bigbank-account/src/main/java/bigbank/account/ secure-bigbank-account/src/main/java/bigbank/accountdata/ secure-bigbank-account/src/main/java/bigb...

Author: svkrish
Date: Mon Dec  3 07:23:38 2007
New Revision: 600563

URL: http://svn.apache.org/viewvc?rev=600563&view=rev
Log:
making Accounts

Added:
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java
Removed:
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/PasswordCallbackHandler.java
Modified:
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/   (props changed)
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/AccountDataService.java
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/StockAccount.java
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/AccountData.composite
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/BigBank.composite
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/definitions.xml
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-calculator/   (props changed)
    incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-stockquote/   (props changed)

Propchange: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Dec  3 07:23:38 2007
@@ -0,0 +1,14 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+

Modified: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java?rev=600563&r1=600562&r2=600563&view=diff
==============================================================================
--- incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java (original)
+++ incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java Mon Dec  3 07:23:38 2007
@@ -52,7 +52,10 @@
 
         // Get the checking, savings and stock accounts from the AccountData
         // service component
-        CheckingAccount checking = accountDataService.getCheckingAccount(customerID);
+        CheckingAccount checking = null;
+        try {
+            checking = accountDataService.getCheckingAccount(customerID);
+        
         System.out.println("Checking account: " + checking);
 
         SavingsAccount savings = accountDataService.getSavingsAccount(customerID);
@@ -64,7 +67,7 @@
         // Get the stock price in USD
         double price = stockQuoteService.getQuote(stock.getSymbol());
         System.out.println("Stock price for " + stock.getSymbol() + ": " + price);
-
+        
         // Convert to the configured currency
         if (currency.equals("EURO")) {
             
@@ -81,5 +84,9 @@
         double balance = checking.getBalance() + savings.getBalance() + stockValue;
         
         return balance;
+        } catch ( Throwable e ) {
+            e.printStackTrace();
+            return 0;
+        }
     }
 }

Modified: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/AccountDataService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/AccountDataService.java?rev=600563&r1=600562&r2=600563&view=diff
==============================================================================
--- incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/AccountDataService.java (original)
+++ incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/AccountDataService.java Mon Dec  3 07:23:38 2007
@@ -18,10 +18,12 @@
  */
 package bigbank.accountdata;
 
+import org.osoa.sca.annotations.Remotable;
+
 /**
  * @version $$Rev: 540764 $$ $$Date: 2007-05-23 03:17:57 +0530 (Wed, 23 May 2007) $$
  */
-
+@Remotable
 public interface AccountDataService {
     
     public CheckingAccount getCheckingAccount(String customerID);

Modified: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/StockAccount.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/StockAccount.java?rev=600563&r1=600562&r2=600563&view=diff
==============================================================================
--- incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/StockAccount.java (original)
+++ incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/accountdata/StockAccount.java Mon Dec  3 07:23:38 2007
@@ -36,7 +36,7 @@
         this.accountNumber = n;
     }
 
-    public double getQuantity() {
+    public int getQuantity() {
         return quantity;
     }
 

Added: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java?rev=600563&view=auto
==============================================================================
--- incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java (added)
+++ incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java Mon Dec  3 07:23:38 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package bigbank.security;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class 
+ */
+public class AccountsDataPasswordCallbackHandler implements CallbackHandler {
+
+    public void handle(Callback[] callbacks) throws IOException,
+            UnsupportedCallbackException {
+    	for (int i = 0; i < callbacks.length; i++) {
+            WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+            if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) {
+                System.out.println(" Usage is SIGNATURE ... ");
+                pwcb.setPassword("bbservice");
+            } else if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN ) {
+                System.out.println("*** Calling ACCOUNTS-DATA Passwd Handler for AUTHENTICATING userID = " 
+                                   + pwcb.getIdentifer() + " and password = " + pwcb.getPassword() );
+                if ( pwcb.getIdentifer().equals("bbaservice") && pwcb.getPassword().equals("bbaservice")) {
+                    System.out.println("AUTHENTICATION SUCCESSFUL!");
+                } else {
+                    System.out.println("AUTHENTICATION FAILED!");
+                    throw new UnsupportedCallbackException(pwcb, "UserId - Password Authentication Failed!");
+                }
+            }
+        }
+    }
+
+}

Added: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java?rev=600563&view=auto
==============================================================================
--- incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java (added)
+++ incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java Mon Dec  3 07:23:38 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package bigbank.security;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class 
+ */
+public class BigbankPasswordCallbackHandler implements CallbackHandler {
+
+    public void handle(Callback[] callbacks) throws IOException,
+            UnsupportedCallbackException {
+    	for (int i = 0; i < callbacks.length; i++) {
+            WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+            //System.out.println("*** Getting password for user ...."  + pwcb.getIdentifer() + " & " + pwcb.getKey());
+            if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) {
+                System.out.println("*** Calling BIG-BANK Passwd Handler for SIGNING...." );
+                pwcb.setPassword("bbservice");
+            } else if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN ) {
+                if ( pwcb.getIdentifer().equals("bbaservice")) {
+                    System.out.println("*** Calling BIG-BANK Passwd Handler for setting AUTHENTICATION password...." );
+                    pwcb.setPassword("bbaservice");
+                }
+            }
+        }
+    }
+
+}

Modified: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/AccountData.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/AccountData.composite?rev=600563&r1=600562&r2=600563&view=diff
==============================================================================
--- incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/AccountData.composite (original)
+++ incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/AccountData.composite Mon Dec  3 07:23:38 2007
@@ -24,6 +24,7 @@
 
     <service name="AccountDataService" promote="AccountDataServiceComponent">
         <interface.java interface="bigbank.accountdata.AccountDataService"/>
+        <binding.ws uri="http://localhost:8085/services/AccountDataWebService" requires="authentication"/>
     </service>
 
     <component name="AccountDataServiceComponent">

Modified: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/BigBank.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/BigBank.composite?rev=600563&r1=600562&r2=600563&view=diff
==============================================================================
--- incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/BigBank.composite (original)
+++ incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/BigBank.composite Mon Dec  3 07:23:38 2007
@@ -32,7 +32,12 @@
 			<binding.sca/>
 	    </service>
 
-        <reference name="accountDataService" target="AccountDataServiceComponent"/>
+        <!-- reference name="accountDataService" target="AccountDataServiceComponent"/-->
+        
+        <reference name="accountDataService">
+	        <binding.ws uri="http://localhost:8084/services/AccountDataWebService" requires="tuscany:wsAuthentication"/>
+        </reference>
+        
 	    <reference name="calculatorService">
 	    	<tuscany:binding.rmi host="localhost" port="8099" serviceName="CalculatorRMIService"/>
 	   	</reference>

Modified: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/definitions.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/definitions.xml?rev=600563&r1=600562&r2=600563&view=diff
==============================================================================
--- incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/definitions.xml (original)
+++ incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-account/src/main/resources/definitions.xml Mon Dec  3 07:23:38 2007
@@ -51,8 +51,22 @@
  			 </description>
  </sca:intent>
  
+ <sca:intent name="authentication" 
+ 			 constrains="sca:binding.ws">
+ 			 <description>
+ 			 Communitcation thro this binding required Authentication.
+ 			 </description>
+ </sca:intent>
+ 
+ <sca:intent name="tuscany:wsAuthentication" 
+ 			 constrains="sca:binding.ws">
+ 			 <description>
+ 			 Communitcation thro this binding required Authentication.
+ 			 </description>
+ </sca:intent>
+ 
  <!-- WS Security POLICY SETS -->
- <sca:policySet name="wsIntegrityPolicy"
+ <sca:policySet name="tuscany:wsIntegrityPolicy"
  	provides="integrity"
  	appliesTo="sca:binding.ws">
  	<tuscany:wsConfigParam>
@@ -67,10 +81,39 @@
         		<items>Timestamp Signature</items>
         		<user>bbservice</user>
         		<signaturePropFile>security.properties</signaturePropFile>
-        		<passwordCallbackClass>bigbank.account.PasswordCallbackHandler</passwordCallbackClass>
+        		<passwordCallbackClass>bigbank.security.BigbankPasswordCallbackHandler</passwordCallbackClass>
         		<signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
       		</action>
     	</parameter>
  	</tuscany:wsConfigParam>
  </sca:policySet>
- </sca:definitions>
\ No newline at end of file
+ 
+ <sca:policySet name="tuscany:wsAuthenticationPolicy"
+ 	provides="authentication"
+ 	appliesTo="sca:binding.ws">
+ 	<tuscany:wsConfigParam>
+ 		<parameter name="InflowSecurity">
+ 			<action>
+ 				<items>UsernameToken</items>
+ 				<passwordCallbackClass>bigbank.security.AccountsDataPasswordCallbackHandler</passwordCallbackClass>
+       		</action>
+      	</parameter>
+ 	</tuscany:wsConfigParam>
+ </sca:policySet>
+ 
+ <sca:policySet name="tuscany:wsClientAuthenticationPolicy"
+ 	provides="tuscany:wsAuthentication"
+ 	appliesTo="sca:binding.ws">
+ 	<tuscany:wsConfigParam>
+ 		<parameter name="OutflowSecurity">
+ 			<action>
+ 				<items>UsernameToken</items>
+ 				<user>bbaservice</user>
+				<passwordCallbackClass>bigbank.security.BigbankPasswordCallbackHandler</passwordCallbackClass>
+                <passwordType>PasswordText</passwordType>
+               </action>
+    	</parameter>
+ 	</tuscany:wsConfigParam>
+ </sca:policySet>
+ 
+</sca:definitions>
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-calculator/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Dec  3 07:23:38 2007
@@ -0,0 +1,14 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+

Propchange: incubator/tuscany/java/sca/demos/secure-bigbank/secure-bigbank-stockquote/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Dec  3 07:23:38 2007
@@ -0,0 +1,14 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org