Agent System POND 1.2 (28.2.2002)

FIM.payment
Interface Invoice

All Superinterfaces:
Serializable, XMLEncodeable
All Known Implementing Classes:
AnonymousInvoice

public interface Invoice
extends XMLEncodeable, Serializable

This class models an invoice to another entity. It might be signed. Can be encoded in XML. Contains the date, a title, and the items.

Version:
1.0
Author:
Michael Sonntag
See Also:
InvoiceItem

Method Summary
 Certificate getCertificate()
          Retrieve the certificate passed in upon signing.
 Date getDate()
          Retrieve the date of the invoice.
 byte[] getEncoded()
          Retrieve the invoice in encoded form to be used for signing.
 String getIssuer()
          Retrieve the issuer of the invoice as a string.
 Certificate getIssuerCertificate()
          Retrieve the issuer of the invoice as a certificate (might be null).
 InvoiceItem[] getItems()
          Retrieve the items contained within the invoice (items or lines).
 String getTitle()
          Retrieve the title of the invoice.
 Price getTotalPrice()
          Retrieve the total value of all items in the invoice.
 boolean isSigned()
          Check whether this invoice is signed or not.
 void sign(String signAlgorithm, PrivateKey pk, Certificate cert)
          Sign the invoice.
 String toString()
          Retrieve the invoice as a string, suitable for presenting to the user in a very simple form.
 void verifySignature(String provider)
          Verify the signature of the invoice based on the certificate contained.
 void verifySignature(String provider, PublicKey pk)
          Verify the signature of the invoice based on the public key passed in.
 
Methods inherited from interface FIM.Util.XML.XMLEncodeable
decodeXMLElement, getAsSerializable, getAsXMLElement
 

Method Detail

getDate

public Date getDate()
Retrieve the date of the invoice.
Returns:
the date of the invoice

getTitle

public String getTitle()
Retrieve the title of the invoice.
Returns:
the title of the invoice

getItems

public InvoiceItem[] getItems()
Retrieve the items contained within the invoice (items or lines).
Returns:
the items of the invoice

getTotalPrice

public Price getTotalPrice()
Retrieve the total value of all items in the invoice.
Returns:
the total price

getIssuer

public String getIssuer()
Retrieve the issuer of the invoice as a string.
Returns:
the issuer of the invoice

getIssuerCertificate

public Certificate getIssuerCertificate()
Retrieve the issuer of the invoice as a certificate (might be null).
Returns:
the issuer of the invoice or null

isSigned

public boolean isSigned()
Check whether this invoice is signed or not.
Returns:
true if the invoice is signed

sign

public void sign(String signAlgorithm,
                 PrivateKey pk,
                 Certificate cert)
          throws InvalidKeyException,
                 NoSuchAlgorithmException
Sign the invoice.
Parameters:
signAlgorithm - the algorithm to be used for signing
pk - the private key to be used for signing
cert - the certificate of the public key associated with the private key (can be null)
Throws:
InvalidKeyException - if the private key is invalid
NoSuchAlgorithmException - if the algorithm is not supported

getCertificate

public Certificate getCertificate()
Retrieve the certificate passed in upon signing. Is null if non provided then.
Returns:
the certificate of the signer or null

verifySignature

public void verifySignature(String provider)
                     throws NoSuchAlgorithmException,
                            InvalidKeyException,
                            NoSuchProviderException,
                            SignatureException
Verify the signature of the invoice based on the certificate contained. Will fail if not signed or if no certificate is present.
Parameters:
provider - the security provider to be used for checking. if null, the standard provider is used
Throws:
InvalidKeyException - if the public key is invalid
NoSuchAlgorithmException - if the algorithm used for signing is not supported
InvalidKeyException - if the key in the certificate is erroneous
NoSuchProviderException - if the security provider could not be found
SignatureException - if the signature is invalid

verifySignature

public void verifySignature(String provider,
                            PublicKey pk)
                     throws NoSuchAlgorithmException,
                            InvalidKeyException,
                            NoSuchProviderException,
                            SignatureException
Verify the signature of the invoice based on the public key passed in. Will fail if not signed. Teh certificate included is ignored.
Parameters:
provider - the security provider to be used for checking. if null, the standard provider is used
pk - the public key to use for verification. If null, the key from the certificate is used (if no certificate in this case, verification fails)
Throws:
NoSuchAlgorithmException - if the algorithm used for signing is not supported
InvalidKeyException - if the public key (or the key in the certificate) is invalid
NoSuchProviderException - if the security provider could not be found
SignatureException - if the signature is invalid

getEncoded

public byte[] getEncoded()
Retrieve the invoice in encoded form to be used for signing. Does NOT include the signing information itself (which will be created based on the result!). Must be exactly the same on all calls and if the content is the same.
Returns:
the invoice in encoded form

toString

public String toString()
Retrieve the invoice as a string, suitable for presenting to the user in a very simple form.
Specified by:
toString in interface XMLEncodeable
Overrides:
toString in class Object
Returns:
the invoice encoded as a string

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.