# fixes in doc and tests

This commit is contained in:
cbonar 2012-02-02 17:51:56 +01:00
parent 4180c86cea
commit 636e8b1382
6 changed files with 80 additions and 83 deletions

View file

@ -37,13 +37,13 @@
<tempfile property="build.bigsource.js" destDir="${build.dir}" prefix="lib${ant.project.name}" suffix=".js" /> <tempfile property="build.bigsource.js" destDir="${build.dir}" prefix="lib${ant.project.name}" suffix=".js" />
<!-- TODO handle encoding (and eol?) --> <!-- TODO handle encoding (and eol?) -->
<concat destfile="${build.bigsource.js}"> <concat destfile="${build.bigsource.js}">
<!-- order is important because of function dependencies --> <!-- Order is important because of function dependencies -->
<!-- TODO no direct reference to the directory where dependencies are stored --> <!-- TODO no direct reference to the directory where dependencies are stored : use Ivy to order them accordingly to dependency priorities -->
<fileset dir="${build.dir}/ivy/source"> <fileset dir="${build.dir}/ivy/source">
<include name="rsa*.js" />
<include name="hex*.js" /> <include name="hex*.js" />
<include name="base64*.js" /> <include name="base64*.js" />
<include name="sha1*.js" /> <include name="sha1*.js" />
<include name="rsa*.js" />
<include name="minilib.js" /> <include name="minilib.js" />
</fileset> </fileset>
<fileset dir="${src.dir}" includes="*.js" /> <fileset dir="${src.dir}" includes="*.js" />

View file

