Author: bblfish
Date: Wed Mar 23 21:00:36 2011
New Revision: 1084741

URL: http://svn.apache.org/viewvc?rev=1084741&view=rev
Log:
very initial implementation of CLEREZZA-473 "enable global friend requests"

Added:
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_collection_panel.scala
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_item_panel.scala
Modified:
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/pom.xml
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PersonPanel.scala
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/profile_panel.scala

Modified: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/pom.xml?rev=1084741&r1=1084740&r2=1084741&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/pom.xml
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/pom.xml
 Wed Mar 23 21:00:36 2011
@@ -124,6 +124,10 @@
                        <groupId>org.apache.clerezza</groupId>
                        <artifactId>platform.config</artifactId>
                </dependency>
+        <dependency>
+            <groupId>org.scala-lang</groupId>
+            <artifactId>scala-library</artifactId>
+        </dependency>
                <dependency>
                        <groupId>org.apache.clerezza</groupId>
                        
<artifactId>platform.typerendering.scalaserverpages</artifactId>

Modified: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml?rev=1084741&r1=1084740&r2=1084741&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/resources/OSGI-INF/serviceComponents.xml
 Wed Mar 23 21:00:36 2011
@@ -38,7 +38,6 @@
     </scr:component>
 
 
-
     <scr:component enabled="true" 
name="org.apache.clerezza.platform.accountcontrolpanel.ProfilePanel">
         <implementation 
class="org.apache.clerezza.platform.accountcontrolpanel.ProfilePanel"/>
         <service servicefactory="false">
@@ -63,8 +62,6 @@
         <property name="service.pid" 
value="org.apache.clerezza.platform.accountcontrolpanel.profile_panel"/>
     </scr:component>
 
-
-
        <scr:component enabled="true" 
name="org.apache.clerezza.platform.accountcontrolpanel.PersonPanel">
                <implementation 
class="org.apache.clerezza.platform.accountcontrolpanel.PersonPanel"/>
                <service servicefactory="false">
@@ -82,4 +79,31 @@
                <property name="service.pid" 
value="org.apache.clerezza.platform.accountcontrolpanel.person_panel"/>
        </scr:component>
 
+    <scr:component enabled="true" 
name="org.apache.clerezza.platform.accountcontrolpanel.PingBack">
+        <implementation 
class="org.apache.clerezza.platform.accountcontrolpanel.PingBack"/>
+        <service servicefactory="false">
+            <provide interface="java.lang.Object"/>
+        </service>
+        <property name="javax.ws.rs" type="Boolean" value="true"/>
+        <property name="service.pid" 
value="org.apache.clerezza.platform.accountcontrolpanel.PingBack"/>
+        <reference name="tcManager" 
interface="org.apache.clerezza.rdf.core.access.TcManager"
+        cardinality="1..1" policy="static" bind="bindTcManager" 
unbind="unbindTcManager"/>
+    </scr:component>
+    <scr:component enabled="true" 
name="org.apache.clerezza.platform.accountcontrolpanel.ping_back_panel">
+        <implementation 
class="org.apache.clerezza.platform.accountcontrolpanel.ping_back_collection_panel"/>
+        <service servicefactory="false">
+            <provide 
interface="org.apache.clerezza.platform.typerendering.TypeRenderlet"/>
+        </service>
+        <property name="javax.ws.rs" type="Boolean" value="true"/>
+        <property name="service.pid" 
value="org.apache.clerezza.platform.accountcontrolpanel.ping_back_collection_panel"/>
+    </scr:component>
+    <scr:component enabled="true" 
name="org.apache.clerezza.platform.accountcontrolpanel.ping_back_item_panel">
+        <implementation 
class="org.apache.clerezza.platform.accountcontrolpanel.ping_back_item_panel"/>
+        <service servicefactory="false">
+            <provide 
interface="org.apache.clerezza.platform.typerendering.TypeRenderlet"/>
+        </service>
+        <property name="javax.ws.rs" type="Boolean" value="true"/>
+        <property name="service.pid" 
value="org.apache.clerezza.platform.accountcontrolpanel.ping_back_item_panel"/>
+    </scr:component>
+
 </components>

Modified: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PersonPanel.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PersonPanel.scala?rev=1084741&r1=1084740&r2=1084741&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PersonPanel.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PersonPanel.scala
 Wed Mar 23 21:00:36 2011
@@ -18,56 +18,23 @@
  */
 package org.apache.clerezza.platform.accountcontrolpanel
 
-import java.util.ArrayList
-import java.util.Arrays
-import java.util.Iterator
-import org.apache.clerezza.platform.security.UserUtil
-import org.apache.clerezza.ssl.keygen.CertSerialisation
-import org.apache.clerezza.ssl.keygen.Certificate
-import org.apache.clerezza.foafssl.ontologies.CERT
-import org.apache.clerezza.foafssl.ontologies.RSA
-import org.apache.clerezza.jaxrs.utils.RedirectUtil
-import org.apache.clerezza.jaxrs.utils.TrailingSlash
 import org.apache.clerezza.platform.accountcontrolpanel.ontologies.CONTROLPANEL
-import org.apache.clerezza.platform.config.PlatformConfig
-import org.apache.clerezza.platform.typerendering.RenderletManager
-import 
org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet
-import org.apache.clerezza.platform.usermanager.UserManager
 import org.apache.clerezza.rdf.core._
