Author: vvalchev
Date: Tue Nov 18 08:37:37 2014
New Revision: 1640280

URL: http://svn.apache.org/r1640280
Log:
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

Removed:
    
felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/crypto-js-3.0.2/
    felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/json2.min.js
Modified:
    felix/trunk/webconsole-plugins/useradmin/pom.xml
    
felix/trunk/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES
    
felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java
    
felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java
    
felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties
    
felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
    felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.css
    felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.html
    felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.js

Modified: felix/trunk/webconsole-plugins/useradmin/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/pom.xml?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/useradmin/pom.xml (original)
+++ felix/trunk/webconsole-plugins/useradmin/pom.xml Tue Nov 18 08:37:37 2014
@@ -1,109 +1,130 @@
-<!-- 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. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>felix-parent</artifactId>
-        <version>2.1</version>
-        <relativePath>../../../pom/pom.xml</relativePath>
-    </parent>
-
-    <artifactId>org.apache.felix.webconsole.plugins.useradmin</artifactId>
-    <packaging>bundle</packaging>
-    <version>0.0.1-SNAPSHOT</version>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.apache.felix</groupId>
+               <artifactId>felix-parent</artifactId>
+               <version>2.1</version>
+               <relativePath>../../../pom/pom.xml</relativePath>
+       </parent>
+
+       <artifactId>org.apache.felix.webconsole.plugins.useradmin</artifactId>
+       <packaging>bundle</packaging>
+       <version>0.0.1-SNAPSHOT</version>
 
-    <name>Apache Felix Web Console User Admin Plugin</name>
-    <description>
+       <name>Apache Felix Web Console User Admin Plugin</name>
+       <description>
         This is a plugin for the Apache Felix OSGi web console for 
displaying/managing OSGi Users and Groups.
     </description>
 
