Author: bblfish
Date: Mon Nov  1 22:29:05 2010
New Revision: 1029869

URL: http://svn.apache.org/viewvc?rev=1029869&view=rev
Log:
These changes update the control panel to work with IE. This was written some 
time ago, and I still need to synchronise this piece with the main 
acountcontrolpanel code. Will come next. 

Added:
    
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/IEKeygen.js
Modified:
    
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/
   (props changed)
    
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml
    
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java
    
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp

Propchange: 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Nov  1 22:29:05 2010
@@ -1 +1,2 @@
 target
+.idea

Modified: 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml?rev=1029869&r1=1029868&r2=1029869&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/pom.xml
 Mon Nov  1 22:29:05 2010
@@ -1,5 +1,6 @@
 <?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"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
        <modelVersion>4.0.0</modelVersion>
        <parent>
                <groupId>org.apache.clerezza</groupId>
@@ -50,10 +51,10 @@
                        <groupId>org.apache.clerezza</groupId>
                        <artifactId>org.apache.clerezza.rdf.core</artifactId>
                </dependency>
-        <dependency>
-            <groupId>org.apache.clerezza</groupId>
-            <artifactId>org.apache.clerezza.rdf.scala.utils</artifactId>
-        </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       
<artifactId>org.apache.clerezza.rdf.scala.utils</artifactId>
+               </dependency>
                <dependency>
                        <groupId>org.apache.clerezza</groupId>
                        
<artifactId>org.apache.clerezza.rdf.ontologies</artifactId>
@@ -106,10 +107,10 @@
                        <groupId>org.apache.clerezza</groupId>
                        
<artifactId>org.apache.clerezza.permissiondescriptions</artifactId>
                </dependency>
-        <dependency>
-            <groupId>bblfish.net</groupId>
-            <artifactId>keygenapp-base</artifactId>
-            <version>0.3-SNAPSHOT</version>
-        </dependency>
+               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       
<artifactId>org.apache.clerezza.ssl.keygen.base</artifactId>
+                       <version>0.5</version>
+               </dependency>
        </dependencies>
 </project>
\ No newline at end of file

Modified: 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java?rev=1029869&r1=1029868&r2=1029869&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/java/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.java
 Mon Nov  1 22:29:05 2010
@@ -18,8 +18,8 @@
  */
 package org.apache.clerezza.platform.accountcontrolpanel;
 
-import net.bblfish.dev.foafssl.keygen.CertSerialisation;
-import net.bblfish.dev.foafssl.keygen.Certificate;
+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;
@@ -76,7 +76,7 @@ public class ProfilePanel extends FileSe
        @Reference
        private UserManager userManager;
        @Reference
-       private net.bblfish.dev.foafssl.keygen.KeygenService keygenSrvc;
+       private org.apache.clerezza.ssl.keygen.KeygenService keygenSrvc;
        @Reference
        private TcManager tcManager;
        @Reference
@@ -89,8 +89,8 @@ public class ProfilePanel extends FileSe
        protected void activate(ComponentContext componentContext) {
                URL templateURL = getClass().getResource("profile-panel.ssp");
                
renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
-                               new UriRef(templateURL.toString()), 
CONTROLPANEL.ProfilePage,
-                               "naked", MediaType.APPLICATION_XHTML_XML_TYPE, 
true);
+                                 new UriRef(templateURL.toString()), 
CONTROLPANEL.ProfilePage,
+                                 "naked", 
MediaType.APPLICATION_XHTML_XML_TYPE, true);
                configure(componentContext.getBundleContext(), 
"profile-staticweb");
        }
 
@@ -115,14 +115,14 @@ public class ProfilePanel extends FileSe
                                        SimpleMGraph simpleMGraph = new 
SimpleMGraph();
                                        GraphNode profileNode = new 
GraphNode(new BNode(), simpleMGraph);
                                        
