summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity')
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java83
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java89
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java74
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java131
-rw-r--r--tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java56
5 files changed, 0 insertions, 433 deletions
diff --git a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java b/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java
deleted file mode 100644
index 773c874a90..0000000000
--- a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.identity;
-
-import java.util.List;
-
-import javax.security.auth.Subject;
-
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.invocation.Phase;
-import org.apache.tuscany.sca.invocation.PhasedInterceptor;
-import org.apache.tuscany.sca.policy.security.SecurityUtil;
-import org.oasisopen.sca.ServiceRuntimeException;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SecurityIdentityImplementationPolicyInterceptor implements PhasedInterceptor {
- private List<SecurityIdentityPolicy> securityIdentityPolicies;
- private Invoker next;
-
- public SecurityIdentityImplementationPolicyInterceptor(List<SecurityIdentityPolicy> securityIdentityPolicies) {
- super();
- this.securityIdentityPolicies = securityIdentityPolicies;
- }
-
- /**
- * @see org.apache.tuscany.sca.invocation.Interceptor#getNext()
- */
- public Invoker getNext() {
- return next;
- }
-
- /**
- * @see org.apache.tuscany.sca.invocation.Interceptor#setNext(org.apache.tuscany.sca.invocation.Invoker)
- */
- public void setNext(Invoker next) {
- this.next = next;
- }
-
- public String getPhase() {
- return Phase.IMPLEMENTATION_POLICY;
- }
-
-
- /**
- * @see org.apache.tuscany.sca.invocation.Invoker#invoke(org.apache.tuscany.sca.invocation.Message)
- */
- public Message invoke(Message msg) {
- try {
-
- Subject subject = SecurityUtil.getSubject(msg);
-
- // May do some selection here based on runAs settings.
- // by default though there is nothing to do as the implementation
- // assumes the callers user credentials
-
-
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- return getNext().invoke(msg);
- }
-
-}
diff --git a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java b/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java
deleted file mode 100644
index 2783a37316..0000000000
--- a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.identity;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.PhasedInterceptor;
-import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.provider.PolicyProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SecurityIdentityImplementationPolicyProvider implements PolicyProvider {
- private RuntimeComponent component;
- private Implementation implementation;
-
- public SecurityIdentityImplementationPolicyProvider(RuntimeComponent component) {
- super();
- this.component = component;
- this.implementation = component.getImplementation();
- }
-
- private List<SecurityIdentityPolicy> findPolicies(Operation op) {
- List<SecurityIdentityPolicy> polices = new ArrayList<SecurityIdentityPolicy>();
- /*
- // FIXME: How do we get a list of effective policySets for a given operation?
- if (implementation instanceof OperationsConfigurator) {
- OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
- for (ConfiguredOperation cop : operationsConfigurator.getConfiguredOperations()) {
- if (cop.getName().equals(op.getName())) {
- for (PolicySet ps : cop.getPolicySets()) {
- for (Object p : ps.getPolicies()) {
- if (SecurityIdentityPolicy.class.isInstance(p)) {
- polices.add((SecurityIdentityPolicy)p);
- }
- }
- }
- }
- }
- }
- */
-
- List<PolicySet> policySets = component.getPolicySets();
- for (PolicySet ps : policySets) {
- for (Object p : ps.getPolicies()) {
- if (SecurityIdentityPolicy.class.isInstance(p)) {
- polices.add((SecurityIdentityPolicy)p);
- }
- }
- }
- return polices;
- }
-
- public PhasedInterceptor createInterceptor(Operation operation) {
- List<SecurityIdentityPolicy> policies = findPolicies(operation);
- if (policies == null || policies.isEmpty()) {
- return null;
- } else {
- return new SecurityIdentityImplementationPolicyInterceptor(findPolicies(operation));
- }
- }
-
- public void start() {
- }
-
- public void stop() {
- }
-}
diff --git a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java b/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java
deleted file mode 100644
index 28ffcaf348..0000000000
--- a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.identity;
-
-import javax.xml.namespace.QName;
-
-/**
- * Models the SCA Implementation Security Policy Assertion for Security Identity.
- *
- * @version $Rev$ $Date$
- */
-public class SecurityIdentityPolicy {
- private final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
- public static final QName NAME = new QName(SCA11_NS, "securityIdentity");
-
- private boolean useCallerIdentity;
-
- private String runAsRole;
-
- public SecurityIdentityPolicy() {
- }
-
- public boolean isUnresolved() {
- return false;
- }
-
- public void setUnresolved(boolean unresolved) {
- }
-
- public QName getSchemaName() {
- return NAME;
- }
-
- public boolean isUseCallerIdentity() {
- return useCallerIdentity;
- }
-
- public void setUseCallerIdentity(boolean useCallerIdentity) {
- this.useCallerIdentity = useCallerIdentity;
- }
-
- public String getRunAsRole() {
- return runAsRole;
- }
-
- public void setRunAsRole(String runAsRole) {
- this.runAsRole = runAsRole;
- }
-
- @Override
- public String toString() {
- if (useCallerIdentity) {
- return "useCallerIdentity";
- }
- return "runAs " + runAsRole;
- }
-}
diff --git a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java b/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java
deleted file mode 100644
index 3c91b9fbcf..0000000000
--- a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.identity;
-
-import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
-import static javax.xml.stream.XMLStreamConstants.START_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.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.tuscany.sca.monitor.Problem.Severity;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class SecurityIdentityPolicyProcessor implements StAXArtifactProcessor<SecurityIdentityPolicy> {
- private static final String ROLE = "role";
-
- public QName getArtifactType() {
- return SecurityIdentityPolicy.NAME;
- }
-
- public SecurityIdentityPolicyProcessor(FactoryExtensionPoint modelFactories) {
- }
-
- /**
- * Report a error.
- *
- * @param problems
- * @param message
- * @param model
- */
- private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "policy-security-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
- }
-
- public SecurityIdentityPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
- SecurityIdentityPolicy policy = new SecurityIdentityPolicy();
- int event = reader.getEventType();
- QName start = reader.getName();
- while (true) {
- switch (event) {
- case START_ELEMENT:
- String ac = reader.getName().getLocalPart();
- if ("runAs".equals(ac)) {
- String roleName = reader.getAttributeValue(null, ROLE);
- if (roleName == null) {
- error(context.getMonitor(), "RequiredAttributeRolesMissing", reader);
- //throw new IllegalArgumentException("Required attribute 'roles' is missing.");
- } else {
- policy.setRunAsRole(roleName);
- }
- } else if ("useCallerIdentity".equals(ac)) {
- policy.setUseCallerIdentity(true);
- }
- break;
- case END_ELEMENT:
- if (start.equals(reader.getName())) {
- if (reader.hasNext()) {
- reader.next();
- }
- return policy;
- }
-
- }
- if (reader.hasNext()) {
- event = reader.next();
- } else {
- return policy;
- }
- }
- }
-
- public void write(SecurityIdentityPolicy policy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException,
- XMLStreamException {
- writer.writeStartElement(SecurityIdentityPolicy.NAME.getLocalPart());
-
- String child = policy.isUseCallerIdentity() ? "useCallerIdentity" : "runAs";
- writer.writeStartElement(child);
-
- if (!policy.isUseCallerIdentity()) {
- writer.writeAttribute(ROLE, policy.getRunAsRole());
- }
-
- writer.writeEndElement();
- writer.writeEndElement();
- }
-
- public Class<SecurityIdentityPolicy> getModelType() {
- return SecurityIdentityPolicy.class;
- }
-
- public void resolve(SecurityIdentityPolicy policy, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
-
- if (policy.getRunAsRole() != null)
- //right now nothing to resolve
- policy.setUnresolved(false);
- }
-
-}
diff --git a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java
deleted file mode 100644
index 80e1494796..0000000000
--- a/tags/java/sca/2.0-M4-RC3/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.identity;
-
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.provider.PolicyProvider;
-import org.apache.tuscany.sca.provider.PolicyProviderFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * @version $Rev$ $Date$
- */
-public class SecurityIdentityPolicyProviderFactory implements PolicyProviderFactory<SecurityIdentityPolicy> {
- private ExtensionPointRegistry registry;
-
- public SecurityIdentityPolicyProviderFactory(ExtensionPointRegistry registry) {
- super();
- this.registry = registry;
- }
-
- public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
- return new SecurityIdentityImplementationPolicyProvider(component);
- }
-
- public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
- return null;
- }
-
- public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
- return null;
- }
-
- public Class<SecurityIdentityPolicy> getModelType() {
- return SecurityIdentityPolicy.class;
- }
-
-}