Added in API level 1

Service

open class Service
kotlin.Any
   ↳ java.security.Provider.Service

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 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 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.

Summary

Public constructors
Service(provider: Provider!, type: String!, algorithm: String!, className: String!, aliases: MutableList<String!>!, attributes: MutableMap<String!, String!>!)

Construct a new service.

Public methods
String!

Return the name of the algorithm of this service.

String!

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

String!

Return the name of the class implementing this service.

Provider!

Return the Provider of this service.

String!

Get the type of this service.

open Any!
newInstance(constructorParameter: Any!)

Return a new instance of the implementation described by this service.

open Boolean
supportsParameter(parameter: Any!)

Test whether this Service can use the specified parameter.

open String

Return a String representation of this service.

Public constructors

Service

Added in API level 1
Service(
    provider: Provider!,
    type: String!,
    algorithm: String!,
    className: String!,
    aliases: MutableList<String!>!,
    attributes: MutableMap<String!, String!>!)

Construct a new service.

Parameters
provider Provider!: the provider that offers this service
type String!: the type of this service
algorithm String!: the algorithm name
className String!: the name of the class implementing this service
aliases MutableList<String!>!: List of aliases or null if algorithm has no aliases
attributes MutableMap<String!, String!>!: Map of attributes or null if this implementation has no attributes
Exceptions
java.lang.NullPointerException if provider, type, algorithm, or className is null

Public methods

getAlgorithm

Added in API level 1
fun getAlgorithm(): String!

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

Return
String! the algorithm of this service

getAttribute

Added in API level 1
fun getAttribute(name: String!): String!

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

Parameters
name String!: the name of the requested attribute
Return
String! the value of the specified attribute or null if the attribute is not present
Exceptions
java.lang.NullPointerException if name is null

getClassName

Added in API level 1
fun getClassName(): String!

Return the name of the class implementing this service.

Return
String! the name of the class implementing this service

getProvider

Added in API level 1
fun getProvider(): Provider!

Return the Provider of this service.

Return
Provider! the Provider of this service

getType

Added in API level 1
fun getType(): String!

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

Return
String! the type of this service

newInstance

Added in API level 1
open fun newInstance(constructorParameter: Any!): Any!

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 Any!: the value to pass to the constructor, or null if this type of service does not use a constructorParameter.
Return
Any! a new implementation of this service
Exceptions
java.security.InvalidParameterException if the value of constructorParameter is invalid for this type of service.
java.security.NoSuchAlgorithmException if instantiation failed for any other reason.

supportsParameter

Added in API level 1
open fun supportsParameter(parameter: Any!): Boolean

Test whether this Service can use the specified parameter. Returns 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 API Specification & Reference. Security providers can override it to implement their own test.

Parameters
parameter Any!: the parameter to test
Return
Boolean false if this this service cannot use the specified parameter; true if it can possibly use the parameter
Exceptions
java.security.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

Added in API level 1
open fun toString(): String

Return a String representation of this service.

Return
String a String representation of this service.