Java Platform 1.2
Beta 4

Class java.security.Security

java.lang.Object
  |
  +--java.security.Security

public final class Security
extends Object

This class centralizes all security properties and common security methods. One of its primary uses is to manage providers.


Method Summary
static int addProvider(Provider provider)
          Adds a provider to the next position available.
static String getAlgorithmProperty(String algName, String propName)
          Deprecated. This method used to return the value of a proprietary property in the master file of the "SUN" Cryptographic Service Provider in order to determine how to parse algorithm-specific parameters. Use the new provider-based and algorithm-independent AlgorithmParameters and KeyFactory engine classes (introduced in JDK 1.2) instead.
static String getProperty(String key)
          Gets a security property.
static Provider getProvider(String name)
          Returns the provider installed with the specified name, if any.
static Provider[] getProviders()
          Returns an array containing all the installed providers.
static int insertProviderAt(Provider provider, int position)
          Adds a new provider, at a specified position.
static void removeProvider(String name)
          Removes the provider with the specified name.
static void setProperty(String key, String datum)
          Sets a security property.
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Method Detail

getAlgorithmProperty

public static String getAlgorithmProperty(String algName,
                                          String propName)
Deprecated. This method used to return the value of a proprietary property in the master file of the "SUN" Cryptographic Service Provider in order to determine how to parse algorithm-specific parameters. Use the new provider-based and algorithm-independent AlgorithmParameters and KeyFactory engine classes (introduced in JDK 1.2) instead.
Gets a specified property for an algorithm. The algorithm name should be a standard name. See Appendix A in the Java Cryptography Architecture API Specification & Reference for information about standard algorithm names. One possible use is by specialized algorithm parsers, which may map classes to algorithms which they understand (much like Key parsers do).
Parameters:
algName - the algorithm name.
propName - the name of the property to get.
Returns:
the value of the specified property.

insertProviderAt

public static int insertProviderAt(Provider provider,
                                   int position)
Adds a new provider, at a specified position. The position is the preference order in which providers are searched for requested algorithms. Note that it is not guaranteed that this preference will be respected. The position is 1-based, that is, 1 is most preferred, followed by 2, and so on. Sometimes it will be legal to add a provider, but only in the last position, in which case the position argument will be ignored.

If the given provider is installed at the requested position, the provider that used to be at that position, and all providers with a position greater than position, are shifted up one position (towards the end of the list of installed providers).

A provider cannot be added if it is already installed.

Parameters:
provider - the provider to be added.
position - the preference position that the caller would like for this provider.
Returns:
the actual preference position in which the provider was added, or -1 if the provider was not added because it is already installed.
See Also:
getProvider(java.lang.String), removeProvider(java.lang.String)

addProvider

public static int addProvider(Provider provider)
Adds a provider to the next position available.
Parameters:
provider - the provider to be added.
Returns:
the preference position in which the provider was added, or -1 if the provider was not added because it is already installed.
See Also:
getProvider(java.lang.String), removeProvider(java.lang.String)

removeProvider

public static void removeProvider(String name)
Removes the provider with the specified name.

When the specified provider is removed, all providers located at a position greater than where the specified provider was are shifted down one position (towards the head of the list of installed providers).

This method returns silently if the provider is not installed.

Parameters:
name - the name of the provider to remove.
See Also:
getProvider(java.lang.String), addProvider(java.security.Provider)

getProviders

public static Provider[] getProviders()
Returns an array containing all the installed providers. The order of the providers in the array is their preference order.
Returns:
an array of all the installed providers.

getProvider

public static Provider getProvider(String name)
Returns the provider installed with the specified name, if any. Returns null if no provider with the speicified name is installed.
Parameters:
name - the name of the provider to get.
Returns:
the provider of the specified name.
See Also:
removeProvider(java.lang.String), addProvider(java.security.Provider)

getProperty

public static String getProperty(String key)
Gets a security property.

If a security manager exists, its checkPermission method is called with the java.security.SecurityPermission("Security.getProperty."+key) permission. This may result in a security exception.

Parameters:
key - the key of the property being retrieved.
Returns:
the value of the security property corresponding to key.
Throws:
SecurityException - if a security manager exists and the calling thread does not have permission to retrieve the specified security property.

setProperty

public static void setProperty(String key,
                               String datum)
Sets a security property.

If a security manager exists, its checkPermission method is called with the java.security.SecurityPermission("Security.setProperty."+key) permission. This may result in a security exception.

Parameters:
key - the name of the property to be set.
datum - the value of the property to be set.
Throws:
SecurityException - if a security manager exists and the calling thread does not have permission to set the specified security property.

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.