You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2005/12/19 22:11:03 UTC

svn commit: r357800 - /xml/security/branches/jsr105_0_16/src/javax/xml/crypto/dsig/TransformService.java

Author: mullan
Date: Mon Dec 19 13:10:57 2005
New Revision: 357800

URL: http://svn.apache.org/viewcvs?rev=357800&view=rev
Log:
Don't use reflection to find and load provider class.

Modified:
    xml/security/branches/jsr105_0_16/src/javax/xml/crypto/dsig/TransformService.java

Modified: xml/security/branches/jsr105_0_16/src/javax/xml/crypto/dsig/TransformService.java
URL: http://svn.apache.org/viewcvs/xml/security/branches/jsr105_0_16/src/javax/xml/crypto/dsig/TransformService.java?rev=357800&r1=357799&r2=357800&view=diff
==============================================================================
--- xml/security/branches/jsr105_0_16/src/javax/xml/crypto/dsig/TransformService.java (original)
+++ xml/security/branches/jsr105_0_16/src/javax/xml/crypto/dsig/TransformService.java Mon Dec 19 13:10:57 2005
@@ -22,13 +22,9 @@
  */
 package javax.xml.crypto.dsig;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.security.AccessController;
 import java.security.InvalidAlgorithmParameterException;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
-import java.security.PrivilegedAction;
 import java.security.Provider;
 import java.security.Security;
 import java.util.*;
@@ -108,28 +104,6 @@
     private String mechanism;
     private Provider provider;
 
-    private static Class cl;
-    private static final Class[] getImplParams =
-        { String.class, Map.Entry.class, String.class, Provider.class };
-    private static Method getImplMethod;
-    static {
-        try {
-            cl = Class.forName("javax.xml.crypto.dsig.XMLDSigSecurity");
-        } catch (ClassNotFoundException cnfe) { }
-        getImplMethod = (Method)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    Method m = null;
-                    try {
-                        m = cl.getDeclaredMethod("getImpl", getImplParams);
-                        if (m != null)
-                            m.setAccessible(true);
-                    } catch (NoSuchMethodException nsme) { }
-                    return m;
-                }
-            });
-    }
-
     /**
      * Default constructor, for invocation by subclasses.
      */
@@ -243,23 +217,9 @@
 	String mechanismType, Provider provider) 
 	throws NoSuchAlgorithmException {
 
-        if (getImplMethod == null) {
-            throw new NoSuchAlgorithmException
-                ("Cannot find + algorithm:" + algorithm);
-        }
-
-        Object[] objs = null;
-        try {
-            objs = (Object[]) getImplMethod.invoke(null, new Object[]
-                {algorithm, new MechanismMapEntry(algorithm, mechanismType), 
-		 "TransformService", provider});
-        } catch (IllegalAccessException iae) {
-            throw (NoSuchAlgorithmException) new NoSuchAlgorithmException
-                ("Cannot find algorithm:" + algorithm).initCause(iae);
-        } catch (InvocationTargetException ite) {
-            throw (NoSuchAlgorithmException) new NoSuchAlgorithmException
-                ("Cannot find algorithm:" + algorithm).initCause(ite);
-        }
+	Object[] objs = (Object[]) XMLDSigSecurity.getImpl
+	    (algorithm, new MechanismMapEntry(algorithm, mechanismType),
+	    "TransformService", provider);
 
         TransformService spi = (TransformService) objs[0];
         spi.mechanism = mechanismType;
@@ -271,9 +231,11 @@
     private static class MechanismMapEntry implements Map.Entry {
 	private final String mechanism;
 	private final String algorithm;
+	private final String key;
 	MechanismMapEntry(String algorithm, String mechanism) {
 	    this.algorithm = algorithm;
 	    this.mechanism = mechanism;
+	    this.key = "TransformService." + algorithm + " MechanismType";
 	}
 	public boolean equals(Object o) {
 	    if (!(o instanceof Map.Entry)) {
@@ -286,7 +248,7 @@
       		    e.getValue()==null : getValue().equals(e.getValue()));
 	}
 	public Object getKey() {
-	    return "TransformService." + algorithm + " MechanismType";
+	    return key;
 	}
 	public Object getValue() {
 	    return mechanism;