Permalink
Browse files

jotnode-register: more work

	modified:   contrib/jotnode-register/jotnode_register_cli.js
	new file:   contrib/jotnode-register/mini_mustache.js
	modified:   contrib/jotnode-register/x509_certtool_t.js
	modified:   lib/base64.js
  • Loading branch information...
1 parent 0c031e0 commit 786c3c7fa25915ff59e95f097483d16b8bcc4a50 @jeromeetienne committed Sep 8, 2010
@@ -21,7 +21,7 @@ if( false ){
}
-if(false){
+if(true){
var fname_priv = "/tmp/user.priv.der";
var fname_creq = "/tmp/user.creq.der";
var fname_cert = "/tmp/user.cert.der";
@@ -43,9 +43,9 @@ if(false){
-if( true ){
+if( false ){
var http = require('http');
- var url = "http://127.0.0.1:8124/register?creq="+base64.encode("supertruc");
+ var url = "http://127.0.0.1:8124/register?creq="+base64.encode_safe("supertruc");
var parsed_url = require('url').parse(url);
var pqh_str = parsed_url.pathname;
if( parsed_url.query ) pqh_str += "?"+parsed_url.query;
@@ -0,0 +1,17 @@
+/**
+ * Minimal version of mustache
+ * - a lot less that the real thing, but maintainable by me :)
+ * - http://mustache.github.com/
+*/
+var render = function(tmpl, data){
+ var result = tmpl;
+ for(var key in data){
+ var val = data[key];
+ var re = new RegExp("{{\\s*"+key+"\\s*}}");
+ result = result.replace(re, val)
+ }
+ return result;
+}
+
+// export it via commonjs
+exports.render = render;
@@ -49,7 +49,7 @@ var x509_certtool_t = function(){
cmdline += " --outder --outfile '"+fname_cert+"'";
cmdline += " --load-ca-privkey '"+fname_capriv+"'";
cmdline += " --load-ca-certificate '"+fname_cacert+"'";
- cmdline += " --template '"+fname_temp+"'";
+ cmdline += " --template '"+fname_catemp+"'";
cmdline_run(cmdline, success_cb, faillure_cb);
}
View
@@ -21,6 +21,24 @@ var base64 = {
_keyStr_defl : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/=",
_keyStr_safe : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
+
+ // public method for encoding
+ encode : function (input) {
+ return base64._encode_base(input, base64._keyStr_defl);
+ },
+ // public method for decoding
+ decode : function (input) {
+ return base64._decode_base(input, base64._keyStr_defl);
+ },
+ // public method for encoding
+ encode_safe : function (input) {
+ return base64._encode_base(input, base64._keyStr_safe);
+ },
+ // public method for decoding
+ decode_safe : function (input) {
+ return base64._decode_base(input, base64._keyStr_safe);
+ },
+
// public method for encoding
_encode_base : function (input, keyStr) {
var output = "";
@@ -85,25 +103,7 @@ var base64 = {
output = base64._utf8_decode(output);
return output;
},
-
- // public method for encoding
- encode : function (input) {
- return base64._encode_base(input, base64._keyStr_defl);
- },
- // public method for decoding
- decode : function (input) {
- return base64._decode_base(input, base64._keyStr_defl);
- },
- // public method for encoding
- encode_safe : function (input) {
- return base64._encode_base(input, base64._keyStr_safe);
- },
- // public method for decoding
- decode_safe : function (input) {
- return base64._decode_base(input, base64._keyStr_safe);
- },
-
-
+
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");

0 comments on commit 786c3c7

Please sign in to comment.