harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r566479 - /harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java
Date Thu, 16 Aug 2007 04:14:03 GMT
Author: leoli
Date: Wed Aug 15 21:14:02 2007
New Revision: 566479

URL: http://svn.apache.org/viewvc?view=rev&rev=566479
Log:
Add Java 6 new feature in auth module (javax.security.auth.login.Configuration.getInstance
and javax.security.auth.login.ConfigurationSpi) and Related modification in security module(java.security.Provider.Service.newInstance()
to support javax.security.auth.login.Configuration).

Modified:
    harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java?view=diff&rev=566479&r1=566478&r2=566479
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/java/security/Provider.java
Wed Aug 15 21:14:02 2007
@@ -836,34 +836,39 @@
                     throw result;
                 }
             }
-            if (constructorParameter == null) {
-                try {
-                    return implementation.newInstance();
-                } catch (Exception e) {
-                    throw new NoSuchAlgorithmException(Messages.getString("security.199",
//$NON-NLS-1$
-                            type, algorithm), e);
-                }
-            } else {
-                if (!supportsParameter(constructorParameter)) {
-                    throw new InvalidParameterException(
-                            Messages.getString("security.12", type)); //$NON-NLS-1$
+            
+            Class[] parameterTypes = new Class[1];
+
+            if (constructorParameter != null
+                    && !supportsParameter(constructorParameter)) {
+                throw new InvalidParameterException(Messages.getString(
+                        "security.12", type)); //$NON-NLS-1$
+            }
+            Object[] initargs = { constructorParameter };
+
+            try {
+                if (type.equalsIgnoreCase("CertStore")) { //$NON-NLS-1$
+                    parameterTypes[0] = Class
+                            .forName("java.security.cert.CertStoreParameters"); //$NON-NLS-1$
+                } else if (type.equalsIgnoreCase("Configuration")) {
+                    parameterTypes[0] = Class
+                            .forName("javax.security.auth.login.Configuration$Parameters");
                 }
 
-                Class[] parameterTypes = new Class[1];
-                Object[] initargs = { constructorParameter };
-                try {
-                    if (type.equalsIgnoreCase("CertStore")) { //$NON-NLS-1$
-                        parameterTypes[0] = Class
-                                .forName("java.security.cert.CertStoreParameters"); //$NON-NLS-1$
+                if (parameterTypes[0] == null) {
+                    if (constructorParameter == null) {
+                        return implementation.newInstance();
                     } else {
                         parameterTypes[0] = constructorParameter.getClass();
                     }
-                    return implementation.getConstructor(parameterTypes)
-                            .newInstance(initargs);
-                } catch (Exception e) {
-                    throw new NoSuchAlgorithmException(Messages.getString("security.199",
//$NON-NLS-1$
-                            type, algorithm), e);
                 }
+                return implementation.getConstructor(parameterTypes)
+                        .newInstance(initargs);
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new NoSuchAlgorithmException(Messages.getString(
+                        "security.199", //$NON-NLS-1$
+                        type, algorithm), e);
             }
         }
 



Mime
View raw message