com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Canonicalizer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method register
 *
 * @param algorithmURI
 * @param implementingClass
 * @throws AlgorithmAlreadyRegisteredException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the canonicalizer
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
    JavaUtils.checkRegisterPermission();
    // check whether URI is already registered
    Class<? extends CanonicalizerSpi> registeredClass =
        canonicalizerHash.get(algorithmURI);

    if (registeredClass != null)  {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }

    canonicalizerHash.put(
        algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
    );
}
 
Example #2
Source File: Canonicalizer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method register
 *
 * @param algorithmURI
 * @param implementingClass
 * @throws AlgorithmAlreadyRegisteredException
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
    // check whether URI is already registered
    Class<? extends CanonicalizerSpi> registeredClass =
        canonicalizerHash.get(algorithmURI);

    if (registeredClass != null)  {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }

    canonicalizerHash.put(
        algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
    );
}
 
Example #3
Source File: ClassLoaderTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #4
Source File: Canonicalizer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method register
 *
 * @param algorithmURI
 * @param implementingClass
 * @throws AlgorithmAlreadyRegisteredException
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
    // check whether URI is already registered
    Class<? extends CanonicalizerSpi> registeredClass =
        canonicalizerHash.get(algorithmURI);

    if (registeredClass != null)  {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }

    canonicalizerHash.put(
        algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
    );
}
 
Example #5
Source File: SignatureAlgorithm.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>.
 * @param implementingClass <code>implementingClass</code> the implementing class of
 * {@link SignatureAlgorithmSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
 * @throws XMLSignatureException
 */
public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
   throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
       XMLSignatureException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
    }

    // are we already registered?
    Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
    if (registeredClass != null) {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException(
            "algorithm.alreadyRegistered", exArgs
        );
    }
    algorithmHash.put(algorithmURI, implementingClass);
}
 
Example #6
Source File: Canonicalizer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method register
 *
 * @param algorithmURI
 * @param implementingClass
 * @throws AlgorithmAlreadyRegisteredException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the canonicalizer
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
    JavaUtils.checkRegisterPermission();
    // check whether URI is already registered
    Class<? extends CanonicalizerSpi> registeredClass =
        canonicalizerHash.get(algorithmURI);

    if (registeredClass != null)  {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }

    canonicalizerHash.put(
        algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
    );
}
 
Example #7
Source File: Transform.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
 * @param implementingClass <code>implementingClass</code> the implementing
 * class of {@link TransformSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
 * is already registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the transform
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
        InvalidTransformException {
    JavaUtils.checkRegisterPermission();
    // are we already registered?
    Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
    if (transformSpi != null) {
        Object exArgs[] = { algorithmURI, transformSpi };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }
    Class<? extends TransformSpi> transformSpiClass =
        (Class<? extends TransformSpi>)
            ClassLoaderUtils.loadClass(implementingClass, Transform.class);
    transformSpiHash.put(algorithmURI, transformSpiClass);
}
 
Example #8
Source File: SignatureAlgorithm.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>SignatureAlgorithm</code>.
 * @param implementingClass <code>implementingClass</code> the implementing class of
 * {@link SignatureAlgorithmSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
 * @throws XMLSignatureException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the signature algorithm
 */
public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
   throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
       XMLSignatureException {
    JavaUtils.checkRegisterPermission();
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
    }

    // are we already registered?
    Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
    if (registeredClass != null) {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException(
            "algorithm.alreadyRegistered", exArgs
        );
    }
    algorithmHash.put(algorithmURI, implementingClass);
}
 
Example #9
Source File: Canonicalizer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method register
 *
 * @param algorithmURI
 * @param implementingClass
 * @throws AlgorithmAlreadyRegisteredException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the canonicalizer
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
    JavaUtils.checkRegisterPermission();
    // check whether URI is already registered
    Class<? extends CanonicalizerSpi> registeredClass =
        canonicalizerHash.get(algorithmURI);

    if (registeredClass != null)  {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }

    canonicalizerHash.put(
        algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
    );
}
 
