Provider (Java 2 Platform SE 5.0) (original) (raw)
java.security
Class Provider
java.lang.Object
java.util.Dictionary<K,V>
java.util.Hashtable<Object,Object>
java.util.Properties
java.security.Provider
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>
Direct Known Subclasses:
public abstract class Provider
extends Properties
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:
- Algorithms (such as DSA, RSA, MD5 or SHA-1).
- Key generation, conversion, and management facilities (such as for algorithm-specific keys).
Each provider has a name and a version number, and is configured in each runtime it is installed in.
See The Provider Class in the "Java Cryptography Architecture API Specification & Reference" for information about how a particular type of provider, the cryptographic service provider, works and is installed. However, 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.
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.
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:
Name | Value |
---|---|
Provider.id name | String.valueOf(provider.getName()) |
Provider.id version | String.valueOf(provider.getVersion()) |
Provider.id info | String.valueOf(provider.getInfo()) |
Provider.id className | provider.getClass().getName() |
See Also:
Nested Class Summary | |
---|---|
static class | Provider.Service The description of a security service. |
Field Summary |
---|
Fields inherited from class java.util.Properties |
---|
defaults |
Constructor Summary | |
---|---|
protected | [Provider](../../java/security/Provider.html#Provider%28java.lang.String, double, java.lang.String%29)(String name, double version,String info) Constructs a provider with the specified name, version number, and information. |
Method Summary | |
---|---|
void | clear() Clears this provider so that it no longer contains the properties used to look up facilities implemented by the provider. |
Set<Map.Entry<Object,Object>> | entrySet() Returns an unmodifiable Set view of the property entries contained in this Provider. |
String | getInfo() Returns a human-readable description of the provider and its services. |
String | getName() Returns the name of this provider. |
Provider.Service | [getService](../../java/security/Provider.html#getService%28java.lang.String, java.lang.String%29)(String type,String algorithm) Get the service describing this Provider's implementation of the specified type of this algorithm or alias. |
Set<Provider.Service> | getServices() Get an unmodifiable Set of all services supported by this Provider. |
double | getVersion() Returns the version number for this provider. |
Set<Object> | keySet() Returns an unmodifiable Set view of the property keys contained in this provider. |
void | load(InputStream inStream) Reads a property list (key and element pairs) from the input stream. |
Object | [put](../../java/security/Provider.html#put%28java.lang.Object, java.lang.Object%29)(Object key,Object value) Sets the key property to have the specifiedvalue. |
void | putAll(Map t) Copies all of the mappings from the specified Map to this provider. |
protected void | putService(Provider.Service s) Add a service. |
Object | remove(Object key) Removes the key property (and its correspondingvalue). |
protected void | removeService(Provider.Service s) Remove a service previously added using putService(). |
String | toString() Returns a string with the name and the version number of this provider. |
Collection<Object> | values() Returns an unmodifiable Collection view of the property values contained in this provider. |
Methods inherited from class java.util.Properties |
---|
getProperty, [getProperty](../../java/util/Properties.html#getProperty%28java.lang.String, java.lang.String%29), list, list, loadFromXML, propertyNames, [save](../../java/util/Properties.html#save%28java.io.OutputStream, java.lang.String%29), [setProperty](../../java/util/Properties.html#setProperty%28java.lang.String, java.lang.String%29), [store](../../java/util/Properties.html#store%28java.io.OutputStream, java.lang.String%29), [storeToXML](../../java/util/Properties.html#storeToXML%28java.io.OutputStream, java.lang.String%29), [storeToXML](../../java/util/Properties.html#storeToXML%28java.io.OutputStream, java.lang.String, java.lang.String%29) |
Methods inherited from class java.util.Hashtable |
---|
clone, contains, containsKey, containsValue, elements, equals, get, hashCode, isEmpty, keys, rehash, size |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29) |
Constructor Detail |
---|
Provider
protected Provider(String name, double version, String info)
Constructs a provider with the specified name, version number, and information.
Parameters:
name
- the provider name.
version
- the provider version number.
info
- a description of the provider and its services.
Method Detail |
---|
getName
public String getName()
Returns the name of this provider.
Returns:
the name of this provider.
getVersion
public double getVersion()
Returns the version number for this provider.
Returns:
the version number for this provider.
getInfo
public String getInfo()
Returns a human-readable description of the provider and its services. This may return an HTML page, with relevant links.
Returns:
a description of the provider and its services.
toString
public String toString()
Returns a string with the name and the version number of this provider.
Overrides:
[toString](../../java/util/Hashtable.html#toString%28%29)
in class [Hashtable](../../java/util/Hashtable.html "class in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Returns:
the string with the name and the version number for this provider.
clear
public void clear()
Clears this provider so that it no longer contains the properties used to look up facilities implemented by the provider.
First, if there is a security manager, its checkSecurityAccess
method is called with the string "clearProviderProperties."+name
(where name
is the provider name) to see if it's ok to clear this provider. If the default implementation of checkSecurityAccess
is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission
method with a SecurityPermission("clearProviderProperties."+name)
permission.
Specified by:
[clear](../../java/util/Map.html#clear%28%29)
in interface [Map](../../java/util/Map.html "interface in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Overrides:
[clear](../../java/util/Hashtable.html#clear%28%29)
in class [Hashtable](../../java/util/Hashtable.html "class in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Throws:
[SecurityException](../../java/lang/SecurityException.html "class in java.lang")
- if a security manager exists and its [SecurityManager.checkSecurityAccess(java.lang.String)](../../java/lang/SecurityManager.html#checkSecurityAccess%28java.lang.String%29)
method denies access to clear this provider
Since:
1.2
load
public void load(InputStream inStream) throws IOException
Reads a property list (key and element pairs) from the input stream.
Overrides:
[load](../../java/util/Properties.html#load%28java.io.InputStream%29)
in class [Properties](../../java/util/Properties.html "class in java.util")
Parameters:
inStream
- the input stream.
Throws:
[IOException](../../java/io/IOException.html "class in java.io")
- if an error occurred when reading from the input stream.
See Also:
Properties.load(java.io.InputStream)
putAll
public void putAll(Map t)
Copies all of the mappings from the specified Map to this provider. These mappings will replace any properties that this provider had for any of the keys currently in the specified Map.
Specified by:
[putAll](../../java/util/Map.html#putAll%28java.util.Map%29)
in interface [Map](../../java/util/Map.html "interface in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Overrides:
[putAll](../../java/util/Hashtable.html#putAll%28java.util.Map%29)
in class [Hashtable](../../java/util/Hashtable.html "class in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Parameters:
t
- Mappings to be stored in this map.
Since:
1.2
entrySet
public Set<Map.Entry<Object,Object>> entrySet()
Returns an unmodifiable Set view of the property entries contained in this Provider.
Specified by:
[entrySet](../../java/util/Map.html#entrySet%28%29)
in interface [Map](../../java/util/Map.html "interface in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Overrides:
[entrySet](../../java/util/Hashtable.html#entrySet%28%29)
in class [Hashtable](../../java/util/Hashtable.html "class in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Returns:
a set view of the mappings contained in this map.
Since:
1.2
See Also:
keySet
Returns an unmodifiable Set view of the property keys contained in this provider.
Specified by:
[keySet](../../java/util/Map.html#keySet%28%29)
in interface [Map](../../java/util/Map.html "interface in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Overrides:
[keySet](../../java/util/Hashtable.html#keySet%28%29)
in class [Hashtable](../../java/util/Hashtable.html "class in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Returns:
a set view of the keys contained in this map.
Since:
1.2
values
public Collection<Object> values()
Returns an unmodifiable Collection view of the property values contained in this provider.
Specified by:
[values](../../java/util/Map.html#values%28%29)
in interface [Map](../../java/util/Map.html "interface in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Overrides:
[values](../../java/util/Hashtable.html#values%28%29)
in class [Hashtable](../../java/util/Hashtable.html "class in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Returns:
a collection view of the values contained in this map.
Since:
1.2
put
public Object put(Object key, Object value)
Sets the key
property to have the specifiedvalue
.
First, if there is a security manager, its checkSecurityAccess
method is called with the string "putProviderProperty."+name
, where name
is the provider name, to see if it's ok to set this provider's property values. If the default implementation of checkSecurityAccess
is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission
method with a SecurityPermission("putProviderProperty."+name)
permission.
Specified by:
[put](../../java/util/Map.html#put%28K, V%29)
in interface [Map](../../java/util/Map.html "interface in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Overrides:
[put](../../java/util/Hashtable.html#put%28K, V%29)
in class [Hashtable](../../java/util/Hashtable.html "class in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Parameters:
key
- the property key.
value
- the property value.
Returns:
the previous value of the specified property (key
), or null if it did not have one.
Throws:
[SecurityException](../../java/lang/SecurityException.html "class in java.lang")
- if a security manager exists and its [SecurityManager.checkSecurityAccess(java.lang.String)](../../java/lang/SecurityManager.html#checkSecurityAccess%28java.lang.String%29)
method denies access to set property values.
Since:
1.2
See Also:
Object.equals(Object), Hashtable.get(Object)
remove
public Object remove(Object key)
Removes the key
property (and its correspondingvalue
).
First, if there is a security manager, its checkSecurityAccess
method is called with the string "removeProviderProperty."+name
, where name
is the provider name, to see if it's ok to remove this provider's properties. If the default implementation of checkSecurityAccess
is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission
method with aSecurityPermission("removeProviderProperty."+name)
permission.
Specified by:
[remove](../../java/util/Map.html#remove%28java.lang.Object%29)
in interface [Map](../../java/util/Map.html "interface in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Overrides:
[remove](../../java/util/Hashtable.html#remove%28java.lang.Object%29)
in class [Hashtable](../../java/util/Hashtable.html "class in java.util")<[Object](../../java/lang/Object.html "class in java.lang"),[Object](../../java/lang/Object.html "class in java.lang")>
Parameters:
key
- the key for the property to be removed.
Returns:
the value to which the key had been mapped, or null if the key did not have a mapping.
Throws:
[SecurityException](../../java/lang/SecurityException.html "class in java.lang")
- if a security manager exists and its [SecurityManager.checkSecurityAccess(java.lang.String)](../../java/lang/SecurityManager.html#checkSecurityAccess%28java.lang.String%29)
method denies access to remove this provider's properties.
Since:
1.2
getService
public Provider.Service getService(String type, String algorithm)
Get the service describing this Provider's implementation of the specified type of this algorithm or alias. If no such implementation exists, this method returns null. If there are two matching services, one added to this provider using putService() and one added via [put()](../../java/security/Provider.html#put%28java.lang.Object, java.lang.Object%29), the service added via putService() is returned.
Parameters:
type
- the type of service requested (for example, MessageDigest
)
algorithm
- the case insensitive algorithm name (or alternate alias) of the service requested (for example, SHA-1
)
Returns:
the service describing this Provider's matching service or null if no such service exists
Throws:
[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")
- if type or algorithm is null
Since:
1.5
getServices
public Set<Provider.Service> getServices()
Get an unmodifiable Set of all services supported by this Provider.
Returns:
an unmodifiable Set of all services supported by this Provider
Since:
1.5
putService
protected void putService(Provider.Service s)
Add a service. If a service of the same type with the same algorithm name exists and it was added using putService(), it is replaced by the new service. This method also places information about this service in the provider's Hashtable values in the format described in the Java Cryptography Architecture API Specification & Reference .
Also, if there is a security manager, its checkSecurityAccess
method is called with the string "putProviderProperty."+name
, where name
is the provider name, to see if it's ok to set this provider's property values. If the default implementation of checkSecurityAccess
is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission
method with a SecurityPermission("putProviderProperty."+name)
permission.
Parameters:
s
- the Service to add
Throws:
[SecurityException](../../java/lang/SecurityException.html "class in java.lang")
- if a security manager exists and its [SecurityManager.checkSecurityAccess(java.lang.String)](../../java/lang/SecurityManager.html#checkSecurityAccess%28java.lang.String%29)
method denies access to set property values.
[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")
- if s is null
Since:
1.5
removeService
protected void removeService(Provider.Service s)
Remove a service previously added using putService(). The specified service is removed from this provider. It will no longer be returned by [getService()](../../java/security/Provider.html#getService%28java.lang.String, java.lang.String%29) and its information will be removed from this provider's Hashtable.
Also, if there is a security manager, its checkSecurityAccess
method is called with the string "removeProviderProperty."+name
, where name
is the provider name, to see if it's ok to remove this provider's properties. If the default implementation of checkSecurityAccess
is used (that is, that method is not overriden), then this results in a call to the security manager's checkPermission
method with aSecurityPermission("removeProviderProperty."+name)
permission.
Parameters:
s
- the Service to be removed
Throws:
[SecurityException](../../java/lang/SecurityException.html "class in java.lang")
- if a security manager exists and its [SecurityManager.checkSecurityAccess(java.lang.String)](../../java/lang/SecurityManager.html#checkSecurityAccess%28java.lang.String%29)
method denies access to remove this provider's properties.
[NullPointerException](../../java/lang/NullPointerException.html "class in java.lang")
- if s is null
Since:
1.5
Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.