Java Code Examples for com.sun.org.apache.xml.internal.security.utils.JavaUtils

The following examples show how to use com.sun.org.apache.xml.internal.security.utils.JavaUtils. These examples are extracted from open source projects. 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 Project: jdk8u-jdk   Source File: SignatureAlgorithm.java    License: 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 2
Source Project: dragonwell8_jdk   Source File: Transform.java    License: 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 3
Source Project: hottub   Source File: Transform.java    License: 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 4
Source Project: TencentKona-8   Source File: Transform.java    License: 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 5
Source Project: hottub   Source File: Canonicalizer.java    License: 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 6
Source Project: openjdk-jdk9   Source File: Canonicalizer.java    License: 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
/**
 * 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 8
Source Project: jdk8u60   Source File: SignatureAlgorithm.java    License: 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 Project: jdk8u_jdk   Source File: SignatureAlgorithm.java    License: 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 10
Source Project: jdk8u-dev-jdk   Source File: Canonicalizer.java    License: 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 11
/**
 * 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 12
Source Project: hottub   Source File: SignatureAlgorithm.java    License: 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 Project: jdk1.8-source-analysis   Source File: ResourceResolver.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Registers a ResourceResolverSpi class. This method logs a warning if
 * the class cannot be registered.
 *
 * @param className the name of the ResourceResolverSpi class to be registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register a resource resolver
 */
@SuppressWarnings("unchecked")
public static void register(String className) {
    JavaUtils.checkRegisterPermission();
    try {
        Class<ResourceResolverSpi> resourceResolverClass =
            (Class<ResourceResolverSpi>) Class.forName(className);
        register(resourceResolverClass, false);
    } catch (ClassNotFoundException e) {
        log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className + " disabling it");
    }
}
 
Example 14
Source Project: hottub   Source File: XMLSignatureInput.java    License: GNU General Public License v2.0 5 votes vote down vote up
private byte[] getBytesFromInputStream() throws IOException {
    if (bytes != null) {
        return bytes;
    }
    if (inputOctetStreamProxy == null) {
        return null;
    }
    try {
        bytes = JavaUtils.getBytesFromStream(inputOctetStreamProxy);
    } finally {
        inputOctetStreamProxy.close();
    }
    return bytes;
}
 
Example 15
Source Project: jdk1.8-source-analysis   Source File: ResourceResolver.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Registers a ResourceResolverSpi instance. This method logs a warning if the class
 * cannot be registered.
 * @param resourceResolverSpi
 * @param start
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register a resource resolver
 */
public static void register(ResourceResolverSpi resourceResolverSpi, boolean start) {
    JavaUtils.checkRegisterPermission();
    synchronized(resolverList) {
        if (start) {
            resolverList.add(0, new ResourceResolver(resourceResolverSpi));
        } else {
            resolverList.add(new ResourceResolver(resourceResolverSpi));
        }
    }
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Registered resolver: " + resourceResolverSpi.toString());
    }
}
 
Example 16
Source Project: jdk1.8-source-analysis   Source File: XMLSignatureInput.java    License: Apache License 2.0 5 votes vote down vote up
private byte[] getBytesFromInputStream() throws IOException {
    if (bytes != null) {
        return bytes;
    }
    if (inputOctetStreamProxy == null) {
        return null;
    }
    try {
        bytes = JavaUtils.getBytesFromStream(inputOctetStreamProxy);
    } finally {
        inputOctetStreamProxy.close();
    }
    return bytes;
}
 
Example 17
Source Project: jdk8u_jdk   Source File: Canonicalizer.java    License: GNU General Public License v2.0 5 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
 */
public static void register(String algorithmURI, Class<? extends CanonicalizerSpi> 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, implementingClass);
}
 
Example 18
Source Project: jdk1.8-source-analysis   Source File: Canonicalizer.java    License: Apache License 2.0 5 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
 */
public static void register(String algorithmURI, Class<? extends CanonicalizerSpi> 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, implementingClass);
}
 
Example 19
@Override
byte[] preVerifyFormat(Key key, byte[] sig) throws IOException {
    // If signature needs to be in ASN.1 (i.e., if the fallback
    // algorithm will be used to verify the sig), convert the signature
    // to the ASN.1 format
    if (asn1) {
        int size = ((DSAKey) key).getParams().getQ().bitLength();
        return JavaUtils.convertDsaXMLDSIGtoASN1(sig, size / 8);
    } else {
        return sig;
    }
}
 
Example 20
Source Project: openjdk-jdk8u   Source File: Canonicalizer.java    License: GNU General Public License v2.0 5 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
 */
public static void register(String algorithmURI, Class<? extends CanonicalizerSpi> 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, implementingClass);
}
 
Example 21
/**
 * Registers a ResourceResolverSpi class at the beginning of the provider
 * list. This method logs a warning if the class cannot be registered.
 *
 * @param className the name of the ResourceResolverSpi class to be registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register a resource resolver
 */