profileNode.addProperty(CONTROLPANEL.isLocalProfile,
-                                                       
LiteralFactory.getInstance().createTypedLiteral(true));
+                                                         
LiteralFactory.getInstance().createTypedLiteral(true));
                                        UriRef suggestedPPDUri = 
getSuggestedPPDUri(userName);
                                        
profileNode.addProperty(CONTROLPANEL.suggestedPPDUri,
-                                                       
LiteralFactory.getInstance().createTypedLiteral(suggestedPPDUri));
+                                                         
LiteralFactory.getInstance().createTypedLiteral(suggestedPPDUri));
                                        NonLiteral agent = new BNode();
                                        
profileNode.addProperty(FOAF.primaryTopic, agent);
                                        simpleMGraph.add(new TripleImpl(agent, 
PLATFORM.userName,
-                                                       
LiteralFactory.getInstance().createTypedLiteral(userName)));
+                                                         
LiteralFactory.getInstance().createTypedLiteral(userName)));
                                        return profileNode;
                                } else {
                                        return getProfileInUserGraph((UriRef) 
userNodeInSystemGraph, profile);
@@ -133,7 +133,7 @@ public class ProfilePanel extends FileSe
 
        private UriRef getSuggestedPPDUri(String userName) {
                return new 
UriRef(platformConfig.getDefaultBaseUri().getUnicodeString()
-                               + "user/" + userName + "/profile");
+                                 + "user/" + userName + "/profile");
        }
 
        private GraphNode getProfileInUserGraph(UriRef webId, UriRef profile) {
@@ -142,9 +142,9 @@ public class ProfilePanel extends FileSe
                logger.debug("got publicUserGraph of size {}.", 
userGraph.size());
                GraphNode userGraphNode = new GraphNode(webId, userGraph);
                GraphNode resultNode = new GraphNode(profile,
-                               new UnionMGraph(new SimpleMGraph(), 
userGraphNode.getGraph()));
+                                 new UnionMGraph(new SimpleMGraph(), 
userGraphNode.getGraph()));
                resultNode.addProperty(CONTROLPANEL.isLocalProfile,
-                               
LiteralFactory.getInstance().createTypedLiteral(webIdGraphs.isLocal()));
+                                 
LiteralFactory.getInstance().createTypedLiteral(webIdGraphs.isLocal()));
                resultNode.addProperty(FOAF.primaryTopic, 
userGraphNode.getNode());
                return resultNode;
        }
