Provider.Service

public static class Provider.Service extends Object

The description of a security service. It encapsulates the properties of a service and contains a factory method to obtain new implementation instances of this service.

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 instantes 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 API Specification & Reference 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.

Public Constructor Summary

Provider.Service(Provider provider, String type, String algorithm, String className, List<String> aliases, Map<StringString> attributes)
Construct a new service.

Public Method Summary

final String
getAlgorithm()
Return the name of the algorithm of this service.
final String
getAttribute(String name)
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(Object constructorParameter)
Return a new instance of the implementation described by this service.
boolean
supportsParameter(Object parameter)
Test whether this Service can use the specified parameter.
String
toString()
Return a String representation of this service.

Inherited Method Summary

Public Constructors

public Provider.Service (Provider provider, String type, String algorithm, String className, List<String> aliases, Map<StringString> attributes)

Construct a new service.

Parameters
provider the provider that offers this service
type the type of this service
algorithm the algorithm name
className the name of the class implementing this service
aliases List of aliases or null if algorithm has no aliases
attributes Map of attributes or null if this implementation has no attributes
Throws
NullPointerException if provider, type, algorithm, or className is null

Public Methods

public final String getAlgorithm ()

Return the name of the algorithm of this service. For example, SHA-1.

Returns
  • the algorithm of this service

public final String getAttribute (String name)

Return the value of the specified attribute or null if this attribute is not set for this Service.

Parameters
name the name of the requested attribute
Returns
  • the value of the specified attribute or null if the attribute is not present
Throws
NullPointerException if name is null

public final String getClassName ()

Return the name of the class implementing this service.

Returns
  • the name of the class implementing this service

public final Provider getProvider ()

Return the Provider of this service.

Returns
  • the Provider of this service

public final String getType ()

Get the type of this service. For example, MessageDigest.

Returns
  • the type of this service

public Object newInstance (Object constructorParameter)

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 API Specification & Reference.

Parameters
constructorParameter the value to pass to the constructor, or null if 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 instantation failed for any other reason.

public boolean supportsParameter (Object parameter)