Fixed FELIX-4703 : User Admin plugin should use all available to the JVM crypto algorithms
https://issues.apache.org/jira/browse/FELIX-4703

Meanwhile also updated :
- the apache-rat configuration
- the dependencies file, as json2.min and crypto-js were removed
- the activator, removing some dead code


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1640280 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES b/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES
index 7173c8d..48c7042 100644
--- a/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES
+++ b/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES
@@ -13,17 +13,6 @@
 Copyright (c) 2009 Ivan Bozhanov (vakata.com)
 Licensed under The MIT License (http://www.opensource.org/licenses/mit-license.php)
 
-This product uses software developed at
-CryptoJS (http://code.google.com/p/crypto-js/).
-Copyright © 2009–2012 by Jeff Mott. All rights reserved.
-Licensed under New BSD License
-
-This product uses software developed at
-JSON.js (https://github.com/douglascrockford/JSON-js).
-Available as Public Domain code
-
 III. License Summary
 - Apache License 2.0
 - The MIT License
-- New BSD License
-- Public Domain
diff --git a/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java b/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java
index 4428428..48bddb0 100644
--- a/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java
+++ b/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java
@@ -20,7 +20,6 @@
 import org.osgi.framework.BundleActivator;

 import org.osgi.framework.BundleContext;

 import org.osgi.framework.ServiceReference;

-import org.osgi.framework.ServiceRegistration;

 import org.osgi.service.useradmin.UserAdmin;

 import org.osgi.util.tracker.ServiceTracker;

 import org.osgi.util.tracker.ServiceTrackerCustomizer;

@@ -35,7 +34,6 @@
     private BundleContext context;

 

     private SimpleWebConsolePlugin plugin;

-    private ServiceRegistration printerRegistration;

 

     /**

      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)

@@ -92,20 +90,12 @@
     public final void removedService(ServiceReference reference, Object service)

     {

         SimpleWebConsolePlugin plugin = this.plugin;

+        this.plugin = null;

 

-        if (tracker.size() <= 1 && plugin != null)

+        if (plugin != null)

         {

             // remove service

             plugin.unregister();

-            this.plugin = null;

-            // unregister configuration printer too

-            ServiceRegistration reg = printerRegistration;

-            if (reg != null)

-            {

-                reg.unregister();

-                printerRegistration = null;

-            }

         }

-

     }

 }

diff --git a/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java b/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java
index 361692b..b6fa70e 100644
--- a/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java
+++ b/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java
@@ -18,6 +18,9 @@
 

 import java.io.IOException;

 import java.io.PrintWriter;

+import java.security.MessageDigest;

+import java.security.Provider;

+import java.security.Security;

 import java.util.Dictionary;

 import java.util.Enumeration;

 import java.util.Iterator;

@@ -60,7 +63,6 @@
         TEMPLATE = readTemplateFile("/res/plugin.html"); //$NON-NLS-1$

     }

 

-

     public String getCategory()

     {

         return CATEGORY;

@@ -90,6 +92,7 @@
 

         try

         {

+

             if ("addMember".equals(action)) { //$NON-NLS-1$

                 final Role xrole = userAdmin.getRole(role);

                 final Group xgroup = (Group) userAdmin.getRole(group);

@@ -108,6 +111,19 @@
                 xgroup.removeMember(xrole);

                 toJSON(jw, xgroup, false);

             }

+            else if ("getDigestAlgorithms".equals(action)) { //$NON-NLS-1$

+                getMessageDigestAlgorithms(jw);

+            }

+            else if ("digest".equals(action)) { //$NON-NLS-1$

+                final String dataRaw = req.getParameter("data"); //$NON-NLS-1$

+                final String algorithm = req.getParameter("algorithm"); //$NON-NLS-1$

+                final MessageDigest digest = MessageDigest.getInstance(algorithm);

+                final byte[] encoded = digest.digest(dataRaw.getBytes());

+                jw.object();

+                jw.key("encoded"); //$NON-NLS-1$

+                jw.value(encoded);

+                jw.endObject();

+            }

             else if ("del".equals(action)) { //$NON-NLS-1$

                 out.print(userAdmin.removeRole(role));

             }

@@ -267,4 +283,25 @@
         }

         jw.endArray();

     }

+

+    private static final String DIGEST_KEY_PREFIX = "MessageDigest."; //$NON-NLS-1$

+

+    private static void getMessageDigestAlgorithms(final JSONWriter jw)

+        throws JSONException

+    {

+        Provider[] providers = Security.getProviders();

+        jw.array();

+        for (int i = 0; providers != null && i < providers.length; i++)

+        {

+            for (Iterator keys = providers[i].keySet().iterator(); keys.hasNext();)

+            {

+                final String key = (String) keys.next();

+                if (key.startsWith(DIGEST_KEY_PREFIX) && key.indexOf(' ') == -1)

+                {

+                    jw.value(key.substring(DIGEST_KEY_PREFIX.length()));

+                }

+            }

+        }

+        jw.endArray();

+    }

 }

diff --git a/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties
index 62fe008..8fad024 100644
--- a/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties
+++ b/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -39,10 +39,7 @@
 role.type.2=Group

 type.string=String

 type.bytes=Byte[]

-type.password-MD5=Password Hash (MD5)

-type.password-SHA1=Password Hash (SHA-1)

-type.password-SHA256=Password Hash (SHA256)

-type.password-SHA512=Password Hash (SHA512)

+type.password=Password Hash

 role.statline=There are {1} user(s) and {2} role(s) arranged in {0} groups.

 role.help.initial=\

 - Select a role on the left side to open it and edit it's properties and credentials<br/>\

diff --git a/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties b/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
index 746887b..ef397ae 100644
--- a/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
+++ b/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
@@ -39,10 +39,7 @@
 role.type.2=Група

 type.string=Низ

 type.bytes=Данни

-type.password-MD5=Парола (MD5)

-type.password-SHA1=Парола (SHA-1)

-type.password-SHA256=Парола (SHA256)

-type.password-SHA512=Парола (SHA512)

+type.password=Парола

 role.statline=Има {1} потребител(я) и {2} роли организирани в {0} групи.

 role.help.initial=\

 - Изберете роля от ляво, за да я отворите и промените нейните атрибути<br/>\

diff --git a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/core-min.js b/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/core-min.js
deleted file mode 100644
index 65e57cc..0000000
--- a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/core-min.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
-CryptoJS v3.0.2
-code.google.com/p/crypto-js
-(c) 2009-2012 by Jeff Mott. All rights reserved.
-code.google.com/p/crypto-js/wiki/License
-*/
-var CryptoJS=CryptoJS||function(h,o){var f={},j=f.lib={},k=j.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;b&&c.mixIn(b);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),i=j.WordArray=k.extend({init:function(a,b){a=
-this.words=a||[];this.sigBytes=b!=o?b:4*a.length},toString:function(a){return(a||p).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var e=0;e<a;e++)b[d+e>>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535<c.length)for(e=0;e<a;e+=4)b[d+e>>>2]=c[e>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=h.ceil(b/4)},clone:function(){var a=
-k.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c<a;c+=4)b.push(4294967296*h.random()|0);return i.create(b,a)}}),l=f.enc={},p=l.Hex={stringify:function(a){for(var b=a.words,a=a.sigBytes,c=[],d=0;d<a;d++){var e=b[d>>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16));c.push((e&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return i.create(c,b/2)}},n=l.Latin1={stringify:function(a){for(var b=
-a.words,a=a.sigBytes,c=[],d=0;d<a;d++)c.push(String.fromCharCode(b[d>>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d++)c[d>>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return i.create(c,b)}},q=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},m=j.BufferedBlockAlgorithm=k.extend({reset:function(){this._data=i.create();
-this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=q.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,e=this.blockSize,f=d/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0),a=f*e,d=h.min(4*a,d);if(a){for(var g=0;g<a;g+=e)this._doProcessBlock(c,g);g=c.splice(0,a);b.sigBytes-=d}return i.create(g,d)},clone:function(){var a=k.clone.call(this);a._data=this._data.clone();return a},_minBufferSize:0});j.Hasher=m.extend({init:function(){this.reset()},
-reset:function(){m.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);this._doFinalize();return this._hash},clone:function(){var a=m.clone.call(this);a._hash=this._hash.clone();return a},blockSize:16,_createHelper:function(a){return function(b,c){return a.create(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return r.HMAC.create(a,c).finalize(b)}}});var r=f.algo={};return f}(Math);
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/license.txt b/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/license.txt
deleted file mode 100644
index 6f4eaa6..0000000
--- a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/license.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-© 2009–2012 by Jeff Mott. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-    Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
-    Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation or other materials provided with the distribution.
-    Neither the name CryptoJS nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS," AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/md5-min.js b/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/md5-min.js
deleted file mode 100644
index 59ba77c..0000000
--- a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/md5-min.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-CryptoJS v3.0.2
-code.google.com/p/crypto-js
-(c) 2009-2012 by Jeff Mott. All rights reserved.
-code.google.com/p/crypto-js/wiki/License
-*/
-(function(q){function k(b,c,a,f,d,e,g){b=b+(c&a|~c&f)+d+g;return(b<<e|b>>>32-e)+c}function l(b,c,a,f,d,e,g){b=b+(c&f|a&~f)+d+g;return(b<<e|b>>>32-e)+c}function m(b,c,a,f,d,e,g){b=b+(c^a^f)+d+g;return(b<<e|b>>>32-e)+c}function n(b,c,a,f,d,e,g){b=b+(a^(c|~f))+d+g;return(b<<e|b>>>32-e)+c}var o=CryptoJS,j=o.lib,r=j.WordArray,j=j.Hasher,p=o.algo,i=[];(function(){for(var b=0;64>b;b++)i[b]=4294967296*q.abs(q.sin(b+1))|0})();p=p.MD5=j.extend({_doReset:function(){this._hash=r.create([1732584193,4023233417,
-2562383102,271733878])},_doProcessBlock:function(b,c){for(var a=0;16>a;a++){var f=c+a,d=b[f];b[f]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360}for(var f=this._hash.words,d=f[0],e=f[1],g=f[2],h=f[3],a=0;64>a;a+=4)16>a?(d=k(d,e,g,h,b[c+a],7,i[a]),h=k(h,d,e,g,b[c+a+1],12,i[a+1]),g=k(g,h,d,e,b[c+a+2],17,i[a+2]),e=k(e,g,h,d,b[c+a+3],22,i[a+3])):32>a?(d=l(d,e,g,h,b[c+(a+1)%16],5,i[a]),h=l(h,d,e,g,b[c+(a+6)%16],9,i[a+1]),g=l(g,h,d,e,b[c+(a+11)%16],14,i[a+2]),e=l(e,g,h,d,b[c+a%16],20,i[a+3])):48>a?(d=
-m(d,e,g,h,b[c+(3*a+5)%16],4,i[a]),h=m(h,d,e,g,b[c+(3*a+8)%16],11,i[a+1]),g=m(g,h,d,e,b[c+(3*a+11)%16],16,i[a+2]),e=m(e,g,h,d,b[c+(3*a+14)%16],23,i[a+3])):(d=n(d,e,g,h,b[c+3*a%16],6,i[a]),h=n(h,d,e,g,b[c+(3*a+7)%16],10,i[a+1]),g=n(g,h,d,e,b[c+(3*a+14)%16],15,i[a+2]),e=n(e,g,h,d,b[c+(3*a+5)%16],21,i[a+3]));f[0]=f[0]+d|0;f[1]=f[1]+e|0;f[2]=f[2]+g|0;f[3]=f[3]+h|0},_doFinalize:function(){var b=this._data,c=b.words,a=8*this._nDataBytes,f=8*b.sigBytes;c[f>>>5]|=128<<24-f%32;c[(f+64>>>9<<4)+14]=(a<<8|a>>>
-24)&16711935|(a<<24|a>>>8)&4278255360;b.sigBytes=4*(c.length+1);this._process();b=this._hash.words;for(c=0;4>c;c++)a=b[c],b[c]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360}});o.MD5=j._createHelper(p);o.HmacMD5=j._createHmacHelper(p)})(Math);
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha1-min.js b/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha1-min.js
deleted file mode 100644
index 21ac562..0000000
--- a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha1-min.js
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
-CryptoJS v3.0.2
-code.google.com/p/crypto-js
-(c) 2009-2012 by Jeff Mott. All rights reserved.
-code.google.com/p/crypto-js/wiki/License
-*/
-(function(){var d=CryptoJS,c=d.lib,l=c.WordArray,c=c.Hasher,j=[],k=d.algo.SHA1=c.extend({_doReset:function(){this._hash=l.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(c,m){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],i=a[3],d=a[4],b=0;80>b;b++){if(16>b)j[b]=c[m+b]|0;else{var g=j[b-3]^j[b-8]^j[b-14]^j[b-16];j[b]=g<<1|g>>>31}g=(e<<5|e>>>27)+d+j[b];g=20>b?g+((f&h|~f&i)+1518500249):40>b?g+((f^h^i)+1859775393):60>b?g+((f&h|f&i|h&i)-1894007588):g+((f^h^i)-
-899497514);d=i;i=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+i|0;a[4]=a[4]+d|0},_doFinalize:function(){var d=this._data,c=d.words,a=8*this._nDataBytes,e=8*d.sigBytes;c[e>>>5]|=128<<24-e%32;c[(e+64>>>9<<4)+15]=a;d.sigBytes=4*c.length;this._process()}});d.SHA1=c._createHelper(k);d.HmacSHA1=c._createHmacHelper(k)})();
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha256-min.js b/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha256-min.js
deleted file mode 100644
index fd9dc42..0000000
--- a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha256-min.js
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
-CryptoJS v3.0.2
-code.google.com/p/crypto-js
-(c) 2009-2012 by Jeff Mott. All rights reserved.
-code.google.com/p/crypto-js/wiki/License
-*/
-(function(k){var h=CryptoJS,i=h.lib,r=i.WordArray,i=i.Hasher,c=h.algo,p=[],q=[];(function(){function g(a){for(var b=k.sqrt(a),d=2;d<=b;d++)if(!(a%d))return!1;return!0}function d(a){return 4294967296*(a-(a|0))|0}for(var a=2,b=0;64>b;)g(a)&&(8>b&&(p[b]=d(k.pow(a,0.5))),q[b]=d(k.pow(a,1/3)),b++),a++})();var g=[],c=c.SHA256=i.extend({_doReset:function(){this._hash=r.create(p.slice(0))},_doProcessBlock:function(i,d){for(var a=this._hash.words,b=a[0],m=a[1],n=a[2],h=a[3],f=a[4],c=a[5],o=a[6],k=a[7],e=0;64>
-e;e++){if(16>e)g[e]=i[d+e]|0;else{var j=g[e-15],l=g[e-2];g[e]=((j<<25|j>>>7)^(j<<14|j>>>18)^j>>>3)+g[e-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+g[e-16]}j=k+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&c^~f&o)+q[e]+g[e];l=((b<<30|b>>>2)^(b<<19|b>>>13)^(b<<10|b>>>22))+(b&m^b&n^m&n);k=o;o=c;c=f;f=h+j|0;h=n;n=m;m=b;b=j+l|0}a[0]=a[0]+b|0;a[1]=a[1]+m|0;a[2]=a[2]+n|0;a[3]=a[3]+h|0;a[4]=a[4]+f|0;a[5]=a[5]+c|0;a[6]=a[6]+o|0;a[7]=a[7]+k|0},_doFinalize:function(){var c=this._data,d=c.words,a=8*this._nDataBytes,
-b=8*c.sigBytes;d[b>>>5]|=128<<24-b%32;d[(b+64>>>9<<4)+15]=a;c.sigBytes=4*d.length;this._process()}});h.SHA256=i._createHelper(c);h.HmacSHA256=i._createHmacHelper(c)})(Math);
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha512-min.js b/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha512-min.js
deleted file mode 100644
index dcb8ad8..0000000
--- a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/sha512-min.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
-CryptoJS v3.0.2
-code.google.com/p/crypto-js
-(c) 2009-2012 by Jeff Mott. All rights reserved.
-code.google.com/p/crypto-js/wiki/License
-*/
-(function(){function a(){return v.create.apply(v,arguments)}var d=CryptoJS,r=d.lib.Hasher,e=d.x64,v=e.Word,S=e.WordArray,e=d.algo,da=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),
-a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,
-2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),
-a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,
-3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],s=[];(function(){for(var T=0;80>T;T++)s[T]=a()})();e=e.SHA512=r.extend({_doReset:function(){this._hash=S.create([a(1779033703,4089235720),a(3144134277,2227873595),a(1013904242,4271175723),a(2773480762,1595750129),a(1359893119,2917565137),a(2600822924,725511199),a(528734635,4215389547),a(1541459225,327033209)])},_doProcessBlock:function(a,e){for(var f=this._hash.words,C=f[0],d=f[1],D=f[2],E=f[3],F=f[4],G=f[5],H=
-f[6],f=f[7],r=C.high,I=C.low,v=d.high,J=d.low,X=D.high,K=D.low,Y=E.high,L=E.low,Z=F.high,M=F.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=f.high,P=f.low,j=r,g=I,w=v,t=J,x=X,u=K,U=Y,y=L,k=Z,h=M,Q=$,z=N,R=aa,A=O,V=ba,B=P,l=0;80>l;l++){var o=s[l];if(16>l)var i=o.high=a[e+2*l]|0,b=o.low=a[e+2*l+1]|0;else{var i=s[l-15],b=i.high,m=i.low,i=(m<<31|b>>>1)^(m<<24|b>>>8)^b>>>7,m=(b<<31|m>>>1)^(b<<24|m>>>8)^(b<<25|m>>>7),q=s[l-2],b=q.high,c=q.low,q=(c<<13|b>>>19)^(b<<3|c>>>29)^b>>>6,c=(b<<13|c>>>19)^(c<<3|b>>>29)^
-(b<<26|c>>>6),b=s[l-7],W=b.high,p=s[l-16],n=p.high,p=p.low,b=m+b.low,i=i+W+(b>>>0<m>>>0?1:0),b=b+c,i=i+q+(b>>>0<c>>>0?1:0),b=b+p,i=i+n+(b>>>0<p>>>0?1:0);o.high=i;o.low=b}var W=k&Q^~k&R,p=h&z^~h&A,o=j&w^j&x^w&x,S=g&t^g&u^t&u,m=(g<<4|j>>>28)^(j<<30|g>>>2)^(j<<25|g>>>7),q=(j<<4|g>>>28)^(g<<30|j>>>2)^(g<<25|j>>>7),c=da[l],ea=c.high,ca=c.low,c=B+((k<<18|h>>>14)^(k<<14|h>>>18)^(h<<23|k>>>9)),n=V+((h<<18|k>>>14)^(h<<14|k>>>18)^(k<<23|h>>>9))+(c>>>0<B>>>0?1:0),c=c+p,n=n+W+(c>>>0<p>>>0?1:0),c=c+ca,n=n+ea+
-(c>>>0<ca>>>0?1:0),c=c+b,n=n+i+(c>>>0<b>>>0?1:0),b=q+S,o=m+o+(b>>>0<q>>>0?1:0),V=R,B=A,R=Q,A=z,Q=k,z=h,h=y+c|0,k=U+n+(h>>>0<y>>>0?1:0)|0,U=x,y=u,x=w,u=t,w=j,t=g,g=c+b|0,j=n+o+(g>>>0<c>>>0?1:0)|0}I=C.low=I+g|0;C.high=r+j+(I>>>0<g>>>0?1:0)|0;J=d.low=J+t|0;d.high=v+w+(J>>>0<t>>>0?1:0)|0;K=D.low=K+u|0;D.high=X+x+(K>>>0<u>>>0?1:0)|0;L=E.low=L+y|0;E.high=Y+U+(L>>>0<y>>>0?1:0)|0;M=F.low=M+h|0;F.high=Z+k+(M>>>0<h>>>0?1:0)|0;N=G.low=N+z|0;G.high=$+Q+(N>>>0<z>>>0?1:0)|0;O=H.low=O+A|0;H.high=aa+R+(O>>>0<A>>>
-0?1:0)|0;P=f.low=P+B|0;f.high=ba+V+(P>>>0<B>>>0?1:0)|0},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();this._hash=this._hash.toX32()},blockSize:32});d.SHA512=r._createHelper(e);d.HmacSHA512=r._createHmacHelper(e)})();
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/x64-core-min.js b/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/x64-core-min.js
deleted file mode 100644
index d754bfe..0000000
--- a/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/x64-core-min.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
-CryptoJS v3.0.2
-code.google.com/p/crypto-js
-(c) 2009-2012 by Jeff Mott. All rights reserved.
-code.google.com/p/crypto-js/wiki/License
-*/
-(function(g){var a=CryptoJS,f=a.lib,e=f.Base,h=f.WordArray,a=a.x64={};a.Word=e.extend({init:function(b,c){this.high=b;this.low=c}});a.WordArray=e.extend({init:function(b,c){b=this.words=b||[];this.sigBytes=c!=g?c:8*b.length},toX32:function(){for(var b=this.words,c=b.length,a=[],d=0;d<c;d++){var e=b[d];a.push(e.high);a.push(e.low)}return h.create(a,this.sigBytes)},clone:function(){for(var b=e.clone.call(this),c=b.words=this.words.slice(0),a=c.length,d=0;d<a;d++)c[d]=c[d].clone();return b}})})();
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/json2.min.js b/webconsole-plugins/useradmin/src/main/resources/res/json2.min.js
deleted file mode 100644
index 2360c34..0000000
--- a/webconsole-plugins/useradmin/src/main/resources/res/json2.min.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/* http://www.JSON.org/json2.js */