@SuppressWarnings("unchecked")
public static void registerAtStart(String className) {
    JavaUtils.checkRegisterPermission();
    try {
        Class<ResourceResolverSpi> resourceResolverClass =
            (Class<ResourceResolverSpi>) Class.forName(className);
        register(resourceResolverClass, true);
    } catch (ClassNotFoundException e) {
        log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className + " disabling it");
    }
}
 
Example 22
/**
 * Registers a ResourceResolverSpi instance. This method logs a warning if the class
 * cannot be registered.
 * @param resourceResolverSpi
 * @param start
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register a resource resolver
 */
public static void register(ResourceResolverSpi resourceResolverSpi, boolean start) {
    JavaUtils.checkRegisterPermission();
    synchronized(resolverList) {
        if (start) {
            resolverList.add(0, new ResourceResolver(resourceResolverSpi));
        } else {
            resolverList.add(new ResourceResolver(resourceResolverSpi));
        }
    }
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Registered resolver: " + resourceResolverSpi.toString());
    }
}
 
Example 23
Source Project: jdk8u-jdk   Source File: Transform.java    License: GNU General Public License v2.0 5 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
 */
public static void register(String algorithmURI, Class<? extends TransformSpi> implementingClass)
    throws AlgorithmAlreadyRegisteredException {
    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);
    }
    transformSpiHash.put(algorithmURI, implementingClass);
}
 
Example 24
Source Project: jdk8u_jdk   Source File: Transform.java    License: GNU General Public License v2.0 5 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
 */
public static void register(String algorithmURI, Class<? extends TransformSpi> implementingClass)
    throws AlgorithmAlreadyRegisteredException {
    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);
    }
    transformSpiHash.put(algorithmURI, implementingClass);
}
 
Example 25
/**
 * Registers a ResourceResolverSpi class at the beginning of the provider
 * list. This method logs a warning if the class cannot be registered.
 *
 * @param className the name of the ResourceResolverSpi class to be registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register a resource resolver
 */
@SuppressWarnings("unchecked")
public static void registerAtStart(String className) {
    JavaUtils.checkRegisterPermission();
    try {
        Class<ResourceResolverSpi> resourceResolverClass =
            (Class<ResourceResolverSpi>) Class.forName(className);
        register(resourceResolverClass, true);
    } catch (ClassNotFoundException e) {
        log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className + " disabling it");
    }
}
 
Example 26
Source Project: jdk8u-jdk   Source File: XMLSignatureInput.java    License: GNU General Public License v2.0 5 votes vote down vote up
private byte[] getBytesFromInputStream() throws IOException {
    if (bytes != null) {
        return bytes;
    }
    if (inputOctetStreamProxy == null) {
        return null;
    }
    try {
        bytes = JavaUtils.getBytesFromStream(inputOctetStreamProxy);
    } finally {
        inputOctetStreamProxy.close();
    }
    return bytes;
}
 
Example 27
/**
 * Registers a ResourceResolverSpi class. This method logs a warning if
 * the class cannot be registered.
 *
 * @param className the name of the ResourceResolverSpi class to be registered
 * @throws SecurityException if a security manager is installed and the
 *    caller does not have permission to register a resource resolver
 */
@SuppressWarnings("unchecked")
public static void register(String className) {
    JavaUtils.checkRegisterPermission();
    try {
        Class<ResourceResolverSpi> resourceResolverClass =
            (Class<ResourceResolverSpi>) Class.forName(className);
        register(resourceResolverClass, false);
    } catch (ClassNotFoundException e) {
        log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className + " disabling it");
    }
}
 
Example 28
Source Project: jdk8u-dev-jdk   Source File: Canonicalizer.java    License: GNU General Public License v2.0 5 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
 */
public static void register(String algorithmURI, Class<? extends CanonicalizerSpi> 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, implementingClass);
}
 
Example 29
private byte[] getBytesFromInputStream() throws IOException {
    if (bytes != null) {
        return bytes;
    }
    if (inputOctetStreamProxy == null) {
        return null;
    }
    try {
        bytes = JavaUtils.getBytesFromStream(inputOctetStreamProxy);
    } finally {
        inputOctetStreamProxy.close();
    }
    return bytes;
}
 
Example 30
Source Project: jdk8u-jdk   Source File: XMLSignatureInput.java    License: GNU General Public License v2.0 5 votes vote down vote up
private byte[] getBytesFromInputStream() throws IOException {
    if (bytes != null) {
        return bytes;
    }
    if (inputOctetStreamProxy == null) {
        return null;
    }
    try {
        bytes = JavaUtils.getBytesFromStream(inputOctetStreamProxy);
    } finally {
        inputOctetStreamProxy.close();
    }
    return bytes;
}