jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
changeset 18240 cda839ac048f
parent 13791 059978b7e438
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java	Tue Apr 09 12:05:27 2013 +0400
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java	Mon Apr 22 11:23:33 2013 +0100
@@ -2,38 +2,43 @@
  * reserved comment block
  * DO NOT REMOVE OR ALTER!
  */
-/*
- * Copyright  1999-2004 The Apache Software Foundation.
- *
- *  Licensed 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
+/**
+ * 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
+ * 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.
- *
+ * 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.
  */
 package com.sun.org.apache.xml.internal.security;
 
 import java.io.InputStream;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
 import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm;
 import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
-import com.sun.org.apache.xml.internal.security.keys.KeyInfo;
 import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolver;
 import com.sun.org.apache.xml.internal.security.transforms.Transform;
+import com.sun.org.apache.xml.internal.security.utils.ElementProxy;
 import com.sun.org.apache.xml.internal.security.utils.I18n;
-//import com.sun.org.apache.xml.internal.security.utils.PRNG;
 import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
 import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver;
 import org.w3c.dom.Attr;
@@ -47,367 +52,317 @@
  * the mapping of Canonicalization and Transform algorithms. Initialization is
  * done by calling {@link Init#init} which should be done in any static block
  * of the files of this library. We ensure that this call is only executed once.
- *
- * @author $Author: mullan $
  */
-public final class Init {
+public class Init {
 
-  /** {@link java.util.logging} logging facility */
-  static java.util.logging.Logger log =
+    /** The namespace for CONF file **/
+    public static final String CONF_NS = "http://www.xmlsecurity.org/NS/#configuration";
+
+    /** {@link org.apache.commons.logging} logging facility */
+    private static java.util.logging.Logger log =
         java.util.logging.Logger.getLogger(Init.class.getName());
 
-   /** Field _initialized */
-   private static boolean _alreadyInitialized = false;
+    /** Field alreadyInitialized */
+    private static boolean alreadyInitialized = false;
 
-   /** The namespace for CONF file **/
-   public static final String CONF_NS="http://www.xmlsecurity.org/NS/#configuration";
+    /**
+     * Method isInitialized
+     * @return true if the library is already initialized.
+     */
+    public static synchronized final boolean isInitialized() {
+        return Init.alreadyInitialized;
+    }
+
+    /**
+     * Method init
+     *
+     */
+    public static synchronized void init() {
+        if (alreadyInitialized) {
+            return;
+        }
 
-   /**
-    * Method isInitialized
-    * @return true if the librairy is already initialized.
-    *
-    */
-   public static final boolean isInitialized() {
-      return Init._alreadyInitialized;
-   }
+        InputStream is =
+            AccessController.doPrivileged(
+                new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
+                        String cfile =
+                            System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
+                        if (cfile == null) {
+                            return null;
+                        }
+                        return getClass().getResourceAsStream(cfile);
+                    }
+                });
+        if (is == null) {
+            dynamicInit();
+        } else {
+            fileInit(is);
+        }
 
-   /**
-    * Method init
-    *
-    */
-   public synchronized static void init() {
+        alreadyInitialized = true;
+    }
+
+    /**
+     * Dynamically initialise the library by registering the default algorithms/implementations
+     */
+    private static void dynamicInit() {
+        //
+        // Load the Resource Bundle - the default is the English resource bundle.
+        // To load another resource bundle, call I18n.init(...) before calling this
+        // method.
+        //
+        I18n.init("en", "US");
 
-      if (_alreadyInitialized) {
-        return;
-      }
-      long XX_configure_i18n_end=0;
-      long XX_configure_reg_c14n_start=0;
-      long XX_configure_reg_c14n_end=0;
-      long XX_configure_reg_jcemapper_end=0;
-      long XX_configure_reg_keyInfo_start=0;
-      long XX_configure_reg_keyResolver_end=0;
-      long XX_configure_reg_prefixes_start=0;
-      long XX_configure_reg_resourceresolver_start=0;
-      long XX_configure_reg_sigalgos_end=0;
-      long XX_configure_reg_transforms_end=0;
-      long XX_configure_reg_keyInfo_end=0;
-      long XX_configure_reg_keyResolver_start=0;
-         _alreadyInitialized = true;
+        if (log.isLoggable(java.util.logging.Level.FINE)) {
+            log.log(java.util.logging.Level.FINE, "Registering default algorithms");
+        }
+        try {
+            //
+            // Bind the default prefixes
+            //
+            ElementProxy.registerDefaultPrefixes();
+
+            //
+            // Set the default Transforms
+            //
+            Transform.registerDefaultAlgorithms();
+
+            //
+            // Set the default signature algorithms
+            //
+            SignatureAlgorithm.registerDefaultAlgorithms();
+
+            //
+            // Set the default JCE algorithms
+            //
+            JCEMapper.registerDefaultAlgorithms();
 
-         try {
-            long XX_init_start = System.currentTimeMillis();
-            long XX_prng_start = System.currentTimeMillis();
+            //
+            // Set the default c14n algorithms
+            //
+            Canonicalizer.registerDefaultAlgorithms();
 
-            //PRNG.init(new java.security.SecureRandom());
+            //
+            // Register the default resolvers
+            //
+            ResourceResolver.registerDefaultResolvers();
 
-            long XX_prng_end = System.currentTimeMillis();
+            //
+            // Register the default key resolvers
+            //
+            KeyResolver.registerDefaultResolvers();
+        } catch (Exception ex) {
+            log.log(java.util.logging.Level.SEVERE, ex.getMessage(), ex);
+            ex.printStackTrace();
+        }
+    }
 
+    /**
+     * Initialise the library from a configuration file
+     */
+    private static void fileInit(InputStream is) {
+        try {
             /* read library configuration file */
-            long XX_parsing_start = System.currentTimeMillis();
             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
 
             dbf.setNamespaceAware(true);
             dbf.setValidating(false);
 
             DocumentBuilder db = dbf.newDocumentBuilder();
-            // We don't allow users to override the Apache XML Security
-            // configuration in the JRE. Users should use the standard security
-            // provider mechanism instead if implementing their own
-            // transform or canonicalization algorithms.
-            // InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml");
-            InputStream is = AccessController.doPrivileged(
-                new PrivilegedAction<InputStream>() {
-                    public InputStream run() {
-//                        String cfile = System.getProperty
-//                            ("com.sun.org.apache.xml.internal.security.resource.config");
-                        return getClass().getResourceAsStream
-//                            (cfile != null ? cfile : "resource/config.xml");
-                            ("resource/config.xml");
-                    }
-                });
-
             Document doc = db.parse(is);
-            long XX_parsing_end = System.currentTimeMillis();
-            long XX_configure_i18n_start = 0;
-
-            {
-                XX_configure_reg_keyInfo_start = System.currentTimeMillis();
-               try {
-                  KeyInfo.init();
-               } catch (Exception e) {
-                  e.printStackTrace();
-
-                  throw e;
-               }
-               XX_configure_reg_keyInfo_end = System.currentTimeMillis();
-            }
-
-                        long XX_configure_reg_transforms_start=0;
-                        long XX_configure_reg_jcemapper_start=0;
-                        long XX_configure_reg_sigalgos_start=0;
-                        long XX_configure_reg_resourceresolver_end=0;
-                        long XX_configure_reg_prefixes_end=0;
-            Node config=doc.getFirstChild();
-            for (;config!=null;config=config.getNextSibling()) {
+            Node config = doc.getFirstChild();
+            for (; config != null; config = config.getNextSibling()) {
                 if ("Configuration".equals(config.getLocalName())) {
-                        break;
+                    break;
                 }
             }
-            for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
-                if (el.getNodeType() != Node.ELEMENT_NODE) {
-                        continue;
+            if (config == null) {
+                log.log(java.util.logging.Level.SEVERE, "Error in reading configuration file - Configuration element not found");
+                return;
+            }
+            for (Node el = config.getFirstChild(); el != null; el = el.getNextSibling()) {
+                if (Node.ELEMENT_NODE != el.getNodeType()) {
+                    continue;
+                }
+                String tag = el.getLocalName();
+                if (tag.equals("ResourceBundles")) {
+                    Element resource = (Element)el;
+                    /* configure internationalization */
+                    Attr langAttr = resource.getAttributeNode("defaultLanguageCode");
+                    Attr countryAttr = resource.getAttributeNode("defaultCountryCode");
+                    String languageCode =
+                        (langAttr == null) ? null : langAttr.getNodeValue();
+                    String countryCode =
+                        (countryAttr == null) ? null : countryAttr.getNodeValue();
+                    I18n.init(languageCode, countryCode);
                 }
-                String tag=el.getLocalName();
-//
-// Commented out: not supported in the JDK. We use the default locale.
-//
-//            if (tag.equals("ResourceBundles")){
-//                XX_configure_i18n_start = System.currentTimeMillis();
-//                Element resource=(Element)el;
-//               /* configure internationalization */
-//               Attr langAttr = resource.getAttributeNode("defaultLanguageCode");
-//               Attr countryAttr = resource.getAttributeNode("defaultCountryCode");
-//               String languageCode = (langAttr == null)
-//                                     ? null
-//                                     : langAttr.getNodeValue();
-//               String countryCode = (countryAttr == null)
-//                                    ? null
-//                                    : countryAttr.getNodeValue();
-//
-//               I18n.init(languageCode, countryCode);
-//               XX_configure_i18n_end = System.currentTimeMillis();
-//            }
+
+                if (tag.equals("CanonicalizationMethods")) {
+                    Element[] list =
+                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "CanonicalizationMethod");
+
+                    for (int i = 0; i < list.length; i++) {
+                        String uri = list[i].getAttributeNS(null, "URI");
+                        String javaClass =
+                            list[i].getAttributeNS(null, "JAVACLASS");
+                        try {
+                            Canonicalizer.register(uri, javaClass);
+                            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                                log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + uri + ", " + javaClass + ")");
+                            }
+                        } catch (ClassNotFoundException e) {
+                            Object exArgs[] = { uri, javaClass };
+                            log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
+                        }
+                    }
+                }
+
+                if (tag.equals("TransformAlgorithms")) {
+                    Element[] tranElem =
+                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "TransformAlgorithm");
 
-            if (tag.equals("CanonicalizationMethods")){
-                XX_configure_reg_c14n_start = System.currentTimeMillis();
-               Canonicalizer.init();
-               Element[] list=XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,"CanonicalizationMethod");
+                    for (int i = 0; i < tranElem.length; i++) {
+                        String uri = tranElem[i].getAttributeNS(null, "URI");
+                        String javaClass =
+                            tranElem[i].getAttributeNS(null, "JAVACLASS");
+                        try {
+                            Transform.register(uri, javaClass);
+                            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                                log.log(java.util.logging.Level.FINE, "Transform.register(" + uri + ", " + javaClass + ")");
+                            }
+                        } catch (ClassNotFoundException e) {
+                            Object exArgs[] = { uri, javaClass };
 
-               for (int i = 0; i < list.length; i++) {
-                  String URI = list[i].getAttributeNS(null,
-                                  "URI");
-                  String JAVACLASS =
-                     list[i].getAttributeNS(null,
-                        "JAVACLASS");
-                  try {
-                      Class.forName(JAVACLASS);
-/*                     Method methods[] = c.getMethods();
+                            log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
+                        } catch (NoClassDefFoundError ex) {
+                            log.log(java.util.logging.Level.WARNING, "Not able to found dependencies for algorithm, I'll keep working.");
+                        }
+                    }
+                }
 
-                     for (int j = 0; j < methods.length; j++) {
-                        Method currMeth = methods[j];
-
-                        if (currMeth.getDeclaringClass().getName()
-                                .equals(JAVACLASS)) {
-                           log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
+                if ("JCEAlgorithmMappings".equals(tag)) {
+                    Node algorithmsNode = ((Element)el).getElementsByTagName("Algorithms").item(0);
+                    if (algorithmsNode != null) {
+                        Element[] algorithms =
+                            XMLUtils.selectNodes(algorithmsNode.getFirstChild(), CONF_NS, "Algorithm");
+                        for (int i = 0; i < algorithms.length; i++) {
+                            Element element = algorithms[i];
+                            String id = element.getAttribute("URI");
+                            JCEMapper.register(id, new JCEMapper.Algorithm(element));
                         }
-                     }*/
-                      if (log.isLoggable(java.util.logging.Level.FINE))
-                        log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + URI + ", "
-                            + JAVACLASS + ")");
-                     Canonicalizer.register(URI, JAVACLASS);
-                  } catch (ClassNotFoundException e) {
-                     Object exArgs[] = { URI, JAVACLASS };
+                    }
+                }
+
+                if (tag.equals("SignatureAlgorithms")) {
+                    Element[] sigElems =
+                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "SignatureAlgorithm");
+
+                    for (int i = 0; i < sigElems.length; i++) {
+                        String uri = sigElems[i].getAttributeNS(null, "URI");
+                        String javaClass =
+                            sigElems[i].getAttributeNS(null, "JAVACLASS");
+
+                        /** $todo$ handle registering */
 
-                     log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
-                                              exArgs));
-                  }
-               }
-               XX_configure_reg_c14n_end = System.currentTimeMillis();
-            }
+                        try {
+                            SignatureAlgorithm.register(uri, javaClass);
+                            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                                log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + uri + ", "
+                                          + javaClass + ")");
+                            }
+                        } catch (ClassNotFoundException e) {
+                            Object exArgs[] = { uri, javaClass };
 
-            if (tag.equals("TransformAlgorithms")){
-               XX_configure_reg_transforms_start = System.currentTimeMillis();
-               Transform.init();
+                            log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
+                        }
+                    }
+                }
 
