From 42f6010685593eb05e63b57c13f3dfc444059540 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 12 Nov 2009 08:34:50 +0000 Subject: Delete RC tag git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835300 13f79535-47bb-0310-9956-ffa450edef68 --- .../basic/BasicAuthenticationPolicy.java | 65 ----------- .../basic/BasicAuthenticationPolicyProcessor.java | 123 --------------------- .../BasicAuthenticationPolicyProviderFactory.java | 59 ---------- .../basic/BasicAuthenticationPrincipal.java | 80 -------------- ...icAuthenticationReferencePolicyInterceptor.java | 101 ----------------- ...BasicAuthenticationReferencePolicyProvider.java | 71 ------------ ...asicAuthenticationServicePolicyInterceptor.java | 102 ----------------- .../BasicAuthenticationServicePolicyProvider.java | 71 ------------ .../authentication/token/TokenPrincipal.java | 74 ------------- 9 files changed, 746 deletions(-) delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java delete mode 100644 sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java (limited to 'sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication') diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java deleted file mode 100644 index c735f63b7d..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java +++ /dev/null @@ -1,65 +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.authentication.basic; - -import javax.xml.namespace.QName; - -/** - * Implementation for policies that could be injected as parameter - * into the axis2config. - * - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationPolicy { - private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - - public static final QName BASIC_AUTHENTICATION_POLICY_QNAME = new QName(SCA10_TUSCANY_NS, "basicAuthentication"); - public static final String BASIC_AUTHENTICATION_USERNAME = "userName"; - public static final String BASIC_AUTHENTICATION_PASSWORD = "password"; - - private String userName; - private String password; - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public QName getSchemaName() { - return BASIC_AUTHENTICATION_POLICY_QNAME; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java deleted file mode 100644 index 3df06c1e00..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java +++ /dev/null @@ -1,123 +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.authentication.basic; - -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; - -/** - * - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationPolicyProcessor implements StAXArtifactProcessor { - private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - - public QName getArtifactType() { - return BasicAuthenticationPolicy.BASIC_AUTHENTICATION_POLICY_QNAME; - } - - public BasicAuthenticationPolicyProcessor(FactoryExtensionPoint modelFactories) { - } - - - public BasicAuthenticationPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { - BasicAuthenticationPolicy policy = new BasicAuthenticationPolicy(); - int event = reader.getEventType(); - QName name = null; - - while (reader.hasNext()) { - event = reader.getEventType(); - switch (event) { - case START_ELEMENT : { - name = reader.getName(); - if ( name.equals(getArtifactType()) ) { - // no attributes at the moment - } else if ( BasicAuthenticationPolicy.BASIC_AUTHENTICATION_USERNAME.equals(name.getLocalPart()) ) { - policy.setUserName(reader.getElementText()); - } else if ( BasicAuthenticationPolicy.BASIC_AUTHENTICATION_PASSWORD.equals(name.getLocalPart()) ) { - policy.setPassword(reader.getElementText()); - } - break; - } - } - - if ( event == END_ELEMENT ) { - if ( getArtifactType().equals(reader.getName()) ) { - break; - } - } - - //Read the next element - if (reader.hasNext()) { - reader.next(); - } - } - - return policy; - } - - public void write(BasicAuthenticationPolicy policy, XMLStreamWriter writer, ProcessorContext context) - throws ContributionWriteException, XMLStreamException { - String prefix = "tuscany"; - writer.writeStartElement(prefix, - getArtifactType().getLocalPart(), - getArtifactType().getNamespaceURI()); - writer.writeNamespace("tuscany", SCA10_TUSCANY_NS); - - if ( policy.getUserName() != null ) { - writer.writeStartElement(prefix, - BasicAuthenticationPolicy.BASIC_AUTHENTICATION_USERNAME, - getArtifactType().getNamespaceURI()); - writer.writeCharacters(policy.getUserName()); - writer.writeEndElement(); - } - - if ( policy.getPassword() != null ) { - writer.writeStartElement(prefix, - BasicAuthenticationPolicy.BASIC_AUTHENTICATION_PASSWORD, - getArtifactType().getNamespaceURI()); - writer.writeCharacters(policy.getPassword()); - writer.writeEndElement(); - } - - writer.writeEndElement(); - } - - public Class getModelType() { - return BasicAuthenticationPolicy.class; - } - - public void resolve(BasicAuthenticationPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { - - } - -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java deleted file mode 100644 index 9b894101ef..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java +++ /dev/null @@ -1,59 +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.authentication.basic; - -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 BasicAuthenticationPolicyProviderFactory implements PolicyProviderFactory { - private ExtensionPointRegistry registry; - - public BasicAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - } - - public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) { - return null; - } - - public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) { - return new BasicAuthenticationReferencePolicyProvider(endpointReference); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProviderFactory#createServicePolicyProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentService, org.apache.tuscany.sca.assembly.Binding) - */ - public PolicyProvider createServicePolicyProvider(Endpoint endpoint) { - return new BasicAuthenticationServicePolicyProvider(endpoint); - } - - public Class getModelType() { - return BasicAuthenticationPolicy.class; - } - -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java deleted file mode 100644 index 3ab9cb656d..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java +++ /dev/null @@ -1,80 +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.authentication.basic; - -import java.security.Principal; - - -/** - * - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationPrincipal implements Principal { - - private String name; - private String password; - - public BasicAuthenticationPrincipal(String name, String password){ - if (name == null) { - throw new IllegalArgumentException("name cannot be null"); - } - - this.name = name; - this.password = password; - } - - public String getName() { - return name; - } - - public String getPassword() { - return password; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public String toString() { - return name; - } - - - @Override - public boolean equals(Object principal) { - if (principal == null) - return false; - if (this == principal) - return true; - if (getClass() != principal.getClass()) - return false; - final BasicAuthenticationPrincipal other = (BasicAuthenticationPrincipal)principal; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)){ - return false; - } - - return true; - } - -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java deleted file mode 100644 index 189866a23f..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java +++ /dev/null @@ -1,101 +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.authentication.basic; - -import javax.security.auth.Subject; -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.interfacedef.Operation; -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.PolicySet; -import org.apache.tuscany.sca.policy.security.SecurityUtil; - -/** - * - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationReferencePolicyInterceptor implements PhasedInterceptor { - private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication"); - - private Invoker next; - private Operation operation; - private PolicySet policySet = null; - private String context; - private BasicAuthenticationPolicy policy; - - public BasicAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) { - super(); - this.operation = operation; - this.policySet = policySet; - this.context = context; - init(); - } - - private void init() { - if (policySet != null) { - for (Object policyObject : policySet.getPolicies()){ - if (policyObject instanceof BasicAuthenticationPolicy){ - policy = (BasicAuthenticationPolicy)policyObject; - break; - } - } - } - } - - public Message invoke(Message msg) { - - // get the security context - Subject subject = SecurityUtil.getSubject(msg); - BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject, - BasicAuthenticationPrincipal.class); - - // if no credentials propogated from the reference then use - // the ones from the policy - if (principal == null && - policy.getUserName() != null && - !policy.getUserName().equals("")) { - principal = new BasicAuthenticationPrincipal(policy.getUserName(), - policy.getPassword()); - subject.getPrincipals().add(principal); - } - - if (principal == null){ - // alternatively we could call out here to some 3rd party system to get credentials - // or convert from some other security principal - } - - return getNext().invoke(msg); - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public String getPhase() { - return Phase.REFERENCE_POLICY; - } -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java deleted file mode 100644 index d4d8e59429..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java +++ /dev/null @@ -1,71 +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.authentication.basic; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.EndpointReference; -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; - -/** - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationReferencePolicyProvider implements PolicyProvider { - private EndpointReference endpointReference; - - public BasicAuthenticationReferencePolicyProvider(EndpointReference endpointReference) { - super(); - this.endpointReference = endpointReference; - } - - private PolicySet findPolicySet() { - List policySets = endpointReference.getPolicySets(); - for (PolicySet ps : policySets) { - for (Object p : ps.getPolicies()) { - if (BasicAuthenticationPolicy.class.isInstance(p)) { - return ps; - } - } - } - return null; - } - - private String getContext() { - return endpointReference.getURI(); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public PhasedInterceptor createInterceptor(Operation operation) { - PolicySet ps = findPolicySet(); - return ps == null ? null : new BasicAuthenticationReferencePolicyInterceptor(getContext(), operation, ps); - } - - public void start() { - } - - public void stop() { - } - -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java deleted file mode 100644 index 39f70c7e78..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java +++ /dev/null @@ -1,102 +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.authentication.basic; - - -import javax.security.auth.Subject; -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.interfacedef.Operation; -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.PolicySet; -import org.apache.tuscany.sca.policy.security.SecurityUtil; - - -/** - * Policy handler to handle PolicySet related to Logging with the QName - * {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy - * - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationServicePolicyInterceptor implements PhasedInterceptor { - private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, "wsBasicAuthentication"); - - private Invoker next; - private Operation operation; - private PolicySet policySet = null; - private String context; - private BasicAuthenticationPolicy policy; - - public BasicAuthenticationServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) { - super(); - this.operation = operation; - this.policySet = policySet; - this.context = context; - init(); - } - - private void init() { - if (policySet != null) { - for (Object policyObject : policySet.getPolicies()){ - if (policyObject instanceof BasicAuthenticationPolicy){ - policy = (BasicAuthenticationPolicy)policyObject; - break; - } - } - } - } - - public Message invoke(Message msg) { - - Subject subject = SecurityUtil.getSubject(msg); - BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject, - BasicAuthenticationPrincipal.class); - - if (principal != null){ - - System.out.println("Username: " + - principal.getName() + - " Password: " + - principal.getPassword()); - - // could call out here to some 3rd party system to do whatever you - // need to do do with username and password - - } - - return getNext().invoke(msg); - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - - public String getPhase() { - return Phase.SERVICE_POLICY; - } - -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java deleted file mode 100644 index b640ec60e5..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java +++ /dev/null @@ -1,71 +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.authentication.basic; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Endpoint; -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; - -/** - * @version $Rev$ $Date$ - */ -public class BasicAuthenticationServicePolicyProvider implements PolicyProvider { - private Endpoint endpoint; - - public BasicAuthenticationServicePolicyProvider(Endpoint endpoint) { - super(); - this.endpoint = endpoint; - } - - private PolicySet findPolicySet() { - List policySets = endpoint.getPolicySets(); - for (PolicySet ps : policySets) { - for (Object p : ps.getPolicies()) { - if (BasicAuthenticationPolicy.class.isInstance(p)) { - return ps; - } - } - } - return null; - } - - private String getContext() { - return endpoint.getURI(); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public PhasedInterceptor createInterceptor(Operation operation) { - PolicySet ps = findPolicySet(); - return ps == null ? null : new BasicAuthenticationServicePolicyInterceptor(getContext(), operation, ps); - } - - public void start() { - } - - public void stop() { - } - -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java b/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java deleted file mode 100644 index 147b863c01..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.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.authentication.token; - -import java.security.Principal; - - -/** - * - * @version $Rev$ $Date$ - */ -public class TokenPrincipal implements Principal { - - private String name; - - public TokenPrincipal(String name){ - if (name == null) { - throw new IllegalArgumentException("name cannot be null"); - } - - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public String toString() { - return name; - } - - - @Override - public boolean equals(Object principal) { - if (principal == null) - return false; - if (this == principal) - return true; - if (getClass() != principal.getClass()) - return false; - final TokenPrincipal other = (TokenPrincipal)principal; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)){ - return false; - } - - return true; - } - -} -- cgit v1.2.3