@@ -152,7 +152,7 @@ public class ProfilePanel extends FileSe
        @POST
        @Path("set-existing-webid")
        public Response setExistingWebId(@Context final UriInfo uriInfo,
-                       @FormParam("webid") final UriRef webId, 
@PathParam(value = "id") final String userName) {
+                         @FormParam("webid") final UriRef webId, 
@PathParam(value = "id") final String userName) {
                //TODO check that its not local
                //TODO check its not an existing user
                return AccessController.doPrivileged(new 
PrivilegedAction<Response>() {
@@ -169,7 +169,7 @@ public class ProfilePanel extends FileSe
        @POST
        @Path("create-new-web-id")
        public Response createNewWebId(@Context final UriInfo uriInfo,
-                       @PathParam(value = "id") final String userName) {
+                         @PathParam(value = "id") final String userName) {
                //TODO check its not an existing user
                final UriRef ppd = getSuggestedPPDUri(userName);
                final UriRef webId = new UriRef(ppd.getUnicodeString() + "#me");
@@ -190,17 +190,21 @@ public class ProfilePanel extends FileSe
        @POST
        @Path("keygen")
        public Response createCert(@FormParam("webId") UriRef webId,
-                       @FormParam("cn") String commonName,
-                       @FormParam("spkac") String spkac,
-                       @FormParam("crmf") String crmf,
-                       @FormParam("hours") String hours,
-                       @FormParam("days") String days) {
+                         @FormParam("cn") String commonName,
+                         @FormParam("spkac") String spkac,
+                         @FormParam("crmf") String crmf,
+                         @FormParam("hours") String hours,
+                         @FormParam("days") String days,
+                         @FormParam("csr") String csr) {
+
                logger.info("in keygen code. webId={}", webId);
                logger.info("cn={}", commonName);
                logger.info("hours={}", hours);
                logger.info("days={}", days);
                logger.info("spkac={}", spkac);
                logger.info("crmf={}", crmf);
+               logger.info("csr={}",csr);
+
                Certificate cert = null;
                if (spkac != null && spkac.length() > 0) {
                        cert = keygenSrvc.createFromSpkac(spkac);
@@ -214,12 +218,19 @@ public class ProfilePanel extends FileSe
                                logger.warn("unable to create certificate from 
crmf requrest :" + crmf);
                        }
                }
+               if (cert == null && csr != null && csr.length() > 0 ) {
+                       cert = keygenSrvc.createFromPEM(csr);
+                       if (cert == null) {
+                               logger.warn("unable to create certificate from 
csr request :"+ csr);
+                       }
+               }
                if (cert == null) {
                        throw new RuntimeException("The server was unable to 
craete a certificate");
                }
                cert.setSubjectCommonName(commonName);
                cert.addDurationInHours(hours);
                cert.addDurationInDays(days);
+               cert.startEarlier("2"); // start a few hours earlier in order 
to remove chances of time synchronisation issues
                cert.setSubjectWebID(webId.getUnicodeString());
 
                CertSerialisation ser;
@@ -228,7 +239,7 @@ public class ProfilePanel extends FileSe
                } catch (Exception ex) {
                        throw new RuntimeException(ex);
                }
-               RSAPublicKey pubKey = 
(RSAPublicKey)cert.getSubjectPublicKey().getPublicKey();
+               RSAPublicKey pubKey = (RSAPublicKey) 
cert.getSubjectPublicKey().getPublicKey();
                BigInteger publicExponent = pubKey.getPublicExponent();
                BigInteger modulus = pubKey.getModulus();
                final WebIdGraphsService.WebIdGraphs webIdGraphs = 
webIdGraphsService.getWebIdGraphs(webId);
@@ -247,10 +258,10 @@ public class ProfilePanel extends FileSe
        @POST
        @Path("modify")
        public Response modifyProfile(@Context final UriInfo uriInfo,
-                       @PathParam(value = "id") final String userName,
-                       @FormParam("webId") final UriRef webId,
-                       @FormParam("name") final String name,
-                       @FormParam("description") final String description) {
+                         @PathParam(value = "id") final String userName,
+                         @FormParam("webId") final UriRef webId,
+                         @FormParam("name") final String name,
+                         @FormParam("description") final String description) {
                final WebIdGraphsService.WebIdGraphs webIdGraphs = 
webIdGraphsService.getWebIdGraphs(webId);
                final GraphNode agent = new GraphNode(webId, 
webIdGraphs.localGraph());
                agent.deleteProperties(FOAF.name);

Modified: 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp?rev=1029869&r1=1029868&r2=1029869&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-panel.ssp
 Mon Nov  1 22:29:05 2010
@@ -9,159 +9,158 @@ def cp(s: Any) = new UriRef("http://cler
 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>);
+               <a href="#">Profile</a>
+                                                                               
                         </li>);
 resultDocModifier.addNodes2Elem("tx-module-tabs-ol", <li>
-  <a href="control-panel">Settings</a>
-</li>);
+               <a href="control-panel">Settings</a>
+                                                                               
                         </li>);
 
 val agent: RichGraphNode = res / FOAF.primaryTopic
 var webId =""
 
 def createWebId() = {
-  <h3>Associate Profile to Web-id</h3>
-  <div id="newOrExistingSelection">
-    <p>Your profile is not currently associated to a Web-ID.A Web-ID 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 Web-Id or associate your account to an
-        existing Web-Id.Only creating a Web-Id here will allow you to manage 
your
-        profile here.
-    </p>
-    <form action="#" id="associateSelection">
+       <h3>Associate Profile to Web-id</h3>
+       <div id="newOrExistingSelection">
+               <p>Your profile is not currently associated to a Web-ID.A 
Web-ID 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 Web-Id or associate your account 
to an
+                       existing Web-Id.Only creating a Web-Id 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>
+       </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">Web-Id</label> <input type="text" name="webid" 
size="80" title="Web-ID"/>
-        <br/>
-        <input value="Associate Profile to Web-Id" type="submit"/>
-        <p/>
-    </form>
-  </div>
+               </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">Web-Id</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()
-  }
+       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*}/>
-            <label for="name">name</label> <input type="text" name="name" 
value={agent / FOAF.name *}/>
-              <br/>
-            <label for="description">description</label>
-                       <textarea name="description">{agent / DC.description 
*}</textarea> <br/>
-              <input value="Modify" type="submit"/>
-              <p/>
-          </form>
-
-                 <h1>web-is stuff</h1>
-
+       <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*}/>
+               <label for="name">name</label> <input type="text" name="name" 
value={agent / FOAF.name *}/>
+               <br/>
+               <label for="description">description</label>
+               <textarea name="description">{agent / DC.description 
*}</textarea> <br/>
+               <input value="Modify" type="submit"/>
+               <p/>
+       </form>
+
+       <h3>WebID Login</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" size="60" id="webId" type="hidden" 
value={agent*} />
-      <table width="95%">
-        <tr>
-          <td>Common Name (for identifying certificate in browser):</td>
-          <td>
-              <input name="cn" size="30" id="cn" type="text" value={import 
java.net.URI
-                         ((agent/FOAF.name*)+" @ "+new 
URI(agent*).getAuthority)}/>
-          </td>
-        </tr>
-        <tr>
-          <td>Key strength:</td>
-          <td id="keystrenghtd">
-              <keygen id="spkac" name="spkac" challenge="TheChallenge1"/>
-          </td>
-        </tr>
-        <tr>
-          <td>Valid for:
-              <br/>
-            (defaults to 1 year)</td>
-          <td>
-              <input type="text" name="hours" value="0.0" size="4"/>
-            hours
-              <br/>
-              <input type="text" name="days" value="356" size="4"/>
-            days</td>
-        </tr>
-        <tr>
-          <td colspan="2">
-            #if ($nodebug)
-            Clicking the submit button will start the following sequence of 
events:
-            #else
-            If none of the above debug options are checked then the following 
will happen on clicking submit:
-            #end
-            <ol>
-              <li>your browser will create a public/private key pair</li>
-              <li>send us your public key, in what is known as a
-                <a 
href="http://en.wikipedia.org/wiki/Certification_request";>certification 
request</a>
-                along with information from the form above</li>
-              <li>we will create a certificate with the parameters 
specified</li>
-              <li>it will be returned to you and your browser will match it 
with your private key and add the pair to your keychain</li>
-              <li>a
-                <a 
href="$xwiki.getDocument('WebId.RSAPubKeyClass').getURL('edit','editor=class')">WebId.RSAPubKeyClass</a>
-                object will be created in
-                <a href="$homepage.getURL()">your public profile</a>, which 
you will then see clearly in
-                <a target="_blank" 
href="${homepage.getURL('edit','editor=object')}">its object view</a>.Your 
profile should also have an RDF view of the key.</li>
-            </ol>
-          </td>
-        </tr>
-      </table>
-      <input id="keygensubmit" type="submit" value="submit certificate 
request" />
-         </form>
+               <table>
+                       <tr>
+                               <td>Common Name (for identifying certificate in 
browser):</td>
+                               <td>
+                                       <input name="cn" size="35" id="cn" 
type="text" value={import java.net.URI
+                                                                               
                                                                  
((agent/FOAF.name*)+" @ "+new URI(agent*).getAuthority)}/>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td>Key strength:</td>
+                               <td id="keystrenghtd">
+                                       <keygen id="spkac" name="spkac" 
challenge="TheChallenge1"/>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td>Valid for:
+                                       <br/>
+                                       (defaults to 1 year)</td>
+                               <td>
+                                       <input type="text" name="hours" 
value="0.0" size="4"/>
+                                       hours
+                                       <br/>
+                                       <input type="text" name="days" 
value="365" size="4"/>
+                                       days</td>
+                       </tr>
+               </table>
+               <input id="keygensubmit" type="submit" value="submit 
certificate request" />
+       </form>
 }
 
 def roamingUser() = {
-  <h3>Using remote profile</h3>
-          <p>
-            {agent / FOAF.nick *}, you have accessed this site using your 
Web-Id
-            {"<" + (agent *) + ">"}
-            which has not been
-            created on this site.To edit your profile you should visit the 
site issuing the
-            profile.</p>
+       <h3>Using remote profile</h3>
+       <p>
+               {agent / FOAF.nick *}, you have accessed this site using your 
Web-Id
+               {"<" + (agent *) + ">"}
+               which has not been
+               created on this site.To edit your profile you should visit the 
site issuing the
+               profile.</p>
 }
 
 <div id="tx-content">
-       <h2>Personal Profile</h2>
+<h2>Personal Profile</h2>
 
-       {
-               agent! match {
-  case _: BNode => createWebId()
-  case _: UriRef => existingWebId()
-               }
+{
+       agent! match {
+               case _: BNode => createWebId()
+               case _: UriRef => existingWebId()
        }
+}
 </div>
\ No newline at end of file

Added: 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/IEKeygen.js
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/IEKeygen.js?rev=1029869&view=auto
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/IEKeygen.js
 (added)
+++ 
incubator/clerezza/issues/CLEREZZA-243/org.apache.clerezza.platform.accountcontrolpanel/org.apache.clerezza.platform.accountcontrolpanel.core/src/main/resources/org/apache/clerezza/platform/accountcontrolpanel/profile-staticweb/scripts/IEKeygen.js
 Mon Nov  1 22:29:05 2010
@@ -0,0 +1,266 @@
+/**
+ *
+ * Copyright (c) 2008-2010, The University of Manchester, United Kingdom. All
+ * rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials 
provided
+ * with the distribution. Neither the name of the The University of Manchester
+ * nor the names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Author........: Bruno Harbulot
+ *
+ */
+
+var location = "error";
+
+
+function createCsrCertEnroll(enrollFactObj, keylength) {
+       /*
+        * Creates a CX509EnrollmentWebClassFactory (used to create all the 
other
+        * objects).
+        */
+       if (enrollFactObj == null) {
+               enrollFactObj = new ActiveXObject(
+                       "X509Enrollment.CX509EnrollmentWebClassFactory");
+       }
+
+       /*
+        * Load the information about the providers.
+        */
+       var providerInfosObj = enrollFactObj
+       .CreateObject("X509Enrollment.CCspInformations");
+       providerInfosObj.AddAvailableCsps();
+
+       /*
+        * Find the provider of RSA type (sufficient for this example). The type
+        * numbers for this are 1, 2 and 24.
+        * http://msdn.microsoft.com/en-us/library/aa379427%28VS.85%29.aspx
+        */
+       var providerType = -1;
+       var providerName = null;
+       for ( var i = 0; i < providerInfosObj.Count; i++) {
+               var providerInfoObj = providerInfosObj.ItemByIndex(i);
+               switch (providerInfoObj.Type) {
+                       case 1:
+                       case 2:
+                       case 24:
+                               providerType = providerInfoObj.Type;
+                               providerName = providerInfoObj.Name;
+                               break;
+                       default:
+               }
+       }
+
+       /*
+        * Creates a 2048-bit key with this provider.
+        */
+       var privKeyObj = enrollFactObj
+       .CreateObject("X509Enrollment.CX509PrivateKey");
+       privKeyObj.ProviderType = providerInfoObj.Type;
+       privKeyObj.KeySpec = 1;
+       privKeyObj.Length = keylength;
+       // http://msdn.microsoft.com/en-us/library/aa379024%28VS.85%29.aspx
+       privKeyObj.MachineContext = false;
+       // http://msdn.microsoft.com/en-us/library/aa379414%28VS.85%29.aspx
+       privKeyObj.KeyProtection = 2;
+       // http://msdn.microsoft.com/en-us/library/aa379002%28VS.85%29.aspx
+       privKeyObj.ExportPolicy = 1;
+
+       /*
+        * Creates the PKCS#10 object and initialise as a user context.
+        */
+       var pkcs10CsrObj = enrollFactObj
+       .CreateObject("X509Enrollment.CX509CertificateRequestPkcs10");
+       pkcs10CsrObj.InitializeFromPrivateKey(1, privKeyObj, "");
+
+       /*
+        * Creates the enrolment object and exports the CSR.
+        */
+       var enrollObj = enrollFactObj
+       .CreateObject("X509Enrollment.CX509Enrollment");
+       enrollObj.InitializeFromRequest(pkcs10CsrObj);
+       var csr = enrollObj.CreateRequest(1);
+       csr = "-----BEGIN CERTIFICATE REQUEST-----\r\n" + csr
+       + "-----END CERTIFICATE REQUEST-----";
+
+       /*
+        * Makes the request to the server.
+        */
+    xmlHttpRequest = createRequest(csr);
+
+    /**
+        * What to do on response
+        */
+    xmlHttpRequest.onreadystatechange = function() {
+               if (xmlHttpRequest.readyState == 4) {
+                       if (xmlHttpRequest.status == 200) {
+                               /*
+                                * Installs the certificate.
+                                */
+                               try {
+                                       enrollObj.InstallResponse(4, 
xmlHttpRequest.responseText,
+                                               0, "");
+                                       window.alert("A certificate has been 
installed.");
+                               } catch (e1) {
+                                       try {
+                                               enrollObj.InstallResponse(0,
+                                                       
xmlHttpRequest.responseText, 0, "");
+                                               window.alert("A certificate has 
been installed.");
+                                       } catch (e2) {
+                                               window
+                                               .alert("You're probably using 
Vista without SP1 or above, in which case you need to add the certificate of 
this authority as a trusted root certificate (not recommended in general).");
+                                       }
+                               }
+                       } else {
+                               window.alert("The server returned an error 
status: "
+                                       + xmlHttpRequest.status);
+                       }
+               }
+       }
+}
+
+
+function createRequest(csrString) {
+       var xmlHttpRequest = new XMLHttpRequest();
+
+       xmlHttpRequest.open("POST", location, true);
+
+       var params = "webId=" + 
encodeURIComponent(document.getElementById("webId").value);
+       params += "&cn=" + 
encodeURIComponent(document.getElementById("cn").value);
+       params += "&csr=" + encodeURIComponent(csrString);
+       params += 
"&days="+encodeURIComponent(document.getElementById("days").value);
+       params += 
"&hours="+encodeURIComponent(document.getElementById("hours").value);
+
+       xmlHttpRequest.setRequestHeader("Content-type", 
"application/x-www-form-urlencoded");
+       xmlHttpRequest.setRequestHeader("Content-length", params.length);
+       xmlHttpRequest.setRequestHeader("Connection", "close");
+
+       xmlHttpRequest.send(params);
+
+       return xmlHttpRequest;
+
+}
+
+
+function createCsrXenroll(enrollObj, keylength) {
+       if (enrollObj == null) {
+               enrollObj = new ActiveXObject("CEnroll.CEnroll");
+       }
+
+       // http://msdn.microsoft.com/en-us/library/aa379941%28VS.85%29.aspx
+       // CRYPT_EXPORTABLE: 1?
+       enrollObj.GenKeyFlags = (keylength * 256 * 256) + 1;
+       enrollObj.KeySpec = 2;
+
+       var csr = enrollObj.createPKCS10("", "");
+       csr = "-----BEGIN CERTIFICATE REQUEST-----\r\n" + csr
+       + "-----END CERTIFICATE REQUEST-----";
+
+       xmlHttpRequest = createRequest(csr);
+
+       xmlHttpRequest.onreadystatechange = function() {
+               if (xmlHttpRequest.readyState == 4) {
+                       if (xmlHttpRequest.status == 200) {
+                               
enrollObj.acceptPKCS7(xmlHttpRequest.responseText);
+                               window.alert("A certificate has been 
installed.");
+                       } else {
+                               window.alert("The server returned an error 
status: "
+                                       + xmlHttpRequest.status);
+                       }
+               }
+       }
+}
+
+function createCsr() {
+       var keystrengthSelectElem = document.getElementById("keylength");
+       var keylength = keystrengthSelectElem.value;
+
+       var enrollFactObj = null;
+       try {
+               enrollFactObj = new ActiveXObject(
+                       "X509Enrollment.CX509EnrollmentWebClassFactory");
+       } catch (e) {
+       }
+
+       if (enrollFactObj != null) {
+               createCsrCertEnroll(enrollFactObj, keylength);
+       } else {
+               var enrollObj = null;
+               try {
+                       enrollObj = new ActiveXObject("CEnroll.CEnroll");
+               } catch (e) {
+               }
+               if (enrollObj != null) {
+                       createCsrXenroll(enrollObj, keylength);
+               } else {
+                       window.alert("ActiveX certificate creation not 
supported or not enabled.");
+               }
+       }
+}
+
+function configurePage() {
+       location = document.getElementById("keygenform").getAttribute("action");
+
+       var keygenElem = document.getElementById("spkac");
+
+       if (navigator.appName == "Microsoft Internet Explorer") {
+               var keygenFormElem = document.getElementById("keygenform");
+               keygenFormElem.removeAttribute("action");
+               keygenFormElem.removeAttribute("method");
+
+               /*
+                * Try the ActiveX approach, assume Internet Explorer.
+                */
+
+               var iehelptextElem = document.getElementById("iehelptext");
+               iehelptextElem.style.display = "block";
+
+               var submitButtonElem = document.getElementById("keygensubmit");
+               var newSumbitButtonElem = document.createElement("input");
+               newSumbitButtonElem.setAttribute("type", "button");
+               newSumbitButtonElem.setAttribute("value", "Submit");
+               submitButtonElem.parentNode.replaceChild(newSumbitButtonElem,
+                       submitButtonElem);
+               submitButtonElem = newSumbitButtonElem;
+
+               if (submitButtonElem.attachEvent) {
+                       submitButtonElem.attachEvent("onclick", createCsr);
+               } else {
+                       submitButtonElem.setAttribute("onclick", "createCsr()");
+               }
+
+               var keystrengthSelectElem = document.createElement("select");
+               keystrengthSelectElem.setAttribute("id", "keylength");
+               keystrengthSelectElem.setAttribute("name", "keylength");
+               var optionElem;
+               optionElem = document.createElement("option");
+               optionElem.setAttribute("value", "1024");
+               optionElem.appendChild(document.createTextNode("1024"));
+               keystrengthSelectElem.appendChild(optionElem);
+               optionElem = document.createElement("option");
+               optionElem.setAttribute("value", "2048");
+               optionElem.appendChild(document.createTextNode("2048"));
+               keystrengthSelectElem.appendChild(optionElem);
+               var keystrengthTdElem = document.getElementById("keystrenghtd");
+               keystrengthTdElem.appendChild(keystrengthSelectElem);
+       }
+}
\ No newline at end of file


Reply via email to