APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.security

public abstract Class Provider

extends Properties
Class Inheritance
Known Direct Subclasses
com.sun.crypto.provider.SunJCE, sun.security.provider.Sun, sun.security.provider.VerificationProvider, sun.security.rsa.SunRsaSign, sun.security.ec.SunEC, sun.security.ssl.HybridProvider.ProviderImpl, sun.security.ssl.SunJSSE, java.security.AuthProvider
Imports
jdk.internal.event.SecurityProviderServiceEvent, javax.crypto.KDFParameters, javax.security.auth.login.Configuration, java.io.*, java.security.cert.CertStoreParameters, java.util.*, java.lang.ref.*, java.lang.reflect.*, java.util.function.BiConsumer, .BiFunction, .Function, java.util.concurrent.ConcurrentHashMap

This class represents a "provider" for the Java Security API, where a provider implements some or all parts of Java Security. Services that a provider may implement include:

Some provider implementations may encounter unrecoverable internal errors during their operation, for example a failure to communicate with a security token. A ProviderException should be used to indicate such errors.

Please note that a provider can be used to implement any security service in Java that uses a pluggable architecture with a choice of implementations that fit underneath.

The service type Provider is reserved for use by the security framework. Services of this type cannot be added, removed, or modified by applications. The following attributes are automatically placed in each Provider object:

Attributes Automatically Placed in a Provider Object
NameValue
Provider.id name String.valueOf(provider.getName())
Provider.id version String.valueOf(provider.getVersionStr())
Provider.id info String.valueOf(provider.getInfo())
Provider.id className provider.getClass().getName()

Each provider has a name and a version string. A provider normally identifies itself with a file named java.security.Provider in the resource directory META-INF/services. Security providers are looked up via the ServiceLoader mechanism using the application class loader.

Providers may be configured such that they are automatically installed and made available at runtime via the Security.getProviders() method. The mechanism for configuring and installing security providers is implementation-specific.

Implementation Note

The JDK implementation supports static registration of the security providers via the conf/security/java.security file in the Java installation directory. These providers are automatically installed by the JDK runtime, see The Provider Class in the Java Cryptography Architecture (JCA) Reference Guide for information about how a particular type of provider, the cryptographic service provider, works and is installed.

Authors
Benjamin Renaud, Andreas Sterbenz
Since
1.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static enum
public static class
Provider.Service

The description of a security service.

private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final int
private static final String
private static final String
private static final Debug
private static final Object[]
private transient Set<Map.Entry<Object, Object>>
private transient int
private final String
info

A description of the provider and its services.

private transient boolean
private static final Map<String, Provider.EngineDescription>
private transient volatile boolean
private transient Map<Provider.ServiceKey, Provider.Service>
private final String
name

The provider name.

private static final ThreadLocal<Provider.ServiceKey>
private transient Set<String>
private static final long
private transient Map<Provider.ServiceKey, Provider.Service>
private transient volatile boolean
private transient volatile Set<Provider.Service>
private double
version

The provider version number.

private String
versionStr

The provider version string.

Inherited from java.util.Properties:
defaults

Constructor Summary

AccessConstructor and Description
protected
Provider(String
the provider name.
name
,
double
the provider version number.
version
,
String
a description of the provider and its services.
info
)
Deprecated since 9. use Provider(String, String, String) instead.

Constructs a Provider with the specified name, version number, and information.

protected
Provider(String
the provider name.
name
,
String
the provider version string.
versionStr
,
String
a description of the provider and its services.
info
)

Constructs a Provider with the specified name, version string, and information.

Method Summary

Modifier and TypeMethod and Description
private static void
addEngine(String name, boolean sp, Class<?> constructorParameterClass)

private void
checkAndUpdateSecureRandom(String type, String algo, boolean doAdd)

private void
private static boolean
public synchronized void
clear()

Overrides java.util.Properties.clear.

Implements java.util.Map.clear.

Clears this Provider so that it no longer contains the properties used to look up facilities implemented by the Provider.

public synchronized Object
compute(Object key, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction)

Overrides java.util.Properties.compute.

Overrides default java.util.Map.compute.

Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping).

public synchronized Object
computeIfAbsent(Object key, Function<? super Object, ? extends Object> mappingFunction)

Overrides java.util.Properties.computeIfAbsent.

Overrides default java.util.Map.computeIfAbsent.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.

public synchronized Object
computeIfPresent(Object key, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction)

Overrides java.util.Properties.computeIfPresent.

Overrides default java.util.Map.computeIfPresent.

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.

public Provider

Returns:

a Provider configured with the supplied configuration argument.
configure
(String
the configuration information for configuring this provider.
configArg
)

Apply the supplied configuration argument to this Provider instance and return the configured Provider.

public Enumeration<Object>
elements()

Overrides java.util.Properties.elements.

Returns an enumeration of the values in this hashtable.

public synchronized Set<Map.Entry<Object, Object>>
entrySet()

Overrides java.util.Properties.entrySet.

Implements java.util.Map.entrySet.

Returns an unmodifiable Set view of the property entries contained in this Provider.

public synchronized void
forEach(BiConsumer<? super Object, ? super Object> action)

Overrides java.util.Properties.forEach.

Overrides default java.util.Map.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.

public Object
get(Object key)

Overrides java.util.Properties.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

pack-priv Provider.Service
private static String
public String

Returns:

a description of the Provider and its services.
getInfo
()

Returns a human-readable description of the Provider and its services.

public String

Returns:

the name of this Provider.
getName
()

Returns the name of this Provider.

