# java.security

Provides the classes and interfaces for the security framework. This includes classes that implement an easily configurable, fine-grained access control security architecture. This package also supports the generation and storage of cryptographic public key pairs, as well as a number of exportable cryptographic operations including those for message digest and signature generation. Finally, this package provides classes that support signed/guarded objects and secure random number generation. Many of the classes provided in this package (the cryptographic and secure random number generator classes in particular) are provider-based. The class itself defines a programming interface to which applications may write. The implementations themselves may then be written by independent third-party vendors and plugged in seamlessly as needed. Therefore application developers may take advantage of any number of provider-based implementations without having to add or rewrite code.

## Package Specification

- [**Java™
  Cryptography Architecture (JCA) Reference Guide**](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/crypto/CryptoSpec.html)
- PKCS #8: Private-Key Information Syntax Standard, Version 1.2, November 1993
- [**Java™
  Cryptography Architecture Standard Algorithm Name
  Documentation**](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/StandardNames.html)

## Related Documentation

For further documentation, please see:

- [**Java™
  SE Platform Security Architecture**](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/spec/security-spec.doc.html)
- [**How to Implement a Provider in the
  Java™ Cryptography Architecture**](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/crypto/HowToImplAProvider.html)
- [**Default Policy Implementation and Policy File Syntax**](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/PolicyFiles.html)
- [**Permissions in the
  Java™ SE Development Kit (JDK)**](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/permissions.html)
