java.lang.Object | ||
↳ | java.security.SignatureSpi | |
↳ | java.security.Signature |
Signature
is an engine class which is capable of creating and
verifying digital signatures, using different algorithms that have been
registered with the Security
class.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | SIGN | Constant that indicates that this Signature instance has been
initialized for signing. |
|||||||||
int | UNINITIALIZED | Constant that indicates that this Signature instance has not yet
been initialized. |
|||||||||
int | VERIFY | Constant that indicates that this Signature instance has been
initialized for verification. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
state | Represents the current state of this Signature . |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.security.SignatureSpi
|
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new instance of
Signature with the name of
the algorithm to use. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates and returns a copy of this
Object . | |||||||||||
Returns the name of the algorithm of this
Signature . | |||||||||||
Returns a new instance of
Signature that utilizes the specified
algorithm from the specified provider. | |||||||||||
Returns a new instance of
Signature that utilizes the specified
algorithm. | |||||||||||
Returns a new instance of
Signature that utilizes the specified
algorithm from the specified provider. | |||||||||||
This method is deprecated.
There is no generally accepted parameter naming convention.
| |||||||||||
Returns the
AlgorithmParameters of this Signature
instance. | |||||||||||
Returns the provider associated with this
Signature . | |||||||||||
Initializes this
Signature instance for signing, using the
private key of the identity whose signature is going to be generated. | |||||||||||
Initializes this
Signature instance for signing, using the
private key of the identity whose signature is going to be generated and
the specified source of randomness. | |||||||||||
Initializes this
Signature instance for signature verification,
using the public key of the identity whose signature is going to be
verified. | |||||||||||
Initializes this
Signature instance for signature verification,
using the certificate of the identity whose signature is going to be
verified. | |||||||||||
This method is deprecated.
Use
setParameter(AlgorithmParameterSpec)
| |||||||||||
Sets the specified
AlgorithmParameterSpec . | |||||||||||
Generates and returns the signature of all updated data.
| |||||||||||
Generates and stores the signature of all updated data in the provided
byte[] at the specified position with the specified length. | |||||||||||
Returns a string containing a concise, human-readable description of this
Signature including its algorithm and its state. | |||||||||||
Updates the data to be verified or to be signed, using the specified
byte[] . | |||||||||||
Updates the data to be verified or to be signed, using the specified
byte . | |||||||||||
Updates the data to be verified or to be signed, using the given
byte[] , starting form the specified index for the specified length. | |||||||||||
Updates the data to be verified or to be signed, using the specified
ByteBuffer . | |||||||||||
Indicates whether the given
signature can be verified using the
public key or a certificate of the signer. | |||||||||||
Indicates whether the given
signature starting at index offset with length bytes can be verified using the public key or
a certificate of the signer. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.security.SignatureSpi
| |||||||||||
From class java.lang.Object
|
Constant that indicates that this Signature
instance has been
initialized for signing.
Constant that indicates that this Signature
instance has not yet
been initialized.
Constant that indicates that this Signature
instance has been
initialized for verification.
Represents the current state of this Signature
. The three
possible states are UNINITIALIZED
, SIGN
or
VERIFY
.
Constructs a new instance of Signature
with the name of
the algorithm to use.
algorithm | the name of algorithm to use. |
---|
Creates and returns a copy of this Object
. The default
implementation returns a so-called "shallow" copy: It creates a new
instance of the same class and then copies the field values (including
object references) from this instance to the new instance. A "deep" copy,
in contrast, would also recursively clone nested objects. A subclass that
needs to implement this kind of cloning should call super.clone()
to create the new instance and then create deep copies of the nested,
mutable objects.
CloneNotSupportedException |
---|
Returns the name of the algorithm of this Signature
.
Signature
.
Returns a new instance of Signature
that utilizes the specified
algorithm from the specified provider.
algorithm | the name of the algorithm to use. |
---|---|
provider | the name of the provider. |
Signature
that utilizes the specified
algorithm from the specified provider.NoSuchAlgorithmException | if the specified algorithm is not available. |
---|---|
NoSuchProviderException | if the specified provider is not available. |
NullPointerException | if algorithm is null .
|
Returns a new instance of Signature
that utilizes the specified
algorithm.
algorithm | the name of the algorithm to use. |
---|
Signature
that utilizes the specified
algorithm.NoSuchAlgorithmException | if the specified algorithm is not available. |
---|---|
NullPointerException | if algorithm is null .
|
Returns a new instance of Signature
that utilizes the specified
algorithm from the specified provider.
algorithm | the name of the algorithm to use. |
---|---|
provider | the security provider. |
Signature
that utilizes the specified
algorithm from the specified provider.NoSuchAlgorithmException | if the specified algorithm is not available. |
---|---|
NullPointerException | if algorithm is null .
|
This method is deprecated.
There is no generally accepted parameter naming convention.
Returns the value of the parameter with the specified name.
param | the name of the requested parameter value |
---|
null
.InvalidParameterException | if param is not a valid parameter for this Signature or an other error occures. |
---|
Returns the provider associated with this Signature
.
Signature
.
Initializes this Signature
instance for signing, using the
private key of the identity whose signature is going to be generated.
privateKey | the private key. |
---|
InvalidKeyException | if privateKey is not valid.
|
---|
Initializes this Signature
instance for signing, using the
private key of the identity whose signature is going to be generated and
the specified source of randomness.
privateKey | the private key. |
---|---|
random | the SecureRandom to use. |
InvalidKeyException | if privateKey is not valid.
|
---|
Initializes this Signature
instance for signature verification,
using the public key of the identity whose signature is going to be
verified.
publicKey | the public key. |
---|
InvalidKeyException | if publicKey is not valid.
|
---|
Initializes this Signature
instance for signature verification,
using the certificate of the identity whose signature is going to be
verified.
If the given certificate is an instance of X509Certificate
and
has a key usage parameter that indicates, that this certificate is not to
be used for signing, an InvalidKeyException
is thrown.
certificate | the certificate used to verify a signature. |
---|
InvalidKeyException | if the publicKey in the certificate is not valid or not to be used for signing. |
---|
This method is deprecated.
Use setParameter(AlgorithmParameterSpec)
Sets the specified parameter to the given value.
param | the name of the parameter. |
---|---|
value | the parameter value. |
InvalidParameterException | if the parameter is invalid, already set or is not allowed to be changed. |
---|
Sets the specified AlgorithmParameterSpec
.
params | the parameter to set. |
---|
InvalidAlgorithmParameterException | if the parameter is invalid, already set or is not allowed to be changed. |
---|
Generates and returns the signature of all updated data.
This Signature
instance is reset to the state of its last
initialization for signing and thus can be used for another signature
from the same identity.
SignatureException | if this Signature instance is not initialized
properly.
|
---|
Generates and stores the signature of all updated data in the provided
byte[]
at the specified position with the specified length.
This Signature
instance is reset to the state of its last
initialization for signing and thus can be used for another signature
from the same identity.
outbuf | the buffer to store the signature. |
---|---|
offset | the index of the first byte in outbuf to store. |
len | the number of bytes allocated for the signature. |
outbuf
.SignatureException | if this Signature instance is not initialized
properly. |
---|---|
IllegalArgumentException | if offset or len are not valid in respect to
outbuf .
|
Returns a string containing a concise, human-readable description of this
Signature
including its algorithm and its state.
Signature
.
Updates the data to be verified or to be signed, using the specified
byte[]
.
data | the byte array to update with. |
---|
SignatureException | if this Signature instance is not initialized
properly.
|
---|
Updates the data to be verified or to be signed, using the specified
byte
.
b | the byte to update with. |
---|
SignatureException | if this Signature instance is not initialized
properly.
|
---|
Updates the data to be verified or to be signed, using the given byte[]
, starting form the specified index for the specified length.
data | the byte array to update with. |
---|---|
off | the start index in data of the data. |
len | the number of bytes to use. |
SignatureException | if this Signature instance is not initialized
properly.
|
---|
Updates the data to be verified or to be signed, using the specified
ByteBuffer
.
data | the ByteBuffer to update with. |
---|
SignatureException | if this Signature instance is not initialized
properly.
|
---|
Indicates whether the given signature
can be verified using the
public key or a certificate of the signer.
This Signature
instance is reset to the state of its last
initialization for verifying and thus can be used to verify another
signature of the same signer.
signature | the signature to verify. |
---|
true
if the signature was verified, false
otherwise.SignatureException | if this Signature instance is not initialized
properly.
|
---|
Indicates whether the given signature
starting at index offset
with length
bytes can be verified using the public key or
a certificate of the signer.
This Signature
instance is reset to the state of its last
initialization for verifying and thus can be used to verify another
signature of the same signer.
signature | the byte[] containing the signature to verify. |
---|---|
offset | the start index in signature of the signature. |
length | the number of bytes allocated for the signature. |
true
if the signature was verified, false
otherwise.SignatureException | if this Signature instance is not initialized
properly. |
---|---|
IllegalArgumentException | if offset or length are not valid in respect
to signature .
|