-import org.apache.clerezza.rdf.core.access.TcManager
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph
-import org.apache.clerezza.rdf.core.impl.TripleImpl
-import org.apache.clerezza.rdf.ontologies.DC
 import org.apache.clerezza.rdf.ontologies.FOAF
 import org.apache.clerezza.rdf.ontologies.PLATFORM
 import org.apache.clerezza.rdf.ontologies.RDF
 import org.apache.clerezza.rdf.utils.GraphNode
-import org.apache.clerezza.rdf.utils.UnionMGraph
-import org.apache.clerezza.web.fileserver.FileServer
-import org.apache.felix.scr.annotations.Component
-import org.apache.felix.scr.annotations.Property
-import org.apache.felix.scr.annotations.Reference
-import org.apache.felix.scr.annotations.Service
 import org.osgi.service.component.ComponentContext
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 import javax.ws.rs._
 import javax.ws.rs.core.Context
-import javax.ws.rs.core.MediaType
-import javax.ws.rs.core.Response
 import javax.ws.rs.core.UriInfo
-import java.math.BigInteger
-import java.net.URL
-import java.security.AccessController
-import java.security.PrivilegedAction
-import java.security.interfaces.RSAPublicKey
-import java.util.List
-import org.apache.clerezza.platform.typerendering.scala.PageRenderlet
-import org.apache.clerezza.rdf.ontologies.RDFS
-import org.apache.clerezza.ssl.keygen.KeygenService
+
 
 object PersonPanel {
-       private val logger: Logger = 
LoggerFactory.getLogger(classOf[ProfilePanel])
+       private val logger: Logger = 
LoggerFactory.getLogger(classOf[PersonPanel])
 }
 
 /**
@@ -77,8 +44,6 @@ object PersonPanel {
  */
 @Path("/user/{id}/people")
 class PersonPanel  {
-       import PersonPanel.logger
-
        protected def activate(componentContext: ComponentContext): Unit = {
 //             this.componentContext = componentContext
        }
@@ -94,7 +59,6 @@ class PersonPanel  {
                //so here the initial fetch could be used to decide if 
information is available at all,
                //ie, if the URL is accessible, if there are error conditions - 
try later for example...
 
-
                //Here we make a BNode the subject of the properties as a 
workaround to CLEREZZA-447
                val resultNode: GraphNode = new GraphNode(new 
UriRef(uriInfo.getRequestUri().toString),new SimpleMGraph())
                resultNode.addProperty(RDF.`type`, PLATFORM.HeadedPage)

Added: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala?rev=1084741&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
 (added)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
 Wed Mar 23 21:00:36 2011
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2011 Apache.
+ *
+ * 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.platform.accountcontrolpanel
+
+import org.apache.clerezza.platform.accountcontrolpanel.ontologies.PINGBACK
+import org.apache.clerezza.rdf.core.access.{NoSuchEntityException, TcManager}
+import org.apache.clerezza.rdf.ontologies.{SIOC, PLATFORM, RDF}
+import org.osgi.service.component.ComponentContext
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.apache.clerezza.rdf.core.access.security.TcPermission
+import org.apache.clerezza.platform.Constants
+import java.security.{PrivilegedAction, AccessController}
+import javax.ws.rs.core.{Response, Context, UriInfo}
+import org.apache.clerezza.rdf.core.{MGraph, UriRef}
+import javax.ws.rs.{PathParam, FormParam, POST, QueryParam, GET, Path}
+import java.net.URI
+import org.apache.clerezza.rdf.utils.{UnionMGraph, GraphNode}
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph
+
+
+object PingBack {
+       private val logger: Logger = LoggerFactory.getLogger(classOf[PingBack])
+
+       val classPathTemplate = 
classOf[PingBack].getAnnotation(classOf[Path]).value
+       val regex = """\{([^}]+)\}""".r
+
+       // taken from 
http://dcsobral.blogspot.com/2010/01/string-interpolation-in-scala-with.html
+       def interpolate(text: String, values: String*) = {
+               val it = values.iterator
+               regex.replaceAllIn(text, _ => it.next)
+       }
+}
+
+/**
+ * The PingBack JSR311 class. Should enable the following
+ * - adding pings to a list of pings to be awaited
+ * - showing the rdf of the pings
+ *
+ * @author Henry Story
+ */
+
+@Path("/user/{id}/ping")
+class PingBack {
+
+       import PingBack._
+
+       protected def activate(componentContext: ComponentContext): Unit = {
+       }
+
+
+       /**
+        * The ping form, where you can POST new pings
+        */
+       def pingGraphNode(id: String, uriInfo: UriInfo): GraphNode = {
+               val pingRef = new UriRef(pingCollUri(id, uriInfo))
+               val resultNode: GraphNode = new GraphNode(pingRef, 
pingColl(pingRef))
+               resultNode
+       }
+
+       @GET
+       @Path("add")
+       def pingForm(@Context uriInfo: UriInfo,
+                                        @QueryParam("uri") uri: UriRef,
+                                        @PathParam("id") id: String): 
GraphNode = {
+               val resultNode: GraphNode = pingGraphNode(id, uriInfo)
+               resultNode.addProperty(RDF.`type`, PLATFORM.HeadedPage)
+               resultNode.addProperty(RDF.`type`, PINGBACK.Container)
+               return resultNode
+
+       }
+
+
+
+       /**
+        * get Ping Collection
+        */
+       def pingColl(pingCollRef: UriRef): MGraph = {
+               AccessController.doPrivileged(new PrivilegedAction[MGraph] {
+                       def run: MGraph = try {
+                               tcManager.getMGraph(pingCollRef)
+                       } catch {
+                               //todo: getTriples should state that it throws 
this exception. It makes it easier to know that one should catch it
+                               case e: NoSuchEntityException => {
+                                       tcManager.getTcAccessController.
+                                               
setRequiredReadPermissionStrings(pingCollRef,
+                                               
java.util.Collections.singleton(new 
TcPermission(Constants.CONTENT_GRAPH_URI_STRING, TcPermission.READ).toString))
+                                       tcManager.createMGraph(pingCollRef)
+                               }
+                       }
+               })
+       }
+
+
+       /**
+        * This is not written with all the tools available to someone with 
access to
+        * a full UriInfo implementation or Jersey's ExtendedUriInfo as triaxrs 
implementation
+        * UriInfoImpl has many methods that are not yet implemented.
+        * Apparently if they were one could use getMatchedURIs or one of those 
methods to build this
+        * more cleanly.
+        * Perhaps one should look at 
http://incubator.apache.org/wink/index.html implementations...
+        *
+        * Currently this assumes that the path of the class is a root class, 
ie, that it starts with /
+        */
+       def pingCollUri(id: String, uriInfo: UriInfo): String = {
+               val path = interpolate(classPathTemplate, id)
+               val uriStr = uriInfo.getBaseUri.resolve(path); //a bit 
expensive for something so simple
+               System.out.println("res=" + uriStr)
+               uriStr.toString
+       }
+
+
+       /**
+        * Add a new Ping Item
+        */
+       @POST
+       def addPing(@Context uriInfo: UriInfo,
+                                       @FormParam("source") source: UriRef,
+                                       @FormParam("target") target: UriRef,
+                                       @FormParam("comment") comment: String,
+                                       @PathParam("id") id: String): Response 
= {
+
+               // check that the resource pointed to, does in fact contain a 
reference to the resource
+               // in question
+
+
+               //create a new Resource for this ping (we'll use time stamps to 
get going)
+               val pingCollStr: String = pingCollUri(id, uriInfo)
+               val pingItem = new UriRef(pingCollStr + "/ts" + 
System.currentTimeMillis)
+
+               //build the graph and add to the store if ok
+               val itemNde: GraphNode = new GraphNode(pingItem, pingColl(new 
UriRef(pingCollStr)))
+               itemNde.addProperty(RDF.`type`, PINGBACK.Item)
+               itemNde.addProperty(PINGBACK.source, source)
+               itemNde.addProperty(PINGBACK.target, target)
+               itemNde.addPropertyValue(SIOC.content, comment)
+               itemNde.addInverseProperty(SIOC.container_of,new 
UriRef(pingCollStr))
+
+               val resultNode = new GraphNode(pingItem,new UnionMGraph(new 
SimpleMGraph(),itemNde.getGraph))
+               resultNode.addProperty(RDF.`type`, PLATFORM.HeadedPage)
+               //response
+               Response.ok(resultNode).header("Content-Location",new 
URI(pingItem.getUnicodeString).getPath).build()
+       }
+
+       @GET
+       def viewCollection(@Context uriInfo: UriInfo,
+                                                        @PathParam("id") id: 
String): GraphNode = {
+               val resultNode: GraphNode = pingGraphNode(id,uriInfo )
+               resultNode.addProperty(RDF.`type`, PLATFORM.HeadedPage)
+               resultNode.addProperty(RDF.`type`, PINGBACK.Container)
+               return resultNode
+       }
+
+       @POST
+       @Path("delete")
+       def deleteItems(@Context uriInfo: UriInfo,
+                                                @PathParam("id") id: String,
+                                                @FormParam("item") items: 
java.util.List[UriRef]): GraphNode= {
+               import collection.JavaConversions._
+
+               val pingColl: GraphNode = pingGraphNode(id,uriInfo )
+               //todo: verify if access is allowed
+               for(item <- items) {
+                        new GraphNode(item,pingColl.getGraph).deleteNodeContext
+               }
+               //todo: return a read only collection
+               return pingColl
+       }
+
+       /**
+        *
+        */
+       @GET
+       @Path("{item}")
+       def viewPing(@Context uriInfo: UriInfo,
+                                        @PathParam("id") id: String,
+                                        @PathParam("item") item: String): 
GraphNode = {
+
+               //ITS the wrong ping collection!!!
+
+               val resultNode: GraphNode = new GraphNode(
+                       new UriRef(uriInfo.getAbsolutePath.toString),
+                       pingColl(new UriRef(pingCollUri(id, uriInfo)))
+               )
+               resultNode.addProperty(RDF.`type`, PLATFORM.HeadedPage)
+               resultNode.addProperty(RDF.`type`, PINGBACK.Item)
+               return resultNode
+
+       }
+
+       protected var tcManager: TcManager = null;
+
+       protected def bindTcManager(tcManager: TcManager) = {
+               this.tcManager = tcManager
+       }
+
+       protected def unbindTcManager(tcManager: TcManager) = {
+               this.tcManager = null
+       }
+
+}

Modified: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala?rev=1084741&r1=1084740&r2=1084741&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/person_panel.scala
 Wed Mar 23 21:00:36 2011
@@ -112,8 +112,6 @@ object person_panel {
  */
 class person_panel extends SRenderlet {
        def getRdfType() = CONTROLPANEL.ProfileViewerPage
-  import person_panel._
-
 
        override def renderedPage(arguments: XmlResult.Arguments) = new 
XmlPerson(arguments)
 }
@@ -139,20 +137,23 @@ class XmlPerson(args: XmlResult.Argument
        lazy val agent : RichGraphNode=  $[WebProxy].fetchSemantics(webIdUri) 
match { case Some(grph) => grph; case None => res};
 
        //
-       // the content itself.
-       // This is the piece that is closest to a pure ssp, though there is 
still too much code in it
+       // setting some header info
        //
 
-       override def content = {
-                resultDocModifier.addStyleSheet("profile/style/profile.css");
-                resultDocModifier.setTitle("Profile Viewer");
-                resultDocModifier.addNodes2Elem("tx-module", <h1>Account 
Control Panel</h1>);
-                resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li 
class="tx-active"><a href="#">Profile Viewer</a></li>);
-                resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="control-panel">Settings</a></li>);
-                resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="profile">Profile</a></li>);
+       resultDocModifier.addStyleSheet("profile/style/profile.css");
+       resultDocModifier.setTitle("Profile Viewer");
+       resultDocModifier.addNodes2Elem("tx-module", <h1>Account Control 
Panel</h1>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li 
class="tx-active"><a href="#">Profile Viewer</a></li>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="control-panel">Settings</a></li>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="profile">Profile</a></li>);
 
 
-       <div id="tx-content">
+       //
+       // the content itself.
+       // This is the piece that is closest to a pure ssp, though there is 
still too much code in it
+       //
+
+       override def content = <div id="tx-content">
                <h2>Profile Viewer</h2>
                <form action="profile/addContact" method="POST">
                        <table>
@@ -175,7 +176,7 @@ class XmlPerson(args: XmlResult.Argument
                        }</pre>
                </code>
        </div>
-       }
+
 
        //
        // Methods called by the content

