Author: bblfish
Date: Thu Feb 24 13:36:55 2011
New Revision: 1074141

URL: http://svn.apache.org/viewvc?rev=1074141&view=rev
Log:
Very beginning of adding a package of test servlets to test foafssl.

Added:
    incubator/clerezza/trunk/parent/platform.security.foafssl/test/
    incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xml
    incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/
    incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/resources/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/resources/OSGI-INF/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/resources/OSGI-INF/serviceComponents.xml
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/testservlet/
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/testservlet/TestMe.scala
Modified:
    incubator/clerezza/trunk/parent/platform.security.foafssl/pom.xml

Modified: incubator/clerezza/trunk/parent/platform.security.foafssl/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/pom.xml?rev=1074141&r1=1074140&r2=1074141&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.security.foafssl/pom.xml (original)
+++ incubator/clerezza/trunk/parent/platform.security.foafssl/pom.xml Thu Feb 
24 13:36:55 2011
@@ -13,5 +13,6 @@
        <modules>
                <module>ontologies</module>
                <module>core</module>
+        <module>test</module>
        </modules>
 </project>

Added: incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xml?rev=1074141&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xml 
(added)
+++ incubator/clerezza/trunk/parent/platform.security.foafssl/test/pom.xml Thu 
Feb 24 13:36:55 2011
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project 
xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.apache.clerezza</groupId>
+               <artifactId>platform.security.foafssl</artifactId>
+               <version>0.1-incubating-SNAPSHOT</version>
+       </parent>
+       <groupId>org.apache.clerezza</groupId>
+       <artifactId>platform.security.foafssl.test</artifactId>
+       <version>0.1-incubating-SNAPSHOT</version>
+       <packaging>bundle</packaging>
+       <name>Clerezza - Platform Security foaf+ssl Tests</name>
+       <description>
+               Foaf + Ssl test "servlets" to run WebID tests on.
+       </description>
+
+       <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       
<artifactId>platform.security.foafssl.ontologies</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       <artifactId>rdf.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       <artifactId>platform</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       <artifactId>platform.typerendering.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       
<artifactId>platform.typerendering.scalaserverpages</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       <artifactId>rdf.scala.utils</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       <artifactId>platform.security</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       <artifactId>platform.users.core</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>javax.ws.rs</groupId>
+                       <artifactId>jsr311-api</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.scala-lang</groupId>
+                       <artifactId>scala-library</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.jsslutils</groupId>
+                       <artifactId>jsslutils</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.wymiwyg</groupId>
+                       <artifactId>jetty-osgi-httpservice</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+
+       <build>
+               <sourceDirectory>src/main/scala</sourceDirectory>
+               <testSourceDirectory>src/test/scala</testSourceDirectory>
+               <plugins>
+                       <plugin>
+                               <groupId>org.scala-tools</groupId>
+                               <artifactId>maven-scala-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>compile</goal>
+                                                       <goal>testCompile</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                               <configuration>
+                                       <!-- 
<scalaVersion>${scala.version}</scalaVersion> -->
+                                       <!-- <args>
+                                               <arg>-target:jvm-1.5</arg>
+                                       </args> -->
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <configuration>
+                                       <instructions>
+                                               
<Service-Component>OSGI-INF/serviceComponents.xml</Service-Component>
+                                               
<Export-Package>!org.apache.clerezza.foafssl.ontologies,
+                                                               
org.apache.clerezza.foafssl.*</Export-Package>
+                                               
<Bundle-SymbolicName>org.apache.clerezza.foafssl</Bundle-SymbolicName>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+</project>

Added: 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/resources/OSGI-INF/serviceComponents.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/resources/OSGI-INF/serviceComponents.xml?rev=1074141&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/resources/OSGI-INF/serviceComponents.xml
 (added)
