Agent System POND 1.2 (28.2.2002)

FIM.payment
Class PaymentBase

java.lang.Object
  |
  +--FIM.payment.PaymentBase
All Implemented Interfaces:
Payment, Serializable, XMLEncodeable
Direct Known Subclasses:
CreditCardPayment, DataPayment, EmptyPayment, VoucherPayment

public abstract class PaymentBase
extends Object
implements Payment

A helper class with common methods of interface Payment implemented.

Version:
1.0
Author:
Michael Sonntag
See Also:
Invoice, Serialized Form

Constructor Summary
protected PaymentBase()
          Create a new empty object.
  PaymentBase(Invoice inv, String characteristic)
          Create a new payment object with a characteristic.
 
Method Summary
 String characteristics()
          Retrieve the characteristic string for this type of payment (description of the content)
 void decodeXMLElement(Element elem)
          Parse back the payment from an XML element.
 Serializable getAsSerializable()
          Retrieve the payment as a serializable (just returns this as this object is directly serializable).
 Element getAsXMLElement(Document doc)
          Retrieve the payment as an XML element.
 Certificate getCertificate()
          Retrieve the certificate passed in upon signing.
 byte[] getEncoded()
          Retrieve the payment in encoded form to be used for signing.
 Invoice getInvoice()
          Retrieve the invoice this payment is for.
 boolean isSigned()
          Check whether this payment is signed or not.
 void sign(String signAlgorithm, PrivateKey pk, Certificate cert)
          Sign the payment.
 void verifySignature(String provider)
          Verify the signature of the payment based on the certificate contained.
 void verifySignature(String provider, PublicKey pk)
          Verify the signature of the payment based on the public key passed in.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface FIM.payment.Payment
toString
 

Constructor Detail

PaymentBase

public PaymentBase(Invoice inv,
                   String characteristic)
Create a new payment object with a characteristic.
Parameters:
invoice - the invoice this payment is for
characteristic - the description of the content
stringData - the string data

PaymentBase

protected PaymentBase()
Create a new empty object. To be used for parsing in XML data later.
Method Detail

getInvoice

public Invoice getInvoice()
Retrieve the invoice this payment is for.
Specified by:
getInvoice in interface Payment
Returns:
the invoice

getCertificate

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

isSigned

public boolean isSigned()
Check whether this payment is signed or not.
Specified by:
isSigned in interface Payment
Returns:
true if the payment is signed

sign

public void sign(String signAlgorithm,
                 PrivateKey pk,
                 Certificate cert)
          throws InvalidKeyException,
                 NoSuchAlgorithmException
Sign the payment.
Specified by:
sign in interface Payment
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

verifySignature

public void verifySignature(String provider)
                     throws NoSuchAlgorithmException,
                            InvalidKeyException,
                            NoSuchProviderException,
                            SignatureException
Verify the signature of the payment based on the certificate contained. Will fail if not signed or if no certificate is present.
Specified by:
verifySignature in interface Payment
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 payment based on the public key passed in. Will fail if not signed. Teh certificate included is ignored.
Specified by:
verifySignature in interface Payment
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 payment 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.
Specified by:
getEncoded in interface Payment
Returns:
the payment in encoded form

characteristics

public String characteristics()
Retrieve the characteristic string for this type of payment (description of the content)
Specified by:
characteristics in interface Payment
Returns:
the characteristic of this payment

getAsSerializable

public Serializable getAsSerializable()
Retrieve the payment as a serializable (just returns this as this object is directly serializable).
Specified by:
getAsSerializable in interface XMLEncodeable
Returns:
the currency object as a serializable

getAsXMLElement

public Element getAsXMLElement(Document doc)
Retrieve the payment as an XML element.
Specified by:
getAsXMLElement in interface XMLEncodeable
Parameters:
doc - the document within which to create the element
Returns:
the currency as an element

decodeXMLElement

public void decodeXMLElement(Element elem)
                      throws IllegalArgumentException
Parse back the payment from an XML element.
Specified by:
decodeXMLElement in interface XMLEncodeable
Parameters:
elem - the element containing the currency to parse back
Throws:
IllegalArgumentException - if the element is incorrect (e. g. wrong tag name)

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.