summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-1.x')
-rw-r--r--branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java30
-rw-r--r--branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java17
-rw-r--r--branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java68
-rw-r--r--branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java95
-rw-r--r--branches/sca-java-1.x/modules/policy-security-http/pom.xml6
-rw-r--r--branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java45
-rw-r--r--branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java156
-rw-r--r--branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor3
-rw-r--r--branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.java34
-rw-r--r--branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml24
-rw-r--r--branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite64
11 files changed, 519 insertions, 23 deletions
diff --git a/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
index 67c782ef05..6e01ac5f9f 100644
--- a/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
+++ b/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.binding.http.provider;
import java.util.List;
import javax.servlet.Servlet;
+import javax.xml.namespace.QName;
import org.apache.tuscany.sca.binding.http.HTTPBinding;
import org.apache.tuscany.sca.host.http.SecurityContext;
@@ -31,8 +32,10 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.authentication.AuthenticationConfigurationPolicy;
import org.apache.tuscany.sca.policy.confidentiality.ConfidentialityPolicy;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -45,6 +48,9 @@ import org.apache.tuscany.sca.runtime.RuntimeWire;
* @version $Rev$ $Date$
*/
public class HTTPServiceBindingProvider implements ServiceBindingProvider {
+ private static final QName AUTEHTICATION_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","authentication");
+ private static final QName CONFIDENTIALITY_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","confidentiality");
+
private RuntimeComponentService service;
private HTTPBinding binding;
private MessageFactory messageFactory;
@@ -127,19 +133,37 @@ public class HTTPServiceBindingProvider implements ServiceBindingProvider {
SecurityContext securityContext = new SecurityContext();
+ boolean isConfidentialityRequired = false;
+ boolean isAuthenticationRequired = false;
+
// find out which policies are active
if (binding instanceof PolicySetAttachPoint) {
+ List<Intent> intents = ((PolicySetAttachPoint)binding).getRequiredIntents();
+ for(Intent intent : intents) {
+ if (intent.getName().equals(AUTEHTICATION_INTENT)) {
+ isAuthenticationRequired = true;
+ } else if (intent.getName().equals(CONFIDENTIALITY_INTENT)) {
+ isConfidentialityRequired = true;
+ }
+ }
+
List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
- if (ConfidentialityPolicy.class.isInstance(p)) {
+ if (ConfidentialityPolicy.class.isInstance(p) && isConfidentialityRequired) {
+ //Handle enabling and configuring SSL
ConfidentialityPolicy confidentialityPolicy = (ConfidentialityPolicy)p;
securityContext.setSSLEnabled(true);
securityContext.setSSLProperties(confidentialityPolicy.toProperties());
- } else {
- // etc. check for other types of policy being present
+ } else if(AuthenticationConfigurationPolicy.class.isInstance(p) && isAuthenticationRequired) {
+ // Handle authentication and user configuration
+ AuthenticationConfigurationPolicy authenticationConfiguration = (AuthenticationConfigurationPolicy)p;
+
+ securityContext.setAuthenticationEnabled(true);
+ securityContext.getUsers().clear();
+ securityContext.getUsers().addAll(authenticationConfiguration.getUsers());
}
}
}
diff --git a/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java b/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
index 05140d6e29..f290bb3e59 100644
--- a/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
+++ b/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
@@ -19,6 +19,8 @@
package org.apache.tuscany.sca.host.http;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
/**
@@ -29,6 +31,9 @@ public class SecurityContext {
private boolean isSSLEnabled = false;
private Properties sslProperties;
+ private boolean isAuthenticationEnabled = false;
+ private List<UserContext> users = new ArrayList<UserContext>();
+
public boolean isSSLEnabled() {
return isSSLEnabled;
}
@@ -44,4 +49,16 @@ public class SecurityContext {
public void setSSLProperties(Properties sslProperties) {
this.sslProperties = sslProperties;
}
+
+ public boolean isAuthenticationEnabled() {
+ return this.isAuthenticationEnabled;
+ }
+
+ public void setAuthenticationEnabled(boolean value) {
+ this.isAuthenticationEnabled = value;
+ }
+
+ public List<UserContext> getUsers() {
+ return this.users;
+ }
}
diff --git a/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java b/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
new file mode 100644
index 0000000000..4a19eda81d
--- /dev/null
+++ b/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.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 org.apache.tuscany.sca.host.http;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Model class used to define list of users and it's roles
+ *
+ * These info is used to configure authentication/authorization
+ * in embedded http servers
+ *
+ * @version $Rev$ $Date$
+ */
+public class UserContext {
+ private String username;
+ private String password;
+ private List<String> roles = new ArrayList<String>();
+
+
+ public UserContext() {
+
+ }
+
+ public UserContext(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public List<String> getRoles() {
+ return this.roles;
+ }
+
+}
diff --git a/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java b/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java
new file mode 100644
index 0000000000..93f49197f2
--- /dev/null
+++ b/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java
@@ -0,0 +1,95 @@
+/*
+ * 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 org.apache.tuscany.sca.http.tomcat;
+
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.catalina.realm.RealmBase;
+import org.apache.tuscany.sca.host.http.UserContext;
+
+public class TomcatPolicyBaseRealm extends RealmBase {
+ private static final String REALM_NAME = "Tuscany Realm";
+
+ private Map<String, UserContext> userMap = new HashMap<String, UserContext>();
+
+ public TomcatPolicyBaseRealm(List<UserContext> users) {
+ for(UserContext userContext : users) {
+ userMap.put(userContext.getUsername(), userContext);
+ }
+ }
+
+ @Override
+ protected String getName() {
+ return REALM_NAME;
+ }
+
+ @Override
+ protected String getPassword(String username) {
+ UserContext userContext = userMap.get(username);
+
+ if (userContext != null) {
+ return userContext.getPassword();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected Principal getPrincipal(String username) {
+ UserContext userContext = userMap.get(username);
+
+ if (userContext != null) {
+ Principal principal = new TuscanyPrincipal(userContext.getUsername());
+ return principal;
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean hasRole(java.security.Principal principal, java.lang.String role) {
+ UserContext userContext = userMap.get(principal.getName());
+
+ if (userContext != null) {
+ if (userContext.getRoles().contains(role)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ class TuscanyPrincipal implements java.security.Principal {
+ private final String username;
+
+ TuscanyPrincipal(String username) {
+ this.username = username;
+ }
+
+ public String getName() {
+ return this.username;
+ }
+
+ }
+}
diff --git a/branches/sca-java-1.x/modules/policy-security-http/pom.xml b/branches/sca-java-1.x/modules/policy-security-http/pom.xml
index 07c5112f55..b25db4ad5c 100644
--- a/branches/sca-java-1.x/modules/policy-security-http/pom.xml
+++ b/branches/sca-java-1.x/modules/policy-security-http/pom.xml
@@ -37,6 +37,12 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>1.5-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-policy-security</artifactId>
<version>1.5-SNAPSHOT</version>
</dependency>
diff --git a/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java b/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java
new file mode 100644
index 0000000000..4ab7e582ac
--- /dev/null
+++ b/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java
@@ -0,0 +1,45 @@
+/*
+ * 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 org.apache.tuscany.sca.policy.authentication;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.host.http.UserContext;
+
+/**
+ * This policy configures authentication/authorization
+ * in embedded http servers
+ *
+ * @version $Rev$ $Date$
+ */
+public class AuthenticationConfigurationPolicy {
+ public static final QName NAME = new QName(Constants.SCA10_TUSCANY_NS, "basicAuthenticationConfiguration");
+
+ private List<UserContext> users = new ArrayList<UserContext>();
+
+ public List<UserContext> getUsers() {
+ return this.users;
+ }
+
+}
diff --git a/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java b/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java
new file mode 100644
index 0000000000..77d8fa6203
--- /dev/null
+++ b/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java
@@ -0,0 +1,156 @@
+/*
+ * 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 org.apache.tuscany.sca.policy.authentication;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.StringTokenizer;
+
+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.builder.impl.ProblemImpl;
+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;
+import org.apache.tuscany.sca.host.http.UserContext;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * <sca:policySet name="widgetBindingAuthenticationPolicySet"
+ * provides="sca:authentication"
+ * appliesTo="tuscany:binding.http">
+ * <tuscany:authenticationConfiguration>
+ * <tuscany:user username="user1" password="tuscany" roles="admin"/>
+ * <tuscany:user username="user2" password="tuscany" roles="admin, user"/>
+ * <tuscany:user username="user3" password="tuscany" roles="user"/>
+ * </tuscany:authenticationConfiguration>
+ * </sca:policySet>
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class AuthenticationConfigurationPolicyProcessor implements StAXArtifactProcessor<AuthenticationConfigurationPolicy> {
+ private static final QName AUTHENTICATION_CONFIGURATION_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "authenticationConfiguration");
+ private static final QName USER_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "user");
+
+ private Monitor monitor;
+
+ public AuthenticationConfigurationPolicyProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+ this.monitor = monitor;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem = new ProblemImpl(this.getClass().getName(), "policy-security-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public QName getArtifactType() {
+ return AuthenticationConfigurationPolicy.NAME;
+ }
+
+ public Class<AuthenticationConfigurationPolicy> getModelType() {
+ return AuthenticationConfigurationPolicy.class;
+ }
+
+ public AuthenticationConfigurationPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ AuthenticationConfigurationPolicy authenticationConfiguration = new AuthenticationConfigurationPolicy();
+
+ int event = reader.getEventType();
+ QName start = reader.getName();
+ QName name = null;
+ while (true) {
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+ if(USER_QNAME.equals(name)) {
+ UserContext user = new UserContext();
+ //<tuscany:user username="user1" password="tuscany" roles="admin, user"/>
+ String username = reader.getAttributeValue(null, "username");
+ if(username == null) {
+ error("RequiredAttributeUsernameMissing", reader);
+ } else {
+ user.setUsername(username);
+ }
+
+ String password = reader.getAttributeValue(null, "password");
+ if(password == null) {
+ error("RequiredAttributePasswordMissing", reader);
+ } else {
+ user.setPassword(password);
+ }
+
+ String roles = reader.getAttributeValue(null, "roles");
+ if(roles == null) {
+ error("RequiredAttributeRolesMissing", reader);
+ } else {
+ for (StringTokenizer tokens = new StringTokenizer(roles, ","); tokens.hasMoreTokens();) {
+ user.getRoles().add(tokens.nextToken());
+ }
+ }
+
+ authenticationConfiguration.getUsers().add(user);
+ }
+ break;
+ case END_ELEMENT:
+ if (start.equals(reader.getName())) {
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ return authenticationConfiguration;
+ }
+
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return authenticationConfiguration;
+ }
+ }
+ }
+
+ public void write(AuthenticationConfigurationPolicy model, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+ // TODO Auto-generated method stub
+ }
+
+ public void resolve(AuthenticationConfigurationPolicy model, ModelResolver resolver) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
index bd44ec8681..65605d69fe 100644
--- a/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ b/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -16,4 +16,5 @@
# under the License.
# Implementation class for the artifact processor extension
-org.apache.tuscany.sca.policy.confidentiality.ConfidentialityPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#confidentiality,model=org.apache.tuscany.sca.policy.confidentiality.ConfidentialityPolicy \ No newline at end of file
+org.apache.tuscany.sca.policy.confidentiality.ConfidentialityPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#confidentiality,model=org.apache.tuscany.sca.policy.confidentiality.ConfidentialityPolicy
+org.apache.tuscany.sca.policy.authentication.AuthenticationConfigurationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#authenticationConfiguration,model=org.apache.tuscany.sca.policy.authentication.AuthenticationConfigurationPolicy
diff --git a/branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.java b/branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.java
new file mode 100644
index 0000000000..ffdf9db47b
--- /dev/null
+++ b/branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.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 launch;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class LaunchProtected {
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting ...");
+ SCADomain scaDomain = SCADomain.newInstance("store-protected.composite");
+ System.out.println("store.composite ready for big business !!!");
+ System.in.read();
+ System.out.println("Stopping ...");
+ scaDomain.close();
+ System.out.println();
+ }
+}
diff --git a/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml b/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml
index 0b1d409c7f..140c5fd1c5 100644
--- a/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml
+++ b/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml
@@ -27,27 +27,13 @@
<sca:policySet name="widgetBindingAuthenticationPolicySet"
provides="sca:authentication"
appliesTo="tuscany:binding.http">
- <tuscany:basicAuthentication>
- <tuscany:authorizedUsers>
- <tuscany:user name="user1" password="pwd1" role="admin"/>
- <tuscany:user name="user2" password="pwd2" role="user"/>
- <tuscany:user name="user3" password="pwd3" role="user"/>
- </tuscany:authorizedUsers>
- </tuscany:basicAuthentication>
+ <tuscany:authenticationConfiguration>
+ <tuscany:user username="admin" password="tuscany" roles="admin"/>
+ <tuscany:user username="user1" password="tuscany" roles="user"/>
+ <tuscany:user username="user2" password="tuscany" roles="user"/>
+ </tuscany:authenticationConfiguration>
</sca:policySet>
- <sca:policySet name="widgetServiceAuthenticationPolicySet"
- provides="sca:authentication"
- appliesTo="sca:service">
- <tuscany:basicAuthentication>
- <tuscany:authorizedUsers>
- <tuscany:user name="user1" password="pwd1" role="admin"/>
- <tuscany:user name="user2" password="pwd2" role="user"/>
- <tuscany:user name="user3" password="pwd3" role="user"/>
- </tuscany:authorizedUsers>
- </tuscany:basicAuthentication>
- </sca:policySet>
-
<sca:policySet name="widgetConfidentialityConfigurationPolicySet"
provides="sca:confidentiality"
appliesTo="tuscany:binding.http">
diff --git a/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite b/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
new file mode 100644
index 0000000000..5619afd8d9
--- /dev/null
+++ b/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://store"
+ name="store">
+
+ <component name="Store">
+ <t:implementation.widget location="uiservices/store.html"/>
+ <service name="Widget">
+ <t:binding.http uri="/store" requires="authentication"/>
+ </service>
+ <reference name="catalog" target="Catalog">
+ <t:binding.jsonrpc/>
+ </reference>
+ <reference name="shoppingCart" target="ShoppingCart/Cart">
+ <t:binding.atom/>
+ </reference>
+ <reference name="shoppingTotal" target="ShoppingCart/Total">
+ <t:binding.jsonrpc/>
+ </reference>
+ </component>
+
+ <component name="Catalog">
+ <implementation.java class="services.FruitsCatalogImpl"/>
+ <property name="currencyCode">USD</property>
+ <service name="Catalog">
+ <t:binding.jsonrpc/>
+ </service>
+ <reference name="currencyConverter" target="CurrencyConverter"/>
+ </component>
+
+ <component name="ShoppingCart">
+ <implementation.java class="services.ShoppingCartImpl"/>
+ <service name="Cart">
+ <t:binding.atom uri="/ShoppingCart/Cart"/>
+ </service>
+ <service name="Total">
+ <t:binding.jsonrpc/>
+ </service>
+ </component>
+
+ <component name="CurrencyConverter">
+ <implementation.java class="services.CurrencyConverterImpl"/>
+ </component>
+
+</composite>