Cryptix OpenPGP

cryptix.openpgp
Class PGPAbstractSignatureParameterBuilder

java.lang.Object
  extended bycryptix.openpgp.PGPAbstractSignatureParameterBuilder
Direct Known Subclasses:
PGPCertificateParameterBuilder, PGPSelfCertificateParameterBuilder

public abstract class PGPAbstractSignatureParameterBuilder
extends java.lang.Object

Abstract class for signature parameters.

Version:
$Revision: 1.3 $
Author:
Edwin Woudt

Constructor Summary
protected PGPAbstractSignatureParameterBuilder(java.security.Key issuerkey, byte sigtype)
          Construct a new PGPAbstractSignatureParameterBuilder using the given issuer key and signature type byte.
protected PGPAbstractSignatureParameterBuilder(KeyID issuerkeyid, byte sigtype)
          Construct a new PGPAbstractSignatureParameterBuilder using the given issuer key id and signature type byte.
 
Method Summary
 void addPacket(cryptix.openpgp.signature.PGPSignatureSubPacket ssp)
          Add a packet to the hashed area This method simply adds the packet to the hashed area, without checking if a packet with the same id already exists.
 void addUnhashedPacket(cryptix.openpgp.signature.PGPSignatureSubPacket ssp)
          Add a packet to the unhashed area This method simply adds the packet to the unhashed area, without checking if a packet with the same id already exists.
 java.security.spec.AlgorithmParameterSpec build()
          Build an immutable parameter specification This method can be called more than once, which is useful in case you want to create multiple signatures with almost the same parameters.
 cryptix.openpgp.signature.PGPSignatureSubPacket removePacket(byte packetid)
          Remove the packet in the hashed area with the given packetid Note: if more than one packet with the given packetid exist in the hashed area, then only one (the first one) will be removed.
 cryptix.openpgp.signature.PGPSignatureSubPacket removeUnhashedPacket(byte packetid)
          Remove the packet in the unhashed area with the given packetid Note: if more than one packet with the given packetid exist in the unhashed area, then only one (the first one) will be removed.
 void setCreationDate(java.util.Date creation)
          Set the signature creation date packet With this method one can set the signature creation date and time to any random value.
 void setIssuerKeyID(KeyID issuerkeyid)
          Set the issuer key id
 cryptix.openpgp.signature.PGPSignatureSubPacket setPacket(cryptix.openpgp.signature.PGPSignatureSubPacket ssp)
          Add or replace a packet into the hashed area If a packet with the same packetid already exists in the hashed area it is replaced by the given packet.
 void setSignatureType(byte sigtype)
          Sets the signature type byte
 cryptix.openpgp.signature.PGPSignatureSubPacket setUnhashedPacket(cryptix.openpgp.signature.PGPSignatureSubPacket ssp)
          Add or replace a packet into the unhashed area If a packet with the same packetid already exists in the unhashed area it is replaced by the given packet.
 void updateCreationDate()
          Updates the signature creation date packet to the current date and time This method is simply a wrapper around setCreationDate, calling it with the current date and time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PGPAbstractSignatureParameterBuilder

protected PGPAbstractSignatureParameterBuilder(KeyID issuerkeyid,
                                               byte sigtype)
Construct a new PGPAbstractSignatureParameterBuilder using the given issuer key id and signature type byte.

Parameters:
issuerkeyid - the key id of the key issuing the signature
sigtype - the signature type byte

PGPAbstractSignatureParameterBuilder

protected PGPAbstractSignatureParameterBuilder(java.security.Key issuerkey,
                                               byte sigtype)
                                        throws java.security.InvalidKeyException
Construct a new PGPAbstractSignatureParameterBuilder using the given issuer key and signature type byte.

Note: this is just a convenience method that will extract the key id from the given key. If you already have the key id, calling the other constructor with that key id is faster.

Parameters:
issuerkey - the key issuing the signature
sigtype - the signature type byte
Throws:
java.security.InvalidKeyException - if getting the key id of the issuer key fails because of an incompatible or invalid key.
Method Detail

build

public java.security.spec.AlgorithmParameterSpec build()
Build an immutable parameter specification

This method can be called more than once, which is useful in case you want to create multiple signatures with almost the same parameters. Note that in this case all parameters will stay the same, including the creation date and time, which may not be desirable. Use the updateCreationDate() method to prevent this from happening.


updateCreationDate

public void updateCreationDate()
Updates the signature creation date packet to the current date and time

This method is simply a wrapper around setCreationDate, calling it with the current date and time.


setCreationDate

public void setCreationDate(java.util.Date creation)
Set the signature creation date packet

With this method one can set the signature creation date and time to any random value. While this has useful applications, it should be used carefully because setting it to something else than the current time may break some things.

Parameters:
creation - the new date and time

setIssuerKeyID

public void setIssuerKeyID(KeyID issuerkeyid)
Set the issuer key id

Parameters:
issuerkeyid - the key id of the key issuing the signature

setSignatureType

public void setSignatureType(byte sigtype)
Sets the signature type byte

Parameters:
sigtype - the new signature type byte

addPacket

public void addPacket(cryptix.openpgp.signature.PGPSignatureSubPacket ssp)
Add a packet to the hashed area

This method simply adds the packet to the hashed area, without checking if a packet with the same id already exists. In many cases, using the setPacket(...) method is therefore a better idea.

Parameters:
ssp - the signature subpacket that should be added to the hashed area.

setPacket

public cryptix.openpgp.signature.PGPSignatureSubPacket setPacket(cryptix.openpgp.signature.PGPSignatureSubPacket ssp)
Add or replace a packet into the hashed area

If a packet with the same packetid already exists in the hashed area it is replaced by the given packet. Otherwise the given packet is simply added.

Parameters:
ssp - the signature subpacket that should be added to the hashed area.
Returns:
the packet that was replaced by the new packet, or null if no packet was replaced and the new packet was just added to the hashed area.

removePacket

public cryptix.openpgp.signature.PGPSignatureSubPacket removePacket(byte packetid)
Remove the packet in the hashed area with the given packetid

Note: if more than one packet with the given packetid exist in the hashed area, then only one (the first one) will be removed.

Parameters:
packetid - the ID of the packet to remove
Returns:
the removed packet or null if no packet could be found

addUnhashedPacket

public void addUnhashedPacket(cryptix.openpgp.signature.PGPSignatureSubPacket ssp)
Add a packet to the unhashed area

This method simply adds the packet to the unhashed area, without checking if a packet with the same id already exists. In many cases, using the setUnhashedPacket(...) method is therefore a better idea.

Parameters:
ssp - the signature subpacket that should be added to the hashed area.

setUnhashedPacket

public cryptix.openpgp.signature.PGPSignatureSubPacket setUnhashedPacket(cryptix.openpgp.signature.PGPSignatureSubPacket ssp)
Add or replace a packet into the unhashed area

If a packet with the same packetid already exists in the unhashed area it is replaced by the given packet. Otherwise the given packet is simply added.

Parameters:
ssp - the signature subpacket that should be added to the unhashed area.
Returns:
the packet that was replaced by the new packet, or null if no packet was replaced and the new packet was just added to the unhashed area.

removeUnhashedPacket

public cryptix.openpgp.signature.PGPSignatureSubPacket removeUnhashedPacket(byte packetid)
Remove the packet in the unhashed area with the given packetid

Note: if more than one packet with the given packetid exist in the unhashed area, then only one (the first one) will be removed.

Parameters:
packetid - the ID of the packet to remove
Returns:
the removed packet or null if no packet could be found

Cryptix OpenPGP

Copyright (C) 1999-2003 The Cryptix Foundation Ltd.