public synchronized Object
getOrDefault(Object key, Object defaultValue)

Overrides java.util.Properties.getOrDefault.

Overrides default java.util.Map.getOrDefault.

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

public String
getProperty(String key)

Overrides java.util.Properties.getProperty.

Searches for the property with the specified key in this property list.

public Provider.Service

Returns:

the service describing this Provider's matching service or null if no such service exists
getService
(String
the type of service requested (for example, MessageDigest)
type
,
String
the case-insensitive algorithm name (or alternate alias) of the service requested (for example, SHA-1)
algorithm
)

Get the service describing this Provider's implementation of the specified type of this algorithm or alias.

public Set<Provider.Service>

Returns:

an unmodifiable Set of all services supported by this Provider
getServices
()

Get an unmodifiable Set of all services supported by this Provider.

private static String[]
public double

Returns:

the version number for this Provider.
getVersion
()
Deprecated since 9. use getVersionStr instead.

Returns the version number for this Provider.

public String

Returns:

the version string for this Provider.
getVersionStr
()

Returns the version string for this Provider.

private void
private Object
implCompute(Object key, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction)

private Object
implComputeIfAbsent(Object key, Function<? super Object, ? extends Object> mappingFunction)

private Object
implComputeIfPresent(Object key, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction)

private Object
implMerge(Object key, Object value, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction)

private Object
implPut(Object key, Object value)

private void
implPutAll(Map<?, ?> t)

Copies all the mappings from the specified Map to this provider.

private Object
private Object
private boolean
implRemove(Object key, Object value)

private void
private boolean
implReplace(Object key, Object oldValue, Object newValue)

private Object
private void
implReplaceAll(BiFunction<? super Object, ? super Object, ? extends Object> function)

public boolean

Returns:

true if no further configuration is needed, false otherwise.
isConfigured
()

Check if this Provider instance has been configured.

public Enumeration<Object>
keys()

Overrides java.util.Properties.keys.

Returns an enumeration of the keys in this hashtable.

public Set<Object>
keySet()

Overrides java.util.Properties.keySet.

Implements java.util.Map.keySet.

Returns an unmodifiable Set view of the property keys contained in this Provider.

public synchronized void
load(InputStream
the input stream.
inStream
)

Overrides java.util.Properties.load.

Reads a property list (key and element pairs) from the input stream.

public synchronized Object
merge(Object key, Object value, BiFunction<? super Object, ? super Object, ? extends Object> remappingFunction)

Overrides java.util.Properties.merge.

Overrides default java.util.Map.merge.

If the specified key is not already associated with a value or is associated with null, associates it with the given value.

private void
parseLegacy(String name, String value, Provider.OPType opType)

private static double
public synchronized Object
put(Object key, Object value)

Overrides java.util.Properties.put.

Implements java.util.Map.put.

Sets the key property to have the specified value.

public synchronized void
putAll(Map<?, ?> t)

Overrides java.util.Properties.putAll.

Implements java.util.Map.putAll.

Copies all the mappings from the specified Map to this Provider.

private void
public synchronized Object
putIfAbsent(Object key, Object value)

Overrides java.util.Properties.putIfAbsent.

Overrides default java.util.Map.putIfAbsent.

If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value.

private void
putPropertyStrings(Provider.Service s)

Put the string properties for this Service in this Provider's Hashtable.

protected void
putService(Provider.Service
the Service to add
s
)

Add a service.

private void
readObject(ObjectInputStream
the ObjectInputStream to read
in
)

Hides java.util.Hashtable.readObject.

Reads the ObjectInputStream for the default serializable fields.

public synchronized Object
remove(Object key)

Overrides java.util.Properties.remove.

Implements java.util.Map.remove.

Removes the key property (and its corresponding value).

public synchronized boolean
remove(Object key, Object value)

Overrides java.util.Properties.remove.

Overrides default java.util.Map.remove.

Removes the entry for the specified key only if it is currently mapped to the specified value.

private void
removePropertyStrings(Provider.Service s)

Remove the string properties for this Service from this Provider's Hashtable.

protected void
removeService(Provider.Service
the Service to be removed
s
)

Remove a service previously added using putService().

public synchronized boolean
replace(Object key, Object oldValue, Object newValue)

Overrides java.util.Properties.replace.

Overrides default java.util.Map.replace.

Replaces the entry for the specified key only if currently mapped to the specified value.

public synchronized Object
replace(Object key, Object value)

Overrides java.util.Properties.replace.

Overrides default java.util.Map.replace.

Replaces the entry for the specified key only if it is currently mapped to some value.

public synchronized void
replaceAll(BiFunction<? super Object, ? super Object, ? extends Object> function)

Overrides java.util.Properties.replaceAll.

Overrides default java.util.Map.replaceAll.

Replaces each entry's value with the result of invoking the given function on that entry, in the order entries are returned by an entry set iterator, until all entries have been processed or the function throws an exception.

public String

Returns:

the string with the name and the version string for this Provider.
toString
()

Overrides java.util.Properties.toString.

Returns a string with the name and the version string of this Provider.

public Collection<Object>
values()

Overrides java.util.Properties.values.

Implements java.util.Map.values.

Returns an unmodifiable Collection view of the property values contained in this Provider.

Inherited from java.util.Properties:
clonecontainscontainsKeycontainsValueequalsgetPropertyhashCodeisEmptylistlistloadloadFromXMLpropertyNamesrehashsavesetPropertysizestorestorestoreToXMLstoreToXMLstoreToXMLstringPropertyNames