Provider
public static class Provider.Service extends Object
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.
Constructor | Description |
---|---|
Service |
Construct a new service. |
Modifier and Type | Method | Description |
---|---|---|
final String |
getAlgorithm() |
Return the name of the algorithm of this service. |
final String |
getAttribute |
Return the value of the specified attribute or null if this attribute is not set for this Service. |
final String |
getClassName() |
Return the name of the class implementing this service. |
final Provider |
getProvider() |
Return the Provider of this service. |
final String |
getType() |
Get the type of this service. |
Object |
newInstance |
Return a new instance of the implementation described by this service. |
boolean |
supportsParameter |
Test whether this Service can use the specified parameter. |
String |
toString() |
Return a String representation of this service. |
public Service(Provider provider, String type, String algorithm, String className, List<String> aliases, Map<String,String> attributes)
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 or null
if algorithm has no aliasesattributes
- Map of attributes or null
if this implementation has no attributesNullPointerException
- if provider, type, algorithm, or className is null
public final String getType()
MessageDigest
.public final String getAlgorithm()
SHA-1
.public final Provider getProvider()
public final String getClassName()
public final String getAttribute(String name)
null
if this attribute is not set for this Service.name
- the name of the requested attributenull
if the attribute is not presentNullPointerException
- if name is null
public Object newInstance(Object constructorParameter) throws NoSuchAlgorithmException
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.
constructorParameter
- the value to pass to the constructor, or null
if this type of service does not use a constructorParameter.InvalidParameterException
- if the value of constructorParameter is invalid for this type of service.NoSuchAlgorithmException
- if instantiation failed for any other reason.public boolean supportsParameter(Object parameter)
false
if this service cannot use the parameter. Returns true
if 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.
parameter
- the parameter to testfalse
if this service cannot use the specified parameter; true
if it can possibly use the parameterInvalidParameterException
- if the value of parameter is invalid for this type of service or if this method cannot be used with this type of servicepublic String toString()
String
representation of this service.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/Provider.Service.html