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 2007/12/14 19:07:45 UTC
svn commit: r604245 - in /incubator/tuscany/java/sca/modules:
core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/
implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/
implem...
Author: svkrish
Date: Fri Dec 14 10:07:40 2007
New Revision: 604245
URL: http://svn.apache.org/viewvc?rev=604245&view=rev
Log:
starting to add JAAS based security to Java Implementation
Added:
incubator/tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/
incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java
incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java
incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java
incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasLoginModule.java
incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java
Removed:
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
Modified:
incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
Modified: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java?rev=604245&r1=604244&r2=604245&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java Fri Dec 14 10:07:40 2007
@@ -26,13 +26,12 @@
import java.util.List;
import java.util.Map;
-import javax.xml.namespace.QName;
-
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.impl.JavaConstructorImpl;
import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
import org.apache.tuscany.sca.implementation.java.impl.JavaScopeImpl;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
/**
@@ -59,8 +58,8 @@
private long maxAge = -1;
private long maxIdleTime = -1;
private JavaScopeImpl scope = JavaScopeImpl.STATELESS;
- private Map<ClassLoader, Map<QName, String>> policyHandlerClassNames = null;
-
+ private Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames = null;
+
protected BeanJavaImplementationImpl(BeanDefinitionRegistry beanRegistry) {
super(beanRegistry);
}
@@ -165,11 +164,11 @@
this.maxIdleTime = maxIdleTime;
}
- public Map<ClassLoader, Map<QName, String>> getPolicyHandlerClassNames() {
+ public Map<ClassLoader, List<PolicyHandlerTuple>> getPolicyHandlerClassNames() {
return policyHandlerClassNames;
}
- public void setPolicyHandlerClassNames(Map<ClassLoader, Map<QName, String>> policyHandlerClassNames) {
+ public void setPolicyHandlerClassNames(Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames) {
this.policyHandlerClassNames = policyHandlerClassNames;
}
}
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java?rev=604245&r1=604244&r2=604245&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java Fri Dec 14 10:07:40 2007
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.implementation.java.invocation;
+import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
@@ -40,6 +41,7 @@
import org.apache.tuscany.sca.implementation.java.injection.ResourceObjectFactory;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.osoa.sca.ComponentContext;
@@ -60,7 +62,7 @@
JavaPropertyValueObjectFactory propertyValueObjectFactory,
ComponentContextFactory componentContextFactory,
RequestContextFactory requestContextFactory,
- Map<ClassLoader, Map<QName, String>> policyHandlerClassNames) {
+ Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames) {
super();
this.implementation = implementation;
this.requestContextFactory = requestContextFactory;
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java?rev=604245&r1=604244&r2=604245&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java Fri Dec 14 10:07:40 2007
@@ -19,16 +19,16 @@
package org.apache.tuscany.sca.implementation.java.invocation;
+import java.util.List;
import java.util.Map;
-import javax.xml.namespace.QName;
-
import org.apache.tuscany.sca.context.ComponentContextFactory;
import org.apache.tuscany.sca.context.RequestContextFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.provider.ImplementationProvider;
import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -42,14 +42,14 @@
private ProxyFactory proxyService;
private ComponentContextFactory componentContextFactory;
private RequestContextFactory requestContextFactory;
- private Map<ClassLoader, Map<QName, String>> policyHandlerClassNames = null;
+ private Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames = null;
public JavaImplementationProviderFactory(ProxyFactory proxyService,
DataBindingExtensionPoint dataBindingRegistry,
JavaPropertyValueObjectFactory propertyValueObjectFactory,
ComponentContextFactory componentContextFactory,
RequestContextFactory requestContextFactory,
- Map<ClassLoader, Map<QName, String>> policyHandlerClassNames) {
+ Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames) {
super();
this.proxyService = proxyService;
this.dataBindingRegistry = dataBindingRegistry;
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java?rev=604245&r1=604244&r2=604245&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java Fri Dec 14 10:07:40 2007
@@ -23,16 +23,16 @@
import java.util.List;
import java.util.Map;
-import javax.xml.namespace.QName;
-
import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.invocation.InvocationChain;
+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.util.PolicyHandler;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeWire;
@@ -112,24 +112,31 @@
}
private PolicyHandler getPolicyHandler(PolicySet policySet,
- Map<ClassLoader, Map<QName, String>> policyHandlerClassNames) throws IllegalAccessException, ClassNotFoundException, InstantiationException {
+ Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames)
+ throws IllegalAccessException, ClassNotFoundException, InstantiationException {
+
PolicyHandler handler = null;
- String handlerClassName = null;
for (ClassLoader classLoader : policyHandlerClassNames.keySet()) {
- Map<QName, String> policyHandlerClassnamesMap = policyHandlerClassNames.get(classLoader);
- for ( QName policySetName : policyHandlerClassnamesMap.keySet() ) {
- if ( policySet.getName().equals(policySetName) ) {
- handlerClassName = policyHandlerClassnamesMap.get(policySet.getName());
- if ( handlerClassName != null ) {
- handler =
- (PolicyHandler)Class.forName(handlerClassName, true, classLoader).newInstance();
- handler.setApplicablePolicySet(policySet);
- break;
+ for ( PolicyHandlerTuple handlerTuple : policyHandlerClassNames.get(classLoader) ) {
+ for ( Intent intent : policySet.getProvidedIntents() ) {
+ if ( intent.getName().equals(handlerTuple.getProvidedIntentName())) {
+ for ( Object policy : policySet.getPolicies() ) {
+ if ( policy.getClass().getName().equals(handlerTuple.getPolicyModelClassName())) {
+ handler =
+ (PolicyHandler)Class.forName(handlerTuple.getPolicyHandlerClassName(),
+ true,
+ classLoader).newInstance();
+ handler.setApplicablePolicySet(policySet);
+ return handler;
+ }
+ }
}
}
}
- }
+ }
+
return handler;
}
+
}
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java?rev=604245&r1=604244&r2=604245&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java Fri Dec 14 10:07:40 2007
@@ -20,7 +20,10 @@
package org.apache.tuscany.sca.implementation.java.module;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -68,6 +71,7 @@
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.util.PolicyHandler;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
@@ -75,8 +79,6 @@
* @version $Rev$ $Date$
*/
public class JavaRuntimeModuleActivator implements ModuleActivator {
- private static final String POLICY_HANDLERS_STORE_FILE =
- "org.apache.tuscany.sca.implementation.java.PolicySetHandlers";
public JavaRuntimeModuleActivator() {
}
@@ -122,7 +124,7 @@
ComponentContextFactory componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class);
RequestContextFactory requestContextFactory = contextFactories.getFactory(RequestContextFactory.class);
- Map<ClassLoader, Map<QName, String>> policyHandlerClassNames = null;
+ Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames = null;
try {
policyHandlerClassNames = loadPolicyHandlerClassnames();
} catch (IOException e) {
@@ -169,7 +171,7 @@
throw new IllegalArgumentException("Invalid qname: " + qname);
}
- private Map<ClassLoader, Map<QName, String>> loadPolicyHandlerClassnames() throws IOException {
+ private Map<ClassLoader, List<PolicyHandlerTuple>> loadPolicyHandlerClassnames() throws IOException {
// Get the processor service declarations
Set<ServiceDeclaration> sds;
try {
@@ -177,8 +179,24 @@
} catch (IOException e) {
throw new IllegalStateException(e);
}
+
+ Map<ClassLoader, List<PolicyHandlerTuple>> handlerTuples = new Hashtable<ClassLoader, List<PolicyHandlerTuple>>();
+ for (ServiceDeclaration sd : sds) {
+ ClassLoader cl = sd.getClassLoader();
+
+ List<PolicyHandlerTuple> handlerTupleList = handlerTuples.get(cl);
+ if ( handlerTupleList == null ) {
+ handlerTupleList = new ArrayList<PolicyHandlerTuple>();
+ handlerTuples.put(cl, handlerTupleList);
+ }
+ Map<String, String> attributes = sd.getAttributes();
+ String intentName = attributes.get("intent");
+ QName intentQName = getQName(intentName);
+ String policyModelClassName = attributes.get("model");
+ handlerTupleList.add(new PolicyHandlerTuple(sd.getClassName(), intentQName, policyModelClassName));
+ }
- Map<ClassLoader, Map<QName, String>> policyHandlerClassNames = new HashMap<ClassLoader, Map<QName, String>>();
+ /*Map<ClassLoader, Map<QName, String>> policyHandlerClassNames = new HashMap<ClassLoader, Map<QName, String>>();
for (ServiceDeclaration sd : sds) {
Map<String, String> attributes = sd.getAttributes();
@@ -192,8 +210,8 @@
}
map.put(name, sd.getClassName());
}
-
- return policyHandlerClassNames;
+ */
+ return handlerTuples;
}
}
Modified: incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java?rev=604245&r1=604244&r2=604245&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java Fri Dec 14 10:07:40 2007
@@ -31,6 +31,7 @@
import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
import org.apache.tuscany.sca.implementation.java.impl.JavaScopeImpl;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
/**
* Represents a Java implementation.
@@ -188,11 +189,11 @@
/**
* @return the map of a policy handler classnames
*/
- public Map<ClassLoader, Map<QName, String>> getPolicyHandlerClassNames();
+ public Map<ClassLoader, List<PolicyHandlerTuple>> getPolicyHandlerClassNames();
/**
* @param map of policyhandler classnames
*/
- public void setPolicyHandlerClassNames(Map<ClassLoader, Map<QName, String>> policyHandlerClassNames);
+ public void setPolicyHandlerClassNames(Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames);
}
Modified: incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java?rev=604245&r1=604244&r2=604245&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java Fri Dec 14 10:07:40 2007
@@ -26,9 +26,8 @@
import java.util.List;
import java.util.Map;
-import javax.xml.namespace.QName;
-
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
/**
* A component type specialization for POJO implementations
@@ -51,7 +50,7 @@
private long maxAge = -1;
private long maxIdleTime = -1;
private JavaScopeImpl scope = JavaScopeImpl.STATELESS;
- private Map<ClassLoader, Map<QName, String>> policyHandlerClassNames = null;
+ private Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames = null;
protected JavaImplementationImpl() {
super();
@@ -157,11 +156,11 @@
this.maxIdleTime = maxIdleTime;
}
- public Map<ClassLoader, Map<QName, String>> getPolicyHandlerClassNames() {
+ public Map<ClassLoader, List<PolicyHandlerTuple>> getPolicyHandlerClassNames() {
return policyHandlerClassNames;
}
- public void setPolicyHandlerClassNames(Map<ClassLoader, Map<QName, String>> policyHandlerClassNames) {
+ public void setPolicyHandlerClassNames(Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames) {
this.policyHandlerClassNames = policyHandlerClassNames;
}
Added: incubator/tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler?rev=604245&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler (added)
+++ incubator/tuscany/java/sca/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler Fri Dec 14 10:07:40 2007
@@ -0,0 +1,20 @@
+# 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.
+#
+# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures
+# handler classname;qname=<policy intent addressed>;model=<policy model class>
+org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicyHandler;intent=http://tuscany.apache.org/xmlns/sca/1.0#logging,model=org.apache.tuscany.sca.policy.logging.jdk.JDKLoggingPolicy
Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java?rev=604245&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java Fri Dec 14 10:07:40 2007
@@ -0,0 +1,33 @@
+/*
+ * 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.jaas;
+
+public class JaasAuthenticationPolicy {
+ private String callbackHandlerClassName;
+
+ public String getCallbackHandlerClassName() {
+ return callbackHandlerClassName;
+ }
+
+ public void setCallbackHandlerClassName(String callbackHandlerClassName) {
+ this.callbackHandlerClassName = callbackHandlerClassName;
+ }
+
+}
Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java?rev=604245&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java Fri Dec 14 10:07:40 2007
@@ -0,0 +1,74 @@
+package org.apache.tuscany.sca.policy.security.jaas;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginContext;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.util.PolicyHandler;
+
+/*
+ * 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.
+ */
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ */
+public class JaasAuthenticationPolicyHandler implements PolicyHandler {
+ private static final String jaasPolicy = "JaasPolicy";
+ public static final QName policySetQName = new QName(Constants.SCA10_TUSCANY_NS,
+ jaasPolicy);
+ private PolicySet applicablePolicySet = null;
+
+ public void setUp(Object... context) {
+ if ( applicablePolicySet != null ) {
+ }
+ }
+
+ public void cleanUp(Object... context) {
+ }
+
+ public void beforeInvoke(Object... context) {
+ Message msg = null;
+
+ try {
+ CallbackHandler callbackHandler = (CallbackHandler)
+ Class.forName(((JaasAuthenticationPolicy)applicablePolicySet.getPolicies().get(0)).
+ getCallbackHandlerClassName()).newInstance();
+ LoginContext lc = new LoginContext("Calculator", callbackHandler);
+ lc.login();
+ } catch ( Exception e ) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ public void afterInvoke(Object... context) {
+
+ }
+
+ public PolicySet getApplicablePolicySet() {
+ return applicablePolicySet;
+ }
+
+ public void setApplicablePolicySet(PolicySet applicablePolicySet) {
+ this.applicablePolicySet = applicablePolicySet;
+ }
+}
Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java?rev=604245&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java Fri Dec 14 10:07:40 2007
@@ -0,0 +1,109 @@
+/*
+ * 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.jaas;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.logging.Level;
+
+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.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;
+
+/**
+ * @author administrator
+ *
+ */
+public class JaasAuthenticationPolicyProcessor implements StAXArtifactProcessor<JaasAuthenticationPolicy> {
+ private static final QName JAAS_AUTHENTICATION_POLICY_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "jaasAuthentication");
+ private static final String callbackHandler = "callbackHandler";
+ public static final QName CALLBACK_HANDLER_QNAME = new QName(Constants.SCA10_TUSCANY_NS,
+ callbackHandler);
+ public QName getArtifactType() {
+ return JAAS_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public JaasAuthenticationPolicyProcessor(ModelFactoryExtensionPoint modelFactories) {
+ }
+
+
+ public JaasAuthenticationPolicy read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ JaasAuthenticationPolicy policy = new JaasAuthenticationPolicy();
+ int event = reader.getEventType();
+ QName name = null;
+
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT : {
+ name = reader.getName();
+ if ( name.equals(CALLBACK_HANDLER_QNAME) ) {
+ String callbackHandlerClassName = reader.getElementText();
+ policy.setCallbackHandlerClassName(callbackHandlerClassName);
+ }
+ break;
+ }
+ }
+
+ if ( event == END_ELEMENT ) {
+ if ( JAAS_AUTHENTICATION_POLICY_QNAME.equals(reader.getName()) ) {
+ break;
+ }
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return policy;
+ }
+
+ public void write(JaasAuthenticationPolicy policy, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ JAAS_AUTHENTICATION_POLICY_QNAME.getLocalPart(),
+ JAAS_AUTHENTICATION_POLICY_QNAME.getNamespaceURI());
+ writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS);
+
+
+ writer.writeEndElement();
+ }
+
+ public Class<JaasAuthenticationPolicy> getModelType() {
+ return JaasAuthenticationPolicy.class;
+ }
+
+ public void resolve(JaasAuthenticationPolicy arg0, ModelResolver arg1) throws ContributionResolveException {
+
+ }
+
+}
Added: incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasLoginModule.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasLoginModule.java?rev=604245&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasLoginModule.java (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasLoginModule.java Fri Dec 14 10:07:40 2007
@@ -0,0 +1,84 @@
+/*
+ * 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.jaas;
+
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JaasLoginModule implements LoginModule {
+
+ private CallbackHandler callbackHandler = null;
+ private Subject subject = null;
+
+ public boolean abort() throws LoginException {
+ return true;
+ }
+
+
+ public boolean commit() throws LoginException {
+ return true;
+ }
+
+ public void initialize(Subject subject,
+ CallbackHandler callbackHandler,
+ Map<String, ?> sharedState,
+ Map<String, ?> options) {
+ this.callbackHandler = callbackHandler;
+ this.subject = subject;
+ }
+
+ public boolean login() throws LoginException {
+ Callback[] callbacks = new Callback[2];
+ callbacks[0] = new NameCallback("UserId:");
+ callbacks[1] = new PasswordCallback("Password:", false);
+
+ try {
+ callbackHandler.handle(callbacks);
+ String userId = ((NameCallback)callbacks[0]).getName();
+ String password = new String(((PasswordCallback)callbacks[1]).getPassword());
+
+ if ( userId.equals("CalculatorUser") && password.equals("CalculatorUserPasswd")) {
+ System.out.println("Successfully AUTHENTICATED!!");
+ return true;
+ } else {
+ System.out.println("Incorrect userId / password! AUTHENTICATION FAILED!!");
+ return false;
+ }
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public boolean logout() throws LoginException {
+ return true;
+ }
+
+}
Modified: incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=604245&r1=604244&r2=604245&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (original)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Fri Dec 14 10:07:40 2007
@@ -17,3 +17,4 @@
# Implementation class for the artifact processor extension
org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#wsConfigParam,model=org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicy
+org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#jaasAuthentication,model=org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicy
\ No newline at end of file
Added: incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler?rev=604245&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler (added)
+++ incubator/tuscany/java/sca/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler Fri Dec 14 10:07:40 2007
@@ -0,0 +1,20 @@
+# 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.
+#
+# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures
+# handler classname;qname=<policy intent addressed>;model=<policy model class>
+org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicyHandler;intent=http://tuscany.apache.org/xmlns/sca/1.0#jaasAuthentication,model=org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicy
Added: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java?rev=604245&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java (added)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java Fri Dec 14 10:07:40 2007
@@ -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.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * PolicyHanlder tuples stored in policy handler services files
+ */
+public class PolicyHandlerTuple {
+ private String policyHandlerClassName;
+ private QName providedIntentName;
+ private String policyModelClassName;
+
+ public PolicyHandlerTuple(String handlerClassName,
+ QName providedIntentName,
+ String policyModelClassName) {
+ this.policyHandlerClassName = handlerClassName;
+ this.providedIntentName = providedIntentName;
+ this.policyModelClassName = policyModelClassName;
+ }
+
+ public String getPolicyHandlerClassName() {
+ return policyHandlerClassName;
+ }
+ public void setPolicyHandlerClassName(String policyHandlerClassName) {
+ this.policyHandlerClassName = policyHandlerClassName;
+ }
+ public String getPolicyModelClassName() {
+ return policyModelClassName;
+ }
+ public void setPolicyModelClassName(String policyModelClassName) {
+ this.policyModelClassName = policyModelClassName;
+ }
+ public QName getProvidedIntentName() {
+ return providedIntentName;
+ }
+ public void setProvidedIntentName(QName providedIntentName) {
+ this.providedIntentName = providedIntentName;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org