- [**Summary of Tools for
  Java™ Platform Security**](https://developers.google.com/j2objc/javadoc/jre/technotes/guides/security/SecurityToolsSummary.html)
- **keytool** ([for Solaris/Linux](https://developers.google.com/j2objc/javadoc/jre/technotes/tools/unix/keytool.html)) ([for Windows](https://developers.google.com/j2objc/javadoc/jre/technotes/tools/windows/keytool.html))
- **jarsigner** ([for Solaris/Linux](https://developers.google.com/j2objc/javadoc/jre/technotes/tools/unix/jarsigner.html)) ([for Windows](https://developers.google.com/j2objc/javadoc/jre/technotes/tools/windows/jarsigner.html))

### Interfaces

|---|---|
| [AlgorithmConstraints](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmConstraints.html) | This interface specifies constraints for cryptographic algorithms, keys (key sizes), and other algorithm parameters. |
| [DomainCombiner](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/DomainCombiner.html) | Legacy security code; do not use. |
| [Guard](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Guard.html) | This interface represents a guard, which is an object that is used to protect access to another object. |
| [Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html) | The Key interface is the top-level interface for all keys. |
| [KeyStore.Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.html) | A marker interface for `KeyStore` entry types. |
| [KeyStore.Entry.Attribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Entry.Attribute.html) | An attribute associated with a keystore entry. |
| [KeyStore.LoadStoreParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.LoadStoreParameter.html) | A marker interface for `KeyStore` `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.html#load(java.security.KeyStore.LoadStoreParameter)` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.html#store(java.security.KeyStore.LoadStoreParameter)` parameters. |
| [KeyStore.ProtectionParameter](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.ProtectionParameter.html) | A marker interface for keystore protection parameters. |
| [Policy.Parameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Policy.Parameters.html) |   |
| [Principal](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Principal.html) | This interface represents the abstract notion of a principal, which can be used to represent any entity, such as an individual, a corporation, and a login id. |
| [PrivateKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivateKey.html) | A private key. |
| [PrivilegedAction](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedAction.html)\<T\> | Legacy security code; do not use. |
| [PrivilegedExceptionAction](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedExceptionAction.html)\<T\> | Legacy security code; do not use. |
| [PublicKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PublicKey.html) | A public key. |

### Classes

|---|---|
| [AccessControlContext](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AccessControlContext.html) | Legacy security code; do not use. |
| [AccessController](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AccessController.html) | Legacy security code; do not use. |
| [AlgorithmParameterGenerator](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameterGenerator.html) | The `AlgorithmParameterGenerator` class is used to generate a set of parameters to be used with a certain algorithm. |
| [AlgorithmParameterGeneratorSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameterGeneratorSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `AlgorithmParameterGenerator` class, which is used to generate a set of parameters to be used with a certain algorithm. |
| [AlgorithmParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameters.html) | This class is used as an opaque representation of cryptographic parameters. |
| [AlgorithmParametersSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParametersSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `AlgorithmParameters` class, which is used to manage algorithm parameters. |
| [AllPermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AllPermission.html) | Legacy security code; do not use. |
| [BasicPermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/BasicPermission.html) | Legacy security code; do not use. |
| [CodeSigner](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CodeSigner.html) | This class encapsulates information about a code signer. |
| [CodeSource](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CodeSource.html) | Legacy security code; do not use. |
| [DigestInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/DigestInputStream.html) | A transparent stream that updates the associated message digest using the bits going through the stream. |
| [DigestOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/DigestOutputStream.html) | A transparent stream that updates the associated message digest using the bits going through the stream. |
| [GuardedObject](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/GuardedObject.html) | A GuardedObject is an object that is used to protect access to another object. |
| [KeyFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyFactory.html) | Key factories are used to convert *keys* (opaque cryptographic keys of type `Key`) into *key specifications* (transparent representations of the underlying key material), and vice versa. |
| [KeyFactorySpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyFactorySpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `KeyFactory` class. |
| [KeyPair](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPair.html) | This class is a simple holder for a key pair (a public key and a private key). |
| [KeyPairGenerator](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGenerator.html) | The KeyPairGenerator class is used to generate pairs of public and private keys. |
| [KeyPairGeneratorSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyPairGeneratorSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `KeyPairGenerator` class, which is used to generate pairs of public and private keys. |
| [KeyRep](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyRep.html) | Standardized representation for serialized Key objects. |
| [KeyStore](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.html) | This class represents a storage facility for cryptographic keys and certificates. |
| [KeyStore.Builder](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.Builder.html) | A description of a to-be-instantiated KeyStore object. |
| [KeyStore.CallbackHandlerProtection](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.CallbackHandlerProtection.html) | A ProtectionParameter encapsulating a CallbackHandler. |
| [KeyStore.PasswordProtection](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PasswordProtection.html) | A password-based implementation of `ProtectionParameter`. |
| [KeyStore.PrivateKeyEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.PrivateKeyEntry.html) | A `KeyStore` entry that holds a `PrivateKey` and corresponding certificate chain. |
| [KeyStore.SecretKeyEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.SecretKeyEntry.html) | A `KeyStore` entry that holds a `SecretKey`. |
| [KeyStore.TrustedCertificateEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStore.TrustedCertificateEntry.html) | A `KeyStore` entry that holds a trusted `Certificate`. |
| [KeyStoreSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStoreSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `KeyStore` class. |
| [MessageDigest](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/MessageDigest.html) | This MessageDigest class provides applications the functionality of a message digest algorithm, such as SHA-1 or SHA-256. |
| [MessageDigestSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/MessageDigestSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `MessageDigest` class, which provides the functionality of a message digest algorithm, such as MD5 or SHA. |
| [Permission](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Permission.html) | Legacy security code; do not use. |
| [PermissionCollection](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PermissionCollection.html) | Legacy security code; do not use. |
| [Permissions](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Permissions.html) | Legacy security code; do not use. |
| [Policy](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Policy.html) | Legacy security code; do not use. |
| [ProtectionDomain](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/ProtectionDomain.html) | Legacy security code; do not use. |
| [Provider](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.html) | This class represents a "provider" for the Java Security API, where a provider implements some or all parts of Java Security. |
| [Provider.Service](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Provider.Service.html) | The description of a security service. |
| [SecureClassLoader](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureClassLoader.html) | This class extends ClassLoader with additional support for defining classes with an associated code source and permissions which are retrieved by the system policy by default. |
| [SecureRandom](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandom.html) | This class provides a cryptographically strong random number generator (RNG). |
| [SecureRandomSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecureRandomSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `SecureRandom` class. |
| [Security](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Security.html) | This class centralizes all security properties and common security methods. |
| [SecurityPermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SecurityPermission.html) | Legacy security code; do not use. |
| [Signature](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Signature.html) | The Signature class is used to provide applications the functionality of a digital signature algorithm. |
| [SignatureSpi](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `Signature` class, which is used to provide the functionality of a digital signature algorithm. |
| [Timestamp](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Timestamp.html) | This class encapsulates information about a signed timestamp. |

### Enums

|---|---|
| [CryptoPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CryptoPrimitive.html) | An enumeration of cryptographic primitives. |
| [KeyRep.Type](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyRep.Type.html) | Key type. |

### Exceptions

|---|---|
| [AccessControlException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AccessControlException.html) | This exception is thrown by the AccessController to indicate that a requested access (to a critical system resource such as the file system or the network) is denied. |
| [DigestException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/DigestException.html) | This is the generic Message Digest exception. |
| [GeneralSecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/GeneralSecurityException.html) | The `GeneralSecurityException` class is a generic security exception class that provides type safety for all the security-related exception classes that extend from it. |
| [InvalidAlgorithmParameterException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidAlgorithmParameterException.html) | This is the exception for invalid or inappropriate algorithm parameters. |
| [InvalidKeyException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidKeyException.html) | This is the exception for invalid Keys (invalid encoding, wrong length, uninitialized, etc). |
| [InvalidParameterException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/InvalidParameterException.html) | This exception, designed for use by the JCA/JCE engine classes, is thrown when an invalid parameter is passed to a method. |
| [KeyException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyException.html) | This is the basic key exception. |
| [KeyManagementException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyManagementException.html) | This is the general key management exception for all operations dealing with key management. |
| [KeyStoreException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/KeyStoreException.html) | This is the generic KeyStore exception. |
| [NoSuchAlgorithmException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/NoSuchAlgorithmException.html) | This exception is thrown when a particular cryptographic algorithm is requested but is not available in the environment. |
| [NoSuchProviderException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/NoSuchProviderException.html) | This exception is thrown when a particular security provider is requested but is not available in the environment. |
| [PrivilegedActionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedActionException.html) | Legacy security code; do not use. |
| [ProviderException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/ProviderException.html) | A runtime exception for Provider exceptions (such as misconfiguration errors or unrecoverable internal errors), which may be subclassed by Providers to throw specialized, provider-specific runtime errors. |
| [SignatureException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/SignatureException.html) | This is the generic Signature exception. |
| [UnrecoverableEntryException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/UnrecoverableEntryException.html) | This exception is thrown if an entry in the keystore cannot be recovered. |
| [UnrecoverableKeyException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/UnrecoverableKeyException.html) | This exception is thrown if a key in the keystore cannot be recovered. |