From 5d6ea66721914239e498c87d6cea79571328602e Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 13 Nov 2009 01:22:50 +0000 Subject: Removing obsolete release candidate tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835690 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/calculator/AddService.java | 28 ---- .../src/main/java/calculator/AddServiceImpl.java | 35 ---- .../src/main/java/calculator/CalculatorClient.java | 66 -------- .../main/java/calculator/CalculatorService.java | 35 ---- .../java/calculator/CalculatorServiceImpl.java | 70 -------- .../src/main/java/calculator/DivideService.java | 28 ---- .../main/java/calculator/DivideServiceImpl.java | 35 ---- .../src/main/java/calculator/MultiplyService.java | 28 ---- .../main/java/calculator/MultiplyServiceImpl.java | 35 ---- .../src/main/java/calculator/SubtractService.java | 28 ---- .../main/java/calculator/SubtractServiceImpl.java | 35 ---- .../security/CalculatorCallbackHandler.java | 50 ------ .../java/calculator/security/JaasLoginModule.java | 178 --------------------- .../java/calculator/security/UserPrincipal.java | 66 -------- .../src/main/resources/Calculator.composite | 61 ------- .../src/main/resources/CalculatorJass.config | 3 - .../resources/CalculatorLogMessages.properties | 18 --- .../src/main/resources/definitions.xml | 40 ----- .../test/java/calculator/CalculatorTestCase.java | 74 --------- 19 files changed, 913 deletions(-) delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/Calculator.composite delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/definitions.xml delete mode 100644 sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java (limited to 'sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src') diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java deleted file mode 100644 index 5a1e7a638a..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 Add service interface - */ -public interface AddService { - - double add(double n1, double n2); - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java deleted file mode 100644 index caf4d358df..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/AddServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of the Add service - */ -public class AddServiceImpl implements AddService { - - public double add(double n1, double n2) { - Logger logger = Logger.getLogger("calculator"); - logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); - return n1 + n2; - } - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java deleted file mode 100644 index 2bce187049..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorClient.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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; - -import javax.security.auth.login.Configuration; - -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 CalculatorClient { - public static void main(String[] args) throws Exception { - try { - Configuration secConf = Configuration.getConfiguration(); - } catch (java.lang.SecurityException e) { - System.setProperty("java.security.auth.login.config", CalculatorClient.class.getClassLoader() - .getResource("CalculatorJass.config").toString()); - } - - SCADomain scaDomain = SCADomain.newInstance("Calculator.composite"); - - CalculatorService calculatorService = - scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); - - // Calculate - System.out.println("Calling CalculatorServiceComponent configured with 'logging' " + - "policy for subtract and divide operations..."); - System.out.println("3 + 2=" + calculatorService.add(3, 2)); - System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); - System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); - System.out.println("3 / 2=" + calculatorService.divide(3, 2)); - - calculatorService = - scaDomain.getService(CalculatorService.class, "AnotherCalculatorServiceComponent"); - - // Calculate - System.out.println("Calling CalculatorServiceComponent configured with 'logging' " + - "for all operations in the implementation..."); - System.out.println("3 + 2=" + calculatorService.add(3, 2)); - System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); - System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); - System.out.println("3 / 2=" + calculatorService.divide(3, 2)); - - scaDomain.close(); - } - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java deleted file mode 100644 index ad87375529..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorService.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java deleted file mode 100644 index ae4ed12b7b..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/CalculatorServiceImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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; - -import org.osoa.sca.annotations.Reference; - - -/** - * An implementation of the Calculator service. - */ -public class CalculatorServiceImpl implements CalculatorService { - - private AddService addService; - private SubtractService subtractService; - private MultiplyService multiplyService; - private DivideService divideService; - - @Reference - public void setAddService(AddService addService) { - this.addService = addService; - } - - @Reference - public void setSubtractService(SubtractService subtractService) { - this.subtractService = subtractService; - } - - @Reference - public void setDivideService(DivideService divideService) { - this.divideService = divideService; - } - - @Reference - public void setMultiplyService(MultiplyService multiplyService) { - this.multiplyService = multiplyService; - } - - public double add(double n1, double n2) { - return addService.add(n1, n2); - } - - public double subtract(double n1, double n2) { - return subtractService.subtract(n1, n2); - } - - public double multiply(double n1, double n2) { - return multiplyService.multiply(n1, n2); - } - - public double divide(double n1, double n2) { - return divideService.divide(n1, n2); - } - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java deleted file mode 100644 index ef6a8b375b..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 divide service interface - */ -public interface DivideService { - - double divide(double n1, double n2); - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java deleted file mode 100644 index cd91935f08..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/DivideServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of the Divide service. - */ -public class DivideServiceImpl implements DivideService { - - public double divide(double n1, double n2) { - Logger logger = Logger.getLogger("calculator"); - logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); - return n1 / n2; - } - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java deleted file mode 100644 index db568cc762..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 interface for the multiply service - */ -public interface MultiplyService { - - double multiply(double n1, double n2); - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java deleted file mode 100644 index c85357fcd8..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/MultiplyServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of the Multiply service. - */ -public class MultiplyServiceImpl implements MultiplyService { - - public double multiply(double n1, double n2) { - Logger logger = Logger.getLogger("calculator"); - logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); - return n1 * n2; - } - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java deleted file mode 100644 index 56ee372fc4..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractService.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 interface for the multiply service - */ -public interface SubtractService { - - double subtract(double n1, double n2); - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java deleted file mode 100644 index 1b669084d9..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/SubtractServiceImpl.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of the subtract service. - */ -public class SubtractServiceImpl implements SubtractService { - - public double subtract(double n1, double n2) { - Logger logger = Logger.getLogger("calculator"); - logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); - return n1 - n2; - } - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java deleted file mode 100644 index b48fb90148..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/CalculatorCallbackHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.security; - -import java.io.IOException; - -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.UnsupportedCallbackException; - -/** - * @version $Rev$ $Date$ - */ -public class CalculatorCallbackHandler implements CallbackHandler { - - public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { - for (int i = 0; i < callbacks.length; i++) { - if (callbacks[i] instanceof NameCallback) { - NameCallback nc = (NameCallback)callbacks[i]; - nc.setName("CalculatorUser"); - } else if (callbacks[i] instanceof PasswordCallback) { - PasswordCallback pc = (PasswordCallback)callbacks[i]; - pc.setPassword("CalculatorUserPasswd".toCharArray()); - } else { - throw new UnsupportedCallbackException - (callbacks[i], "Unsupported Callback!"); - } - } - } - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java deleted file mode 100644 index fe4097640b..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/JaasLoginModule.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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.security; - -import java.security.Principal; -import java.util.Map; - -import javax.security.auth.Subject; -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.login.LoginException; -import javax.security.auth.spi.LoginModule; - -/** - * @version $Rev$ $Date$ - */ -public class JaasLoginModule implements LoginModule { - - private CallbackHandler callbackHandler; - private Subject subject; - private Principal userPrincipal; - private String userId; - private String password; - private boolean succeeded; - private boolean commitSucceeded; - - public void initialize(Subject subject, - CallbackHandler callbackHandler, - Map sharedState, - Map options) { - this.callbackHandler = callbackHandler; - this.subject = subject; - } - - public boolean login() throws LoginException { - Callback[] callbacks = new Callback[2]; - callbacks[0] = new NameCallback("UserId:"); - callbacks[1] = new PasswordCallback("Password:", false); - - try { - callbackHandler.handle(callbacks); - userId = ((NameCallback)callbacks[0]).getName(); - password = new String(((PasswordCallback)callbacks[1]).getPassword()); - - if (userId.equals("CalculatorUser") && password.equals("CalculatorUserPasswd")) { - System.out.println("Successfully AUTHENTICATED!!"); - succeeded = true; - return true; - } else { - System.out.println("Incorrect userId / password! AUTHENTICATION FAILED!!"); - return false; - } - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - /** - *

This method is called if the LoginContext's - * overall authentication succeeded - * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules - * succeeded). - * - *

If this LoginModule's own authentication attempt - * succeeded (checked by retrieving the private state saved by the - * login method), then this method associates a - * UserPrincipal - * with the Subject located in the - * LoginModule. If this LoginModule's own - * authentication attempted failed, then this method removes - * any state that was originally saved. - * - *

- * - * @exception LoginException if the commit fails. - * - * @return true if this LoginModule's own login and commit - * attempts succeeded, or false otherwise. - */ - public boolean commit() throws LoginException { - if (succeeded == false) { - return false; - } else { - // add a Principal (authenticated identity) to the Subject - - // assume the user we authenticated is the UserPrincipal - userPrincipal = new UserPrincipal(userId); - if (!subject.getPrincipals().contains(userPrincipal)) - subject.getPrincipals().add(userPrincipal); - - // in any case, clean out state - userId = null; - password = null; - commitSucceeded = true; - return true; - } - } - - /** - *

This method is called if the LoginContext's - * overall authentication failed. - * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules - * did not succeed). - * - *

If this LoginModule's own authentication attempt - * succeeded (checked by retrieving the private state saved by the - * login and commit methods), - * then this method cleans up any state that was originally saved. - * - *

- * - * @exception LoginException if the abort fails. - * - * @return false if this LoginModule's own login and/or commit attempts - * failed, and true otherwise. - */ - public boolean abort() throws LoginException { - if (succeeded == false) { - return false; - } else if (succeeded == true && commitSucceeded == false) { - // login succeeded but overall authentication failed - succeeded = false; - userId = null; - password = null; - userPrincipal = null; - } else { - // overall authentication succeeded and commit succeeded, - // but someone else's commit failed - logout(); - } - return true; - } - - /** - * Logout the user. - * - *

This method removes the SimplePrincipal - * that was added by the commit method. - * - *

- * - * @exception LoginException if the logout fails. - * - * @return true in all cases since this LoginModule - * should not be ignored. - */ - public boolean logout() throws LoginException { - subject.getPrincipals().remove(userPrincipal); - succeeded = false; - succeeded = commitSucceeded; - userId = null; - if (password != null) - password = null; - userPrincipal = null; - return true; - } - -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java deleted file mode 100644 index 595626e672..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/java/calculator/security/UserPrincipal.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * 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.security; - -import java.security.Principal; - -/** - * @version $Rev$ $Date$ - */ -public class UserPrincipal implements Principal { - - private final String name; - - public UserPrincipal(String name) { - if (name == null) - throw new IllegalArgumentException("name cannot be null"); - this.name = name; - } - - public String getName() { - return name; - } - - public String toString() { - return name; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - final UserPrincipal other = (UserPrincipal)obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } -} diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/Calculator.composite b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/Calculator.composite deleted file mode 100644 index d91bf88d96..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/Calculator.composite +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config deleted file mode 100644 index 0e7cb86633..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorJass.config +++ /dev/null @@ -1,3 +0,0 @@ -Calculator { - calculator.security.JaasLoginModule required debug=true; -}; diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties deleted file mode 100644 index f62125eaa9..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/CalculatorLogMessages.properties +++ /dev/null @@ -1,18 +0,0 @@ -# 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. -CALLING_OPERATION=Inovoking operation {0} with arguments {1} -OPERATION_RETURNED=Returning from operation {0} with return value {1} \ No newline at end of file diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/definitions.xml b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/definitions.xml deleted file mode 100644 index 6cccde0d13..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/main/resources/definitions.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - Calculator - calculator.security.CalculatorCallbackHandler - - - - - - - FINER - - - \ No newline at end of file diff --git a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java deleted file mode 100644 index 157570c3df..0000000000 --- a/sca-java-1.x/tags/1.5.1-RC1/samples/calculator-implementation-policies/src/test/java/calculator/CalculatorTestCase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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; - -import javax.security.auth.login.Configuration; - -import junit.framework.TestCase; - -import org.apache.tuscany.sca.host.embedded.SCADomain; - -/** - * This shows how to test the Calculator service component. - */ -public class CalculatorTestCase extends TestCase { - - private CalculatorService calculatorService; - private CalculatorService anotherCalculatorService; - private SCADomain scaDomain; - - @Override - protected void setUp() throws Exception { - try { - Configuration secConf = Configuration.getConfiguration(); - } catch ( java.lang.SecurityException e ) { - //FIXME: We should not compare exception strings as they are localized in various languages - //if ( e.getMessage().equals("Unable to locate a login configuration") ) { - System.setProperty("java.security.auth.login.config", - this.getClass().getClassLoader().getResource("CalculatorJass.config").toString()); - //} else { - // throw e; - //} - } - scaDomain = SCADomain.newInstance("Calculator.composite"); - calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); - anotherCalculatorService = scaDomain.getService(CalculatorService.class, "AnotherCalculatorServiceComponent"); - } - - @Override - protected void tearDown() throws Exception { - scaDomain.close(); - } - - public void testCalculator() throws Exception { - // Calculate - assertEquals(calculatorService.add(3, 2), 5.0); - assertEquals(calculatorService.subtract(3, 2), 1.0); - assertEquals(calculatorService.multiply(3, 2), 6.0); - assertEquals(calculatorService.divide(3, 2), 1.5); - } - - public void testAnotherCalculator() throws Exception { - // Calculate - assertEquals(anotherCalculatorService.add(3, 2), 5.0); - assertEquals(anotherCalculatorService.subtract(3, 2), 1.0); - assertEquals(anotherCalculatorService.multiply(3, 2), 6.0); - assertEquals(anotherCalculatorService.divide(3, 2), 1.5); - } -} -- cgit v1.2.3