Added: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_collection_panel.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_collection_panel.scala?rev=1084741&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_collection_panel.scala
 (added)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_collection_panel.scala
 Wed Mar 23 21:00:36 2011
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2011 Apache.
+ *
+ * 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.platform.accountcontrolpanel
+
+import ontologies.PINGBACK
+import org.apache.clerezza.platform.typerendering.scala.{SRenderlet, XmlResult}
+import org.apache.clerezza.rdf.ontologies.SIOC
+import java.net.URLEncoder
+
+/**
+ * A panel to implement the Pingback "protocol" described at
+ * http://www.w3.org/wiki/Pingback
+ *
+ * @author Henry Story
+ */
+class ping_back_collection_panel extends SRenderlet {
+       def getRdfType() = PINGBACK.Container
+
+   override def renderedPage(arguments: XmlResult.Arguments): XmlResult =  new 
XhtmlPingBackDoc(arguments)
+
+}
+
+class XhtmlPingBackDoc(args: XmlResult.Arguments) extends XmlResult(args) {
+       import org.apache.clerezza.rdf.scala.utils.Preamble._
+
+       resultDocModifier.addStyleSheet("profile/style/profile.css");
+       resultDocModifier.setTitle("Account Control Panel");
+       resultDocModifier.addNodes2Elem("tx-module", <h1>Account Control 
Panel</h1>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="profile">Profile</a></li>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="control-panel">Settings</a></li>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li 
class="tx-active"><a href="#">Ping</a></li>);
+
+       override def content = {<div id="tx-content" 
xmlns:pingback="http://purl.org/net/pingback/"; about="" 
typeof="pingback:Container">
+                 <h3>Pingback Form</h3>
+                 <form method="POST" action="">
+                         <table>
+                               <tr><td><label 
for="source">Source</label></td><td><input type="text" size="80" 
name="source"/></td></tr>
+                               <tr><td><label 
for="target">Target</label></td><td><input type="text" size="80" 
name="target"/></td></tr>
+                               <tr><td><label 
for="comment">Comment</label></td><td><textarea rows="10" cols="80" 
name="comment"></textarea></td></tr>
+                               <tr><td colspan="2"><input type="submit" 
value="Send"/></td></tr>
+                         </table>
+        </form>
+                 <p>
+                 {showItems()}
+                 </p>
+       </div>}
+
+       def showItems() = <form method="POST" action="delete">
+               <input type="submit" value="Delete"/>
+               {
+                       for(item <- res/SIOC.container_of ) yield
+                       <p><!-- todo: say who sent this information, and show 
more info about source or target -->
+                         <a href={item*}>permalink</a> for this pingback</p>
+                         <p>The resource {item/PINGBACK.source} is referring 
to {item/PINGBACK.target}</p>
+                         <p>The sender says:
+                                 <blockquote>{item/SIOC.content*}</blockquote>
+                         <input type="checkbox" name="item" value={item*}/>
+                       </p>
+               }
+               <input type="submit" value="Delete"/>
+       </form>
+
+}