-if(!this.JSON){this.JSON={};}

-(function(){function f(n){return n<10?'0'+n:n;}

-if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+

-f(this.getUTCMonth()+1)+'-'+

-f(this.getUTCDate())+'T'+

-f(this.getUTCHours())+':'+

-f(this.getUTCMinutes())+':'+

-f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}

-var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}

-function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}

-if(typeof rep==='function'){value=rep.call(holder,key,value);}

-switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}

-gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}

-v=partial.length===0?'[]':gap?'[\n'+gap+

-partial.join(',\n'+gap)+'\n'+

-mind+']':'['+partial.join(',')+']';gap=mind;return v;}

-if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}

-v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+

-mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}

-if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}

-rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}

-return str('',{'':value});};}

-if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}

-return reviver.call(holder,key,value);}

-text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+

-('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}

-if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}

-throw new SyntaxError('JSON.parse');};}}());
\ No newline at end of file
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/plugin.css b/webconsole-plugins/useradmin/src/main/resources/res/plugin.css
index 9ec5d94..2ab8f27 100644
--- a/webconsole-plugins/useradmin/src/main/resources/res/plugin.css
+++ b/webconsole-plugins/useradmin/src/main/resources/res/plugin.css
@@ -1,4 +1,19 @@
-/* your css definitions here */

