[rs-commit] r333 - in /rs-interop/trunk/src/site: resources/csr/certenroll.js xhtml5/csr/index.xhtml5

rs-commit at redwax.eu rs-commit at redwax.eu
Sun Mar 1 15:45:05 CET 2020


Author: minfrin at redwax.eu
Date: Sun Mar  1 15:45:04 2020
New Revision: 333

Log:
Format the javascript to better fit on the screen.

Modified:
    rs-interop/trunk/src/site/resources/csr/certenroll.js
    rs-interop/trunk/src/site/xhtml5/csr/index.xhtml5

Modified: rs-interop/trunk/src/site/resources/csr/certenroll.js
==============================================================================
--- rs-interop/trunk/src/site/resources/csr/certenroll.js	(original)
+++ rs-interop/trunk/src/site/resources/csr/certenroll.js	Sun Mar  1 15:45:04 2020
@@ -1,110 +1,163 @@
 /* make sure we can only submit once */
-document.getElementById('createform').addEventListener("submit", function certenroll(event) {
+document
+        .getElementById('createform')
+        .addEventListener(
+                "submit",
+                function certenroll(event) {
 
     document.getElementById('submit').disabled = true;
 
-	try {
-        var objCSP = objCertEnrollClassFactory.CreateObject("X509Enrollment.CCspInformation");
-        var objCSPs = objCertEnrollClassFactory.CreateObject("X509Enrollment.CCspInformations");
-        var objPrivateKey = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509PrivateKey");
-        var objRequest = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509CertificateRequestPkcs10")
-        var objObjectIds = objCertEnrollClassFactory.CreateObject("X509Enrollment.CObjectIds");
-        var objObjectId = objCertEnrollClassFactory.CreateObject("X509Enrollment.CObjectId");
-        var objX509ExtensionEnhancedKeyUsage = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509ExtensionEnhancedKeyUsage");
-        var objExtensionTemplate = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509ExtensionTemplateName")
-        var objDn = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX500DistinguishedName")
-        var objObjectIdChallenge = objCertEnrollClassFactory.CreateObject("X509Enrollment.CObjectId");
-        var objX509ExtensionChallenge = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509Extension");
-        var objEnroll = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509Enrollment")
+    try {
+        var objCSP = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CCspInformation");
+        var objCSPs = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CCspInformations");
+        var objPrivateKey = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509PrivateKey");
+        var objRequest = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509CertificateRequestPkcs10")
+        var objObjectIds = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CObjectIds");
+        var objObjectId = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CObjectId");
+        var objX509ExtensionEnhancedKeyUsage = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509ExtensionEnhancedKeyUsage");
+        var objExtensionTemplate = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509ExtensionTemplateName")
+        var objDn = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX500DistinguishedName")
+        var objObjectIdChallenge = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CObjectId");
+        var objX509ExtensionChallenge = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509Extension");
+        var objEnroll = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509Enrollment")
 
-        /* initialize the CSP using the desired Cryptograhic Service Provider */
-        objCSP.InitializeFromName("Microsoft Enhanced RSA and AES Cryptographic Provider");
+        /*
+         * initialize the CSP using the desired Cryptograhic
+         * Service Provider
+         */
+        objCSP
+            .InitializeFromName(
+                "Microsoft Enhanced RSA and AES Cryptographic Provider");
 
         /* add this CSP to the CSP collection */
         objCSPs.Add(objCSP);
 
-        /* provide key container name, key length and key spec to the private key object */
-        //objPrivateKey.ContainerName = $('#name').val();
+        /*
+         * provide key container name, key length and key spec
+         * to the private key object
+         */
+        // objPrivateKey.ContainerName = $('#name').val();
         objPrivateKey.Length = 4096;
         objPrivateKey.KeySpec = 1; // AT_KEYEXCHANGE = 1
-        objPrivateKey.ProviderType = '24'; // XCN_PROV_RSA_AES = 24
+        objPrivateKey.ProviderType = '24'; // XCN_PROV_RSA_AES
+                                            // = 24
 
-        /* provide the CSP collection object (in this case containing only 1 CSP object) */
+        /*
+         * provide the CSP collection object (in this case
+         * containing only 1 CSP object)
+         */
         /* to the private key object */
         objPrivateKey.CspInformations = objCSPs;
 
         /* initialize P10 based on private key */
-        objRequest.InitializeFromPrivateKey(1, objPrivateKey, ""); // context user = 1
+        objRequest.InitializeFromPrivateKey(1, objPrivateKey,
+                ""); // context user = 1
 
         /* 1.3.6.1.5.5.7.3.2 Oid - extension */
         objObjectId.InitializeFromValue("1.3.6.1.5.5.7.3.2");
         objObjectIds.Add(objObjectId);
-        objX509ExtensionEnhancedKeyUsage.InitializeEncode(objObjectIds);
-        objRequest.X509Extensions.Add(objX509ExtensionEnhancedKeyUsage);
+        objX509ExtensionEnhancedKeyUsage
+                .InitializeEncode(objObjectIds);
+        objRequest.X509Extensions
+                .Add(objX509ExtensionEnhancedKeyUsage);
 
         /* 1.3.6.1.5.5.7.3.3 Oid - extension */
-        //objExtensionTemplate.InitializeEncode("1.3.6.1.5.5.7.3.3");
-        //objRequest.X509Extensions.Add(objExtensionTemplate);
-
+        // objExtensionTemplate.InitializeEncode("1.3.6.1.5.5.7.3.3");
+        // objRequest.X509Extensions.Add(objExtensionTemplate);
         /* DN related stuff */
-        objDn.Encode("CN=" + document.getElementById('name').value, 0); // XCN_CERT_NAME_STR_NONE = 0
+        objDn.Encode("CN="
+                + document.getElementById('name').value, 0); // XCN_CERT_NAME_STR_NONE
+                                                                // = 0
         objRequest.Subject = objDn;
 
-        //objChallengeObjectId.InitializeFromName(CERTENROLL_OBJECTID.XCN_OID_RSA_challengePwd);
-        //objChallengeObjectId.InitializeFromValue("1.2.840.113549.1.9.7");
+        // objChallengeObjectId.
+        //    InitializeFromName(CERTENROLL_OBJECTID.XCN_OID_RSA_challengePwd);
+        // objChallengeObjectId.InitializeFromValue("1.2.840.113549.1.9.7");
 
-        objObjectIdChallenge.InitializeFromValue("1.2.840.113549.1.9.7");
-        objX509ExtensionChallenge.Initialize(objObjectIdChallenge, 6, window.btoa('Hello, world')); // XCN_CRYPT_STRING_BASE64_ANY = 6
-        objRequest.X509Extensions.Add(objX509ExtensionChallenge);
+        objObjectIdChallenge
+                .InitializeFromValue("1.2.840.113549.1.9.7");
+        objX509ExtensionChallenge.Initialize(
+                objObjectIdChallenge, 6, window
+                        .btoa('Hello, world')); // XCN_CRYPT_STRING_BASE64_ANY
+                                                // = 6
+        objRequest.X509Extensions
+                .Add(objX509ExtensionChallenge);
 
         /* enroll */
         objEnroll.InitializeFromRequest(objRequest);
-        document.getElementById('pkcs10').value = objEnroll.CreateRequest(3); // XCN_CRYPT_STRING_BASE64REQUESTHEADER = 3
+        document.getElementById('pkcs10').value = objEnroll
+                .CreateRequest(3); // XCN_CRYPT_STRING_BASE64REQUESTHEADER
+                                    // = 3
 
         /* send the request */
         var xhr = new XMLHttpRequest();
 
         xhr.onerror = function() {
-            alert('A network error occcurred trying to contact the certificate authority. Click create to try again.');
+            alert('A network error occcurred trying to contact the certificate' +
+                    'authority. Click create to try again.');
             document.getElementById('submit').disabled = false;
         }
 
         xhr.onload = function() {
             if (xhr.status != 200) {
-                alert('The certificate authority responded with ' + xhr.status + ': ' + xhr.statusText); // e.g. 404: Not Found
+                alert('The certificate authority responded with '
+                        + xhr.status + ': ' + xhr.statusText); // e.g.
+                                                                // 404:
+                                                                // Not
+                                                                // Found
                 document.getElementById('submit').disabled = false;
             } else {
                 try {
                     var allow = 4; // AllowUntrustedRoot
-                    objEnroll.InstallResponse(allow, xhr.response, 0, "");
-                }
-                catch (ex) {
+                    objEnroll.InstallResponse(allow,
+                            xhr.response, 0, "");
+                } catch (ex) {
                     console.log(ex);
                 }
                 alert('The certificate has been installed successfully.');
-                //document.getElementById('continue').disabled = false;
+                // document.getElementById('continue').disabled
+                // = false;
             }
         };
 
-        xhr.open('POST', document.getElementById('createform').action, true);
-        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-        xhr.setRequestHeader('Accept', 'application/pkcs7-mime');
+        xhr.open('POST',
+                document.getElementById('createform').action,
+                true);
+        xhr.setRequestHeader('Content-Type',
+                'application/x-www-form-urlencoded');
+        xhr
+                .setRequestHeader('Accept',
+                        'application/pkcs7-mime');
         xhr.responseType = 'text';
-        // var formData = new FormData(document.getElementById('createform'));
-        var formData  = encodeURIComponent('pkcs10') + '=' + encodeURIComponent(document.getElementById('pkcs10').value);
+        // var formData = new
+        // FormData(document.getElementById('createform'));
+        var formData = encodeURIComponent('pkcs10')
+                + '='
+                + encodeURIComponent(document
+                        .getElementById('pkcs10').value);
         console.log(formData);
         xhr.send(formData);
 
         event.preventDefault();
 
         return false;
-    }
-    catch (ex) {
+    } catch (ex) {
         console.log(ex);
         if (ex instanceof TypeError) {
             alert('Microsoft CertEnroll is not supported on this browser');
-        }
-        else {
+        } else {
             alert(ex);
         }
 
@@ -117,4 +170,3 @@
 
     return true;
 });
-

Modified: rs-interop/trunk/src/site/xhtml5/csr/index.xhtml5
==============================================================================
--- rs-interop/trunk/src/site/xhtml5/csr/index.xhtml5	(original)
+++ rs-interop/trunk/src/site/xhtml5/csr/index.xhtml5	Sun Mar  1 15:45:04 2020
@@ -192,112 +192,165 @@
                 </p>
                 <pre>
 <code><![CDATA[/* make sure we can only submit once */
-document.getElementById('createform').addEventListener("submit", function certenroll(event) {
+document
+        .getElementById('createform')
+        .addEventListener(
+                "submit",
+                function certenroll(event) {
 
     document.getElementById('submit').disabled = true;
 
-	try {
-        var objCSP = objCertEnrollClassFactory.CreateObject("X509Enrollment.CCspInformation");
-        var objCSPs = objCertEnrollClassFactory.CreateObject("X509Enrollment.CCspInformations");
-        var objPrivateKey = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509PrivateKey");
-        var objRequest = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509CertificateRequestPkcs10")
-        var objObjectIds = objCertEnrollClassFactory.CreateObject("X509Enrollment.CObjectIds");
-        var objObjectId = objCertEnrollClassFactory.CreateObject("X509Enrollment.CObjectId");
-        var objX509ExtensionEnhancedKeyUsage = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509ExtensionEnhancedKeyUsage");
-        var objExtensionTemplate = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509ExtensionTemplateName")
-        var objDn = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX500DistinguishedName")
-        var objObjectIdChallenge = objCertEnrollClassFactory.CreateObject("X509Enrollment.CObjectId");
-        var objX509ExtensionChallenge = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509Extension");
-        var objEnroll = objCertEnrollClassFactory.CreateObject("X509Enrollment.CX509Enrollment")
-
-        /* initialize the CSP using the desired Cryptograhic Service Provider */
-        objCSP.InitializeFromName("Microsoft Enhanced RSA and AES Cryptographic Provider");
+    try {
+        var objCSP = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CCspInformation");
+        var objCSPs = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CCspInformations");
+        var objPrivateKey = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509PrivateKey");
+        var objRequest = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509CertificateRequestPkcs10")
+        var objObjectIds = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CObjectIds");
+        var objObjectId = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CObjectId");
+        var objX509ExtensionEnhancedKeyUsage = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509ExtensionEnhancedKeyUsage");
+        var objExtensionTemplate = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509ExtensionTemplateName")
+        var objDn = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX500DistinguishedName")
+        var objObjectIdChallenge = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CObjectId");
+        var objX509ExtensionChallenge = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509Extension");
+        var objEnroll = objCertEnrollClassFactory
+                .CreateObject("X509Enrollment.CX509Enrollment")
+
+        /*
+         * initialize the CSP using the desired Cryptograhic
+         * Service Provider
+         */
+        objCSP
+            .InitializeFromName(
+                "Microsoft Enhanced RSA and AES Cryptographic Provider");
 
         /* add this CSP to the CSP collection */
         objCSPs.Add(objCSP);
 
-        /* provide key container name, key length and key spec to the private key object */
-        //objPrivateKey.ContainerName = $('#name').val();
+        /*
+         * provide key container name, key length and key spec
+         * to the private key object
+         */
+        // objPrivateKey.ContainerName = $('#name').val();
         objPrivateKey.Length = 4096;
         objPrivateKey.KeySpec = 1; // AT_KEYEXCHANGE = 1
-        objPrivateKey.ProviderType = '24'; // XCN_PROV_RSA_AES = 24
-
-        /* provide the CSP collection object (in this case containing only 1 CSP object) */
+        objPrivateKey.ProviderType = '24'; // XCN_PROV_RSA_AES
+                                            // = 24
+
+        /*
+         * provide the CSP collection object (in this case
+         * containing only 1 CSP object)
+         */
         /* to the private key object */
         objPrivateKey.CspInformations = objCSPs;
 
         /* initialize P10 based on private key */
-        objRequest.InitializeFromPrivateKey(1, objPrivateKey, ""); // context user = 1
+        objRequest.InitializeFromPrivateKey(1, objPrivateKey,
+                ""); // context user = 1
 
         /* 1.3.6.1.5.5.7.3.2 Oid - extension */
         objObjectId.InitializeFromValue("1.3.6.1.5.5.7.3.2");
         objObjectIds.Add(objObjectId);
-        objX509ExtensionEnhancedKeyUsage.InitializeEncode(objObjectIds);
-        objRequest.X509Extensions.Add(objX509ExtensionEnhancedKeyUsage);
+        objX509ExtensionEnhancedKeyUsage
+                .InitializeEncode(objObjectIds);
+        objRequest.X509Extensions
+                .Add(objX509ExtensionEnhancedKeyUsage);
 
         /* 1.3.6.1.5.5.7.3.3 Oid - extension */
-        //objExtensionTemplate.InitializeEncode("1.3.6.1.5.5.7.3.3");
-        //objRequest.X509Extensions.Add(objExtensionTemplate);
-
+        // objExtensionTemplate.InitializeEncode("1.3.6.1.5.5.7.3.3");
+        // objRequest.X509Extensions.Add(objExtensionTemplate);
         /* DN related stuff */
-        objDn.Encode("CN=" + document.getElementById('name').value, 0); // XCN_CERT_NAME_STR_NONE = 0
+        objDn.Encode("CN="
+                + document.getElementById('name').value, 0); // XCN_CERT_NAME_STR_NONE
+                                                                // = 0
         objRequest.Subject = objDn;
 
-        //objChallengeObjectId.InitializeFromName(CERTENROLL_OBJECTID.XCN_OID_RSA_challengePwd);
-        //objChallengeObjectId.InitializeFromValue("1.2.840.113549.1.9.7");
-
-        objObjectIdChallenge.InitializeFromValue("1.2.840.113549.1.9.7");
-        objX509ExtensionChallenge.Initialize(objObjectIdChallenge, 6, window.btoa('Hello, world')); // XCN_CRYPT_STRING_BASE64_ANY = 6
-        objRequest.X509Extensions.Add(objX509ExtensionChallenge);
+        // objChallengeObjectId.
+        //    InitializeFromName(CERTENROLL_OBJECTID.XCN_OID_RSA_challengePwd);
+        // objChallengeObjectId.InitializeFromValue("1.2.840.113549.1.9.7");
+
+        objObjectIdChallenge
+                .InitializeFromValue("1.2.840.113549.1.9.7");
+        objX509ExtensionChallenge.Initialize(
+                objObjectIdChallenge, 6, window
+                        .btoa('Hello, world')); // XCN_CRYPT_STRING_BASE64_ANY
+                                                // = 6
+        objRequest.X509Extensions
+                .Add(objX509ExtensionChallenge);
 
         /* enroll */
         objEnroll.InitializeFromRequest(objRequest);
-        document.getElementById('pkcs10').value = objEnroll.CreateRequest(3); // XCN_CRYPT_STRING_BASE64REQUESTHEADER = 3
+        document.getElementById('pkcs10').value = objEnroll
+                .CreateRequest(3); // XCN_CRYPT_STRING_BASE64REQUESTHEADER
+                                    // = 3
 
         /* send the request */
         var xhr = new XMLHttpRequest();
 
         xhr.onerror = function() {
-            alert('A network error occcurred trying to contact the certificate authority. Click create to try again.');
+            alert('A network error occcurred trying to contact the certificate' +
+                    'authority. Click create to try again.');
             document.getElementById('submit').disabled = false;
         }
 
         xhr.onload = function() {
             if (xhr.status != 200) {
-                alert('The certificate authority responded with ' + xhr.status + ': ' + xhr.statusText); // e.g. 404: Not Found
+                alert('The certificate authority responded with '
+                        + xhr.status + ': ' + xhr.statusText); // e.g.
+                                                                // 404:
+                                                                // Not
+                                                                // Found
                 document.getElementById('submit').disabled = false;
             } else {
                 try {
                     var allow = 4; // AllowUntrustedRoot
-                    objEnroll.InstallResponse(allow, xhr.response, 0, "");
-                }
-                catch (ex) {
+                    objEnroll.InstallResponse(allow,
+                            xhr.response, 0, "");
+                } catch (ex) {
                     console.log(ex);
                 }
                 alert('The certificate has been installed successfully.');
-                //document.getElementById('continue').disabled = false;
+                // document.getElementById('continue').disabled
+                // = false;
             }
         };
 
-        xhr.open('POST', document.getElementById('createform').action, true);
-        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-        xhr.setRequestHeader('Accept', 'application/pkcs7-mime');
+        xhr.open('POST',
+                document.getElementById('createform').action,
+                true);
+        xhr.setRequestHeader('Content-Type',
+                'application/x-www-form-urlencoded');
+        xhr
+                .setRequestHeader('Accept',
+                        'application/pkcs7-mime');
         xhr.responseType = 'text';
-        // var formData = new FormData(document.getElementById('createform'));
-        var formData  = encodeURIComponent('pkcs10') + '=' + encodeURIComponent(document.getElementById('pkcs10').value);
+        // var formData = new
+        // FormData(document.getElementById('createform'));
+        var formData = encodeURIComponent('pkcs10')
+                + '='
+                + encodeURIComponent(document
+                        .getElementById('pkcs10').value);
         console.log(formData);
         xhr.send(formData);
 
         event.preventDefault();
 
         return false;
-    }
-    catch (ex) {
+    } catch (ex) {
         console.log(ex);
         if (ex instanceof TypeError) {
             alert('Microsoft CertEnroll is not supported on this browser');
-        }
-        else {
+        } else {
             alert(ex);
         }
 



More information about the rs-commit mailing list