Added: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_item_panel.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_item_panel.scala?rev=1084741&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_item_panel.scala
 (added)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ping_back_item_panel.scala
 Wed Mar 23 21:00:36 2011
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011 Apache.
+ *
+ * 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.platform.accountcontrolpanel
+
+import ontologies.PINGBACK
+import org.apache.clerezza.platform.typerendering.scala.{SRenderlet, XmlResult}
+import org.apache.clerezza.rdf.ontologies.SIOC
+import org.apache.clerezza.rdf.scala.utils.RichGraphNode
+import org.apache.clerezza.rdf.core.UriRef
+
+/**
+ * A panel to implement the Pingback "protocol" described at
+ * http://www.w3.org/wiki/Pingback
+ *
+ * @author Henry Story
+ */
+class ping_back_item_panel extends SRenderlet {
+       def getRdfType() = PINGBACK.Item
+
+       override def renderedPage(arguments: XmlResult.Arguments): XmlResult = 
new XhtmlPingBackItemDoc(arguments)
+
+
+}
+
+class XhtmlPingBackItemDoc(args: XmlResult.Arguments) extends XmlResult(args) {
+       import org.apache.clerezza.rdf.scala.utils.Preamble._
+
+       resultDocModifier.addStyleSheet("profile/style/profile.css");
+       resultDocModifier.setTitle("Account Control Panel");
+       resultDocModifier.addNodes2Elem("tx-module", <h1>Account Control 
Panel</h1>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="profile">Profile</a></li>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="control-panel">Settings</a></li>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li 
class="tx-active"><a href="#">Ping</a></li>);
+
+       override def content = {<div id="tx-content" 
xmlns:pingback="http://purl.org/net/pingback/"; about="" typeof="pingback:Item">
+                 <h3>Pingback Item</h3>
+                 <p><a 
href={res.getNode.asInstanceOf[UriRef].getUnicodeString}>permalink</a> for this 
pingback</p>
+            <p>The resource {res/PINGBACK.source} is referring to 
{res/PINGBACK.target}</p>
+                 <p>The sender says:
+                         <blockquote>{res/SIOC.content*}</blockquote>
+                 </p>
+       </div> }
+}

