Commit 7ddd8380 by Gary Benson Committed by Gary Benson

Security.java: Merge with classpath.

2006-11-21  Gary Benson  <gbenson@redhat.com>

	* java/security/Security.java: Merge with classpath.
	* java/lang/Package.java: Likewise.
	* java/lang/Class.java (getDeclaredAnnotations): New method.

From-SVN: r119057
parent 0b2229b0
2006-11-21 Gary Benson <gbenson@redhat.com>
* java/security/Security.java: Merge with classpath.
* java/lang/Package.java: Likewise.
* java/lang/Class.java (getDeclaredAnnotations): New method.
2006-11-20 David Daney <ddaney@avtrex.com> 2006-11-20 David Daney <ddaney@avtrex.com>
* include/mips-signal.h (sys/syscall.h): Do not include. * include/mips-signal.h (sys/syscall.h): Do not include.
......
...@@ -40,6 +40,7 @@ package java.lang; ...@@ -40,6 +40,7 @@ package java.lang;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.GenericDeclaration; import java.lang.reflect.GenericDeclaration;
...@@ -949,6 +950,23 @@ public final class Class implements Type, GenericDeclaration, Serializable ...@@ -949,6 +950,23 @@ public final class Class implements Type, GenericDeclaration, Serializable
} }
/** /**
* Returns all annotations directly defined by this class. If there are
* no annotations associated with this class, then a zero-length array
* will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of this
* class, and hence no effect on the return value of this method for
* future callers.
*
* @return the annotations directly defined by this class.
* @since 1.5
*/
public Annotation[] getDeclaredAnnotations()
{
// FIXME write real implementation
return new Annotation[0];
}
/**
* Returns the class which immediately encloses this class. If this class * Returns the class which immediately encloses this class. If this class
* is a top-level class, this method returns <code>null</code>. * is a top-level class, this method returns <code>null</code>.
* *
......
/* Package.java -- information about a package /* Package.java -- information about a package
Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -37,6 +38,8 @@ exception statement from your version. */ ...@@ -37,6 +38,8 @@ exception statement from your version. */
package java.lang; package java.lang;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.net.URL; import java.net.URL;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
...@@ -68,9 +71,10 @@ import java.util.StringTokenizer; ...@@ -68,9 +71,10 @@ import java.util.StringTokenizer;
* @see ClassLoader#definePackage(String, String, String, String, String, * @see ClassLoader#definePackage(String, String, String, String, String,
* String, String, URL) * String, String, URL)
* @since 1.2 * @since 1.2
* @status updated to 1.4 * @status updated to 1.5
*/ */
public class Package public class Package
implements AnnotatedElement
{ {
/** The name of the Package */ /** The name of the Package */
private final String name; private final String name;
...@@ -96,6 +100,20 @@ public class Package ...@@ -96,6 +100,20 @@ public class Package
/** If sealed the origin of the package classes, otherwise null */ /** If sealed the origin of the package classes, otherwise null */
private final URL sealed; private final URL sealed;
/** The class loader that defined this package */
private ClassLoader loader;
/** @deprecated Please use the other constructor that takes the class loader
* that defines the Package.
*/
Package(String name,
String specTitle, String specVendor, String specVersion,
String implTitle, String implVendor, String implVersion, URL sealed)
{
this(name, specTitle, specVendor, specVersion, implTitle, implVendor,
implVersion, sealed, null);
}
/** /**
* A package local constructor for the Package class. All parameters except * A package local constructor for the Package class. All parameters except
* the <code>name</code> of the package may be <code>null</code>. * the <code>name</code> of the package may be <code>null</code>.
...@@ -113,7 +131,8 @@ public class Package ...@@ -113,7 +131,8 @@ public class Package
*/ */
Package(String name, Package(String name,
String specTitle, String specVendor, String specVersion, String specTitle, String specVendor, String specVersion,
String implTitle, String implVendor, String implVersion, URL sealed) String implTitle, String implVendor, String implVersion, URL sealed,
ClassLoader loader)
{ {
if (name == null) if (name == null)
throw new IllegalArgumentException("null Package name"); throw new IllegalArgumentException("null Package name");
...@@ -126,6 +145,7 @@ public class Package ...@@ -126,6 +145,7 @@ public class Package
this.specVendor = specVendor; this.specVendor = specVendor;
this.specVersion = specVersion; this.specVersion = specVersion;
this.sealed = sealed; this.sealed = sealed;
this.loader = loader;
} }
/** /**
...@@ -231,7 +251,7 @@ public class Package ...@@ -231,7 +251,7 @@ public class Package
* *
* @return true if the version is compatible, false otherwise * @return true if the version is compatible, false otherwise
* *
* @Throws NumberFormatException if either version string is invalid * @throws NumberFormatException if either version string is invalid
* @throws NullPointerException if either version string is null * @throws NullPointerException if either version string is null
*/ */
public boolean isCompatibleWith(String version) public boolean isCompatibleWith(String version)
...@@ -314,4 +334,82 @@ public class Package ...@@ -314,4 +334,82 @@ public class Package
return ("package " + name + (specTitle == null ? "" : ", " + specTitle) return ("package " + name + (specTitle == null ? "" : ", " + specTitle)
+ (specVersion == null ? "" : ", version " + specVersion)); + (specVersion == null ? "" : ", version " + specVersion));
} }
/**
* Returns this package's annotation for the specified annotation type,
* or <code>null</code> if no such annotation exists.
*
* @param annotationClass the type of annotation to look for.
* @return this package's annotation for the specified type, or
* <code>null</code> if no such annotation exists.
* @since 1.5
*/
/* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
public Annotation getAnnotation(Class annotationClass)
{
Annotation foundAnnotation = null;
Annotation[] annotations = getAnnotations();
for (int i = 0; i < annotations.length; i++)
if (annotations[i].annotationType() == annotationClass)
foundAnnotation = annotations[i];
return foundAnnotation;
}
/**
* Returns all annotations associated with this package. If there are
* no annotations associated with this package, then a zero-length array
* will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of this
* package, and hence no effect on the return value of this method for
* future callers.
*
* @return this package' annotations.
* @since 1.5
*/
public Annotation[] getAnnotations()
{
/** All a package's annotations are declared within it. */
return getDeclaredAnnotations();
}
/**
* Returns all annotations directly defined by this package. If there are
* no annotations associated with this package, then a zero-length array
* will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of this
* package, and hence no effect on the return value of this method for
* future callers.
*
* @return the annotations directly defined by this package.
* @since 1.5
*/
public Annotation[] getDeclaredAnnotations()
{
try
{
Class pkgInfo = Class.forName(name + ".package-info", false, loader);
return pkgInfo.getDeclaredAnnotations();
}
catch (ClassNotFoundException _)
{
return new Annotation[0];
}
}
/**
* Returns true if an annotation for the specified type is associated
* with this package. This is primarily a short-hand for using marker
* annotations.
*
* @param annotationClass the type of annotation to look for.
* @return true if an annotation exists for the specified type.
* @since 1.5
*/
/* FIXME[GENERICS]: Signature is Class<? extends Annotation> */
public boolean isAnnotationPresent(Class
annotationClass)
{
return getAnnotation(annotationClass) != null;
}
} // class Package } // class Package
...@@ -61,7 +61,7 @@ import java.util.Vector; ...@@ -61,7 +61,7 @@ import java.util.Vector;
/** /**
* This class centralizes all security properties and common security methods. * This class centralizes all security properties and common security methods.
* One of its primary uses is to manage providers. * One of its primary uses is to manage security providers.
* *
* @author Mark Benvenuto (ivymccough@worldnet.att.net) * @author Mark Benvenuto (ivymccough@worldnet.att.net)
*/ */
...@@ -102,7 +102,12 @@ public final class Security ...@@ -102,7 +102,12 @@ public final class Security
System.err.println System.err.println
(" Falling back to standard GNU security provider"); (" Falling back to standard GNU security provider");
} }
// Note that this matches our classpath.security file.
providers.addElement (new gnu.java.security.provider.Gnu()); providers.addElement (new gnu.java.security.provider.Gnu());
providers.addElement(new gnu.javax.crypto.jce.GnuCrypto());
providers.addElement(new gnu.javax.crypto.jce.GnuSasl());
providers.addElement(new gnu.javax.net.ssl.provider.Jessie());
providers.addElement(new gnu.javax.security.auth.callback.GnuCallbacks());
} }
} }
// This class can't be instantiated. // This class can't be instantiated.
...@@ -111,9 +116,9 @@ public final class Security ...@@ -111,9 +116,9 @@ public final class Security
} }
/** /**
* Tries to load the vender specific security providers from the given * Tries to load the vender specific security providers from the given base
* base URL. Returns true if the resource could be read and completely * URL. Returns true if the resource could be read and completely parsed
* parsed successfully, false otherwise. * successfully, false otherwise.
*/ */
private static boolean loadProviders(String baseUrl, String vendor) private static boolean loadProviders(String baseUrl, String vendor)
{ {
...@@ -134,7 +139,8 @@ public final class Security ...@@ -134,7 +139,8 @@ public final class Security
Exception exception = null; Exception exception = null;
try try
{ {
providers.addElement(Class.forName(name).newInstance()); ClassLoader sys = ClassLoader.getSystemClassLoader();
providers.addElement(Class.forName(name, true, sys).newInstance());
} }
catch (ClassNotFoundException x) catch (ClassNotFoundException x)
{ {
...@@ -167,22 +173,18 @@ public final class Security ...@@ -167,22 +173,18 @@ public final class Security
} }
/** /**
* Gets a specified property for an algorithm. The algorithm name should be a * Returns the value associated to a designated property name for a given
* standard name. See Appendix A in the Java Cryptography Architecture API * algorithm.
* Specification &amp; Reference for information about standard algorithm
* names. One possible use is by specialized algorithm parsers, which may map
* classes to algorithms which they understand (much like {@link Key} parsers
* do).
* *
* @param algName the algorithm name. * @param algName
* @param propName the name of the property to get. * the algorithm name.
* @return the value of the specified property. * @param propName
* @deprecated This method used to return the value of a proprietary property * the name of the property to return.
* in the master file of the "SUN" Cryptographic Service Provider in order to * @return the value of the specified property or <code>null</code> if none
* determine how to parse algorithm-specific parameters. Use the new * found.
* provider-based and algorithm-independent {@link AlgorithmParameters} and * @deprecated Use the provider-based and algorithm-independent
* {@link KeyFactory} engine classes (introduced in the Java 2 platform) * {@link AlgorithmParameters} and {@link KeyFactory} engine
* instead. * classes instead.
*/ */
public static String getAlgorithmProperty(String algName, String propName) public static String getAlgorithmProperty(String algName, String propName)
{ {
...@@ -205,37 +207,21 @@ public final class Security ...@@ -205,37 +207,21 @@ public final class Security
} }
/** /**
* <p>Adds a new provider, at a specified position. The position is the * Inserts a new designated {@link Provider} at a designated (1-based)
* preference order in which providers are searched for requested algorithms. * position in the current list of installed {@link Provider}s,
* Note that it is not guaranteed that this preference will be respected. The
* position is 1-based, that is, <code>1</code> is most preferred, followed by
* <code>2</code>, and so on.</p>
* *
* <p>If the given provider is installed at the requested position, the * @param provider
* provider that used to be at that position, and all providers with a * the new {@link Provider} to add.
* position greater than position, are shifted up one position (towards the * @param position
* end of the list of installed providers).</p> * the position (starting from 1) of where to install
* * <code>provider</code>.
* <p>A provider cannot be added if it is already installed.</p> * @return the actual position, in the list of installed Providers. Returns
* * <code>-1</code> if <code>provider</code> was laready in the
* <p>First, if there is a security manager, its <code>checkSecurityAccess() * list. The actual position may be different than the desired
* </code> method is called with the string <code>"insertProvider."+provider. * <code>position</code>.
* getName()</code> to see if it's ok to add a new provider. If the default * @throws SecurityException
* implementation of <code>checkSecurityAccess()</code> is used (i.e., that * if a {@link SecurityManager} is installed and it disallows this
* method is not overriden), then this will result in a call to the security * operation.
* manager's <code>checkPermission()</code> method with a
* <code>SecurityPermission("insertProvider."+provider.getName())</code>
* permission.</p>
*
* @param provider the provider to be added.
* @param position the preference position that the caller would like for
* this provider.
* @return the actual preference position in which the provider was added, or
* <code>-1</code> if the provider was not added because it is already
* installed.
* @throws SecurityException if a security manager exists and its
* {@link SecurityManager#checkSecurityAccess(String)} method denies access
* to add a new provider.
* @see #getProvider(String) * @see #getProvider(String)
* @see #removeProvider(String) * @see #removeProvider(String)
* @see SecurityPermission * @see SecurityPermission
...@@ -265,24 +251,17 @@ public final class Security ...@@ -265,24 +251,17 @@ public final class Security
} }
/** /**
* <p>Adds a provider to the next position available.</p> * Appends the designated new {@link Provider} to the current list of
* * installed {@link Provider}s.
* <p>First, if there is a security manager, its <code>checkSecurityAccess()
* </code> method is called with the string <code>"insertProvider."+provider.
* getName()</code> to see if it's ok to add a new provider. If the default
* implementation of <code>checkSecurityAccess()</code> is used (i.e., that
* method is not overriden), then this will result in a call to the security
* manager's <code>checkPermission()</code> method with a
* <code>SecurityPermission("insertProvider."+provider.getName())</code>
* permission.</p>
* *
* @param provider the provider to be added. * @param provider
* @return the preference position in which the provider was added, or * the new {@link Provider} to append.
* <code>-1</code> if the provider was not added because it is already * @return the position (starting from 1) of <code>provider</code> in the
* installed. * current list of {@link Provider}s, or <code>-1</code> if
* @throws SecurityException if a security manager exists and its * <code>provider</code> was already there.
* {@link SecurityManager#checkSecurityAccess(String)} method denies access * @throws SecurityException
* to add a new provider. * if a {@link SecurityManager} is installed and it disallows this
* operation.
* @see #getProvider(String) * @see #getProvider(String)
* @see #removeProvider(String) * @see #removeProvider(String)
* @see SecurityPermission * @see SecurityPermission
...@@ -293,26 +272,14 @@ public final class Security ...@@ -293,26 +272,14 @@ public final class Security
} }
/** /**
* <p>Removes the provider with the specified name.</p> * Removes an already installed {@link Provider}, given its name, from the
* * current list of installed {@link Provider}s.
* <p>When the specified provider is removed, all providers located at a
* position greater than where the specified provider was are shifted down
* one position (towards the head of the list of installed providers).</p>
*
* <p>This method returns silently if the provider is not installed.</p>
*
* <p>First, if there is a security manager, its <code>checkSecurityAccess()
* </code> method is called with the string <code>"removeProvider."+name</code>
* to see if it's ok to remove the provider. If the default implementation of
* <code>checkSecurityAccess()</code> is used (i.e., that method is not
* overriden), then this will result in a call to the security manager's
* <code>checkPermission()</code> method with a <code>SecurityPermission(
* "removeProvider."+name)</code> permission.</p>
* *
* @param name the name of the provider to remove. * @param name
* @throws SecurityException if a security manager exists and its * the name of an already installed {@link Provider} to remove.
* {@link SecurityManager#checkSecurityAccess(String)} method denies access * @throws SecurityException
* to remove the provider. * if a {@link SecurityManager} is installed and it disallows this
* operation.
* @see #getProvider(String) * @see #getProvider(String)
* @see #addProvider(Provider) * @see #addProvider(Provider)
*/ */
...@@ -334,8 +301,8 @@ public final class Security ...@@ -334,8 +301,8 @@ public final class Security
} }
/** /**
* Returns an array containing all the installed providers. The order of the * Returns the current list of installed {@link Provider}s as an array
* providers in the array is their preference order. * ordered according to their installation preference order.
* *
* @return an array of all the installed providers. * @return an array of all the installed providers.
*/ */
...@@ -347,11 +314,13 @@ public final class Security ...@@ -347,11 +314,13 @@ public final class Security
} }
/** /**
* Returns the provider installed with the specified name, if any. Returns * Returns an already installed {@link Provider} given its name.
* <code>null</code> if no provider with the specified name is installed.
* *
* @param name the name of the provider to get. * @param name
* @return the provider of the specified name. * the name of an already installed {@link Provider}.
* @return the {@link Provider} known by <code>name</code>. Returns
* <code>null</code> if the current list of {@link Provider}s does
* not include one named <code>name</code>.
* @see #removeProvider(String) * @see #removeProvider(String)
* @see #addProvider(Provider) * @see #addProvider(Provider)
*/ */
...@@ -377,18 +346,16 @@ public final class Security ...@@ -377,18 +346,16 @@ public final class Security
} }
/** /**
* <p>Gets a security property value.</p> * Returns the value associated with a Security propery.
* *
* <p>First, if there is a security manager, its <code>checkPermission()</code> * @param key
* method is called with a <code>SecurityPermission("getProperty."+key)</code> * the key of the property to fetch.
* permission to see if it's ok to retrieve the specified security property * @return the value of the Security property associated with
* value.</p> * <code>key</code>. Returns <code>null</code> if no such property
* * was found.
* @param key the key of the property being retrieved. * @throws SecurityException
* @return the value of the security property corresponding to key. * if a {@link SecurityManager} is installed and it disallows this
* @throws SecurityException if a security manager exists and its * operation.
* {@link SecurityManager#checkPermission(Permission)} method denies access
* to retrieve the specified security property value.
* @see #setProperty(String, String) * @see #setProperty(String, String)
* @see SecurityPermission * @see SecurityPermission
*/ */
...@@ -407,18 +374,15 @@ public final class Security ...@@ -407,18 +374,15 @@ public final class Security
} }
/** /**
* <p>Sets a security property value.</p> * Sets or changes a designated Security property to a designated value.
*
* <p>First, if there is a security manager, its <code>checkPermission()</code>
* method is called with a <code>SecurityPermission("setProperty."+key)</code>
* permission to see if it's ok to set the specified security property value.
* </p>
* *
* @param key the name of the property to be set. * @param key
* @param datum the value of the property to be set. * the name of the property to set.
* @throws SecurityException if a security manager exists and its * @param datum
* {@link SecurityManager#checkPermission(Permission)} method denies access * the new value of the property.
* to set the specified security property value. * @throws SecurityException
* if a {@link SecurityManager} is installed and it disallows this
* operation.
* @see #getProperty(String) * @see #getProperty(String)
* @see SecurityPermission * @see SecurityPermission
*/ */
...@@ -435,19 +399,16 @@ public final class Security ...@@ -435,19 +399,16 @@ public final class Security
} }
/** /**
* Returns a Set of Strings containing the names of all available algorithms * For a given <i>service</i> (e.g. Signature, MessageDigest, etc...) this
* or types for the specified Java cryptographic service (e.g., Signature, * method returns the {@link Set} of all available algorithm names (instances
* MessageDigest, Cipher, Mac, KeyStore). Returns an empty Set if there is no * of {@link String}, from all currently installed {@link Provider}s.
* provider that supports the specified service. For a complete list of Java
* cryptographic services, please see the Java Cryptography Architecture API
* Specification &amp; Reference. Note: the returned set is immutable.
* *
* @param serviceName the name of the Java cryptographic service (e.g., * @param serviceName
* Signature, MessageDigest, Cipher, Mac, KeyStore). Note: this parameter is * the case-insensitive name of a service (e.g. Signature,
* case-insensitive. * MessageDigest, etc).
* @return a Set of Strings containing the names of all available algorithms * @return a {@link Set} of {@link String}s containing the names of all
* or types for the specified Java cryptographic service or an empty set if * algorithm names provided by all of the currently installed
* no provider supports the specified service. * {@link Provider}s.
* @since 1.4 * @since 1.4
*/ */
public static Set getAlgorithms(String serviceName) public static Set getAlgorithms(String serviceName)
...@@ -480,53 +441,48 @@ public final class Security ...@@ -480,53 +441,48 @@ public final class Security
} }
/** /**
* <p>Returns an array containing all installed providers that satisfy the * Returns an array of currently installed {@link Provider}s, ordered
* specified selection criterion, or <code>null</code> if no such providers * according to their installation preference order, which satisfy a given
* have been installed. The returned providers are ordered according to their * <i>selection</i> criterion.
* preference order.</p>
* *
* <p>A cryptographic service is always associated with a particular * <p>This implementation recognizes a <i>selection</i> criterion written in
* algorithm or type. For example, a digital signature service is always * one of two following forms:</p>
* associated with a particular algorithm (e.g., <i>DSA</i>), and a
* CertificateFactory service is always associated with a particular
* certificate type (e.g., <i>X.509</i>).</p>
*
* <p>The selection criterion must be specified in one of the following two
* formats:</p>
* *
* <ul> * <ul>
* <li><p>&lt;crypto_service&gt;.&lt;algorithm_or_type&gt;</p> * <li>&lt;crypto_service&gt;.&lt;algorithm_or_type&gt;: Where
* <p>The cryptographic service name must not contain any dots.</p> * <i>crypto_service</i> is a case-insensitive string, similar to what has
* <p>A provider satisfies the specified selection criterion iff the * been described in the {@link #getAlgorithms(String)} method, and
* provider implements the specified algorithm or type for the specified * <i>algorithm_or_type</i> is a known case-insensitive name of an
* cryptographic service.</p> * Algorithm, or one of its aliases.
* <p>For example, "CertificateFactory.X.509" would be satisfied by any
* provider that supplied a CertificateFactory implementation for X.509
* certificates.</p></li>
* *
* <li><p>&lt;crypto_service&gt;.&lt;algorithm_or_type&gt; &lt;attribute_name&gt;:&lt;attribute_value&gt;</p> * <p>For example, "CertificateFactory.X.509" would return all the installed
* <p>The cryptographic service name must not contain any dots. There must * {@link Provider}s which provide a <i>CertificateFactory</i>
* be one or more space charaters between the the &lt;algorithm_or_type&gt; * implementation of <i>X.509</i>.</p></li>
* and the &lt;attribute_name&gt;.</p>
* <p>A provider satisfies this selection criterion iff the provider
* implements the specified algorithm or type for the specified
* cryptographic service and its implementation meets the constraint
* expressed by the specified attribute name/value pair.</p>
* <p>For example, "Signature.SHA1withDSA KeySize:1024" would be satisfied
* by any provider that implemented the SHA1withDSA signature algorithm
* with a keysize of 1024 (or larger).</p></li>
* </ul>
* *
* <p>See Appendix A in the Java Cryptogaphy Architecture API Specification * <li>&lt;crypto_service&gt;.&lt;algorithm_or_type&gt; &lt;attribute_name&gt;:&lt;value&gt;:
* &amp; Reference for information about standard cryptographic service names, * Where <i>crypto_service</i> is a case-insensitive string, similar to what
* standard algorithm names and standard attribute names.</p> * has been described in the {@link #getAlgorithms(String)} method,
* <i>algorithm_or_type</i> is a case-insensitive known name of an Algorithm
* or one of its aliases, <i>attribute_name</i> is a case-insensitive
* property name with no whitespace characters, and no dots, in-between, and
* <i>value</i> is a {@link String} with no whitespace characters in-between.
* *
* @param filter the criterion for selecting providers. The filter is case- * <p>For example, "Signature.Sha1WithDSS KeySize:1024" would return all the
* insensitive. * installed {@link Provider}s which declared their ability to provide
* @return all the installed providers that satisfy the selection criterion, * <i>Signature</i> services, using the <i>Sha1WithDSS</i> algorithm with
* or null if no such providers have been installed. * key sizes of <i>1024</i>.</p></li>
* @throws InvalidParameterException if the filter is not in the required * </ul>
* format. *
* @param filter
* the <i>selection</i> criterion for selecting among the installed
* {@link Provider}s.
* @return all the installed {@link Provider}s which satisfy the <i>selection</i>
* criterion. Returns <code>null</code> if no installed
* {@link Provider}s were found which satisfy the <i>selection</i>
* criterion. Returns ALL installed {@link Provider}s if
* <code>filter</code> is <code>null</code> or is an empty string.
* @throws InvalidParameterException
* if an exception occurs while parsing the <code>filter</code>.
* @see #getProviders(Map) * @see #getProviders(Map)
*/ */
public static Provider[] getProviders(String filter) public static Provider[] getProviders(String filter)
...@@ -548,45 +504,44 @@ public final class Security ...@@ -548,45 +504,44 @@ public final class Security
} }
/** /**
* <p>Returns an array containing all installed providers that satisfy the * Returns an array of currently installed {@link Provider}s which satisfy a
* specified selection criteria, or <code>null</code> if no such providers * set of <i>selection</i> criteria.
* have been installed. The returned providers are ordered according to their
* preference order.</p>
* *
* <p>The selection criteria are represented by a map. Each map entry * <p>The <i>selection</i> criteria are defined in a {@link Map} where each
* represents a selection criterion. A provider is selected iff it satisfies * element specifies a <i>selection</i> querry. The <i>Keys</i> in this
* all selection criteria. The key for any entry in such a map must be in one * {@link Map} must be in one of the two following forms:</p>
* of the following two formats:</p>
* *
* <ul> * <ul>
* <li><p>&lt;crypto_service&gt;.&lt;algorithm_or_type&gt;</p> * <li>&lt;crypto_service&gt;.&lt;algorithm_or_type&gt;: Where
* <p>The cryptographic service name must not contain any dots.</p> * <i>crypto_service</i> is a case-insensitive string, similar to what has
* <p>The value associated with the key must be an empty string.</p> * been described in the {@link #getAlgorithms(String)} method, and
* <p>A provider satisfies this selection criterion iff the provider * <i>algorithm_or_type</i> is a case-insensitive known name of an
* implements the specified algorithm or type for the specified * Algorithm, or one of its aliases. The <i>value</i> of the entry in the
* cryptographic service.</p></li> * {@link Map} for such a <i>Key</i> MUST be the empty string.
* {@link Provider}s which provide an implementation for the designated
* <i>service algorithm</i> are included in the result.</li>
* *
* <li><p>&lt;crypto_service&gt;.&lt;algorithm_or_type&gt; &lt;attribute_name&gt;</p> * <li>&lt;crypto_service&gt;.&lt;algorithm_or_type&gt; &lt;attribute_name&gt;:
* <p>The cryptographic service name must not contain any dots. There must * Where <i>crypto_service</i> is a case-insensitive string, similar to what
* be one or more space charaters between the &lt;algorithm_or_type&gt; and * has been described in the {@link #getAlgorithms(String)} method,
* the &lt;attribute_name&gt;.</p> * <i>algorithm_or_type</i> is a case-insensitive known name of an Algorithm
* <p>The value associated with the key must be a non-empty string. A * or one of its aliases, and <i>attribute_name</i> is a case-insensitive
* provider satisfies this selection criterion iff the provider implements * property name with no whitespace characters, and no dots, in-between. The
* the specified algorithm or type for the specified cryptographic service * <i>value</i> of the entry in this {@link Map} for such a <i>Key</i> MUST
* and its implementation meets the constraint expressed by the specified * NOT be <code>null</code> or an empty string. {@link Provider}s which
* attribute name/value pair.</p></li> * declare the designated <i>attribute_name</i> and <i>value</i> for the
* designated <i>service algorithm</i> are included in the result.</li>
* </ul> * </ul>
* *
* <p>See Appendix A in the Java Cryptogaphy Architecture API Specification * @param filter
* &amp; Reference for information about standard cryptographic service names, * a {@link Map} of <i>selection querries</i>.
* standard algorithm names and standard attribute names.</p> * @return all currently installed {@link Provider}s which satisfy ALL the
* * <i>selection</i> criteria defined in <code>filter</code>.
* @param filter the criteria for selecting providers. The filter is case- * Returns ALL installed {@link Provider}s if <code>filter</code>
* insensitive. * is <code>null</code> or empty.
* @return all the installed providers that satisfy the selection criteria, * @throws InvalidParameterException
* or <code>null</code> if no such providers have been installed. * if an exception is encountered while parsing the syntax of the
* @throws InvalidParameterException if the filter is not in the required * {@link Map}'s <i>keys</i>.
* format.
* @see #getProviders(String) * @see #getProviders(String)
*/ */
public static Provider[] getProviders(Map filter) public static Provider[] getProviders(Map filter)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment