From 5d83de3646c6f1b07d2221f5586088deeca27d0a Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 6 Oct 2009 14:24:43 +0000 Subject: Branch for 1.5.2 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@822292 13f79535-47bb-0310-9956-ffa450edef68 --- branches/sca-java-1.5.2/demos/bigbank/README | 112 +++++ branches/sca-java-1.5.2/demos/bigbank/bigbank.png | Bin 0 -> 100070 bytes branches/sca-java-1.5.2/demos/bigbank/bigbank.svg | 537 +++++++++++++++++++++ .../sca-java-1.5.2/demos/bigbank/build-dojo.xml | 92 ++++ branches/sca-java-1.5.2/demos/bigbank/build.xml | 84 ++++ branches/sca-java-1.5.2/demos/bigbank/pom.xml | 201 ++++++++ .../main/java/bigbank/account/AccountService.java | 32 ++ .../java/bigbank/account/AccountServiceImpl.java | 99 ++++ .../java/bigbank/account/feed/AccountFeedImpl.java | 70 +++ .../main/java/bigbank/client/BigBankClient.java | 50 ++ .../src/main/java/bigbank/demo/BigBankServer.java | 130 +++++ .../security/BigbankPasswordCallbackHandler.java | 51 ++ .../main/java/calculator/CalculatorService.java | 34 ++ .../main/java/stockquote/StockQuoteService.java | 29 ++ .../bigbank/src/main/resources/BigBank.composite | 85 ++++ .../main/resources/META-INF/sca-contribution.xml | 36 ++ .../demos/bigbank/src/main/resources/bigbank.jks | Bin 0 -> 1986 bytes .../bigbank/src/main/resources/definitions.xml | 64 +++ .../bigbank/src/main/resources/security.properties | 20 + .../src/main/resources/web/AccountJSON.html | 92 ++++ .../demos/bigbank/src/main/resources/web/style.css | 22 + .../src/main/resources/wsdl/AccountService.wsdl | 91 ++++ .../src/test/java/test/BigBankTestCase.java | 33 ++ 23 files changed, 1964 insertions(+) create mode 100644 branches/sca-java-1.5.2/demos/bigbank/README create mode 100644 branches/sca-java-1.5.2/demos/bigbank/bigbank.png create mode 100644 branches/sca-java-1.5.2/demos/bigbank/bigbank.svg create mode 100644 branches/sca-java-1.5.2/demos/bigbank/build-dojo.xml create mode 100644 branches/sca-java-1.5.2/demos/bigbank/build.xml create mode 100644 branches/sca-java-1.5.2/demos/bigbank/pom.xml create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/AccountService.java create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/java/stockquote/StockQuoteService.java create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/resources/BigBank.composite create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/resources/bigbank.jks create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/resources/definitions.xml create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/resources/security.properties create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/resources/web/AccountJSON.html create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/resources/web/style.css create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl create mode 100644 branches/sca-java-1.5.2/demos/bigbank/src/test/java/test/BigBankTestCase.java (limited to 'branches/sca-java-1.5.2/demos/bigbank') diff --git a/branches/sca-java-1.5.2/demos/bigbank/README b/branches/sca-java-1.5.2/demos/bigbank/README new file mode 100644 index 0000000000..50df1e8296 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/README @@ -0,0 +1,112 @@ +BigBank Demo +============ + +This application is made of 3 modules that represent the different aspects +of a fictitious banking application. Please see bigbank.png for a diagram of this demo. + +To run the bigbank demo you need to first run bigbank-calculator and bigbank-stockquote composites. This will bring up Tuscany runtime and load the two applications and make them available as services. Bigbank-account is dependent on these services. + +To run this demo you need to use ant to compile and run the application. + +Start Bigbank-calculator composite +---------------------------------- + +Bigbank-calculator is a calculator application which handles add, subtract, multiply and divide operations. Each of these operations is implemented in a different language, including JavaScript, groovy, Ruby and Python. + +To run the bigbank-calculator composite and make it available as a service for this demo do the following: + +cd bigbank-calculator +ant run + +.. Leave the server running + + +Start Bigbank-stockquote +------------------------ + +A very simple web services based stock quote application which returns random +stock quotes on request. Please note that the stockquote service is not live and is implemented instead to allow for this application to always run without dependency on the availability of a webservice. + +cd bigbank-stockquote +ant run + +.. Leave the server running + + +Start Bigbank +------------- +The BigBank comprises of two subsystems that are built from two distinct contributions coming from ... +1) bigbank + This contains all artifacts that make up the bigbank application. This is the application that the + end user interacts with + +2) bigbank-account + This contains all artifacts that deal with the account management within the bigbank. The services + offered by the bigbank-account module are used by the bigbank. The end user never gets to directly + interact with bigbank account + +Besides the bigbank-account the bigbank composite application calls into bigbank-stockquote and +bigbank-calculator services. + +Start bigbank application in the following way: + +cd bigbank +ant run + +.. Leave the server running + +Bigbank and the SCA Policies +---------------------------- +The Bigbank demo uses the Tuscany PolicyFramework to enforce security in the following ways: + +Authentication +-------------- + The bigbank-account subsystem enforces authentication as a required security characteristic for + all interactions with its CheckingAccountService. Hence the 'bigbank' application which is a client + to this service authenticates itself for every interaction with the CheckingAccountService. The interaction + between the bigbank and the CheckingAccountService is over the ws binding. + +Integrity +--------- + All interactions of the bigbank application with the StockQuoteService are guarded with message integrity. + These interactions use the ws binding. + +Authorization +------------- + Within the bigbank-account subsystem the CheckingAccountService implementation enforces authorization on + its operations. This is an instance of a custom policy enforcement i.e. the CheckingAccountService + component's implementation has defined its own customized way of authorizing access to its services. + +Demonstrated features +--------------------- +This demo is to illustrate the following : - +- composition of an application using artifacts belonging to multiple contributions (here two) +- usage of sca policies in composite definitions with specific emphasis on enabling security + + +Run the demo +------------- +The front end of this demo application is a web app which users Json/RPC to communicate with the backend for retrieving account information. + +To try the app out point you browser at: + +http://localhost:8085/AccountJSON.html + +This should display an interface with a single button that goes and retrieves +a single set of account details exercising services across the three running +SCA applications. + +If you press on getAccountReport, you'll see a response posted, +but the detail of the data will be displayed in the console where you started bigbank. Among other +things you will note messages that confirm the enforecement of AUTHENTICATION, AUTHORIZATION and +SIGNING of messages exchaged. + +On the console where you have started the StockQuote Service you should again be able to see messages +that confirm the signing of messages exchanged. + +Stop the demo +------------- +Go to each of the corresponding command line screens and hit 'enter'. +This will stop each of the applications. + + diff --git a/branches/sca-java-1.5.2/demos/bigbank/bigbank.png b/branches/sca-java-1.5.2/demos/bigbank/bigbank.png new file mode 100644 index 0000000000..985cc6bd05 Binary files /dev/null and b/branches/sca-java-1.5.2/demos/bigbank/bigbank.png differ diff --git a/branches/sca-java-1.5.2/demos/bigbank/bigbank.svg b/branches/sca-java-1.5.2/demos/bigbank/bigbank.svg new file mode 100644 index 0000000000..30aa0eab6d --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/bigbank.svg @@ -0,0 +1,537 @@ + + + + + + + + + + image/svg+xml + + + + + + + + CompositeBigBank WebApp + + Component AccountJava + + + + Component AccountDataJava + binding.jsonrpc + binding.ws + binding.rmi + + + + CompositeStockQuote + + CompositeCalculator + + Component CalculatorJava + + + + Component AddJavascript + binding.rmi + + + Component SubtractRuby + + Component MultiplyPython + + Component DivideGroovy + + + + Component StockQuoteJava + + binding.ws + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.5.2/demos/bigbank/build-dojo.xml b/branches/sca-java-1.5.2/demos/bigbank/build-dojo.xml new file mode 100644 index 0000000000..8ef86445a0 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/build-dojo.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.5.2/demos/bigbank/build.xml b/branches/sca-java-1.5.2/demos/bigbank/build.xml new file mode 100644 index 0000000000..81fb704d4d --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/build.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.5.2/demos/bigbank/pom.xml b/branches/sca-java-1.5.2/demos/bigbank/pom.xml new file mode 100644 index 0000000000..1e4c2df83e --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/pom.xml @@ -0,0 +1,201 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-demos + 1.5.1-SNAPSHOT + ../pom.xml + + demo-bigbank + jar + Apache Tuscany SCA Demo BigBank + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.5.1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 1.5.1-SNAPSHOT + + + + org.apache.ws.security + wss4j + 1.5.3 + + + + org.apache.tuscany.sca + demo-bigbank-account + 1.5.1-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.5.1-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-atom-abdera + 1.5.1-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rss-rome + 1.5.1-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.5.1-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 1.5.1-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 1.5.1-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.5.1-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.5.1-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.5.1-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + + + demo-bigbank + + + org.apache.maven.plugins + maven-antrun-plugin + + + + ant + ant-trax + 1.6.5 + + + + + + install-dojo + validate + + run + + + + + + + + + + + copy-dojo-files + generate-resources + + run + + + + + + + + + + + + clean-dojo-files + clean + + run + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/AccountService.java b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/AccountService.java new file mode 100644 index 0000000000..2cb8027874 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/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$$ $$Date$$ + */ + +@Remotable +public interface AccountService { + + public double getAccountReport(String customerID); + +} diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..4f0e3879dc --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/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$$ $$Date$$ + */ + +@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.5.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java new file mode 100644 index 0000000000..13d79a9c33 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/account/feed/AccountFeedImpl.java @@ -0,0 +1,70 @@ +/* + * 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 org.apache.tuscany.sca.data.collection.Collection; +import org.apache.tuscany.sca.data.collection.Entry; +import org.apache.tuscany.sca.data.collection.NotFoundException; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import bigbank.account.AccountService; + +/** + * @version $$Rev$$ $$Date$$ + */ + +@Service(Collection.class) +public class AccountFeedImpl implements Collection { + + @Reference + protected AccountService accountService; + + public Entry[] getAll() { + + // Add the Account report entry + String report = get("1234"); + Entry entry = new Entry("1234", report); + + return new Entry[] { entry } ; + } + + public String get(String id) { + + // Get the account report for the specified customer ID + double balance = accountService.getAccountReport(id); + String report = Double.toString(balance); + + return report; + } + + public void delete(String key) throws NotFoundException { + } + + public String post(String key, String item) { + return null; + } + + public void put(String key, String item) throws NotFoundException { + } + + public Entry[] query(String queryString) { + return null; + } +} diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/client/BigBankClient.java new file mode 100644 index 0000000000..a7fa5ecc22 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/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 = "1234"; + + 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.5.2/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java new file mode 100644 index 0000000000..05360e07a5 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/demo/BigBankServer.java @@ -0,0 +1,130 @@ +/* + * 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 java.net.MalformedURLException; +import java.net.URL; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.service.ContributionService; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain; + +import bigbank.account.savings.SavingsAccountService; + + + +/** + * 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..."); + ClassLoader cl = BigBankServer.class.getClassLoader(); + EmbeddedSCADomain domain = new EmbeddedSCADomain(cl, "http://localhost"); + + //Start the domain + domain.start(); + + // Contribute the SCA contribution + ContributionService contributionService = domain.getContributionService(); + + URL javaContribURL = getContributionURL(SavingsAccountService.class); + Contribution bigbankAcContribution = contributionService.contribute("http://bigbank-account", javaContribURL, false); + for (Composite deployable : bigbankAcContribution.getDeployables()) { + domain.getDomainComposite().getIncludes().add(deployable); + domain.buildComposite(deployable); + } + + URL bigbankContribUrl = getContributionURL(BigBankServer.class); + Contribution bigbankContribution = contributionService.contribute("http://bigbank", bigbankContribUrl, false); + for (Composite deployable : bigbankContribution.getDeployables()) { + domain.getDomainComposite().getIncludes().add(deployable); + domain.buildComposite(deployable); + } + + + //Start Components from composite + for (Composite deployable : bigbankAcContribution.getDeployables()) { + domain.getCompositeActivator().activate(deployable); + domain.getCompositeActivator().start(deployable); + } + + for (Composite deployable : bigbankContribution.getDeployables()) { + domain.getCompositeActivator().activate(deployable); + domain.getCompositeActivator().start(deployable); + } + + if (timeout < 0) { + System.out.println("Press Enter to Exit..."); + System.in.read(); + } else { + Thread.sleep(timeout); + } + + contributionService.remove("http://bigbank-account"); + contributionService.remove("http://bigbank"); + + // Stop Components from composite + for (Composite deployable : bigbankContribution.getDeployables()) { + domain.getCompositeActivator().stop(deployable); + domain.getCompositeActivator().deactivate(deployable); + } + + domain.stop(); + + domain.close(); + + + /*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"); + } + + private static URL getContributionURL(Class cls) throws MalformedURLException { + String flag = "/" + cls.getName().replace('.', '/') + ".class"; + URL url = cls.getResource(flag); + String root = url.toExternalForm(); + root = root.substring(0, root.length() - flag.length() + 1); + if (root.startsWith("jar:") && root.endsWith("!/")) { + root = root.substring(4, root.length() - 2); + } + url = new URL(root); + return url; + } + +} diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/bigbank/security/BigbankPasswordCallbackHandler.java new file mode 100644 index 0000000000..6d3b547939 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/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.5.2/demos/bigbank/src/main/java/calculator/CalculatorService.java b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,34 @@ +/* + * 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 calculator; + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/java/stockquote/StockQuoteService.java b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..749b8ee2f4 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/java/stockquote/StockQuoteService.java @@ -0,0 +1,29 @@ +/* + * 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 stockquote; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the StockQuote service. + */ +@Remotable +public interface StockQuoteService { + public double getQuote(String symbol); +} diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/BigBank.composite b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..11591308b4 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/BigBank.composite @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EURO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..154992c843 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/bigbank.jks b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/bigbank.jks new file mode 100644 index 0000000000..e6294d85f7 Binary files /dev/null and b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/bigbank.jks differ diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/definitions.xml b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/definitions.xml new file mode 100644 index 0000000000..8654151d82 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/definitions.xml @@ -0,0 +1,64 @@ + + + + + + + + + + Timestamp Signature + security.properties + + + + + Timestamp Signature + bbservice + security.properties + bigbank.security.BigbankPasswordCallbackHandler + DirectReference + + + + + + + + + + UsernameToken + bbaservice + bigbank.security.BigbankPasswordCallbackHandler + PasswordText + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/security.properties b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/security.properties new file mode 100644 index 0000000000..d1b489acbb --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/security.properties @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin +org.apache.ws.security.crypto.merlin.keystore.type=jks +org.apache.ws.security.crypto.merlin.keystore.password=bbakeystore +org.apache.ws.security.crypto.merlin.file=bigbank.jks diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/web/AccountJSON.html b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/web/AccountJSON.html new file mode 100644 index 0000000000..9f4368443f --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/web/AccountJSON.html @@ -0,0 +1,92 @@ + + + +Tuscany JSON-RPC BigBank Client + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Tuscany JSON-RPC BigBank Client
+

This example uses the Dojo + Toolkit to create a JavaScript object accountService for + the service at http://localhost:8080/AccountJSONService using Dojo's + RPC classes and providing them with http://localhost:8080/AccountJSONService?smd + for Simple Method Description + (SMD) input.

+

It then creates a Dojo button that will envoke the getAccountReport + method of the accountService object.

+
RequestResponse

+ +
+
+
None Yet.
+
+
Dojo Debug:
+
+ + + + + diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/web/style.css b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/web/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/web/style.css @@ -0,0 +1,22 @@ +/* + * 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. + */ +* { font-family: arial; } + +table, th, td { border: 2px solid blue; border-collapse: collapse; } +th { color: white; background-color: blue; } diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl new file mode 100644 index 0000000000..ac4d987a57 --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/main/resources/wsdl/AccountService.wsdl @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.5.2/demos/bigbank/src/test/java/test/BigBankTestCase.java b/branches/sca-java-1.5.2/demos/bigbank/src/test/java/test/BigBankTestCase.java new file mode 100644 index 0000000000..3b7c5ef2ad --- /dev/null +++ b/branches/sca-java-1.5.2/demos/bigbank/src/test/java/test/BigBankTestCase.java @@ -0,0 +1,33 @@ +/* + * 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 test; + +import junit.framework.TestCase; + +import bigbank.demo.BigBankServer; + +/** + * @version $Rev$ $Date$ + */ +public class BigBankTestCase extends TestCase { + + public void testServer() throws Exception { + BigBankServer.main(new String[] {"1000"}); + } +} -- cgit v1.2.3