-               Element[] tranElem = XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,"TransformAlgorithm");
+                if (tag.equals("ResourceResolvers")) {
+                    Element[]resolverElem =
+                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
+
+                    for (int i = 0; i < resolverElem.length; i++) {
+                        String javaClass =
+                            resolverElem[i].getAttributeNS(null, "JAVACLASS");
+                        String description =
+                            resolverElem[i].getAttributeNS(null, "DESCRIPTION");
 
-               for (int i = 0; i < tranElem.length; i++) {
-                  String URI = tranElem[i].getAttributeNS(null,
-                                  "URI");
-                  String JAVACLASS =
-                     tranElem[i].getAttributeNS(null,
-                        "JAVACLASS");
-                  try {
-                     Class.forName(JAVACLASS);
-                     if (log.isLoggable(java.util.logging.Level.FINE))
-                        log.log(java.util.logging.Level.FINE, "Transform.register(" + URI + ", " + JAVACLASS + ")");
-                     Transform.register(URI, JAVACLASS);
-                  } catch (ClassNotFoundException e) {
-                     Object exArgs[] = { URI, JAVACLASS };
+                        if ((description != null) && (description.length() > 0)) {
+                            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                                log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass + ": "
+                                          + description);
+                            }
+                        } else {
+                            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                                log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass
+                                          + ": For unknown purposes");
+                            }
+                        }
+                        try {
+                            ResourceResolver.register(javaClass);
+                        } catch (Throwable e) {
+                            log.log(java.util.logging.Level.WARNING,
+                                 "Cannot register:" + javaClass
+                                 + " perhaps some needed jars are not installed",
+                                 e
+                             );
+                        }
+                    }
+                }
 
-                     log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
-                                              exArgs));
+                if (tag.equals("KeyResolver")){
+                    Element[] resolverElem =
+                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
+                    List<String> classNames = new ArrayList<String>(resolverElem.length);
+                    for (int i = 0; i < resolverElem.length; i++) {
+                        String javaClass =
+                            resolverElem[i].getAttributeNS(null, "JAVACLASS");
+                        String description =
+                            resolverElem[i].getAttributeNS(null, "DESCRIPTION");
 
-                  } catch (NoClassDefFoundError ex) {
-                                          log.log(java.util.logging.Level.WARNING, "Not able to found dependecies for algorithm, I'm keep working.");
-                  }
-               }
-               XX_configure_reg_transforms_end = System.currentTimeMillis();
-            }
-
-
-            if ("JCEAlgorithmMappings".equals(tag)){
-               XX_configure_reg_jcemapper_start = System.currentTimeMillis();
-               JCEMapper.init((Element)el);
-               XX_configure_reg_jcemapper_end = System.currentTimeMillis();
-            }
-
+                        if ((description != null) && (description.length() > 0)) {
+                            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                                log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass + ": "
+                                          + description);
+                            }
+                        } else {
+                            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                                log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass
+                                          + ": For unknown purposes");
+                            }
+                        }
+                        classNames.add(javaClass);
+                    }
+                    KeyResolver.registerClassNames(classNames);
+                }
 
 
-            if (tag.equals("SignatureAlgorithms")){
-               XX_configure_reg_sigalgos_start = System.currentTimeMillis();
-               SignatureAlgorithm.providerInit();
-
-               Element[] sigElems = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,
-                  "SignatureAlgorithm");
-
-               for (int i = 0; i < sigElems.length; i++) {
-                  String URI = sigElems[i].getAttributeNS(null,
-                                  "URI");
-                  String JAVACLASS =
-                    sigElems[i].getAttributeNS(null,
-                        "JAVACLASS");
-
-                  /** $todo$ handle registering */
-
-                  try {
-                      Class.forName(JAVACLASS);
- //                    Method methods[] = c.getMethods();
-
-//                     for (int j = 0; j < methods.length; j++) {
-//                        Method currMeth = methods[j];
-//
-//                        if (currMeth.getDeclaringClass().getName()
-//                                .equals(JAVACLASS)) {
-//                           log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
-//                        }
-//                     }
-                      if (log.isLoggable(java.util.logging.Level.FINE))
-                        log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + URI + ", " + JAVACLASS + ")");
-                     SignatureAlgorithm.register(URI, JAVACLASS);
-                  } catch (ClassNotFoundException e) {
-                     Object exArgs[] = { URI, JAVACLASS };
-
-                     log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
-                                              exArgs));
+                if (tag.equals("PrefixMappings")){
+                    if (log.isLoggable(java.util.logging.Level.FINE)) {
+                        log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
+                    }
 
-                  }
-               }
-               XX_configure_reg_sigalgos_end = System.currentTimeMillis();
-            }
-
-
-
-            if (tag.equals("ResourceResolvers")){
-               XX_configure_reg_resourceresolver_start = System.currentTimeMillis();
-               ResourceResolver.init();
-
-               Element[]resolverElem = XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,
-                  "Resolver");
-
-               for (int i = 0; i < resolverElem.length; i++) {
-                  String JAVACLASS =
-                      resolverElem[i].getAttributeNS(null,
-                        "JAVACLASS");
-                  String Description =
-                     resolverElem[i].getAttributeNS(null,
-                        "DESCRIPTION");
-
-                  if ((Description != null) && (Description.length() > 0)) {
-                    if (log.isLoggable(java.util.logging.Level.FINE))
-                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
-                  } else {
-                    if (log.isLoggable(java.util.logging.Level.FINE))
-                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
-                  }
-                                  try {
-                                          ResourceResolver.register(JAVACLASS);
-                                  } catch (Throwable e) {
-                                          log.log(java.util.logging.Level.WARNING, "Cannot register:"+JAVACLASS+" perhaps some needed jars are not installed",e);
-                                  }
-                  XX_configure_reg_resourceresolver_end =
-                    System.currentTimeMillis();
-               }
+                    Element[] nl =
+                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "PrefixMapping");
 
