summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank
diff options
context:
space:
mode:
authordims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
committerdims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
commitbdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch)
tree38a92061c0793434c4be189f1d70c3458b6bc41d /branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank')
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountService.java32
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java99
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java50
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java35
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java66
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java94
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java52
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java35
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java66
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java68
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java36
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java60
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/client/BigBankClient.java50
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/demo/BigBankServer.java51
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java54
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankCheckingsAcl.java48
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java51
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthPolicy.java27
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthorizationPolicyHandler.java65
-rw-r--r--branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthorizationPolicyProcessor.java81
20 files changed, 1120 insertions, 0 deletions
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountService.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountService.java
new file mode 100644
index 0000000000..1ae9c9f682
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountService.java
@@ -0,0 +1,32 @@
+/*
+ * 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.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * @version $$Rev: 573144 $$ $$Date: 2007-09-06 09:25:24 +0530 (Thu, 06 Sep 2007) $$
+ */
+
+@Remotable
+public interface AccountService {
+
+ public double getAccountReport(String customerID);
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java
new file mode 100644
index 0000000000..aca34669cc
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/AccountServiceImpl.java
@@ -0,0 +1,99 @@
+/*
+ * 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.account;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import stockquote.StockQuoteService;
+import bigbank.account.checking.CheckingAccountDetails;
+import bigbank.account.checking.CheckingAccountService;
+import bigbank.account.savings.SavingsAccountDetails;
+import bigbank.account.savings.SavingsAccountService;
+import bigbank.account.stock.StockAccountDetails;
+import bigbank.account.stock.StockAccountService;
+import calculator.CalculatorService;
+
+/**
+ * @version $$Rev: 540764 $$ $$Date: 2007-05-23 03:17:57 +0530 (Wed, 23 May 2007) $$
+ */
+
+@Service(AccountService.class)
+public class AccountServiceImpl implements AccountService {
+
+ @Reference
+ protected SavingsAccountService savingsAcService;
+
+ @Reference
+ protected CheckingAccountService checkingAcService;
+
+ @Reference
+ protected StockAccountService stockAcService;
+
+ @Reference
+ protected StockQuoteService stockQuoteService;
+
+ @Reference
+ protected CalculatorService calculatorService;
+
+ @Property
+ protected String currency;
+
+ public double getAccountReport(String customerID) {
+
+ // Get the checking, savings and stock accounts from the AccountData
+ // service component
+ CheckingAccountDetails checking = null;
+ try {
+ checking = checkingAcService.getAccountDetails(customerID);
+ System.out.println("Checking account: " + checking);
+
+ SavingsAccountDetails savings = savingsAcService.getAccountDetails(customerID);
+ System.out.println("Savings account: " + savings);
+
+ StockAccountDetails stock = stockAcService.getAccountDetails(customerID);
+ System.out.println("Stock account: " + stock);
+
+ // 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")) {
+
+ // Use our fancy calculator service to convert to the target currency
+ price = calculatorService.multiply(price, 0.70);
+
+ System.out.println("Converted to " + currency + ": " + price);
+ }
+
+ // Calculate the value of the stock account
+ double stockValue = price * stock.getQuantity();
+
+ // Calculate the total balance of all accounts and return it
+ double balance = checking.getBalance() + savings.getBalance() + stockValue;
+
+ return balance;
+ } catch ( Throwable e ) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java
new file mode 100644
index 0000000000..2a1d26a275
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountDetails.java
@@ -0,0 +1,50 @@
+/*
+ * 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.account.checking;
+
+/**
+ * @version $$Rev: 567543 $$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr
+ * 2007) $$
+ */
+
+public class CheckingAccountDetails {
+ private String accountNumber;
+ private double balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(double b) {
+ this.balance = b;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", balance:" + balance;
+ }
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java
new file mode 100644
index 0000000000..7017cc076c
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountService.java
@@ -0,0 +1,35 @@
+/*
+ * 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.account.checking;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * @version $$Rev: 540764 $$ $$Date: 2007-05-23 03:17:57 +0530 (Wed, 23 May 2007) $$
+ */
+@Remotable
+public interface CheckingAccountService {
+
+ public CheckingAccountDetails getAccountDetails(String customerID);
+
+ public double deposit(String accountNo, double depositAmt);
+
+ public double withdraw(String accountNo, double withdrawalAmount);
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java
new file mode 100644
index 0000000000..a18a4920b8
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/checking/CheckingAccountServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * 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.account.checking;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ *
+ * */
+
+@Service(CheckingAccountService.class)
+public class CheckingAccountServiceImpl implements CheckingAccountService {
+ private Map<String, String> custAcctMap = new HashMap<String, String>();
+ private Map<String, Double> checkingAccts = new HashMap<String, Double>();
+
+ public CheckingAccountServiceImpl() {
+ custAcctMap.put("Customer_01", "CHA_Customer_01");
+ custAcctMap.put("Customer_02", "CHA_Customer_02");
+ custAcctMap.put("Customer_03", "CHA_Customer_03");
+
+ checkingAccts.put("CHA_Customer_01", new Double(1000));
+ checkingAccts.put("CHA_Customer_02", new Double(1500));
+ checkingAccts.put("CHA_Customer_03", new Double(2000));
+ }
+
+ public double deposit(String accountNo, double depositAmt) {
+ checkingAccts.put(accountNo, new Double(checkingAccts.get(accountNo).doubleValue() + depositAmt));
+ return checkingAccts.get(accountNo).doubleValue();
+ }
+
+ public CheckingAccountDetails getAccountDetails(String customerID) {
+ CheckingAccountDetails checkingAccount = new CheckingAccountDetails();
+ checkingAccount.setAccountNumber(custAcctMap.get(customerID));
+ checkingAccount.setBalance(checkingAccts.get(checkingAccount.getAccountNumber()).doubleValue());
+
+ return checkingAccount;
+ }
+
+ public double withdraw(String accountNo, double withdrawalAmount) {
+ double balance = checkingAccts.get(accountNo).doubleValue();
+ if ( balance - withdrawalAmount > 0 ) {
+ balance = balance - withdrawalAmount;
+ checkingAccts.put(accountNo, balance);
+ }
+ return balance;
+ }
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java
new file mode 100644
index 0000000000..4c9decf5c6
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/feed/AccountFeedImpl.java
@@ -0,0 +1,94 @@
+/*
+ * 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.account.feed;
+
+import java.util.Collections;
+
+import org.apache.tuscany.sca.binding.feed.collection.Collection;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+import bigbank.account.AccountService;
+
+import com.sun.syndication.feed.atom.Content;
+import com.sun.syndication.feed.atom.Entry;
+import com.sun.syndication.feed.atom.Feed;
+import com.sun.syndication.feed.atom.Link;
+
+/**
+ * @version $$Rev: 592280 $$ $$Date: 2007-11-06 10:29:48 +0530 (Tue, 06 Nov 2007) $$
+ */
+
+@Service(Collection.class)
+public class AccountFeedImpl implements Collection {
+
+ @Reference
+ protected AccountService accountService;
+
+ @SuppressWarnings("unchecked")
+ public com.sun.syndication.feed.atom.Feed getFeed() {
+
+ // Create a new Feed
+ Feed feed = new Feed();
+ feed.setId("accounts");
+ feed.setTitle("Account Report Feed");
+ Content subtitle = new Content();
+ subtitle.setValue("This is a sample feed");
+ feed.setSubtitle(subtitle);
+ Link link = new Link();
+ link.setHref("http://incubator.apache.org/tuscany");
+ feed.getAlternateLinks().add(link);
+
+ // Add the Account report entry
+ Entry entry = get("1234");
+ feed.getEntries().add(entry);
+
+ return feed;
+ }
+
+ public void delete(String id) {
+ }
+
+ public Entry get(String id) {
+
+ // Get the account report for the specified customer ID
+ double balance = accountService.getAccountReport(id);
+ String value = Double.toString(balance);
+
+ Entry entry = new Entry();
+ entry.setId("account-" + id);
+ entry.setTitle("Account Report Entry");
+ Content summary = new Content();
+ summary.setType(Content.HTML);
+ summary.setValue("This is your account report: <b>" + value + "</b>");
+ entry.setSummary(summary);
+ Content content = new Content();
+ content.setValue(value);
+ entry.setContents(Collections.singletonList(content));
+ return entry;
+ }
+
+ public Entry post(Entry entry) {
+ return null;
+ }
+
+ public void put(String id, Entry entry) {
+ }
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java
new file mode 100644
index 0000000000..815b26dc4c
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountDetails.java
@@ -0,0 +1,52 @@
+/*
+ * 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.account.savings;
+
+import java.io.Serializable;
+
+/**
+ * @version $$Rev: 567543 $$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr
+ * 2007) $$
+ */
+
+public class SavingsAccountDetails implements Serializable {
+ private String accountNumber;
+ private double balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(double b) {
+ this.balance = b;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", balance:" + balance;
+ }
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java
new file mode 100644
index 0000000000..b7f375e859
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountService.java
@@ -0,0 +1,35 @@
+/*
+ * 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.account.savings;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * @version $$Rev: 540764 $$ $$Date: 2007-05-23 03:17:57 +0530 (Wed, 23 May 2007) $$
+ */
+@Remotable
+public interface SavingsAccountService {
+
+ public SavingsAccountDetails getAccountDetails(String customerID);
+
+ public double deposit(String accountNo, double depositAmt);
+
+ public double withdraw(String accountNo, double withdrawalAmount);
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java
new file mode 100644
index 0000000000..fc01bc90c0
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/savings/SavingsAccountServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * 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.account.savings;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ *
+ * */
+
+@Service(SavingsAccountService.class)
+public class SavingsAccountServiceImpl implements SavingsAccountService {
+ private Map<String, String> custAcctMap = new HashMap<String, String>();
+ private Map<String, Double> savingsAccts = new HashMap<String, Double>();
+
+ public SavingsAccountServiceImpl() {
+ custAcctMap.put("Customer_01", "SVA_Customer_01");
+ custAcctMap.put("Customer_02", "SVA_Customer_02");
+ custAcctMap.put("Customer_03", "SVA_Customer_03");
+
+ savingsAccts.put("SVA_Customer_01", new Double(1000));
+ savingsAccts.put("SVA_Customer_02", new Double(1500));
+ savingsAccts.put("SVA_Customer_03", new Double(2000));
+ }
+
+ public double deposit(String accountNo, double depositAmt) {
+ savingsAccts.put(accountNo, new Double(savingsAccts.get(accountNo).doubleValue() + depositAmt));
+ return savingsAccts.get(accountNo).doubleValue();
+ }
+
+ public SavingsAccountDetails getAccountDetails(String customerID) {
+ SavingsAccountDetails savingsAccount = new SavingsAccountDetails();
+ savingsAccount.setAccountNumber(custAcctMap.get(customerID));
+ savingsAccount.setBalance(savingsAccts.get(savingsAccount.getAccountNumber()).doubleValue());
+
+ return savingsAccount;
+ }
+
+ public double withdraw(String accountNo, double withdrawalAmount) {
+ double balance = savingsAccts.get(accountNo).doubleValue();
+ if ( balance - withdrawalAmount > 0 ) {
+ balance = balance - withdrawalAmount;
+ savingsAccts.put(accountNo, balance);
+ }
+ return balance;
+ }
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java
new file mode 100644
index 0000000000..22eac41cc6
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountDetails.java
@@ -0,0 +1,68 @@
+/*
+ * 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.account.stock;
+
+/**
+ * @version $$Rev: 567543 $$ $$Date: 2007-04-09 12:03:34 -0700 (Mon, 09 Apr
+ * 2007) $$
+ */
+
+public class StockAccountDetails {
+ private String accountNumber;
+ private String symbol;
+ private int quantity;
+
+ public StockAccountDetails() {
+ }
+
+ public StockAccountDetails(String acNo, String symbol, int qty) {
+ this.accountNumber = acNo;
+ this.symbol = symbol;
+ this.quantity = qty;
+ }
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String n) {
+ this.accountNumber = n;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int a) {
+ this.quantity = a;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String s) {
+ this.symbol = s;
+ }
+
+ @Override
+ public String toString() {
+ return accountNumber + ", symbol:" + symbol + ", quantity:" + quantity;
+ }
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java
new file mode 100644
index 0000000000..f4503ff672
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountService.java
@@ -0,0 +1,36 @@
+/*
+ * 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.account.stock;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ *
+ */
+@Remotable
+public interface StockAccountService {
+
+ public StockAccountDetails getAccountDetails(String customerID);
+
+ public StockAccountDetails buy(String accountNo, String symbol, int quantity);
+
+ public StockAccountDetails sell(String accountNo, String symbol, int quantity);
+
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java
new file mode 100644
index 0000000000..505bff8826
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/account/stock/StockAccountServiceImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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.account.stock;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ *
+ * */
+
+@Service(StockAccountService.class)
+public class StockAccountServiceImpl implements StockAccountService {
+ private Map<String, String> custAcctMap = new HashMap<String, String>();
+ private Map<String, StockAccountDetails> stockAccts = new HashMap<String, StockAccountDetails>();
+
+ public StockAccountServiceImpl() {
+ custAcctMap.put("Customer_01", "STA_Customer_01");
+ custAcctMap.put("Customer_02", "STA_Customer_02");
+ custAcctMap.put("Customer_03", "STA_Customer_03");
+
+ stockAccts.put("STA_Customer_01", new StockAccountDetails("STA_Customer_01", "IBM", 100));
+ stockAccts.put("STA_Customer_02", new StockAccountDetails("STA_Customer_02", "IBM", 200));
+ stockAccts.put("STA_Customer_03", new StockAccountDetails("STA_Customer_03", "SYM_3", 125));
+ }
+
+
+ public StockAccountDetails buy(String accountNo, String symbol, int quantity) {
+ return null;
+ }
+
+ public StockAccountDetails getAccountDetails(String customerID) {
+ return stockAccts.get(custAcctMap.get(customerID));
+ }
+
+ public StockAccountDetails sell(String accountNo, String symbol, int quantity) {
+ return null;
+ }
+
+
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/client/BigBankClient.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/client/BigBankClient.java
new file mode 100644
index 0000000000..d5ebff5f13
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/client/BigBankClient.java
@@ -0,0 +1,50 @@
+/*
+ * 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.client;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import bigbank.account.AccountService;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class BigBankClient {
+
+ public static void main(String[] args) throws Exception {
+
+ SCADomain domain = SCADomain.newInstance("BigBank.composite");
+
+ AccountService accountService = domain.getService(AccountService.class, "AccountServiceComponent");
+
+ String customerID = "Customer_01";
+
+ System.out.println("Calling account service for customer: " + customerID);
+ System.out.println();
+ double balance = accountService.getAccountReport(customerID);
+
+ System.out.println();
+ System.out.println("Balance: " + balance);
+
+ domain.close();
+ }
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/demo/BigBankServer.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/demo/BigBankServer.java
new file mode 100644
index 0000000000..cb8da15686
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/demo/BigBankServer.java
@@ -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.demo;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class BigBankServer {
+
+ public static void main(String[] args) throws Exception {
+ long timeout = -1L;
+ if (args.length > 0) {
+ timeout = Long.parseLong(args[0]);
+ }
+ System.out.println("Starting the Sample SCA BigBank server...");
+
+ SCADomain domain = SCADomain.newInstance("BigBank.composite");
+
+ if (timeout < 0) {
+ System.out.println("Press Enter to Exit...");
+ System.in.read();
+ } else {
+ Thread.sleep(timeout);
+ }
+
+ domain.close();
+
+ System.out.println("Bye");
+ }
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java
new file mode 100644
index 0000000000..2e34fc6865
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/AccountsDataPasswordCallbackHandler.java
@@ -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!");
+ }
+ }
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankCheckingsAcl.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankCheckingsAcl.java
new file mode 100644
index 0000000000..272999ae98
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankCheckingsAcl.java
@@ -0,0 +1,48 @@
+/*
+ * 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.security.Principal;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BigbankCheckingsAcl {
+ private static Map<String, String>checkingsAcl = new Hashtable<String, String>();
+
+ static {
+ checkingsAcl.put("bbaservice", "Customer_01");
+ checkingsAcl.put("bbUser01", "Customer_01");
+ }
+
+
+ public static void authorize(Principal principal, String resource) {
+ if ( checkingsAcl.get(principal.getName()) == null ||
+ !checkingsAcl.get(principal.getName()).equals(resource) ) {
+ throw new RuntimeException("User - " + principal.getName() + " not authorized to access account " +
+ resource);
+ } else {
+ System.out.println("Successfully Authorized '" + principal.getName() + " to access accounts of " + resource);
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java
new file mode 100644
index 0000000000..c21a4fec5c
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java
@@ -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");
+ }
+ }
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthPolicy.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthPolicy.java
new file mode 100644
index 0000000000..27a1f93374
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthPolicy.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CheckingsDeptAuthPolicy {
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthorizationPolicyHandler.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthorizationPolicyHandler.java
new file mode 100644
index 0000000000..c0882b822b
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthorizationPolicyHandler.java
@@ -0,0 +1,65 @@
+/*
+ * 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.security.Principal;
+
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.util.PolicyHandler;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CheckingsDeptAuthorizationPolicyHandler implements PolicyHandler {
+ private PolicySet applicablePolicySet = null;
+
+ public void afterInvoke(Object... context) {
+ }
+
+ public void beforeInvoke(Object... context) {
+ for ( int count = 0 ; count < context.length ; ++count ) {
+ if ( context[count] instanceof Message ) {
+ Message msg = (Message)context[count];
+ Object args[] = (Object[])msg.getBody();
+ if ( msg.getQoSContext().get(Message.QOS_CTX_SECURITY_PRINCIPAL) != null ) {
+ BigbankCheckingsAcl.authorize((Principal)msg.getQoSContext().get(Message.QOS_CTX_SECURITY_PRINCIPAL),
+ (String)args[0]);
+ }
+ }
+ }
+ }
+
+ public void cleanUp(Object... arg0) {
+ }
+
+ public PolicySet getApplicablePolicySet() {
+ return this.applicablePolicySet;
+ }
+
+ public void setApplicablePolicySet(PolicySet policySet) {
+ this.applicablePolicySet = policySet;
+ }
+
+ public void setUp(Object... arg0) {
+
+ }
+
+}
diff --git a/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthorizationPolicyProcessor.java b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthorizationPolicyProcessor.java
new file mode 100644
index 0000000000..7f22e2e141
--- /dev/null
+++ b/branches/sca-java-1.1/demos/secure-bigbank/secure-bigbank-account/src/main/java/bigbank/security/CheckingsDeptAuthorizationPolicyProcessor.java
@@ -0,0 +1,81 @@
+/*
+ * 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 static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.logging.Level;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+
+/**
+ * @author administrator
+ *
+ */
+public class CheckingsDeptAuthorizationPolicyProcessor implements StAXArtifactProcessor<CheckingsDeptAuthPolicy> {
+ private static final QName CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME = new QName("http://bigbank/checkings", "AuthPolicy");
+ private static final String callbackHandler = "callbackHandler";
+ public static final QName CALLBACK_HANDLER_QNAME = new QName(Constants.SCA10_TUSCANY_NS,
+ callbackHandler);
+ public QName getArtifactType() {
+ return CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME;
+ }
+
+ public CheckingsDeptAuthorizationPolicyProcessor(ModelFactoryExtensionPoint modelFactories) {
+ }
+
+
+ public CheckingsDeptAuthPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ CheckingsDeptAuthPolicy policy = new CheckingsDeptAuthPolicy();
+ return policy;
+ }
+
+ public void write(CheckingsDeptAuthPolicy policy, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME.getLocalPart(),
+ CHECKINGS_DEPT_AUTHORIZATION_POLICY_QNAME.getNamespaceURI());
+ writer.writeNamespace("chk", "http://bigbank/checkings");
+
+
+ writer.writeEndElement();
+ }
+
+ public Class<CheckingsDeptAuthPolicy> getModelType() {
+ return CheckingsDeptAuthPolicy.class;
+ }
+
+ public void resolve(CheckingsDeptAuthPolicy arg0, ModelResolver arg1) throws ContributionResolveException {
+
+ }
+
+}