From 636e8b1382194b9be8c4f03caf11378b33d6640d Mon Sep 17 00:00:00 2001 From: cbonar Date: Thu, 2 Feb 2012 17:51:56 +0100 Subject: [PATCH] # fixes in doc and tests --- ciform/build.xml | 6 +- ciform/src/main/js/ciform.js | 142 ++++++++++++++------------- ciform/src/test/js/scrapbook.html | 7 +- crypto/hex/ivy.xml | 2 +- crypto/hex/src/main/js/hex.js | 4 +- tools/build/common-sample.properties | 2 +- 6 files changed, 80 insertions(+), 83 deletions(-) diff --git a/ciform/build.xml b/ciform/build.xml index d245863..deb1b06 100644 --- a/ciform/build.xml +++ b/ciform/build.xml @@ -37,13 +37,13 @@ - - + + + - diff --git a/ciform/src/main/js/ciform.js b/ciform/src/main/js/ciform.js index 32fd956..1acdfad 100644 --- a/ciform/src/main/js/ciform.js +++ b/ciform/src/main/js/ciform.js @@ -9,73 +9,70 @@ /** - @fileoverview - -

This library provides specifications and basic functions to add encryption to HTML form elements.

- -

It does not contain cryptographic functions ; it's more a 'user-friendly' wrapper - around cryptographic functions, dedicated to securing web forms. -

- -

It has 2 layers :

    -
  1. the {@link Ciform.ciphers} namespace contains the encoders used by Ciform. - This is the layer that really deals with the cryptographic functions.
    -
  2. the {@link Ciform top, 'user' layer} contains classes dedicated to encryption of the data - being exchanged between the client and the server.
    -
-

- -
Example 1 : encrypting password fields
- -

This way you define a simple encryption on all password fields of a form, that will take place when it is submitted.

-
-<HEAD>
-...
-<SCRIPT type="text/javascript">
-	// pubKey is defined elsewhere : it is the public key used by the default RSA encoder
-	var mycipher = new {@link Ciform.Cipher Ciform.Cipher}({'pubKey':pubkey});
-</SCRIPT>
-...
-</HEAD>
-...
-<FORM action="http://myserver/mypage.php" onsubmit="javascript:mycipher.{@link Ciform.Cipher#encryptForm encryptForm}(this,{'allowTypes':"password"});">
-...
-	
- -
Example 2 : different types of encryption within the same page
- -

You can use several {@link Ciform.Cipher Ciform.Cipher} objects at the same time.

-
-var toServer1 = new {@link Ciform.Cipher Ciform.Cipher}({'pubKey':pubkey1});
-// in the following line the server is not the same one, so the public key is different
-var toServer2 = new {@link Ciform.Cipher Ciform.Cipher}({'pubKey':pubKey2});
-...
-toServer1.encryptForm(document.forms[1]);
-...
-toServer2.encryptField($('#country'));
-	
-

