mirror of
https://github.com/nicolabs/ciform.git
synced 2026-04-10 07:54:46 +02:00
# fixes in doc and tests
This commit is contained in:
parent
4180c86cea
commit
636e8b1382
|
|
@ -37,13 +37,13 @@
|
|||
<tempfile property="build.bigsource.js" destDir="${build.dir}" prefix="lib${ant.project.name}" suffix=".js" />
|
||||
<!-- TODO handle encoding (and eol?) -->
|
||||
<concat destfile="${build.bigsource.js}">
|
||||
<!-- order is important because of function dependencies -->
|
||||
<!-- TODO no direct reference to the directory where dependencies are stored -->
|
||||
<!-- Order is important because of function dependencies -->
|
||||
<!-- 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">
|
||||
<include name="rsa*.js" />
|
||||
<include name="hex*.js" />
|
||||
<include name="base64*.js" />
|
||||
<include name="sha1*.js" />
|
||||
<include name="rsa*.js" />
|
||||
<include name="minilib.js" />
|
||||
</fileset>
|
||||
<fileset dir="${src.dir}" includes="*.js" />
|
||||
|
|
|
|||
|
|
@ -9,73 +9,70 @@
|
|||
|
||||
|
||||
/**
|
||||
@fileoverview
|
||||
|
||||
<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>
|
||||
|
||||
<p>It has 2 layers :<ol>
|
||||
<li>the {@link Ciform.ciphers} namespace contains the encoders used by Ciform.
|
||||
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
|
||||
being exchanged between the client and the server.<br>
|
||||
</ol>
|
||||
</p>
|
||||
|
||||
<h5><b>Example 1 : encrypting password fields</b></h5>
|
||||
|
||||
<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>
|
||||
<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"});">
|
||||
...
|
||||
</pre></code>
|
||||
|
||||
<h5><b>Example 2 : different types of encryption within the same page</b></h5>
|
||||
|
||||
<p>You can use several {@link Ciform.Cipher Ciform.Cipher} objects at the same time.</p>
|
||||
<code><pre>
|
||||
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'));
|
||||
</pre></code>
|
||||
</p>
|
||||
|
||||
<h5><b>Example 3 : using the same object to encrypt different fields</b></h5>
|
||||
|
||||
<code><pre>
|
||||
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);
|
||||
</pre></code>
|
||||
|
||||
@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 <a href="http://plugnauth.sourceforge.net/ciform">http://plugnauth.sourceforge.net/ciform</a>.
|
||||
*/
|
||||
* @fileoverview
|
||||
*
|
||||
* <p>This library provides specifications and basic functions to add encryption to HTML form elements.</p>
|
||||
*
|
||||
*
|
||||
* <p>Home : <a href="http://ciform.googlecode.com">http://ciform.googlecode.com</a></p>
|
||||
*
|
||||
* <p>It does not contain cryptographic functions ; it's more a 'user-friendly' wrapper
|
||||
* around cryptographic functions, dedicated to securing web forms.
|
||||
* </p>
|
||||
*
|
||||
* <p>It has 2 layers :<ol>
|
||||
* <li>the {@link Ciform.ciphers} namespace contains the (external) encoders used by Ciform.
|
||||
* 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
|
||||
* being exchanged between the client and the server.<br>
|
||||
* </ol>
|
||||
* </p>
|
||||
*
|
||||
* <h5><b>Example 1 : encrypting password fields</b></h5>
|
||||
*
|
||||
* <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>
|
||||
* <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"});">
|
||||
* ...
|
||||
* </pre></code>
|
||||
*
|
||||
* <h5><b>Example 2 : different types of encryption within the same page</b></h5>
|
||||
*
|
||||
* <p>You can use several {@link Ciform.Cipher} objects at the same time.</p>
|
||||
* <code><pre>
|
||||
* 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'));
|
||||
* </pre></code>
|
||||
* </p>
|
||||
*
|
||||
* <h5><b>Example 3 : using the same object to encrypt different fields</b></h5>
|
||||
*
|
||||
* <code><pre>
|
||||
* 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);
|
||||
* </pre></code>
|
||||
*
|
||||
* @author <a href="http://nicobo.net/contact">nicobo</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,
|
||||
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>
|
||||
|
||||
@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.<br>
|
||||
For instance, pass <code>{'encoder':myencoder,'onerror':function(e,context){dosomething()}}</code> to this constructor
|
||||
to provide it your custom encoder and a custom error handler.
|
||||
For instance, provide <code>{'encoder':myencoder,'onerror':function(e,context){dosomething()}}</code>
|
||||
to use a custom encoder and a custom error handler.
|
||||
*/
|
||||
Ciform.Cipher = function( options )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="../lib/hex.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>
|
||||
<script type="text/javascript" src="../../../target/lib/libciform-1.0.0.js"></script>
|
||||
|
||||
<!-- some style to play with -->
|
||||
<style type="text/css">
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@
|
|||
<artifact name="hex-min" type="js" conf="minified"/>
|
||||
</publications>
|
||||
<dependencies>
|
||||
<!-- no dependency required -->
|
||||
<dependency org="nicommons.crypto" name="rsa" rev="latest.integration" conf="*->source" />
|
||||
</dependencies>
|
||||
</ivy-module>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
/** @namespace */
|
||||
Crypto = typeof Crypto != 'undefined' ? Crypto : {};
|
||||
/** @namespace */
|
||||
Crypto.Hex = (function(/*window, undefined, $*/) {
|
||||
Crypto.Hex = (function(bs,bm) {
|
||||
|
||||
//
|
||||
// START OF ORIGINAL CODE
|
||||
|
|
@ -100,4 +100,4 @@ return {
|
|||
hex2s: hex2s
|
||||
};
|
||||
|
||||
})(/*window, undefined, $*/);
|
||||
})(bs, bm);
|
||||
|
|
@ -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)
|
||||
# (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
|
||||
phpdoc.exe=${tools.dir}/php-5.3.9-Win32-VC9-x86/php.exe ${tools.dir}/PhpDocumentor-1.4.4/phpdoc.php
|
||||
|
|
|
|||
Loading…
Reference in a new issue