Package java.security
Class SignedObject
java.lang.Object
java.security.SignedObject
- All Implemented Interfaces:
Serializable
public final class SignedObject extends Object implements Serializable
A
SignedObject instance acts as a container for another object. The
SignedObject contains the target in serialized form along with a
digital signature of the serialized data.- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description SignedObject(Serializable object, PrivateKey signingKey, Signature signingEngine)Constructs a new instance ofSignedObjectwith the target object, the private key and the engine to compute the signature. -
Method Summary
Modifier and Type Method Description StringgetAlgorithm()Returns the name of the algorithm of thisSignedObject.ObjectgetObject()Returns the encapsulated object.byte[]getSignature()Returns the signature data of the encapsulated serialized object.booleanverify(PublicKey verificationKey, Signature verificationEngine)Indicates whether the contained signature for the encapsulated object is valid.
-
Constructor Details
-
SignedObject
public SignedObject(Serializable object, PrivateKey signingKey, Signature signingEngine) throws IOException, InvalidKeyException, SignatureExceptionConstructs a new instance ofSignedObjectwith the target object, the private key and the engine to compute the signature. The givenobjectis signed with the specified key and engine.- Parameters:
object- the object to bes signed.signingKey- the private key, used to sign theobject.signingEngine- the engine that performs the signature generation.- Throws:
IOException- if a serialization error occurs.InvalidKeyException- if the private key is not valid.SignatureException- if signature generation failed.
-
-
Method Details
-
getObject
Returns the encapsulated object. Each time this method is invoked, the encapsulated object is deserialized before it is returned.- Returns:
- the encapsulated object.
- Throws:
IOException- if deserialization failed.ClassNotFoundException- if the class of the encapsulated object can not be found.
-
getSignature
public byte[] getSignature()Returns the signature data of the encapsulated serialized object.- Returns:
- the signature data of the encapsulated serialized object.
-
getAlgorithm
Returns the name of the algorithm of thisSignedObject.- Returns:
- the name of the algorithm of this
SignedObject.
-
verify
public boolean verify(PublicKey verificationKey, Signature verificationEngine) throws InvalidKeyException, SignatureExceptionIndicates whether the contained signature for the encapsulated object is valid.- Parameters:
verificationKey- the public key to verify the signature.verificationEngine- the signature engine.- Returns:
trueif the contained signature for the encapsulated object is valid,falseotherwise.- Throws:
InvalidKeyException- if the public key is invalid.SignatureException- if signature verification failed.
-