+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You under the Apache License, Version 2.0

+ * (the "License"); you may not use this file except in compliance with

+ * the License.  You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

 #userTree { width: 20% }

 #userTree li a { padding-left: 12px ! important}

 .header ul { float: right }

diff --git a/webconsole-plugins/useradmin/src/main/resources/res/plugin.html b/webconsole-plugins/useradmin/src/main/resources/res/plugin.html
index f0563a6..eee9100 100644
--- a/webconsole-plugins/useradmin/src/main/resources/res/plugin.html
+++ b/webconsole-plugins/useradmin/src/main/resources/res/plugin.html
@@ -1,11 +1,4 @@
 <script type="text/javascript" src="${pluginRoot}/res/jsTree.v.0.9.9a/jquery.tree.min.js"></script>
-<script type="text/javascript" src="${pluginRoot}/res/crypto-js-3.0.2/core-min.js"></script>
-<script type="text/javascript" src="${pluginRoot}/res/crypto-js-3.0.2/x64-core-min.js"></script>
-<script type="text/javascript" src="${pluginRoot}/res/crypto-js-3.0.2/md5-min.js"></script>
-<script type="text/javascript" src="${pluginRoot}/res/crypto-js-3.0.2/sha1-min.js"></script>
-<script type="text/javascript" src="${pluginRoot}/res/crypto-js-3.0.2/sha256-min.js"></script>
-<script type="text/javascript" src="${pluginRoot}/res/crypto-js-3.0.2/sha512-min.js"></script>
-<script type="text/javascript" src="${pluginRoot}/res/json2.min.js"></script>
 <script type="text/javascript" src="${pluginRoot}/res/plugin.js"></script>
 <script type="text/javascript">
 // <![CDATA[
