summaryrefslogtreecommitdiffstats
path: root/java/sca/itest/policy-security-basicauth
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-09-15 08:07:58 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-09-15 08:07:58 +0000
commitfa51018b6c24f598ae8174afa183b0b46436e69b (patch)
treeb6c37b85d26f0755ba95200227ea942bd2135c00 /java/sca/itest/policy-security-basicauth
parent5c5b60f1525a5865a3c2bc35263224c2cd79c713 (diff)
More work exploring the policy extension model by implementing a token based authentication schema across binding.ws and binding.jm. No authentication is actually performed here. That is left for users to provide their own policy interceptors. However tokens are passed and security Subjects/Principals are created. This exercise has highlighted some awkwardness in the process of building policy implementations. I'll post about this on the mail list.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@695374 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/itest/policy-security-basicauth')
-rw-r--r--java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldClientImpl.java6
-rw-r--r--java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldServiceImpl.java15
-rw-r--r--java/sca/itest/policy-security-basicauth/src/main/resources/definitions.xml19
-rw-r--r--java/sca/itest/policy-security-basicauth/src/main/resources/helloworld.composite14
-rw-r--r--java/sca/itest/policy-security-basicauth/src/main/resources/jndi.properties39
5 files changed, 25 insertions, 68 deletions
diff --git a/java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldClientImpl.java b/java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldClientImpl.java
index 55b798edbe..7345af7f7c 100644
--- a/java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldClientImpl.java
+++ b/java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldClientImpl.java
@@ -30,13 +30,11 @@ public class HelloWorldClientImpl implements HelloWorldService {
@Reference
protected HelloWorldService helloworldWS;
- @Reference
- protected HelloWorldService helloworldJMS;
+
public String getGreetings(String name) {
return "Hello " +
- helloworldWS.getGreetings(name) +
- helloworldJMS.getGreetings(name);
+ helloworldWS.getGreetings(name);
}
}
diff --git a/java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldServiceImpl.java
index 411dcae605..6372570d1f 100644
--- a/java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldServiceImpl.java
+++ b/java/sca/itest/policy-security-basicauth/src/main/java/helloworld/HelloWorldServiceImpl.java
@@ -18,6 +18,10 @@
*/
package helloworld;
+import javax.security.auth.Subject;
+
+import org.osoa.sca.RequestContext;
+import org.osoa.sca.annotations.Context;
import org.osoa.sca.annotations.Service;
/**
@@ -26,8 +30,17 @@ import org.osoa.sca.annotations.Service;
@Service(HelloWorldService.class)
public class HelloWorldServiceImpl implements HelloWorldService {
+ @Context
+ protected RequestContext requestContext;
+
public String getGreetings(String name) {
- return "Hello " + name;
+ Subject subject = requestContext.getSecuritySubject();
+
+ if (subject == null){
+ return "Hello " + name + " null subject";
+ } else {
+ return "Hello " + name + " " + subject.toString();
+ }
}
}
diff --git a/java/sca/itest/policy-security-basicauth/src/main/resources/definitions.xml b/java/sca/itest/policy-security-basicauth/src/main/resources/definitions.xml
index 9099191b27..dbdf0cd263 100644
--- a/java/sca/itest/policy-security-basicauth/src/main/resources/definitions.xml
+++ b/java/sca/itest/policy-security-basicauth/src/main/resources/definitions.xml
@@ -27,21 +27,18 @@
<sca:policySet name="BasicAuthenticationPolicySet"
provides="authentication"
appliesTo="sca:binding.ws">
-
<tuscany:basicAuthentication>
<tuscany:userName>myname</tuscany:userName>
<tuscany:password>mypassword</tuscany:password>
</tuscany:basicAuthentication>
-
</sca:policySet>
-
- <!-- some authentication implementation policies - may think about these later
- <policySet name="allowed_users" appliesTo="sca:implementation.java">
- <permitAll/>
- </policySet>
- <policySet name="runAsAdmin" appliesTo="sca:implementation.java">
- <runAs role="Administrator"/>
- </policySet>
- -->
+ <sca:policySet name="ImplementationIdentityPolicySet"
+ provides="tuscany:identity"
+ appliesTo="sca:implementation.java">
+ <securityIdentity>
+ <useCallerIdentity/>
+ </securityIdentity>
+ </sca:policySet>
+
</definitions> \ No newline at end of file
diff --git a/java/sca/itest/policy-security-basicauth/src/main/resources/helloworld.composite b/java/sca/itest/policy-security-basicauth/src/main/resources/helloworld.composite
index 247b2b56e4..f883629180 100644
--- a/java/sca/itest/policy-security-basicauth/src/main/resources/helloworld.composite
+++ b/java/sca/itest/policy-security-basicauth/src/main/resources/helloworld.composite
@@ -33,26 +33,14 @@
<reference name="helloworldWS" requires="authentication">
<binding.ws uri="http://localhost:8085/HelloWorldServiceWSComponent"/>
</reference>
- <reference name="helloworldJMS">
- <binding.jms uri="jms:HelloWorldService"/>
- </reference>
</component>
<component name="HelloWorldServiceWSComponent">
- <implementation.java class="helloworld.HelloWorldServiceImpl" />
+ <implementation.java class="helloworld.HelloWorldServiceImpl" requires="tuscany:identity"/>
<service name="HelloWorldService" requires="authentication">
<interface.java interface="helloworld.HelloWorldService"/>
<binding.ws uri="http://localhost:8085/HelloWorldServiceWSComponent"/>
</service>
</component>
- <component name="HelloWorldServiceJMSComponent">
- <implementation.java class="helloworld.HelloWorldServiceImpl" />
-
- <!--service name="HelloWorldService" requires="authentication"-->
- <service name="HelloWorldService" >
- <interface.java interface="helloworld.HelloWorldService"/>
- <binding.jms/>
- </service>
- </component>
</composite>
diff --git a/java/sca/itest/policy-security-basicauth/src/main/resources/jndi.properties b/java/sca/itest/policy-security-basicauth/src/main/resources/jndi.properties
deleted file mode 100644
index 9abdff215d..0000000000
--- a/java/sca/itest/policy-security-basicauth/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,39 +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.
-## ---------------------------------------------------------------------------
-
-# START SNIPPET: jndi
-
-java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
-
-# use the following property to configure the default connector
-java.naming.provider.url = vm://localhost?broker.persistent=false
-
-# use the following property to specify the JNDI name the connection factory
-# should appear as.
-#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
-connectionFactoryNames = ConnectionFactory
-
-# register some queues in JNDI using the form
-# queue.[jndiName] = [physicalName]
-queue.RequestQueue = RequestQueue
-queue.ResponseQueue = ResponseQueue
-
-# register some topics in JNDI using the form
-# topic.[jndiName] = [physicalName]
-#topic.MyTopic = example.MyTopic
-
-# END SNIPPET: jndi