-    <scm>
-        
<connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/useradmin</connection>
-        
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/useradmin</developerConnection>
-        
<url>http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin</url>
-    </scm>
-
-    <build>
-        <plugins>
-            <!-- translate UTF-8 encoded properties files to ISO-8859-1 -->
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>native2ascii-maven-plugin</artifactId>
-                <version>1.0-beta-1</version>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>native2ascii</goal>
-                        </goals>
-                        <configuration>
-                            <encoding>UTF-8</encoding>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <version>2.3.4</version>
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>
-                            ${project.artifactId}
-                        </Bundle-SymbolicName>
-                        <Bundle-Activator>
-                            
org.apache.felix.webconsole.plugins.useradmin.internal.Activator
-                        </Bundle-Activator>
-                        <Include-Resource>
-                            {maven-resources},OSGI-INF=target/classes/OSGI-INF
-                        </Include-Resource>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <dependencies>
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.4</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-            <version>4.0.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-            <version>4.1.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.webconsole</artifactId>
-            <version>4.0.1-SNAPSHOT</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-            <version>20070829</version>
-            <scope>provided</scope>
-        </dependency>
-    </dependencies>
+       <scm>
+               
<connection>scm:svn:http://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/useradmin</connection>
+               
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/trunk/webconsole-plugins/useradmin</developerConnection>
+               
<url>http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin</url>
+       </scm>
+
+       <build>
+               <plugins>
+                       <!-- translate UTF-8 encoded properties files to 
ISO-8859-1 -->
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               
<artifactId>native2ascii-maven-plugin</artifactId>
+                               <version>1.0-beta-1</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       
<goal>native2ascii</goal>
+                                               </goals>
+                                               <configuration>
+                                                       
<encoding>UTF-8</encoding>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>2.3.4</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <instructions>
+                                               <Bundle-SymbolicName>
+                                                       ${project.artifactId}
+                                               </Bundle-SymbolicName>
+                                               <Bundle-Activator>
+                                                       
org.apache.felix.webconsole.plugins.useradmin.internal.Activator
+                                               </Bundle-Activator>
+                                               <Include-Resource>
+                                                       
{maven-resources},OSGI-INF=target/classes/OSGI-INF
+                                               </Include-Resource>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+
+                       <plugin>
+                               <groupId>org.apache.rat</groupId>
+                               <artifactId>apache-rat-plugin</artifactId>
+                               <configuration>
+                                       <excludes>
+                                               
<exclude>src/main/appended-resources/**</exclude>
+                                               
<exclude>src/main/resources/res/jsTree.v.0.9.9a/**</exclude>
+                                               
<exclude>src/main/resources/res/*.html</exclude>
+                                       </excludes>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <dependencies>
+               <dependency>
+                       <groupId>javax.servlet</groupId>
+                       <artifactId>servlet-api</artifactId>
+                       <version>2.4</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.osgi</groupId>
+                       <artifactId>org.osgi.core</artifactId>
+                       <version>4.0.0</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.osgi</groupId>
+                       <artifactId>org.osgi.compendium</artifactId>
+                       <version>4.1.0</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.felix</groupId>
+                       <artifactId>org.apache.felix.webconsole</artifactId>
+                       <version>4.0.1-SNAPSHOT</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.json</groupId>
+                       <artifactId>json</artifactId>
+                       <version>20070829</version>
+                       <scope>provided</scope>
+               </dependency>
+       </dependencies>
 </project>

Modified: 
felix/trunk/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- 
felix/trunk/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES
 (original)
+++ 
felix/trunk/webconsole-plugins/useradmin/src/main/appended-resources/META-INF/DEPENDENCIES
 Tue Nov 18 08:37:37 2014
@@ -13,17 +13,6 @@ jsTree (http://jstree.com/).
 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

Modified: 
felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- 
felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java
 (original)
+++ 
felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/Activator.java
 Tue Nov 18 08:37:37 2014
@@ -20,7 +20,6 @@ import org.apache.felix.webconsole.Simpl
 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 @@ public class Activator implements Bundle
     private BundleContext context;
 
     private SimpleWebConsolePlugin plugin;
-    private ServiceRegistration printerRegistration;
 
     /**
      * @see 
org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
@@ -92,20 +90,12 @@ public class Activator implements Bundle
     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;
-            }
         }
-
     }
 }

Modified: 
felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- 
felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java
 (original)
+++ 
felix/trunk/webconsole-plugins/useradmin/src/main/java/org/apache/felix/webconsole/plugins/useradmin/internal/WebConsolePlugin.java
 Tue Nov 18 08:37:37 2014
@@ -18,6 +18,9 @@ package org.apache.felix.webconsole.plug
 
 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 @@ class WebConsolePlugin extends SimpleWeb
         TEMPLATE = readTemplateFile("/res/plugin.html"); //$NON-NLS-1$
     }
 
-
     public String getCategory()
     {
         return CATEGORY;
@@ -90,6 +92,7 @@ class WebConsolePlugin extends SimpleWeb
 
         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 @@ class WebConsolePlugin extends SimpleWeb
                 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 @@ class WebConsolePlugin extends SimpleWeb
         }
         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();
+    }
 }

Modified: 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties
 (original)
+++ 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle.properties
 Tue Nov 18 08:37:37 2014
@@ -39,10 +39,7 @@ role.type.1=User
 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/>\

Modified: 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
 (original)
+++ 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/OSGI-INF/l10n/bundle_bg.properties
 Tue Nov 18 08:37:37 2014
@@ -39,10 +39,7 @@ role.type.1=Потреби
 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/>\

Modified: 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.css
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.css?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.css 
(original)
+++ felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.css 
Tue Nov 18 08:37:37 2014
@@ -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 }

Modified: 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.html
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.html?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.html 
(original)
+++ felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.html 
Tue Nov 18 08:37:37 2014
@@ -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 @@ var i18n = {
        close : '${abort}',
        add   : '${save}',
        root  : '${role.tree.root}',
-       status: '${role.statline}'
+       status: '${role.statline}',
+       paswd : '${type.password}'
 }
 // ]]>
 </script>
@@ -76,13 +70,15 @@ var i18n = {
                                                <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">

Modified: 
felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.js
URL: 
http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.js?rev=1640280&r1=1640279&r2=1640280&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.js 
(original)
+++ felix/trunk/webconsole-plugins/useradmin/src/main/resources/res/plugin.js 
Tue Nov 18 08:37:37 2014
@@ -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 @@ var treeSettings = {
 }
 
 $(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 @@ $(function() {
        }).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 @@ function doSaveRole() {
                        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);
                        }


Reply via email to