Agent System POND 1.2 (28.2.2002)

PkgAgentSystem.Messaging
Class SignedMessage

java.lang.Object
  |
  +--PkgAgentSystem.Messaging.Message
        |
        +--PkgAgentSystem.Messaging.SignedMessage
All Implemented Interfaces:
Cloneable, MessageType, Serializable

public class SignedMessage
extends Message

A message signed by the sender.
Based on SignedObject Ver. 1.34, 10/27/98 (Author: Li Gong)

Version:
1.0, 1.7.2000
Author:
Li Gong, Michael Sonntag
See Also:
Serialized Form

Constructor Summary
protected SignedMessage()
          Create a new and empty signed message.
  SignedMessage(MessageType msg, Certificate[] signerCerts, PrivateKey signingKey, Signature signingEngine)
          Constructs a SignedMessage from a Message.
 
Method Summary
 String getAlgorithm()
          Retrieves the name of the signature algorithm used for signing.
 Certificate[] getCertificateChain()
          Retrieves the certificate chain of the signer.
 MessageType getMessage()
          Retrieves the encapsulated message.
 byte[] getSignature()
          Rerieves the signature on the signed object, in the form of a byte array.
 String toString()
          Retrieves a string representation of the signed message
 boolean verify(KeyStore ks)
          Verifies that the signature in this SignedMessage is the valid signature for the message stored inside, with the given key store.
 boolean verify(PublicKey verificationKey)
          Verifies that the signature in this SignedMessage is the valid signature for the message stored inside, with the given verification key.
 boolean verify(PublicKey verificationKey, Signature verificationEngine)
          Verifies that the signature in this SignedMessage is the valid signature for the message stored inside, with the given verification key, using the designated verification engine.
 
Methods inherited from class PkgAgentSystem.Messaging.Message
copy, fromInitiator, getAddressee, getConversationTypeID, getDestConversationID, getSender, getSrcConversationID, setAddressee, setConversationTypeID, setDestConversationID, setFromInitiator, setSender, setSrcConversationID
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SignedMessage

protected SignedMessage()
Create a new and empty signed message.

SignedMessage

public SignedMessage(MessageType msg,
                     Certificate[] signerCerts,
                     PrivateKey signingKey,
                     Signature signingEngine)
              throws IOException,
                     InvalidKeyException,
                     SignatureException
Constructs a SignedMessage from a Message. The given message is signed with the given signing key, using the designated signature engine. The message is stored for future access, but later changes will not be reflected, as it is stored in binary form and signed now.
Parameters:
msg - the message to be signed.
signerCerts - the certificate chain of the signer
signingKey - the private key for signing.
signingEngine - the signature signing engine.
Throws:
IOException - if an error occurs during serialization
InvalidKeyException - if the key is invalid.
SignatureException - if signing fails.
Method Detail

getMessage

public MessageType getMessage()
Retrieves the encapsulated message.
Returns:
the encapsulated message

getCertificateChain

public Certificate[] getCertificateChain()
Retrieves the certificate chain of the signer.
Returns:
the certificate chain

getSignature

public byte[] getSignature()
Rerieves the signature on the signed object, in the form of a byte array.
Returns:
the signature

getAlgorithm

public String getAlgorithm()
Retrieves the name of the signature algorithm used for signing.
Returns:
the signature algorithm name

toString

public String toString()
Retrieves a string representation of the signed message
Overrides:
toString in class Message
Returns:
the string representation

verify

public boolean verify(PublicKey verificationKey)
               throws InvalidKeyException,
                      SignatureException,
                      NoSuchAlgorithmException
Verifies that the signature in this SignedMessage is the valid signature for the message stored inside, with the given verification key.
Parameters:
verificationKey - the public key for verification
Throws:
SignatureException - if signature verification failed
InvalidKeyException - if the verification key is invalid
NoSuchAlgorithmException - if the algorihtm used for signing is not available

verify

public boolean verify(PublicKey verificationKey,
                      Signature verificationEngine)
               throws InvalidKeyException,
                      SignatureException
Verifies that the signature in this SignedMessage is the valid signature for the message stored inside, with the given verification key, using the designated verification engine.
Parameters:
verificationKey - the public key for verification
verificationEngine - the signature verification engine
Throws:
SignatureException - if signature verification failed
InvalidKeyException - if the verification key is invalid

verify

public boolean verify(KeyStore ks)
               throws InvalidKeyException,
                      SignatureException,
                      NoSuchAlgorithmException
Verifies that the signature in this SignedMessage is the valid signature for the message stored inside, with the given key store. Uses the stored certificate chain for verifying the signature (public key of first element used). The verification will fail if the certificate chain is not terminated by a trusted certificate (from the keystore) or the last certificate in the chain is not signed using a trusted certificate.
Parameters:
ks - the key store used for verification
Throws:
SignatureException - if signature verification failed
InvalidKeyException - if the verification key is invalid
NoSuchAlgorithmException - if the algorihtm used for signing is not available

Agent System POND 1.2 (28.2.2002)

Submit a bug

Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.