tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r748014 - in /tuscany/branches/sca-java-1.x: modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/ modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ modules/host-tomcat/src/main/java/org/ap...
Date Thu, 26 Feb 2009 04:41:27 GMT
Author: lresende
Date: Thu Feb 26 04:41:26 2009
New Revision: 748014

URL: http://svn.apache.org/viewvc?rev=748014&view=rev
Log:
Adding support for enabling and configuring authentication for embedded http server using
policy

Added:
    tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
  (with props)
    tuscany/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java
  (with props)
    tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/
    tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java
      - copied, changed from r748011, tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
    tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java
  (with props)
    tuscany/branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.java
      - copied, changed from r748011, tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
    tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
  (with props)
Modified:
    tuscany/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
    tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
    tuscany/branches/sca-java-1.x/modules/policy-security-http/pom.xml
    tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
    tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml

Modified: tuscany/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java?rev=748014&r1=748013&r2=748014&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
Thu Feb 26 04:41:26 2009
@@ -22,6 +22,7 @@
 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.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 @@
  * @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 @@
         
 
         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());
                     }
                 }
             }

Modified: tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java?rev=748014&r1=748013&r2=748014&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
Thu Feb 26 04:41:26 2009
@@ -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 @@
     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 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;
+    }
 }

Added: tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java?rev=748014&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
(added)
+++ tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
Thu Feb 26 04:41:26 2009
@@ -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;
+    }
+    
+}

Propchange: tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/UserContext.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java?rev=748014&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java
(added)
+++ tuscany/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java
Thu Feb 26 04:41:26 2009
@@ -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;
+        }
+        
+    }
+}

Propchange: tuscany/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/modules/host-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatPolicyBaseRealm.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/branches/sca-java-1.x/modules/policy-security-http/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/policy-security-http/pom.xml?rev=748014&r1=748013&r2=748014&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/policy-security-http/pom.xml (original)
+++ tuscany/branches/sca-java-1.x/modules/policy-security-http/pom.xml Thu Feb 26 04:41:26
2009
@@ -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>

Copied: tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java
(from r748011, tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java)
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java?p2=tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java&p1=tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java&r1=748011&r2=748014&rev=748014&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicy.java
Thu Feb 26 04:41:26 2009
@@ -17,31 +17,29 @@
  * under the License.    
  */
 
-package org.apache.tuscany.sca.host.http;
+package org.apache.tuscany.sca.policy.authentication;
 
-import java.util.Properties;
+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;
 
 /**
- * A class to store policy context to enable Security QoS to 
- * HTTP binding  
+ * This policy configures authentication/authorization
+ * in embedded http servers
+ * 
+ * @version $Rev$ $Date$
  */
-public class SecurityContext {
-    private boolean isSSLEnabled = false;
-    private Properties sslProperties;
-    
-    public boolean isSSLEnabled() {
-        return isSSLEnabled;
-    }
+public class AuthenticationConfigurationPolicy {
+    public static final QName NAME = new QName(Constants.SCA10_TUSCANY_NS, "basicAuthenticationConfiguration");
     
-    public void setSSLEnabled(boolean value) {
-        this.isSSLEnabled = value;
-    }
+    private List<UserContext> users = new ArrayList<UserContext>();
     
-    public Properties getSSLProperties() {
-        return sslProperties;
+    public List<UserContext> getUsers() {
+        return this.users;
     }
     
-    public void setSSLProperties(Properties sslProperties) {
-        this.sslProperties = sslProperties;
-    }
 }

Added: tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java?rev=748014&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java
(added)
+++ tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java
Thu Feb 26 04:41:26 2009
@@ -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 {
+
+    }
+
+}

Propchange: tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/java/org/apache/tuscany/sca/policy/authentication/AuthenticationConfigurationPolicyProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=748014&r1=748013&r2=748014&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
(original)
+++ tuscany/branches/sca-java-1.x/modules/policy-security-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
Thu Feb 26 04:41:26 2009
@@ -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

Copied: tuscany/branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.java
(from r748011, tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java)
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.java?p2=tuscany/branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.java&p1=tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java&r1=748011&r2=748014&rev=748014&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/SecurityContext.java
(original)
+++ tuscany/branches/sca-java-1.x/samples/store-secure/src/main/java/launch/LaunchProtected.java
Thu Feb 26 04:41:26 2009
@@ -17,31 +17,18 @@
  * under the License.    
  */
 
-package org.apache.tuscany.sca.host.http;
+package launch;
 
-import java.util.Properties;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
 
-/**
- * A class to store policy context to enable Security QoS to 
- * HTTP binding  
- */
-public class SecurityContext {
-    private boolean isSSLEnabled = false;
-    private Properties sslProperties;
-    
-    public boolean isSSLEnabled() {
-        return isSSLEnabled;
-    }
-    
-    public void setSSLEnabled(boolean value) {
-        this.isSSLEnabled = value;
-    }
-    
-    public Properties getSSLProperties() {
-        return sslProperties;
-    }
-    
-    public void setSSLProperties(Properties sslProperties) {
-        this.sslProperties = sslProperties;
+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();
     }
 }

Modified: tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml?rev=748014&r1=748013&r2=748014&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml
(original)
+++ tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/definitions.xml
Thu Feb 26 04:41:26 2009
@@ -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">

Added: tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite?rev=748014&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
(added)
+++ tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
Thu Feb 26 04:41:26 2009
@@ -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>

Propchange: tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/branches/sca-java-1.x/samples/store-secure/src/main/resources/store-protected.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message