Class Provider.Service
- Enclosing class:
Provider
Each service has a provider that offers the service, a type,
an algorithm name, and the name of the class that implements the
service. Optionally, it also includes a list of alternate algorithm
names for this service (aliases) and attributes, which are a map of
(name, value) String pairs.
This class defines the methods supportsParameter() and newInstance()
which are used by the Java security framework when it searches for
suitable services and instantiates them. The valid arguments to those
methods depend on the type of service. For the service types defined
within Java SE, see the
Java Cryptography Architecture (JCA) Reference Guide
for the valid values.
Note that components outside of Java SE can define additional types of
services and their behavior.
Instances of this class are immutable.
- Since:
- 1.5
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StringReturn the name of the algorithm of this service.final StringgetAttribute(String name) Return the value of the specified attribute ornullif this attribute is not set for this Service.final StringReturn the name of the class implementing this service.final ProviderReturn the Provider of this service.final StringgetType()Get the type of this service.newInstance(Object constructorParameter) Return a new instance of the implementation described by this service.booleansupportsParameter(Object parameter) Test whether this Service can use the specified parameter.toString()Return aStringrepresentation of this service.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
Service
public Service(Provider provider, String type, String algorithm, String className, List<String> aliases, Map<String, String> attributes) Construct a new service.- Parameters:
provider- the provider that offers this servicetype- the type of this servicealgorithm- the algorithm nameclassName- the name of the class implementing this servicealiases- List of aliases ornullif algorithm has no aliasesattributes- Map of attributes ornullif this implementation has no attributes- Throws:
NullPointerException- if provider, type, algorithm, or className isnull
-
-
Method Details
-
getType
Get the type of this service. For example,MessageDigest.- Returns:
- the type of this service
-
getAlgorithm
Return the name of the algorithm of this service. For example,SHA-1.- Returns:
- the algorithm of this service
-
getProvider
Return the Provider of this service.- Returns:
- the Provider of this service
-
getClassName
Return the name of the class implementing this service.- Returns:
- the name of the class implementing this service
-
getAttribute
Return the value of the specified attribute ornullif this attribute is not set for this Service.- Parameters:
name- the name of the requested attribute- Returns:
- the value of the specified attribute or
nullif the attribute is not present - Throws:
NullPointerException- if name isnull
-
newInstance
Return a new instance of the implementation described by this service. The security provider framework uses this method to construct implementations. Applications will typically not need to call it.The default implementation uses reflection to invoke the standard constructor for this type of service. Security providers can override this method to implement instantiation in a different way. For details and the values of constructorParameter that are valid for the various types of services see the Java Cryptography Architecture (JCA) Reference Guide.
- Parameters:
constructorParameter- the value to pass to the constructor, ornullif this type of service does not use a constructorParameter.- Returns:
- a new implementation of this service
- Throws:
InvalidParameterException- if the value of constructorParameter is invalid for this type of service.NoSuchAlgorithmException- if instantiation failed for any other reason.
-
supportsParameter
Test whether this Service can use the specified parameter. Returnsfalseif this service cannot use the parameter. Returnstrueif this service can use the parameter, if a fast test is infeasible, or if the status is unknown.The security provider framework uses this method with some types of services to quickly exclude non-matching implementations for consideration. Applications will typically not need to call it.
For details and the values of parameter that are valid for the various types of services see the top of this class and the Java Cryptography Architecture (JCA) Reference Guide. Security providers can override it to implement their own test.
- Parameters:
parameter- the parameter to test- Returns:
falseif this service cannot use the specified parameter;trueif it can possibly use the parameter- Throws:
InvalidParameterException- if the value of parameter is invalid for this type of service or if this method cannot be used with this type of service
-
toString
-