-            }
-
-
-
-
-
-
-            if (tag.equals("KeyResolver")){
-               XX_configure_reg_keyResolver_start =System.currentTimeMillis();
-               KeyResolver.init();
-
-               Element[] resolverElem = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"Resolver");
-
-               for (int i = 0; i < resolverElem.length; i++) {
-                  String JAVACLASS =
-                     resolverElem[i].getAttributeNS(null,
-                        "JAVACLASS");
-                  String Description =
-                     resolverElem[i].getAttributeNS(null,
-                        "DESCRIPTION");
-
-                  if ((Description != null) && (Description.length() > 0)) {
-                    if (log.isLoggable(java.util.logging.Level.FINE))
-                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
-                  } else {
-                    if (log.isLoggable(java.util.logging.Level.FINE))
-                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
-                  }
-
-                  KeyResolver.register(JAVACLASS);
-               }
-               XX_configure_reg_keyResolver_end = System.currentTimeMillis();
+                    for (int i = 0; i < nl.length; i++) {
+                        String namespace = nl[i].getAttributeNS(null, "namespace");
+                        String prefix = nl[i].getAttributeNS(null, "prefix");
+                        if (log.isLoggable(java.util.logging.Level.FINE)) {
+                            log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
+                        }
+                        ElementProxy.setDefaultPrefix(namespace, prefix);
+                    }
+                }
             }