- -
Example 3 : using the same object to encrypt different fields
- -
-var ciform = new {@link Ciform.Cipher Ciform.Cipher}({'pubKey':pubkey});
-...
-// encrypts an input field : the encrypted value will replace its current value
-ciform.{@link Ciform.Cipher#encryptField encryptField}(document.getElementById('myFieldId'));
-...
-// encrypts the parameters in a URL (and replaces the original value)
-document.getElementById('anAnchor').href = ciform.{@link Ciform.Cipher#encryptURL encryptURL}(document.getElementById('anAnchor').href);
-	
- - @requires http://www.hanewin.net/encrypt/rsa/base64.js - @requires http://www.hanewin.net/encrypt/rsa/hex.js - @requires http://pajhome.org.uk/crypt/md5/sha1.js - @requires http://www.hanewin.net/encrypt/rsa/rsa.js - @author cbonar at users dot sf dot net. - - For more informations, see http://plugnauth.sourceforge.net/ciform. -*/ + * @fileoverview + * + *

This library provides specifications and basic functions to add encryption to HTML form elements.

+ * + * + *

Home : http://ciform.googlecode.com

+ * + *

It does not contain cryptographic functions ; it's more a 'user-friendly' wrapper + * around cryptographic functions, dedicated to securing web forms. + *

+ * + *

It has 2 layers :

    + *
  1. the {@link Ciform.ciphers} namespace contains the (external) encoders used by Ciform. + * This is the layer that really deals with the cryptographic functions.
    + *
  2. the {@link Ciform} top, 'user' layer contains classes dedicated to encryption of the data + * being exchanged between the client and the server.
    + *
+ *

+ * + *
Example 1 : encrypting password fields
+ * + *

This way you define a simple encryption on all password fields of a form, that will take place when it is submitted.

+ *
+ * <HEAD>
+ * ...
+ * <SCRIPT type="text/javascript">
+ *	// pubKey is defined elsewhere : it is the public key used by the default RSA encoder
+ *	var mycipher = new {@link Ciform.Cipher}({'pubKey':pubkey});
+ * </SCRIPT>
+ * ...
+ * </HEAD>
+ * ...
+ * <FORM action="http://myserver/mypage.php" onsubmit="javascript:mycipher.encryptForm(this,{'allowTypes':"password"});">
+ * ...
+ *	
+ * + *
Example 2 : different types of encryption within the same page
+ * + *

You can use several {@link Ciform.Cipher} objects at the same time.

+ *
+ * var toServer1 = new {@link Ciform.Cipher}({'pubKey':pubkey1});
+ * // in the following line the server is not the same one, so the public key is different
+ * var toServer2 = new {@link Ciform.Cipher}({'pubKey':pubKey2});
+ * ...
+ * toServer1.encryptForm(document.forms[1]);
+ * ...
+ * toServer2.encryptField($('#country'));
+ *	
+ *

+ * + *
Example 3 : using the same object to encrypt different fields
+ * + *
+ * var ciform = new {@link Ciform.Cipher}({'pubKey':pubkey});
+ * ...
+ * // encrypts an input field : the encrypted value will replace its current value ; see  {@link Ciform.Cipher#encryptField}
+ * ciform.encryptField(document.getElementById('myFieldId'));
+ * ...
+ * // encrypts the parameters in a URL (and replaces the original value) : {@link Ciform.Cipher#encryptURL}
+ * document.getElementById('anAnchor').href = ciform.encryptURL(document.getElementById('anAnchor').href);
+ *	
+ * + * @author nicobo + */ @@ -90,6 +87,11 @@ document.getElementById('anAnchor').href = ciform.{@link Ciform.Cipher#encryptUR

NOTE : The first letter is in upper case mainly to prevent errors like using 'ciform' to name a variable, and because it should also be considered as an Object containing the definitions of this library.
It is not very clean since other namespaces are named with lower case characters, but there's currently no perfect solution in Javascript.

+ + @requires http://www.hanewin.net/encrypt/rsa/base64.js + @requires http://www.hanewin.net/encrypt/rsa/hex.js + @requires http://pajhome.org.uk/crypt/md5/sha1.js + @requires http://www.hanewin.net/encrypt/rsa/rsa.js */ Ciform = {}; @@ -571,10 +573,10 @@ Ciform.ciphers.CiformPacketizer.prototype.encode = function( message ) It has first to be built with options to define the encryption ; then one of its method must be called on the element to encrypt. @constructor - @param {Object} options (optional) (and next arguments) (optional) + @param {Object} options (optional) (and next arguments) Overrides the default properties and functions of this object.
- For instance, pass {'encoder':myencoder,'onerror':function(e,context){dosomething()}} to this constructor - to provide it your custom encoder and a custom error handler. + For instance, provide {'encoder':myencoder,'onerror':function(e,context){dosomething()}} + to use a custom encoder and a custom error handler. */ Ciform.Cipher = function( options ) { diff --git a/ciform/src/test/js/scrapbook.html b/ciform/src/test/js/scrapbook.html index 43cd9c5..437f761 100644 --- a/ciform/src/test/js/scrapbook.html +++ b/ciform/src/test/js/scrapbook.html @@ -1,11 +1,6 @@ - - - - - - +