@@ -14,7 +7,8 @@
 	close : '${abort}',
 	add   : '${save}',
 	root  : '${role.tree.root}',
-	status: '${role.statline}'
+	status: '${role.statline}',
+	paswd : '${type.password}'
 }
 // ]]>
 </script>
@@ -76,13 +70,15 @@
 						<td><input class="k" /></td>
 						<td><input class="v" /></td>
 						<td>
-							<select class="dynhover">
+							<select class="dynhover propertyType">
 								<option value="string">${type.string}</option>
 								<option value="byte[]">${type.bytes}</option>
+								<!--
 								<option value="password-MD5">${type.password-MD5}</option>
 								<option value="password-SHA1">${type.password-SHA1}</option>
 								<option value="password-SHA256">${type.password-SHA256}</option>
 								<option value="password-SHA512">${type.password-SHA512}</option>
+								-->
 							</select>
 						</td>
 						<td class="actions">
diff --git a/webconsole-plugins/useradmin/src/main/resources/res/plugin.js b/webconsole-plugins/useradmin/src/main/resources/res/plugin.js
index d474482..214b5da 100644
--- a/webconsole-plugins/useradmin/src/main/resources/res/plugin.js
+++ b/webconsole-plugins/useradmin/src/main/resources/res/plugin.js
@@ -1,4 +1,21 @@
-/* your java script code here */