+++ 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/resources/OSGI-INF/serviceComponents.xml
 Thu Feb 24 13:36:55 2011
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0";>
+       <scr:component enabled="true" 
name="org.apache.clerezza.foafssl.ssl.Activator" immediate="true">
+               <implementation 
class="org.apache.clerezza.foafssl.ssl.Activator"/>
+               <reference name="x509TrustManagerWrapperService"
+               
interface="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService"
+               cardinality="1..1" policy="static" 
bind="bindX509TrustManagerWrapperService" 
unbind="unbindX509TrustManagerWrapperService"/>
+       </scr:component>
+       <scr:component enabled="true" 
name="org.apache.clerezza.foafssl.auth.FoafSslAuthentication" immediate="true">
+               <implementation 
class="org.apache.clerezza.foafssl.auth.FoafSslAuthentication"/>
+               <service servicefactory="false">
+                       <provide 
interface="org.apache.clerezza.platform.security.auth.WeightedAuthenticationMethod"/>
+               </service>
+               <reference name="webDescriptionProvider" 
interface="org.apache.clerezza.platform.users.WebDescriptionProvider"
+               cardinality="1..1" policy="static" 
bind="bindWebDescriptionProvider" unbind="unbindWebDescriptionProvider"/>
+               <!-- <reference name="conceptProviderManager"
+               
interface="org.apache.clerezza.platform.concepts.core.ConceptProviderManager"
+               cardinality="1..1" policy="static" 
bind="bindConceptProviderManager" unbind="unbindConceptProviderManager"/>
+               <reference name="renderletManager"
+               
interface="org.apache.clerezza.platform.typerendering.RenderletManager"
+               cardinality="1..1" policy="static" bind="bindRenderletManager" 
unbind="unbindRenderletManager"/> -->
+       </scr:component>
+       <scr:component enabled="true" 
name="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService">
+               <implementation 
class="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService"/>
+               <service servicefactory="false">
+                       <provide 
interface="org.apache.clerezza.foafssl.ssl.X509TrustManagerWrapperService"/>
+               </service>
+               <reference name="tcManager" 
interface="org.apache.clerezza.platform.users.WebDescriptionProvider"
+               cardinality="1..1" policy="static" 
bind="bindWebDescriptionProvider" unbind="unbindWebDescriptionProvider"/>
+               <reference name="systemGraph" 
interface="org.apache.clerezza.rdf.core.access.LockableMGraph" 
+               cardinality="1..1" policy="static" 
target="(name=http://tpf.localhost/system.graph)" 
+               bind="bindSystemGraph" unbind="unbindSystemGraph"/>
+       </scr:component>
+</components>

Added: 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala?rev=1074141&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala
 (added)
+++ 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/Utilities.scala
 Thu Feb 24 13:36:55 2011
@@ -0,0 +1,80 @@
+/*
+ * 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.clerezza.foafssl
+
+import java.security.cert.X509Certificate
+import org.apache.clerezza.rdf.core.UriRef
+
+/**
+ * Utilitie functions to deal with certificates
+ *
+ * @author Reto Bachmann-Gmür, Henry Story
+ */
+object Utilities {
+       
+       /**
+        * same as getClaimedWebIds(chain(0))
+        */
+       def getClaimedWebIds(chain: Array[X509Certificate]): List[UriRef] = {
+               getClaimedWebIds(chain(0))
+       }
+
+
+       /**
+        * Extracts the URIs in the subject alternative name extension of an 
X.509
+        * certificate (perhaps others such as email addresses could also be
+        * useful).
+        *
+        * @param cert
+        *            X.509 certificate from which to extract the URIs.
+        * @return list of java.net.URIs built from the URIs in the 
subjectAltName
+        *         extension.
+        */
+       def getClaimedWebIds(cert: X509Certificate): List[UriRef] = {
+               //           throws CertificateParsingException {
+               var result : List[UriRef] =  Nil
+               if (cert == null) {
+                       return result;
+               }
+
+               val names = cert.getSubjectAlternativeNames()
+               if (names == null) {
+                       return result;
+               }
+
+               //  val n = names(0)
+               import scala.collection.mutable
+               val it = names.iterator;
+               while (it.hasNext)  {
+                       val altNme = it.next()
+                       val altTpe = altNme.get(0);
+                       val altObj = altNme.get(1);
+                       if ((altTpe.asInstanceOf[Integer] == 6) && 
altObj.isInstanceOf[String]) {
+                               result =  new 
UriRef(altObj.asInstanceOf[String]) :: result;
+                       }
+               }
+               return result
+       }
+       
+       def cretateUsernameForWebId(webId: UriRef) = {
+               webId.getUnicodeString.replace(":", "");
+       } 
+
+}
\ No newline at end of file

Added: 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/testservlet/TestMe.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/testservlet/TestMe.scala?rev=1074141&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/testservlet/TestMe.scala
 (added)
+++ 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/testservlet/TestMe.scala
 Thu Feb 24 13:36:55 2011
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011 hjs.
+ *
+ * Licensed 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.clerezza.foafssl.testservlet
+
+import java.security.AccessController
+import java.security.PrivilegedAction
+import org.apache.clerezza.platform.security.UserUtil
+import org.apache.clerezza.platform.usermanager.UserManager
+import org.apache.felix.scr.annotations.Reference;
+import javax.ws.rs._
+
+@Path("/test/webIdEndPoint")
+class TestMe {
+
+  @Reference
+       var userManager: UserManager;
+
+  @GET
+  def getPersonalProfilePage() = {
+    val context = AccessController.getContext();
+    val agent = AccessController.doPrivileged(new 
PrivilegedAction[GraphNode]() {
+                       @Override
+                       def run(): GraphNode = {
+                               val userName = UserUtil.getUserName(context);
+                               if (userName == null) {
+                                       return null;
+                               }
+                               return userManager.getUserGraphNode(userName);
+                       }
+               });
+               if (agent != null) {
+                       node.addProperty(PLATFORM.user, agent.getNode());
+                       MGraph userContext = new 
SimpleMGraph(agent.getNodeContext());
+                       removeTripleWithProperty(userContext, 
PERMISSION.password);
+                       removeTripleWithProperty(userContext, 
PERMISSION.passwordSha1);
+                       node.getGraph().addAll(userContext);
+               }
+               return node;
+    }
+  }
+
+}


Reply via email to