-
-
-            if (tag.equals("PrefixMappings")){
-                XX_configure_reg_prefixes_start = System.currentTimeMillis();
-                if (log.isLoggable(java.util.logging.Level.FINE))
-                    log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
-
-               Element[] nl = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"PrefixMapping");
-
-               for (int i = 0; i < nl.length; i++) {
-                  String namespace = nl[i].getAttributeNS(null,
-                                        "namespace");
-                  String prefix = nl[i].getAttributeNS(null,
-                                     "prefix");
-                  if (log.isLoggable(java.util.logging.Level.FINE))
-                      log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
-                  com.sun.org.apache.xml.internal.security.utils.ElementProxy
-                     .setDefaultPrefix(namespace, prefix);
-               }
-               XX_configure_reg_prefixes_end = System.currentTimeMillis();
-            }
-            }
-
-            long XX_init_end = System.currentTimeMillis();
-
-            //J-
-            if (log.isLoggable(java.util.logging.Level.FINE)) {
-                log.log(java.util.logging.Level.FINE, "XX_init                             " + ((int)(XX_init_end - XX_init_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_prng                           " + ((int)(XX_prng_end - XX_prng_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_parsing                        " + ((int)(XX_parsing_end - XX_parsing_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_i18n                 " + ((int)(XX_configure_i18n_end- XX_configure_i18n_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_c14n             " + ((int)(XX_configure_reg_c14n_end- XX_configure_reg_c14n_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_jcemapper        " + ((int)(XX_configure_reg_jcemapper_end- XX_configure_reg_jcemapper_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_keyInfo          " + ((int)(XX_configure_reg_keyInfo_end- XX_configure_reg_keyInfo_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_keyResolver      " + ((int)(XX_configure_reg_keyResolver_end- XX_configure_reg_keyResolver_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_prefixes         " + ((int)(XX_configure_reg_prefixes_end- XX_configure_reg_prefixes_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_resourceresolver " + ((int)(XX_configure_reg_resourceresolver_end- XX_configure_reg_resourceresolver_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_sigalgos         " + ((int)(XX_configure_reg_sigalgos_end- XX_configure_reg_sigalgos_start)) + " ms");
-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_transforms       " + ((int)(XX_configure_reg_transforms_end- XX_configure_reg_transforms_start)) + " ms");
-            }
-         } catch (Exception e) {
+        } catch (Exception e) {
             log.log(java.util.logging.Level.SEVERE, "Bad: ", e);
             e.printStackTrace();
-         }
-
-   }
-
+        }
+    }
 
 }
+