Example #10
Source File: ClassLoaderTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #11
Source File: Transform.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
 * @param implementingClass <code>implementingClass</code> the implementing
 * class of {@link TransformSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
 * is already registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the transform
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
        InvalidTransformException {
    JavaUtils.checkRegisterPermission();
    // are we already registered?
    Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
    if (transformSpi != null) {
        Object exArgs[] = { algorithmURI, transformSpi };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }
    Class<? extends TransformSpi> transformSpiClass =
        (Class<? extends TransformSpi>)
            ClassLoaderUtils.loadClass(implementingClass, Transform.class);
    transformSpiHash.put(algorithmURI, transformSpiClass);
}
 
Example #12
Source File: SignatureAlgorithm.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>SignatureAlgorithm</code>.
 * @param implementingClass <code>implementingClass</code> the implementing class of
 * {@link SignatureAlgorithmSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
 * @throws XMLSignatureException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the signature algorithm
 */
public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
   throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
       XMLSignatureException {
    JavaUtils.checkRegisterPermission();
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
    }

    // are we already registered?
    Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
    if (registeredClass != null) {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException(
            "algorithm.alreadyRegistered", exArgs
        );
    }
    algorithmHash.put(algorithmURI, implementingClass);
}
 
Example #13
Source File: Canonicalizer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method register
 *
 * @param algorithmURI
 * @param implementingClass
 * @throws AlgorithmAlreadyRegisteredException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the canonicalizer
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
    JavaUtils.checkRegisterPermission();
    // check whether URI is already registered
    Class<? extends CanonicalizerSpi> registeredClass =
        canonicalizerHash.get(algorithmURI);

    if (registeredClass != null)  {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }

    canonicalizerHash.put(
        algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
    );
}
 
