[jboss-cvs] JBossAS SVN: r65603 - trunk/security/src/main/org/jboss/security/plugins.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 25 13:58:08 EDT 2007


Author: anil.saldhana at jboss.com
Date: 2007-09-25 13:58:08 -0400 (Tue, 25 Sep 2007)
New Revision: 65603

Added:
   trunk/security/src/main/org/jboss/security/plugins/JCASecurityInfo.java
Modified:
   trunk/security/src/main/org/jboss/security/plugins/JaasSecurityManagerService.java
   trunk/security/src/main/org/jboss/security/plugins/JaasSecurityManagerServiceMBean.java
Log:
JBAS-3400: Display JCA information

Added: trunk/security/src/main/org/jboss/security/plugins/JCASecurityInfo.java
===================================================================
--- trunk/security/src/main/org/jboss/security/plugins/JCASecurityInfo.java	                        (rev 0)
+++ trunk/security/src/main/org/jboss/security/plugins/JCASecurityInfo.java	2007-09-25 17:58:08 UTC (rev 65603)
@@ -0,0 +1,81 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2007, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.security.plugins;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Set;
+
+//$Id$
+
+/**
+ *  Utility class that provides the Java Cryptography Architecture(JCA)
+ *  information about the JVM
+ *  @author Anil.Saldhana at redhat.com
+ *  @since  Mar 29, 2007 
+ *  @version $Revision$
+ */
+public class JCASecurityInfo
+{ 
+   private String DELIMITER = ";";
+   
+   public JCASecurityInfo()
+   { 
+   }
+   /**
+    * Get information on all the JCA Providers
+    * @return
+    */
+   public String getJCAProviderInfo()
+   { 
+      StringBuilder sb = new StringBuilder();
+      sb.append("Providers=");
+      Provider[] providers = Security.getProviders();
+      for(Provider p:providers)
+      {
+         sb.append(p.toString()).append(DELIMITER);
+      }
+      return sb.toString();
+   }
+   
+   /**
+    * Get the set of algorithms for a particular service
+    * (Cipher,Signature,KeyFactory,SecretKeyFactory,AlgorithmParameters 
+    *  MessageDigest,Mac)
+    * @param serviceName
+    * @return
+    */
+   public String getJCAAlgorithms(String serviceName)
+   {
+      StringBuilder sb = new StringBuilder();
+      Set<String> md2 = Security.getAlgorithms(serviceName);
+      sb.append(serviceName).append(":algorithms=").append(md2.size()).append("["); 
+      
+      for(String algo:md2)
+      {
+         sb.append(algo).append(DELIMITER);
+      }
+      sb.append("]");
+      
+      return sb.toString(); 
+   } 
+}

Modified: trunk/security/src/main/org/jboss/security/plugins/JaasSecurityManagerService.java
===================================================================
--- trunk/security/src/main/org/jboss/security/plugins/JaasSecurityManagerService.java	2007-09-25 17:42:44 UTC (rev 65602)
+++ trunk/security/src/main/org/jboss/security/plugins/JaasSecurityManagerService.java	2007-09-25 17:58:08 UTC (rev 65603)
@@ -687,7 +687,28 @@
    {
       defaultUnauthenticatedPrincipal = principal;
    }
+   
+   /**
+    * @see JaasSecurityManagerServiceMBean#getJCAInformation()
+    */
+   public String displayJCAInformation()
+   {
+      String[] sarr = new String[]{"Cipher","Signature","KeyFactory",
+                             "SecretKeyFactory","AlgorithmParameters",
+                             "MessageDigest","Mac"}; 
+      StringBuilder sb = new StringBuilder();
+      JCASecurityInfo jsi = new JCASecurityInfo();
+      sb.append("JCA Providers=").append(jsi.getJCAProviderInfo());
+      sb.append("JCA Service/Algorithms=");
+      for(String serviceName:sarr)
+      {
+         sb.append(jsi.getJCAAlgorithms(serviceName));
+      }
+      return sb.toString();
+      
+   }
 
+
    // java:/jaas context ObjectFactory implementation
 
    public static class SecurityDomainObjectFactory

Modified: trunk/security/src/main/org/jboss/security/plugins/JaasSecurityManagerServiceMBean.java
===================================================================
--- trunk/security/src/main/org/jboss/security/plugins/JaasSecurityManagerServiceMBean.java	2007-09-25 17:42:44 UTC (rev 65602)
+++ trunk/security/src/main/org/jboss/security/plugins/JaasSecurityManagerServiceMBean.java	2007-09-25 17:58:08 UTC (rev 65603)
@@ -192,4 +192,10 @@
     * @param principal The principal name
     */
    void setDefaultUnauthenticatedPrincipal(String principal);
+ 
+   /**
+    * Get information about the JCA Providers
+    * @return
+    */
+   String displayJCAInformation();
 }




More information about the jboss-cvs-commits mailing list