+/*

+ * Licensed to the Apache Software Foundation (ASF) under one or more

+ * contributor license agreements.  See the NOTICE file distributed with

+ * this work for additional information regarding copyright ownership.

+ * The ASF licenses this file to You under the Apache License, Version 2.0

+ * (the "License"); you may not use this file except in compliance with

+ * the License.  You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+// fix for jQuery tree to work with this version of jQuery

+jQuery.curCSS = jQuery.css;

 

 var userTree = false;

 var selectedRole = false;

@@ -94,6 +111,21 @@
 }

 

 $(function() {

+	// read the available digest algorithms

+	$.ajax({

+		type    : "POST",

+		url     : pluginRoot,

+		async   : false,

+		data    : {'action': 'getDigestAlgorithms' },

+		dataType: 'json',

+		success : function(data) {

+			var _select  = $('select.propertyType');

+			$.each(data, function(id, alg) {

+				_select.append('<option value="password-{0}">{1} {2}</option>'.msgFormat(alg, i18n.paswd, alg));

+			});

+		}

+	});

+

 	userTree = $('#userTree');

 	roleDetails = $('#roleDetails');

 	roleDetailsTable = roleDetails.find('table');

@@ -163,6 +195,24 @@
 	}).click();

 });

 

+function digest(val, alg) {

+	var _ret = false;

+	$.ajax({

+		type    : "POST",

+		url     : pluginRoot,

+		async   : false,

+		data    : {

+			'action': 'digest', 

+			'data' : val, 

+			'algorithm' : alg

+		},

+		dataType: 'json',

+		success : function(data) {

+			_ret = data['encoded'];

+		}

+	});

+	return _ret;

+}

 function newProp() {

 	var tr = roleDetailsTemplate.clone()

 		.find('li').click( function() {

@@ -207,8 +257,10 @@
 			var t = _.find('select').val();

 			

 			if (t.indexOf('password-') == 0) {

-				var hash =  CryptoJS[t.substring(9)](v).toString(CryptoJS.enc.Hex);

-				v = hashToArray(hash);

+				var hash = digest(v, t.substring(9));

+				//CryptoJS[t.substring(9)](v).toString(CryptoJS.enc.Hex);

+				//v = hashToArray(hash);

+				v = hash;

 			} else if (t == 'byte[]') {

 				v = strToArray(v);

 			}