@ -9,73 +9,70 @@
/** /**
@fileoverview * @fileoverview
*
<p>This library provides specifications and basic functions to add encryption to HTML form elements.</p> * <p>This library provides specifications and basic functions to add encryption to HTML form elements.</p>
*
<p>It does not contain cryptographic functions ; it's more a 'user-friendly' wrapper *
around cryptographic functions, dedicated to securing web forms. * <p>Home : <a href="http://ciform.googlecode.com">http://ciform.googlecode.com</a></p>
</p> *
* <p>It does not contain cryptographic functions ; it's more a 'user-friendly' wrapper
<p>It has 2 layers :<ol> * around cryptographic functions, dedicated to securing web forms.
<li>the {@link Ciform.ciphers} namespace contains the encoders used by Ciform. * </p>
This is the layer that really deals with the cryptographic functions.<br> *
<li>the {@link Ciform top, 'user' layer} contains classes dedicated to encryption of the data * <p>It has 2 layers :<ol>
being exchanged between the client and the server.<br> * <li>the {@link Ciform.ciphers} namespace contains the (external) encoders used by Ciform.
</ol> * This is the layer that really deals with the cryptographic functions.<br>
</p> * <li>the {@link Ciform} top, 'user' layer contains classes dedicated to encryption of the data
* being exchanged between the client and the server.<br>
<h5><b>Example 1 : encrypting password fields</b></h5> * </ol>
* </p>
<p>This way you define a simple encryption on all password fields of a form, that will take place when it is submitted.</p> *
<code><pre> * <h5><b>Example 1 : encrypting password fields</b></h5>
&lt;HEAD&gt; *
... * <p>This way you define a simple encryption on all password fields of a form, that will take place when it is submitted.</p>
&lt;SCRIPT type="text/javascript"&gt; * <code><pre>
// pubKey is defined elsewhere : it is the public key used by the default RSA encoder * &lt;HEAD&gt;
var mycipher = new {@link Ciform.Cipher Ciform.Cipher}({'pubKey':pubkey}); * ...
&lt;/SCRIPT&gt; * &lt;SCRIPT type="text/javascript"&gt;
... * // pubKey is defined elsewhere : it is the public key used by the default RSA encoder
&lt;/HEAD&gt; * var mycipher = new {@link Ciform.Cipher}({'pubKey':pubkey});
... * &lt;/SCRIPT&gt;
&lt;FORM action="http://myserver/mypage.php" onsubmit="javascript:mycipher.{@link Ciform.Cipher#encryptForm encryptForm}(this,{'allowTypes':"password"});"&gt; * ...
... * &lt;/HEAD&gt;
</pre></code> * ...
* &lt;FORM action="http://myserver/mypage.php" onsubmit="javascript:mycipher.encryptForm(this,{'allowTypes':"password"});"&gt;
<h5><b>Example 2 : different types of encryption within the same page</b></h5> * ...
* </pre></code>
<p>You can use several {@link Ciform.Cipher Ciform.Cipher} objects at the same time.</p> *
<code><pre> * <h5><b>Example 2 : different types of encryption within the same page</b></h5>
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 * <p>You can use several {@link Ciform.Cipher} objects at the same time.</p>
var toServer2 = new {@link Ciform.Cipher Ciform.Cipher}({'pubKey':pubKey2}); * <code><pre>
... * var toServer1 = new {@link Ciform.Cipher}({'pubKey':pubkey1});
toServer1.encryptForm(document.forms[1]); * // 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});
toServer2.encryptField($('#country')); * ...
</pre></code> * toServer1.encryptForm(document.forms[1]);
</p> * ...
* toServer2.encryptField($('#country'));
<h5><b>Example 3 : using the same object to encrypt different fields</b></h5> * </pre></code>
* </p>
<code><pre> *
var ciform = new {@link Ciform.Cipher Ciform.Cipher}({'pubKey':pubkey}); * <h5><b>Example 3 : using the same object to encrypt different fields</b></h5>
... *
// encrypts an input field : the encrypted value will replace its current value * <code><pre>
ciform.{@link Ciform.Cipher#encryptField encryptField}(document.getElementById('myFieldId')); * var ciform = new {@link Ciform.Cipher}({'pubKey':pubkey});
... * ...
// encrypts the parameters in a URL (and replaces the original value) * // encrypts an input field : the encrypted value will replace its current value ; see {@link Ciform.Cipher#encryptField}
document.getElementById('anAnchor').href = ciform.{@link Ciform.Cipher#encryptURL encryptURL}(document.getElementById('anAnchor').href); * ciform.encryptField(document.getElementById('myFieldId'));
</pre></code> * ...
* // encrypts the parameters in a URL (and replaces the original value) : {@link Ciform.Cipher#encryptURL}
@requires http://www.hanewin.net/encrypt/rsa/base64.js * document.getElementById('anAnchor').href = ciform.encryptURL(document.getElementById('anAnchor').href);
@requires http://www.hanewin.net/encrypt/rsa/hex.js * </pre></code>
@requires http://pajhome.org.uk/crypt/md5/sha1.js *
@requires http://www.hanewin.net/encrypt/rsa/rsa.js * @author <a href="http://nicobo.net/contact">nicobo</a>
@author cbonar at users dot sf dot net. */
For more informations, see <a href="http://plugnauth.sourceforge.net/ciform">http://plugnauth.sourceforge.net/ciform</a>.
*/
@ -90,6 +87,11 @@ document.getElementById('anAnchor').href = ciform.{@link Ciform.Cipher#encryptUR
<p>NOTE : The first letter is in upper case mainly to prevent errors like using 'ciform' to name a variable, <p>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.<br> and because it should also be considered as an Object containing the definitions of this library.<br>
It is not very clean since other namespaces are named with lower case characters, but there's currently no perfect solution in Javascript.</p> It is not very clean since other namespaces are named with lower case characters, but there's currently no perfect solution in Javascript.</p>
@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 = {}; Ciform = {};
@ -571,10 +573,10 @@ Ciform.ciphers.CiformPacketizer.prototype.encode = function( message )
It has first to be built with options to define the encryption ; 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. then one of its method must be called on the element to encrypt.
@constructor @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.<br> Overrides the default properties and functions of this object.<br>
For instance, pass <code>{'encoder':myencoder,'onerror':function(e,context){dosomething()}}</code> to this constructor For instance, provide <code>{'encoder':myencoder,'onerror':function(e,context){dosomething()}}</code>
to provide it your custom encoder and a custom error handler. to use a custom encoder and a custom error handler.
*/ */
Ciform.Cipher = function( options ) Ciform.Cipher = function( options )
{ {

View file

@ -1,11 +1,6 @@
<html> <html>
<head> <head>
<script type="text/javascript" src="../lib/hex.js"></script> <script type="text/javascript" src="../../../target/lib/libciform-1.0.0.js"></script>
<script type="text/javascript" src="../lib/base64.js"></script>
<script type="text/javascript" src="../lib/sha1.js"></script>
<script type="text/javascript" src="../lib/rsa.js"></script>
<script type="text/javascript" src="../src/minilib.js"></script>
<script type="text/javascript" src="../src/ciform.js"></script>
<!-- some style to play with --> <!-- some style to play with -->
<style type="text/css"> <style type="text/css">

View file

@ -16,6 +16,6 @@
<artifact name="hex-min" type="js" conf="minified"/> <artifact name="hex-min" type="js" conf="minified"/>
</publications> </publications>
<dependencies> <dependencies>
<!-- no dependency required --> <dependency org="nicommons.crypto" name="rsa" rev="latest.integration" conf="*->source" />
</dependencies> </dependencies>
</ivy-module> </ivy-module>

View file

@ -7,7 +7,7 @@
/** @namespace */ /** @namespace */
Crypto = typeof Crypto != 'undefined' ? Crypto : {}; Crypto = typeof Crypto != 'undefined' ? Crypto : {};
/** @namespace */ /** @namespace */
Crypto.Hex = (function(/*window, undefined, $*/) { Crypto.Hex = (function(bs,bm) {
// //
// START OF ORIGINAL CODE // START OF ORIGINAL CODE
@ -100,4 +100,4 @@ return {
hex2s: hex2s hex2s: hex2s
}; };
})(/*window, undefined, $*/); })(bs, bm);

View file

@ -46,7 +46,7 @@ yuicompressor.jar=${tools.dir}/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar
# Installation directory of JSDoc-toolkit (http://code.google.com/p/jsdoc-toolkit) # Installation directory of JSDoc-toolkit (http://code.google.com/p/jsdoc-toolkit)
# (required) -> define this property in your "local.properties" file # (required) -> define this property in your "local.properties" file
jsdoc.dir=${tools.dir}/jsdoc-toolkit jsdoc.dir=${tools.dir}/jsdoc_toolkit-2.4.0/jsdoc-toolkit
# Command to run PHPDocumentor # Command to run PHPDocumentor
phpdoc.exe=${tools.dir}/php-5.3.9-Win32-VC9-x86/php.exe ${tools.dir}/PhpDocumentor-1.4.4/phpdoc.php phpdoc.exe=${tools.dir}/php-5.3.9-Win32-VC9-x86/php.exe ${tools.dir}/PhpDocumentor-1.4.4/phpdoc.php