Modified: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/profile_panel.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/profile_panel.scala?rev=1084741&r1=1084740&r2=1084741&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/profile_panel.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/profile_panel.scala
 Wed Mar 23 21:00:36 2011
@@ -31,205 +31,32 @@ import org.apache.clerezza.rdf.web.proxy
 import javax.ws.rs.core.MediaType
 
 class profile_panel extends SRenderlet {
-  def getRdfType() = CONTROLPANEL.ProfilePage
+  override def getRdfType() = CONTROLPANEL.ProfilePage
 
-  override def renderedPage(arguments: XmlResult.Arguments) = {
-       new XmlResult(arguments) {
+  override def renderedPage(arguments: XmlResult.Arguments) = new 
ProfilePanelXHTML(arguments)
+}
 
-         override def content = {
-               def cp(s: Any) =  new 
UriRef("http://clerezza.org/2009/03/controlpanel#"; + s)
-               def platform(s: Any) = new 
UriRef("http://clerezza.org/2009/08/platform#"; + s)
-               resultDocModifier.addStyleSheet("profile/style/profile.css");
-               
resultDocModifier.addScriptReference("profile/scripts/profile.js");
-               
resultDocModifier.addScriptReference("profile/scripts/IEKeygen.js");
-               resultDocModifier.setTitle("Account Control Panel");
-               resultDocModifier.addNodes2Elem("tx-module", <h1>Account 
Control Panel</h1>);
-               resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li 
class="tx-active"><a href="#">Profile</a></li>);
-               resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="control-panel">Settings</a></li>);
-               val agent: RichGraphNode = res / FOAF.primaryTopic
-               var webId =""
-
-               def createWebId() = {
-                 <h3>Associate Profile to WebID</h3>
-                 <div id="newOrExistingSelection">
-                       <p>Your profile is not currently associated to a WebID. 
A WebID allows you
-                         to link your friends as well as to log-in to many 
sites (supporting foaf+ssl
-                         or open-id).
-                       </p>
-                       <p>You may either create a new WebID or associate your 
account to an
-                         existing WebID. Only creating a WebID here will allow 
you to manage your
-                         profile here.
-                       </p>
-                       <form action="#" id="associateSelection">
-                         <button type="button" id="newWebIdButton">Create a 
new Web-Id</button>
-                         <button type="button" id="existingWebIdButton">I 
already have a Web-ID and want to use it</button>
-                       </form>
-                 </div>
-                 <div id="createNewWebId">
-                       <p>You have chosen to create a new Web-Id.</p>
-                       <p>The Web-ID will be created as follows:
-                         <br/>
-                         <ol>
-                               <li>Web-Id:
-                                 {webId = res / cp("suggestedPPDUri") *;
-                                  webId += "#me";
-                                  webId}
-                               </li>
-                               <li>Personal-Profile Document: 
{res/cp("suggestedPPDUri")*}</li>
-                         </ol>
-                       </p>
-                       <form method="post" action="profile/create-new-web-id">
-                         <input value="Create it!" type="submit"/>
-                       </form>
-                 </div>
-                 <div id="setExistingWebId">
-                       <p>Please enter your Web-Id, if your Web-Id supports 
Foaf+SSL you will
-                         be able to use it to log in to this site.</p>
-                       <form method="post" action="profile/set-existing-webid">
-                         <label for="webid">WebID</label> <input type="text" 
name="webid" size="80" title="Web-ID"/>
-                         <br/>
-                         <input value="Associate Profile to Web-Id" 
type="submit"/>
-                         <p/>
-                       </form>
-                 </div>
-
-               }
-
-               def existingWebId() = {
-                 if ((res / cp("isLocalProfile")).as[Boolean]) {
-                       existingLocalWebId()
-                 } else {
-                       roamingUser()
-                 }
-               }
+class ProfilePanelXHTML(arguments: XmlResult.Arguments) extends 
XmlResult(arguments ) {
 
+       //set header properties
 
-               def existingLocalWebId() = {
-                 <h3>Manage your profile</h3>
-          <p>Here you can change your public profile.</p>
-
-        <form method="post" action="profile/modify">
-                       <input type="hidden" name="webId" value={agent *}/>
-                       <table>
-                         <tr><td class="formlabel">Name:</td>
-                               <td><input type="text" name="name" value={agent 
/ FOAF.name *}/></td>
-                         </tr>
-                         <tr><td class="formlabel multiline">Description:</td>
-                               <td><textarea name="description" rows="3" 
cols="80">{agent / DC.description *}</textarea></td>
-                         </tr>
-                         <tr><td class="formlabel"><input value="Modify" 
type="submit"/></td><td/></tr>
-                       </table>
-
-                       <p/>
-        </form>
-
-                 <h3>Contacts</h3>
-                 <form id="addContact" method="get" action="people">
-                 <table>{ var i =0
-                         val friends = for (friend <- agent/FOAF.knows) yield {
-                         import person_panel._
-                         val node = friend.getNode() match {
-                                 case uri: UriRef => 
$[WebProxy].fetchSemantics(uri) match {
-                                         case Some(grp) => personInABox(grp)
-                                         case None => emptyText
-                                 }
-                                 case _ => emptyText //one could show info 
with bnodes too...
-                         }
-                         <td>{node}</td>
-                   }
-                        for (row <- friends.grouped(5)) yield <tr>{row}</tr>
-                 }<tr> <td><input type="submit" value="add contact" /></td>
-                         <td><input type="text" name="uri" size="80"/><!-- 
human input forms cannot require precise WebIds-->
-                 </td></tr>
-            </table>
-                 </form>
-
-                 <h3>Key and Certificate Creation</h3>
-
-                 <script type="text/javascript"> <![CDATA[$(document).ready(  
function() { configurePage(); }   ); ]]> </script>
-
-                 <div id="iehelptext" style="display: none;">
-                       <p>Using Internet Explorer under Windows Vista or above 
or Windows
-                         Server 2008, you need to configure the following for 
this to work:</p>
-                       <ul>
-                         <li>Add this site to the <i>Trusted Sites</i> list: 
in Internet
-                               Options -&gt; Security -&gt; Trusted Sites 
-&gt; Sites -&gt; Add ...</li>
-                         <li>You may need to configure the trust level (in 
this tab), using
-                               <i>Custom Level...</i>: enable <i>Initialize 
and script ActiveX
-                                 controls not marked as safe for 
scripting</i>.</li>
-                         <li>If you are using Windows Vista without SP1 or 
above, you will
-                               probably need to install <a 
href="cacert.crt">this certificate</a> as a
-                               Trusted Root Certification Authority 
Certificate for your own
-                               certificate installation to succeed. You should 
probably remove that
-                               trusted root CA certificate afterwards.</li>
-                       </ul>
-                 </div>
-                 <form id="keygenform" method="post" action="profile/keygen">
-                       <input name="webId" id="webId" type="hidden" 
value={agent*} />
-                       <table>
-                         <colgroup><col width="1*"/><col/></colgroup>
-                         <tr>
-                               <td class="formlabel">Certificate Name:</td>
-                               <td>
-                                 <input alt="create a certificate name that 
will help you distinguish it from others you may have" name="cn"
-                                                       size="35" id="cn" 
type="text" value={ ((agent/FOAF.name*)+"@clerezza")}/>
-                               </td>
-                         </tr>
-                         <tr>
-                               <td class="formlabel">Key strength:</td>
-                               <td id="keystrenghtd">
-                                 <keygen id="spkac" name="spkac" 
challenge="TheChallenge1"/>
-                               </td>
-                         </tr>
-                         <tr>
-                               <td class="formlabel">Valid for:</td>
-                               <td>
-                                 <input type="text" name="days" value="365" 
size="4"/>
-                                 days <input type="text" name="hours" 
value="0.0" size="4"/> hours</td>
-                         </tr>
-                         <tr>
-                               <td class="formlabel">Comment:</td>
-                               <td><input type="text" name="comment" value="" 
size="80"/></td>
-                         </tr>
-                         <tr><td class="formlabel"><input id="keygensubmit" 
type="submit" value="create certificate" /></td><td/></tr>
-                       </table>
-                 </form>
-                 <h3>Existing Certificates</h3>
-                 <form method="post" action="profile/deletekey">
-                       <table>
-                         <tr><th>Delete</th><th>Certificate Details</th></tr>
-                         <input name="webId" id="webId" type="hidden" 
value={agent*} />
-                         <tbody>{
-                                 for (key <- agent/-CERT.identity )
-                                       yield { val modulus = 
(key/RSA.modulus).as[BigInteger]
-                                                  if (modulus == null)  
<span/> //todo: broken public key, should delete it
-                                                  else <tr><td><input 
type="checkbox" name="keyhash" value={modulus.hashCode().toString()}/></td>
-                                               <td><table>
-                                                       <tr><td 
class="propvalue">Created:</td><td>{beautifyDate(key/DC.date )}</td></tr>
-                                                       <tr><td 
class="propvalue">Comment:</td><td>{ key/RDFS.comment* }</td></tr>
-                                                       <tr><td 
class="propvalue multiline">Modulus:</td><td><code>{ 
beautifyHex(key/RSA.modulus) }</code></td></tr>
-                                                       <tr><td 
class="propvalue">Exponent:</td><td><code>{ 
beautifyInt(key/RSA.public_exponent) }</code></td></tr>
-                                                       </table>
-                                               </td>
-                                                               </tr>}
-                               }</tbody>
-                       </table>
-                       <input type="submit" value="Disable Keys"/>
-                 </form>
-                 <p></p>
-
-               }
-
-               def roamingUser() = {
-                 <h3>Using remote profile</h3>
-          <p>
-                       {agent / FOAF.nick *}, you have accessed this site 
using your WebID
-            {"<" + (agent *) + ">"}
-            which has not been
-            created on this site.To edit your profile you should visit the 
site issuing the
-            profile.</p>
-               }
+       resultDocModifier.addStyleSheet("profile/style/profile.css");
+       resultDocModifier.addScriptReference("profile/scripts/profile.js");
+       resultDocModifier.addScriptReference("profile/scripts/IEKeygen.js");
+       resultDocModifier.setTitle("Account Control Panel");
+       resultDocModifier.addNodes2Elem("tx-module", <h1>Account Control 
Panel</h1>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li 
class="tx-active"><a href="#">Profile</a></li>);
+       resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li><a 
href="control-panel">Settings</a></li>);
+
+       //constants and variables
 
+       lazy val agent: RichGraphNode = res / FOAF.primaryTopic
+
+
+       // the content itself
+       // clearly in this case there is so much more in the the methods, that 
one could hesitate to call this an ssp
+
+       override def content = {
          <div id="tx-content">
                  <h2>Personal Profile</h2>{agent ! match {
                                case _: BNode => createWebId()
@@ -237,9 +64,197 @@ class profile_panel extends SRenderlet {
                         }}
          </div>
 
+       }
+
+       //methods used to create content
+
+       def cp(s: Any) =  new 
UriRef("http://clerezza.org/2009/03/controlpanel#"; + s)
+       def platform(s: Any) = new 
UriRef("http://clerezza.org/2009/08/platform#"; + s)
+
+
+       def createWebId() = {
+         <h3>Associate Profile to WebID</h3>
+         <div id="newOrExistingSelection">
+               <p>Your profile is not currently associated to a WebID. A WebID 
allows you
+                 to link your friends as well as to log-in to many sites 
(supporting foaf+ssl
+                 or open-id).
+               </p>
+               <p>You may either create a new WebID or associate your account 
to an
+                 existing WebID. Only creating a WebID here will allow you to 
manage your
+                 profile here.
+               </p>
+               <form action="#" id="associateSelection">
+                 <button type="button" id="newWebIdButton">Create a new 
Web-Id</button>
+                 <button type="button" id="existingWebIdButton">I already have 
a Web-ID and want to use it</button>
+               </form>
+         </div>
+         <div id="createNewWebId">
+               <p>You have chosen to create a new Web-Id.</p>
+               <p>The Web-ID will be created as follows:
+                 <br/>
+                 <ol>
+                       <li>Web-Id:
+                         {var webId = res / cp("suggestedPPDUri") *;
+                               webId += "#me";
+                               webId}
+                       </li>
+                       <li>Personal-Profile Document: 
{res/cp("suggestedPPDUri")*}</li>
+                 </ol>
+               </p>
+               <form method="post" action="profile/create-new-web-id">
+                 <input value="Create it!" type="submit"/>
+               </form>
+         </div>
+         <div id="setExistingWebId">
+               <p>Please enter your Web-Id, if your Web-Id supports Foaf+SSL 
you will
+                 be able to use it to log in to this site.</p>
+               <form method="post" action="profile/set-existing-webid">
+                 <label for="webid">WebID</label> <input type="text" 
name="webid" size="80" title="Web-ID"/>
+                 <br/>
+                 <input value="Associate Profile to Web-Id" type="submit"/>
+                 <p/>
+               </form>
+         </div>
+
+       }
+
+       def existingWebId() = {
+         if ((res / cp("isLocalProfile")).as[Boolean]) {
+               existingLocalWebId()
+         } else {
+               roamingUser()
          }
        }
-  }
+
+
+       def existingLocalWebId() = {
+         <h3>Manage your profile</h3>
+                <p>Here you can change your public profile.</p>
+
+         <form method="post" action="profile/modify">
+               <input type="hidden" name="webId" value={agent *}/>
+               <table>
+                 <tr><td class="formlabel">Name:</td>
+                       <td><input type="text" name="name" value={agent / 
FOAF.name *}/></td>
+                 </tr>
+                 <tr><td class="formlabel multiline">Description:</td>
+                       <td><textarea name="description" rows="3" 
cols="80">{agent / DC.description *}</textarea></td>
+                 </tr>
+                 <tr><td class="formlabel"><input value="Modify" 
type="submit"/></td><td/></tr>
+               </table>
+
+               <p/>
+         </form>
+
+         <h3>Contacts</h3>
+         <form id="addContact" method="get" action="people">
+         <table>{ var i =0
+                 val friends = for (friend <- agent/FOAF.knows) yield {
+                 import person_panel._
+                 val node = friend.getNode() match {
+                         case uri: UriRef => $[WebProxy].fetchSemantics(uri) 
match {
+                                 case Some(grp) => personInABox(grp)
+                                 case None => emptyText
+                         }
+                         case _ => emptyText //one could show info with bnodes 
too...
+                 }
+                 <td>{node}</td>
+                }
+                for (row <- friends.grouped(5)) yield <tr>{row}</tr>
+         }<tr> <td><input type="submit" value="add contact" /></td>
+                 <td><input type="text" name="uri" size="80"/><!-- human input 
forms cannot require precise WebIds-->
+         </td></tr>
+         </table>
+         </form>
+
+         <h3>Key and Certificate Creation</h3>
+
+         <script type="text/javascript"> <![CDATA[$(document).ready(  
function() { configurePage(); }   ); ]]> </script>
+
+         <div id="iehelptext" style="display: none;">
+               <p>Using Internet Explorer under Windows Vista or above or 
Windows
+                 Server 2008, you need to configure the following for this to 
work:</p>
+               <ul>
+                 <li>Add this site to the <i>Trusted Sites</i> list: in 
Internet
+                       Options -&gt; Security -&gt; Trusted Sites -&gt; Sites 
-&gt; Add ...</li>
+                 <li>You may need to configure the trust level (in this tab), 
using
+                       <i>Custom Level...</i>: enable <i>Initialize and script 
ActiveX
+                         controls not marked as safe for scripting</i>.</li>
+                 <li>If you are using Windows Vista without SP1 or above, you 
will
+                       probably need to install <a href="cacert.crt">this 
certificate</a> as a
+                       Trusted Root Certification Authority Certificate for 
your own
+                       certificate installation to succeed. You should 
probably remove that
+                       trusted root CA certificate afterwards.</li>
+               </ul>
+         </div>
+         <form id="keygenform" method="post" action="profile/keygen">
+               <input name="webId" id="webId" type="hidden" value={agent*} />
+               <table>
+                 <colgroup><col width="1*"/><col/></colgroup>
+                 <tr>
+                       <td class="formlabel">Certificate Name:</td>
+                       <td>
+                         <input alt="create a certificate name that will help 
you distinguish it from others you may have" name="cn"
+                                               size="35" id="cn" type="text" 
value={ ((agent/FOAF.name*)+"@clerezza")}/>
+                       </td>
+                 </tr>
+                 <tr>
+                       <td class="formlabel">Key strength:</td>
+                       <td id="keystrenghtd">
+                         <keygen id="spkac" name="spkac" 
challenge="TheChallenge1"/>
+                       </td>
+                 </tr>
+                 <tr>
+                       <td class="formlabel">Valid for:</td>
+                       <td>
+                         <input type="text" name="days" value="365" size="4"/>
+                         days <input type="text" name="hours" value="0.0" 
size="4"/> hours</td>
+                 </tr>
+                 <tr>
+                       <td class="formlabel">Comment:</td>
+                       <td><input type="text" name="comment" value="" 
size="80"/></td>
+                 </tr>
+                 <tr><td class="formlabel"><input id="keygensubmit" 
type="submit" value="create certificate" /></td><td/></tr>
+               </table>
+         </form>
+         <h3>Existing Certificates</h3>
+         <form method="post" action="profile/deletekey">
+               <table>
+                 <tr><th>Delete</th><th>Certificate Details</th></tr>
+                 <input name="webId" id="webId" type="hidden" value={agent*} />
+                 <tbody>{
+                         for (key <- agent/-CERT.identity )
+                               yield { val modulus = 
(key/RSA.modulus).as[BigInteger]
+                                               if (modulus == null)  <span/> 
//todo: broken public key, should delete it
+                                               else <tr><td><input 
type="checkbox" name="keyhash" value={modulus.hashCode().toString()}/></td>
+                                       <td><table>
+                                               <tr><td 
class="propvalue">Created:</td><td>{beautifyDate(key/DC.date )}</td></tr>
+                                               <tr><td 
class="propvalue">Comment:</td><td>{ key/RDFS.comment* }</td></tr>
+                                               <tr><td class="propvalue 
multiline">Modulus:</td><td><code>{ beautifyHex(key/RSA.modulus) 
}</code></td></tr>
+                                               <tr><td 
class="propvalue">Exponent:</td><td><code>{ 
beautifyInt(key/RSA.public_exponent) }</code></td></tr>
+                                               </table>
+                                       </td>
+                                                       </tr>}
+                       }</tbody>
+               </table>
+               <input type="submit" value="Disable Keys"/>
+         </form>
+         <p></p>
+
+       }
+
+       def roamingUser() = {
+         <h3>Using remote profile</h3>
+                <p>
+               {agent / FOAF.nick *}, you have accessed this site using your 
WebID
+                       {"<" + (agent *) + ">"}
+                       which has not been
+                       created on this site.To edit your profile you should 
visit the site issuing the
+                       profile.</p>
+       }
+
+
+
 
   def beautifyDate(dtIt: CollectedIter[RichGraphNode]) {
          if (0 == dtIt.size) return "_"


Reply via email to