3909N/A * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class represents a "provider" for the 0N/A * Java Security API, where a provider implements some or all parts of 0N/A * Java Security. Services that a provider may implement include: 0N/A * <li>Algorithms (such as DSA, RSA, MD5 or SHA-1). 0N/A * <li>Key generation, conversion, and management facilities (such as for 0N/A * algorithm-specific keys). 0N/A * <p>Each provider has a name and a version number, and is configured 0N/A * in each runtime it is installed in. 0N/A * in the "Java Cryptography Architecture API Specification & Reference" 0N/A * for information about how a particular type of provider, the 0N/A * cryptographic service provider, works and is installed. However, 0N/A * please note that a provider can be used to implement any security 0N/A * service in Java that uses a pluggable architecture with a choice 0N/A * of implementations that fit underneath. 0N/A * <p>Some provider implementations may encounter unrecoverable internal 0N/A * errors during their operation, for example a failure to communicate with a 0N/A * security token. A {@link ProviderException} should be used to indicate 0N/A * <p>The service type <code>Provider</code> is reserved for use by the 0N/A * security framework. Services of this type cannot be added, removed, 0N/A * or modified by applications. 0N/A * The following attributes are automatically placed in each Provider object: 0N/A * <table cellspacing=4> 0N/A * <tr><th>Name</th><th>Value</th> 0N/A * <tr><td><code>Provider.id name</code></td> 0N/A * <td><code>String.valueOf(provider.getName())</code></td> 0N/A * <tr><td><code>Provider.id version</code></td> 0N/A * <td><code>String.valueOf(provider.getVersion())</code></td> 0N/A * <tr><td><code>Provider.id info</code></td> 0N/A <td><code>String.valueOf(provider.getInfo())</code></td> 0N/A * <tr><td><code>Provider.id className</code></td> 0N/A * <td><code>provider.getClass().getName()</code></td> 0N/A * @author Benjamin Renaud 0N/A * @author Andreas Sterbenz 0N/A // Declare serialVersionUID to be compatible with JDK1.1 0N/A (
"provider",
"Provider");
0N/A * The provider name. 0N/A * A description of the provider and its services. 0N/A * The provider version number. 0N/A * Constructs a provider with the specified name, version number, 0N/A * @param name the provider name. 0N/A * @param version the provider version number. 0N/A * @param info a description of the provider and its services. 0N/A * Returns the name of this provider. 0N/A * @return the name of this provider. 0N/A * Returns the version number for this provider. 0N/A * @return the version number for this provider. 0N/A * Returns a human-readable description of the provider and its 0N/A * services. This may return an HTML page, with relevant links. 0N/A * @return a description of the provider and its services. 0N/A * Returns a string with the name and the version number 0N/A * @return the string with the name and the version number 0N/A * for this provider. 0N/A * override the following methods to ensure that provider 0N/A * information can only be changed if the caller has the appropriate 0N/A * Clears this provider so that it no longer contains the properties 0N/A * used to look up facilities implemented by the provider. 0N/A * <p>First, if there is a security manager, its 0N/A * <code>checkSecurityAccess</code> method is called with the string 0N/A * <code>"clearProviderProperties."+name</code> (where <code>name</code> 0N/A * is the provider name) to see if it's ok to clear this provider. 0N/A * If the default implementation of <code>checkSecurityAccess</code> 0N/A * is used (that is, that method is not overriden), then this results in 0N/A * a call to the security manager's <code>checkPermission</code> method 0N/A * with a <code>SecurityPermission("clearProviderProperties."+name)</code> 0N/A * @throws SecurityException 0N/A * if a security manager exists and its <code>{@link 0N/A * java.lang.SecurityManager#checkSecurityAccess}</code> method 0N/A * denies access to clear this provider 0N/A * Reads a property list (key and element pairs) from the input stream. 0N/A * @param inStream the input stream. 0N/A * @exception IOException if an error occurred when reading from the 0N/A * Copies all of the mappings from the specified Map to this provider. 0N/A * These mappings will replace any properties that this provider had 0N/A * for any of the keys currently in the specified Map. 0N/A * Returns an unmodifiable Set view of the property entries contained 0N/A * @see java.util.Map.Entry 0N/A // This exception will be thrown if the implementation of 0N/A // Collections.unmodifiableMap.entrySet() is changed such that it 0N/A // no longer calls entrySet() on the backing Map. (Provider's 0N/A // entrySet implementation depends on this "implementation detail", 0N/A // which is unlikely to change. 0N/A * Returns an unmodifiable Set view of the property keys contained in 0N/A * Returns an unmodifiable Collection view of the property values 0N/A * contained in this provider. 0N/A * Sets the <code>key</code> property to have the specified 0N/A * <code>value</code>. 0N/A * <p>First, if there is a security manager, its 0N/A * <code>checkSecurityAccess</code> method is called with the string 0N/A * <code>"putProviderProperty."+name</code>, where <code>name</code> is the 0N/A * provider name, to see if it's ok to set this provider's property values. 0N/A * If the default implementation of <code>checkSecurityAccess</code> 0N/A * is used (that is, that method is not overriden), then this results in 0N/A * a call to the security manager's <code>checkPermission</code> method 0N/A * with a <code>SecurityPermission("putProviderProperty."+name)</code> 0N/A * @param key the property key. 0N/A * @param value the property value. 0N/A * @return the previous value of the specified property 0N/A * (<code>key</code>), or null if it did not have one. 0N/A * @throws SecurityException 0N/A * if a security manager exists and its <code>{@link 0N/A * java.lang.SecurityManager#checkSecurityAccess}</code> method 0N/A * denies access to set property values. 0N/A * Removes the <code>key</code> property (and its corresponding 0N/A * <code>value</code>). 0N/A * <p>First, if there is a security manager, its 0N/A * <code>checkSecurityAccess</code> method is called with the string 0N/A * <code>"removeProviderProperty."+name</code>, where <code>name</code> is 0N/A * the provider name, to see if it's ok to remove this provider's 0N/A * properties. If the default implementation of 0N/A * <code>checkSecurityAccess</code> is used (that is, that method is not 0N/A * overriden), then this results in a call to the security manager's 0N/A * <code>checkPermission</code> method with a 0N/A * <code>SecurityPermission("removeProviderProperty."+name)</code> 0N/A * @param key the key for the property to be removed. 0N/A * @return the value to which the key had been mapped, 0N/A * or null if the key did not have a mapping. 0N/A * @throws SecurityException 0N/A * if a security manager exists and its <code>{@link 0N/A * java.lang.SecurityManager#checkSecurityAccess}</code> method 0N/A * denies access to remove this provider's properties. 0N/A // let javadoc show doc from superclass 0N/A // let javadoc show doc from superclass 0N/A // let javadoc show doc from superclass 0N/A // let javadoc show doc from superclass 0N/A // legacy properties changed since last call to any services method? 0N/A // serviceMap changed since last call to getServices() 0N/A // Map<String,String> 0N/A // Map<ServiceKey,Service> 0N/A // used for services added via putService(), initialized on demand 0N/A // Map<ServiceKey,Service> 0N/A // used for services added via legacy methods, init on demand 0N/A // Unmodifiable set of all services. Initialized on demand. 0N/A // register the id attributes for this provider 0N/A // this is to ensure that equals() and hashCode() do not incorrectly 0N/A // report to different provider objects as the same 0N/A // note: name and info may be null 0N/A * Copies all of the mappings from the specified Map to this provider. 0N/A * Internal method to be called AFTER the security check has been 0N/A // used as key in the serviceMap and legacyMap HashMaps 0N/A * Ensure all the legacy String properties are fully parsed into 0N/A * Remove all invalid services from the Map. Invalid services can only 0N/A * occur if the legacy properties are inconsistent or incomplete. 0N/A // e.g. put("Alg.Alias.MessageDigest.SHA", "SHA-1"); 0N/A // aliasKey ~ MessageDigest.SHA 0N/A // e.g. put("MessageDigest.SHA-1", "sun.security.provider.SHA"); 0N/A }
else {
// attribute 0N/A // e.g. put("MessageDigest.SHA-1 ImplementedIn", "Software"); 0N/A // kill additional spaces 0N/A * Get the service describing this Provider's implementation of the 0N/A * specified type of this algorithm or alias. If no such 0N/A * implementation exists, this method returns null. If there are two 0N/A * matching services, one added to this provider using 0N/A * {@link #putService putService()} and one added via {@link #put put()}, 0N/A * the service added via {@link #putService putService()} is returned. 0N/A * @param type the type of {@link Service service} requested 0N/A * (for example, <code>MessageDigest</code>) 0N/A * @param algorithm the case insensitive algorithm name (or alternate 0N/A * alias) of the service requested (for example, <code>SHA-1</code>) 0N/A * @return the service describing this Provider's matching service 0N/A * or null if no such service exists 0N/A * @throws NullPointerException if type or algorithm is null 0N/A // avoid allocating a new key object if possible 0N/A // ServiceKey from previous getService() call 0N/A // by re-using it if possible we avoid allocating a new object 0N/A // and the toUpperCase() call. 0N/A // re-use will occur e.g. as the framework traverses the provider 0N/A // list and queries each provider with the same values until it finds 0N/A // a matching service 0N/A * Get an unmodifiable Set of all services supported by 0N/A * @return an unmodifiable Set of all services supported by 0N/A * Add a service. If a service of the same type with the same algorithm 0N/A * name exists and it was added using {@link #putService putService()}, 0N/A * it is replaced by the new service. 0N/A * This method also places information about this service 0N/A * in the provider's Hashtable values in the format described in the 0N/A * Java Cryptography Architecture API Specification & Reference </a>. 0N/A * <p>Also, if there is a security manager, its 0N/A * <code>checkSecurityAccess</code> method is called with the string 0N/A * <code>"putProviderProperty."+name</code>, where <code>name</code> is 0N/A * the provider name, to see if it's ok to set this provider's property 0N/A * values. If the default implementation of <code>checkSecurityAccess</code> 0N/A * is used (that is, that method is not overriden), then this results in 0N/A * a call to the security manager's <code>checkPermission</code> method with 0N/A * a <code>SecurityPermission("putProviderProperty."+name)</code> 0N/A * @param s the Service to add 0N/A * @throws SecurityException 0N/A * if a security manager exists and its <code>{@link 0N/A * java.lang.SecurityManager#checkSecurityAccess}</code> method denies 0N/A * access to set property values. 0N/A * @throws NullPointerException if s is null 0N/A (
"service.getProvider() must match this Provider object");
0N/A // remove existing service 0N/A * Put the string properties for this Service in this Provider's 0N/A // use super() to avoid permission check and other processing 0N/A * Remove the string properties for this Service from this Provider's 0N/A // use super() to avoid permission check and other processing 0N/A * Remove a service previously added using 0N/A * {@link #putService putService()}. The specified service is removed from 0N/A * this provider. It will no longer be returned by 0N/A * {@link #getService getService()} and its information will be removed 0N/A * from this provider's Hashtable. 0N/A * <p>Also, if there is a security manager, its 0N/A * <code>checkSecurityAccess</code> method is called with the string 0N/A * <code>"removeProviderProperty."+name</code>, where <code>name</code> is 0N/A * the provider name, to see if it's ok to remove this provider's 0N/A * properties. If the default implementation of 0N/A * <code>checkSecurityAccess</code> is used (that is, that method is not 0N/A * overriden), then this results in a call to the security manager's 0N/A * <code>checkPermission</code> method with a 0N/A * <code>SecurityPermission("removeProviderProperty."+name)</code> 0N/A * @param s the Service to be removed 0N/A * @throws SecurityException 0N/A * if a security manager exists and its <code>{@link 0N/A * java.lang.SecurityManager#checkSecurityAccess}</code> method denies 0N/A * access to remove this provider's properties. 0N/A * @throws NullPointerException if s is null 0N/A // describe relevant properties of a type of engine 0N/A // built in knowledge of the engine types shipped as part of the JDK 0N/A // also index by canonical name to avoid toLowerCase() for some lookups 0N/A "java.security.cert.CertStoreParameters");
0N/A "java.security.Policy$Parameters");
0N/A "java.lang.Object");
0N/A // get the "standard" (mixed-case) engine name for arbitary case engine name 0N/A // if there is no known engine by that name, return s 0N/A // try original case first, usually correct 0N/A * The description of a security service. It encapsulates the properties 0N/A * of a service and contains a factory method to obtain new implementation 0N/A * instances of this service. 0N/A * <p>Each service has a provider that offers the service, a type, 0N/A * an algorithm name, and the name of the class that implements the 0N/A * service. Optionally, it also includes a list of alternate algorithm 0N/A * names for this service (aliases) and attributes, which are a map of 0N/A * (name, value) String pairs. 0N/A * <p>This class defines the methods {@link #supportsParameter 0N/A * supportsParameter()} and {@link #newInstance newInstance()} 0N/A * which are used by the Java security framework when it searches for 0N/A * suitable services and instantes them. The valid arguments to those 0N/A * methods depend on the type of service. For the service types defined 0N/A * within Java SE, see the 0N/A * Java Cryptography Architecture API Specification & Reference </a> 0N/A * for the valid values. 0N/A * Note that components outside of Java SE can define additional types of 0N/A * services and their behavior. 0N/A * <p>Instances of this class are immutable. 0N/A // Reference to the cached implementation Class object 0N/A // flag indicating whether this service has its attributes for 0N/A // supportedKeyFormats or supportedKeyClasses set 0N/A // if null, the values have not been initialized 0N/A // supported encoding formats 0N/A // names of the supported key (super) classes 0N/A // whether this service has been registered with the Provider 0N/A // this constructor and these methods are used for parsing 0N/A // the legacy string properties. 0N/A * Construct a new service. 0N/A * @param provider the provider that offers this service 0N/A * @param type the type of this service 0N/A * @param algorithm the algorithm name 0N/A * @param className the name of the class implementing this service 0N/A * @param aliases List of aliases or null if algorithm has no aliases 0N/A * @param attributes Map of attributes or null if this implementation 0N/A * @throws NullPointerException if provider, type, algorithm, or 0N/A * Get the type of this service. For example, <code>MessageDigest</code>. 0N/A * @return the type of this service 0N/A * Return the name of the algorithm of this service. For example, 0N/A * <code>SHA-1</code>. 0N/A * @return the algorithm of this service 0N/A * Return the Provider of this service. 0N/A * @return the Provider of this service 0N/A * Return the name of the class implementing this service. 0N/A * @return the name of the class implementing this service 0N/A * Return the value of the specified attribute or null if this 0N/A * attribute is not set for this Service. 0N/A * @param name the name of the requested attribute 0N/A * @return the value of the specified attribute or null if the 0N/A * attribute is not present 0N/A * @throws NullPointerException if name is null 0N/A * Return a new instance of the implementation described by this 0N/A * service. The security provider framework uses this method to 0N/A * construct implementations. Applications will typically not need 0N/A * <p>The default implementation uses reflection to invoke the 0N/A * standard constructor for this type of service. 0N/A * Security providers can override this method to implement 0N/A * instantiation in a different way. 0N/A * For details and the values of constructorParameter that are 0N/A * valid for the various types of services see the 0N/A * Java Cryptography Architecture API Specification & 0N/A * @param constructorParameter the value to pass to the constructor, 0N/A * or null if this type of service does not use a constructorParameter. 0N/A * @return a new implementation of this service 0N/A * @throws InvalidParameterException if the value of 0N/A * constructorParameter is invalid for this type of service. 0N/A * @throws NoSuchAlgorithmException if instantation failed for 0N/A (
"Service not registered with Provider " 0N/A // unknown engine type, use generic code 0N/A // this is the code path future for non-core 0N/A // optional packages 0N/A (
"constructorParameter not used with " +
type 0N/A (
"constructorParameter must be instanceof " 0N/A (
"Error constructing implementation (algorithm: " 0N/A (
"Error constructing implementation (algorithm: " 0N/A // return the implementation Class object for this service 0N/A (
"class configured for " +
type +
"(provider: " +
0N/A * Generic code path for unknown engine types. Call the 0N/A * no-args constructor if constructorParameter is null, otherwise 0N/A * use the first matching constructor. 0N/A // find first public constructor that can take the 0N/A // argument as parameter 0N/A * Test whether this Service can use the specified parameter. 0N/A * Returns false if this service cannot use the parameter. Returns 0N/A * true if this service can use the parameter, if a fast test is 0N/A * infeasible, or if the status is unknown. 0N/A * <p>The security provider framework uses this method with 0N/A * some types of services to quickly exclude non-matching 0N/A * implementations for consideration. 0N/A * Applications will typically not need to call it. 0N/A * <p>For details and the values of parameter that are valid for the 0N/A * various types of services see the top of this class and the 0N/A * Java Cryptography Architecture API Specification & 0N/A * Security providers can override it to implement their own test. 0N/A * @param parameter the parameter to test 0N/A * @return false if this this service cannot use the specified 0N/A * parameter; true if it can possibly use the parameter 0N/A * @throws InvalidParameterException if the value of parameter is 0N/A * invalid for this type of service or if this method cannot be 0N/A * used with this type of service 0N/A // unknown engine type, return true by default 0N/A +
"used with " +
type +
" engines");
0N/A // allow null for keys without attributes for compatibility 0N/A (
"Parameter must be instanceof Key for engine " +
type);
0N/A * Return whether this service has its Supported* properties for 0N/A * keys defined. Parses the attributes if not yet initialized. 0N/A synchronized (
this) {
0N/A // get the key class object of the specified name 0N/A * Return a String representation of this service. 0N/A * @return a String representation of this service.