You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2008/04/21 09:06:27 UTC

svn commit: r650032 - /incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/

Author: svkrish
Date: Mon Apr 21 00:06:25 2008
New Revision: 650032

URL: http://svn.apache.org/viewvc?rev=650032&view=rev
Log:
Initial implementation of model and processors for section 1.7.3-Implementation-Security-Policy of the PolicyFwk Specs

Added:
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertion.java   (with props)
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertionProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AuthorizationPolicyAssertion.java   (with props)
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertion.java   (with props)
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertionProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertion.java   (with props)
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertionProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertion.java   (with props)
    incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertionProcessor.java   (with props)

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertion.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertion.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertion.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertion.java Mon Apr 21 00:06:25 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.security;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Models the 'allow' authorization policy assertion
+ * 
+ * @version $Rev$ $Date$
+ */
+public class AllowPolicyAssertion extends AuthorizationPolicyAssertion {
+    public static final QName NAME = new QName(Constants.SCA10_NS, "allow");
+    
+    public AllowPolicyAssertion() {
+        super(ACCESS_LEVEL.ALLOW);
+    }
+    
+    public QName getSchemaName() {
+        return NAME;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertion.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertionProcessor.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertionProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertionProcessor.java Mon Apr 21 00:06:25 2008
@@ -0,0 +1,107 @@
+/*
+ * 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.security;
+
+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.xml.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ClassReference;
+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;
+
+
+public class AllowPolicyAssertionProcessor implements StAXArtifactProcessor<AllowPolicyAssertion> {
+    private static final QName ALLOW_AUTHORIZATION_POLICY_QNAME = AllowPolicyAssertion.NAME;
+    private static final String ROLES = "roles";
+    
+    public QName getArtifactType() {
+        return ALLOW_AUTHORIZATION_POLICY_QNAME;
+    }
+    
+    public AllowPolicyAssertionProcessor(ModelFactoryExtensionPoint modelFactories) {
+    }
+
+    
+    public AllowPolicyAssertion read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        AllowPolicyAssertion policy = new AllowPolicyAssertion();
+        int event = reader.getEventType();
+        QName name = null;
+        
+        String roleNames = reader.getAttributeValue(null, ROLES);
+        StringTokenizer st = new StringTokenizer(roleNames);
+        while ( st.hasMoreTokens() ) {
+            policy.getRoleNames().add(st.nextToken());
+        }
+        
+        while (reader.hasNext()) {
+            event = reader.getEventType();
+            
+            if ( event == END_ELEMENT ) {
+                if ( ALLOW_AUTHORIZATION_POLICY_QNAME.equals(reader.getName()) ) {
+                    break;
+                } 
+            }
+            
+            //Read the next element
+            if (reader.hasNext()) {
+                reader.next();
+            }
+        }
+         
+        return policy;
+    }
+
+    public void write(AllowPolicyAssertion policy, XMLStreamWriter writer) throws ContributionWriteException,
+                                                        XMLStreamException {
+        writer.writeStartElement(ALLOW_AUTHORIZATION_POLICY_QNAME.getLocalPart());
+        
+        StringBuffer sb = new StringBuffer();
+        for ( String role : policy.getRoleNames() ) {
+            sb.append(role);
+        }
+        
+        if ( sb.length() > 0 ) {
+            writer.writeAttribute(ROLES, sb.toString());
+        }
+       
+        writer.writeEndElement();
+    }
+
+    public Class<AllowPolicyAssertion> getModelType() {
+        return AllowPolicyAssertion.class;
+    }
+
+    public void resolve(AllowPolicyAssertion policy, ModelResolver resolver) throws ContributionResolveException {
+        //right now nothing to resolve
+       policy.setUnresolved(false);
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertionProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AllowPolicyAssertionProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AuthorizationPolicyAssertion.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AuthorizationPolicyAssertion.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AuthorizationPolicyAssertion.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AuthorizationPolicyAssertion.java Mon Apr 21 00:06:25 2008
@@ -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.policy.security;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Policy;
+
+/**
+ * Models the SCA Implementatatoin Security Policy Assertion for Athorization
+ * 
+ * @version $Rev$ $Date$
+ */
+public abstract class AuthorizationPolicyAssertion implements Policy {
+    private List<String> roleNames = null;
+    
+    public enum ACCESS_LEVEL { PERMIT_ALL,
+                                DENY_ALL,
+                                ALLOW };
+    
+    public AuthorizationPolicyAssertion(ACCESS_LEVEL accessLevel) {
+        this.accessLevel = accessLevel;
+    }
+    
+    private ACCESS_LEVEL accessLevel;
+
+
+    public ACCESS_LEVEL getAccessLevel() {
+        return accessLevel;
+    }
+
+    public void setAccessLevel(ACCESS_LEVEL accessLevel) {
+        this.accessLevel = accessLevel;
+    }
+
+    public List<String> getRoleNames() {
+        if ( accessLevel == ACCESS_LEVEL.ALLOW && 
+            roleNames == null ) {
+            roleNames = new ArrayList<String>();
+        }
+        return roleNames;
+    }              
+    
+    public boolean isUnresolved() {
+        return false;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AuthorizationPolicyAssertion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/AuthorizationPolicyAssertion.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertion.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertion.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertion.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertion.java Mon Apr 21 00:06:25 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.security;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Models the 'allow' authorization policy assertion
+ * 
+ * @version $Rev$ $Date$
+ */
+public class DenyAllPolicyAssertion extends AuthorizationPolicyAssertion {
+    public static final QName NAME = new QName(Constants.SCA10_NS, "denyAll");
+    
+    public DenyAllPolicyAssertion() {
+        super(ACCESS_LEVEL.DENY_ALL);
+    }
+    
+    public QName getSchemaName() {
+        return NAME;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertion.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertionProcessor.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertionProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertionProcessor.java Mon Apr 21 00:06:25 2008
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.policy.security;
+
+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.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;
+
+
+public class DenyAllPolicyAssertionProcessor implements StAXArtifactProcessor<DenyAllPolicyAssertion> {
+    private static final QName DENY_ALL_AUTHORIZATION_POLICY_QNAME = DenyAllPolicyAssertion.NAME;
+    
+    public QName getArtifactType() {
+        return DENY_ALL_AUTHORIZATION_POLICY_QNAME;
+    }
+    
+    public DenyAllPolicyAssertionProcessor(ModelFactoryExtensionPoint modelFactories) {
+    }
+
+    
+    public DenyAllPolicyAssertion read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        DenyAllPolicyAssertion policy = new DenyAllPolicyAssertion();
+        return policy;
+    }
+
+    public void write(DenyAllPolicyAssertion policy, XMLStreamWriter writer) throws ContributionWriteException,
+                                                        XMLStreamException {
+       writer.writeStartElement(DENY_ALL_AUTHORIZATION_POLICY_QNAME.getLocalPart());
+       writer.writeEndElement();
+    }
+
+    public Class<DenyAllPolicyAssertion> getModelType() {
+        return DenyAllPolicyAssertion.class;
+    }
+
+    public void resolve(DenyAllPolicyAssertion policy, ModelResolver resolver) throws ContributionResolveException {
+        //right now nothing to resolve
+       policy.setUnresolved(false);
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertionProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/DenyAllPolicyAssertionProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertion.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertion.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertion.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertion.java Mon Apr 21 00:06:25 2008
@@ -0,0 +1,41 @@
+/*
+ * 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.security;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * Models the 'permitAll' authorization policy assertion
+ * 
+ * @version $Rev$ $Date$
+ */
+public class PermitAllPolicyAssertion extends AuthorizationPolicyAssertion {
+    public static final QName NAME = new QName(Constants.SCA10_NS, "permitAll");
+    
+    public PermitAllPolicyAssertion() {
+        super(ACCESS_LEVEL.PERMIT_ALL);
+    }
+    
+    public QName getSchemaName() {
+        return NAME;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertion.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertionProcessor.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertionProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertionProcessor.java Mon Apr 21 00:06:25 2008
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.policy.security;
+
+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.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;
+
+
+public class PermitAllPolicyAssertionProcessor implements StAXArtifactProcessor<PermitAllPolicyAssertion> {
+    private static final QName PERMIT_ALL_AUTHORIZATION_POLICY_QNAME = PermitAllPolicyAssertion.NAME;
+    
+    public QName getArtifactType() {
+        return PERMIT_ALL_AUTHORIZATION_POLICY_QNAME;
+    }
+    
+    public PermitAllPolicyAssertionProcessor(ModelFactoryExtensionPoint modelFactories) {
+    }
+
+    
+    public PermitAllPolicyAssertion read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        PermitAllPolicyAssertion policy = new PermitAllPolicyAssertion();
+        return policy;
+    }
+
+    public void write(PermitAllPolicyAssertion policy, XMLStreamWriter writer) throws ContributionWriteException,
+                                                        XMLStreamException {
+       writer.writeStartElement(PERMIT_ALL_AUTHORIZATION_POLICY_QNAME.getLocalPart());
+       writer.writeEndElement();
+    }
+
+    public Class<PermitAllPolicyAssertion> getModelType() {
+        return PermitAllPolicyAssertion.class;
+    }
+
+    public void resolve(PermitAllPolicyAssertion policy, ModelResolver resolver) throws ContributionResolveException {
+        //right now nothing to resolve
+       policy.setUnresolved(false);
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertionProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/PermitAllPolicyAssertionProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertion.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertion.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertion.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertion.java Mon Apr 21 00:06:25 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.security;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.policy.Policy;
+
+/**
+ * Models the 'allow' authorization policy assertion
+ * 
+ * @version $Rev$ $Date$
+ */
+public class RunAsPolicyAssertion implements Policy {
+    private String role = null;
+    private boolean unResolved = false;
+    
+    public static final QName NAME = new QName(Constants.SCA10_NS, "runAs");
+    
+   
+    public QName getSchemaName() {
+        return NAME;
+    }
+    
+    public boolean isUnresolved() {
+        return unResolved;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+        this.unResolved = unresolved;
+    }
+
+    public String getRole() {
+        return role;
+    }
+
+    public void setRole(String role) {
+        this.role = role;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertion.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertionProcessor.java?rev=650032&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertionProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertionProcessor.java Mon Apr 21 00:06:25 2008
@@ -0,0 +1,90 @@
+/*
+ * 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.security;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+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.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;
+
+
+public class RunAsPolicyAssertionProcessor implements StAXArtifactProcessor<RunAsPolicyAssertion> {
+    private static final QName RUNAS_AUTHORIZATION_POLICY_QNAME = RunAsPolicyAssertion.NAME;
+    private static final String ROLE = "role";
+    
+    public QName getArtifactType() {
+        return RUNAS_AUTHORIZATION_POLICY_QNAME;
+    }
+    
+    public RunAsPolicyAssertionProcessor(ModelFactoryExtensionPoint modelFactories) {
+    }
+
+    
+    public RunAsPolicyAssertion read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        RunAsPolicyAssertion policy = new RunAsPolicyAssertion();
+        int event = reader.getEventType();
+        QName name = null;
+        
+        String role = reader.getAttributeValue(null, ROLE);
+        policy.setRole(role);
+        
+        while (reader.hasNext()) {
+            event = reader.getEventType();
+            
+            if ( event == END_ELEMENT ) {
+                if ( RUNAS_AUTHORIZATION_POLICY_QNAME.equals(reader.getName()) ) {
+                    break;
+                } 
+            }
+            
+            //Read the next element
+            if (reader.hasNext()) {
+                reader.next();
+            }
+        }
+         
+        return policy;
+    }
+
+    public void write(RunAsPolicyAssertion policy, XMLStreamWriter writer) throws ContributionWriteException,
+                                                        XMLStreamException {
+        writer.writeStartElement(RUNAS_AUTHORIZATION_POLICY_QNAME.getLocalPart());
+        writer.writeAttribute(ROLE, policy.getRole());
+        writer.writeEndElement();
+    }
+
+    public Class<RunAsPolicyAssertion> getModelType() {
+        return RunAsPolicyAssertion.class;
+    }
+
+    public void resolve(RunAsPolicyAssertion policy, ModelResolver resolver) throws ContributionResolveException {
+        //right now nothing to resolve
+       policy.setUnresolved(false);
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertionProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/RunAsPolicyAssertionProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org