Example #14
Source File: ClassLoaderTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #15
Source File: ClassLoaderTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #16
Source File: Transform.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
 * @param implementingClass <code>implementingClass</code> the implementing
 * class of {@link TransformSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
 * is already registered
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
        InvalidTransformException {
    // are we already registered?
    Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
    if (transformSpi != null) {
        Object exArgs[] = { algorithmURI, transformSpi };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }
    Class<? extends TransformSpi> transformSpiClass =
        (Class<? extends TransformSpi>)
            ClassLoaderUtils.loadClass(implementingClass, Transform.class);
    transformSpiHash.put(algorithmURI, transformSpiClass);
}
 
Example #17
Source File: SignatureAlgorithm.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>SignatureAlgorithm</code>.
 * @param implementingClass <code>implementingClass</code> the implementing class of
 * {@link SignatureAlgorithmSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
 * @throws XMLSignatureException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the signature algorithm
 */
public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
   throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
       XMLSignatureException {
    JavaUtils.checkRegisterPermission();
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
    }

    // are we already registered?
    Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
    if (registeredClass != null) {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException(
            "algorithm.alreadyRegistered", exArgs
        );
    }
    algorithmHash.put(algorithmURI, implementingClass);
}
 
Example #18
Source File: Transform.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
 * @param implementingClass <code>implementingClass</code> the implementing
 * class of {@link TransformSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
 * is already registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the transform
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
        InvalidTransformException {
    JavaUtils.checkRegisterPermission();
    // are we already registered?
    Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
    if (transformSpi != null) {
        Object exArgs[] = { algorithmURI, transformSpi };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }
    Class<? extends TransformSpi> transformSpiClass =
        (Class<? extends TransformSpi>)
            ClassLoaderUtils.loadClass(implementingClass, Transform.class);
    transformSpiHash.put(algorithmURI, transformSpiClass);
}
 
Example #19
Source File: ClassLoaderTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #20
Source File: SignatureAlgorithm.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>SignatureAlgorithm</code>.
 * @param implementingClass <code>implementingClass</code> the implementing class of
 * {@link SignatureAlgorithmSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
 * @throws XMLSignatureException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the signature algorithm
 */
public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
   throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
       XMLSignatureException {
    JavaUtils.checkRegisterPermission();
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
    }

    // are we already registered?
    Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
    if (registeredClass != null) {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException(
            "algorithm.alreadyRegistered", exArgs
        );
    }
    algorithmHash.put(algorithmURI, implementingClass);
}
 
Example #21
Source File: Transform.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
 * @param implementingClass <code>implementingClass</code> the implementing
 * class of {@link TransformSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
 * is already registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the transform
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
        InvalidTransformException {
    JavaUtils.checkRegisterPermission();
    // are we already registered?
    Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
    if (transformSpi != null) {
        Object exArgs[] = { algorithmURI, transformSpi };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }
    Class<? extends TransformSpi> transformSpiClass =
        (Class<? extends TransformSpi>)
            ClassLoaderUtils.loadClass(implementingClass, Transform.class);
    transformSpiHash.put(algorithmURI, transformSpiClass);
}
 
Example #22
Source File: ClassLoaderTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #23
Source File: Canonicalizer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method register
 *
 * @param algorithmURI
 * @param implementingClass
 * @throws AlgorithmAlreadyRegisteredException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the canonicalizer
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
    JavaUtils.checkRegisterPermission();
    // check whether URI is already registered
    Class<? extends CanonicalizerSpi> registeredClass =
        canonicalizerHash.get(algorithmURI);

    if (registeredClass != null)  {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }

    canonicalizerHash.put(
        algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
    );
}
 
Example #24
Source File: ClassLoaderTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #25
Source File: Transform.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
 * @param implementingClass <code>implementingClass</code> the implementing
 * class of {@link TransformSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
 * is already registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the transform
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
        InvalidTransformException {
    JavaUtils.checkRegisterPermission();
    // are we already registered?
    Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
    if (transformSpi != null) {
        Object exArgs[] = { algorithmURI, transformSpi };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }
    Class<? extends TransformSpi> transformSpiClass =
        (Class<? extends TransformSpi>)
            ClassLoaderUtils.loadClass(implementingClass, Transform.class);
    transformSpiHash.put(algorithmURI, transformSpiClass);
}
 
Example #26
Source File: ClassLoaderTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }
 
Example #27
Source File: Canonicalizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method register
 *
 * @param algorithmURI
 * @param implementingClass
 * @throws AlgorithmAlreadyRegisteredException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the canonicalizer
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
    JavaUtils.checkRegisterPermission();
    // check whether URI is already registered
    Class<? extends CanonicalizerSpi> registeredClass =
        canonicalizerHash.get(algorithmURI);

    if (registeredClass != null)  {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }

    canonicalizerHash.put(
        algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
    );
}
 
Example #28
Source File: SignatureAlgorithm.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>SignatureAlgorithm</code>.
 * @param implementingClass <code>implementingClass</code> the implementing class of
 * {@link SignatureAlgorithmSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
 * @throws XMLSignatureException
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the signature algorithm
 */
public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
   throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
       XMLSignatureException {
    JavaUtils.checkRegisterPermission();
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
    }

    // are we already registered?
    Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
    if (registeredClass != null) {
        Object exArgs[] = { algorithmURI, registeredClass };
        throw new AlgorithmAlreadyRegisteredException(
            "algorithm.alreadyRegistered", exArgs
        );
    }
    algorithmHash.put(algorithmURI, implementingClass);
}
 
Example #29
Source File: Transform.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Registers implementing class of the Transform algorithm with algorithmURI
 *
 * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
 * @param implementingClass <code>implementingClass</code> the implementing
 * class of {@link TransformSpi}
 * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
 * is already registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register the transform
 */
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
    throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
        InvalidTransformException {
    JavaUtils.checkRegisterPermission();
    // are we already registered?
    Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
    if (transformSpi != null) {
        Object exArgs[] = { algorithmURI, transformSpi };
        throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
    }
    Class<? extends TransformSpi> transformSpiClass =
        (Class<? extends TransformSpi>)
            ClassLoaderUtils.loadClass(implementingClass, Transform.class);
    transformSpiHash.put(algorithmURI, transformSpiClass);
}
 
Example #30
Source File: ClassLoaderTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        File file = new File(BASE);
        URL[] urls = new URL[1];
        urls[0] = file.toURI().toURL();
        URLClassLoader ucl = new URLClassLoader(urls);
        Class<?> c = ucl.loadClass("MyTransform");
        Constructor<?> cons = c.getConstructor(new Class[] {});
        Object o = cons.newInstance();
        // Apache code swallows the ClassNotFoundExc, so we need to
        // check if the Transform has already been registered by registering
        // it again and catching an AlgorithmAlreadyRegisteredExc
        try {
            Transform.register(MyTransform.URI, "MyTransform");
            throw new Exception("ClassLoaderTest failed");
        } catch (AlgorithmAlreadyRegisteredException e) {
            // test passed
        }
    }