Cryptix OpenPGP

cryptix.message
Class EncryptedMessageBuilder

java.lang.Object
  extended bycryptix.message.EncryptedMessageBuilder

public class EncryptedMessageBuilder
extends java.lang.Object

A class for building an EncryptedMessage.

Version:
$Revision: 1.2 $
Author:
Edwin Woudt

Constructor Summary
protected EncryptedMessageBuilder(EncryptedMessageBuilderSpi builderSpi, java.security.Provider provider, java.lang.String format)
          Create a new EncryptedMessageBuilder object containing the given SPI object.
 
Method Summary
 void addRecipient(KeyBundle bundle)
          Adds a keybundle recipient
 void addRecipient(java.security.PublicKey publickey)
          Adds a public key recipient
 void addRecipient(javax.crypto.SecretKey symmetrickey)
          Adds a symmetric key recipient
 void addRecipient(java.lang.String passphrase)
          Adds a passphrase recipient
 Message build()
          Returns the encrypted message
 java.lang.String getFormat()
          Returns the name of the format of this object.
static EncryptedMessageBuilder getInstance(java.lang.String format)
          Returns an EncryptedMessageBuilder that implements the given format.
static EncryptedMessageBuilder getInstance(java.lang.String format, java.security.Provider provider)
          Returns an EncryptedMessageBuilder from the given provider that implements the given format.
static EncryptedMessageBuilder getInstance(java.lang.String format, java.lang.String provider)
          Returns an EncryptedMessageBuilder from the given provider that implements the given format.
 java.security.Provider getProvider()
          Returns the provider of this object.
 void init(Message contents)
          Initializes this builder with the given message.
 void init(Message contents, java.security.SecureRandom sr)
          Initializes this builder with the given message and SecureRandom object.
 void setAttribute(java.lang.String name, java.lang.Object attr)
          Set a format specific attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncryptedMessageBuilder

protected EncryptedMessageBuilder(EncryptedMessageBuilderSpi builderSpi,
                                  java.security.Provider provider,
                                  java.lang.String format)
Create a new EncryptedMessageBuilder object containing the given SPI object.

Method Detail

getInstance

public static EncryptedMessageBuilder getInstance(java.lang.String format)
                                           throws java.security.NoSuchAlgorithmException
Returns an EncryptedMessageBuilder that implements the given format.

Throws:
java.security.NoSuchAlgorithmException

getInstance

public static EncryptedMessageBuilder getInstance(java.lang.String format,
                                                  java.lang.String provider)
                                           throws java.security.NoSuchAlgorithmException,
                                                  java.security.NoSuchProviderException
Returns an EncryptedMessageBuilder from the given provider that implements the given format.

Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException

getInstance

public static EncryptedMessageBuilder getInstance(java.lang.String format,
                                                  java.security.Provider provider)
                                           throws java.security.NoSuchAlgorithmException
Returns an EncryptedMessageBuilder from the given provider that implements the given format.

Throws:
java.security.NoSuchAlgorithmException

getProvider

public final java.security.Provider getProvider()
Returns the provider of this object.


getFormat

public final java.lang.String getFormat()
Returns the name of the format of this object.


init

public final void init(Message contents)
                throws java.lang.IllegalStateException,
                       MessageException
Initializes this builder with the given message.

Throws:
java.lang.IllegalStateException - if this message has been initialized before.
MessageException - on a variety of format specific problems.

init

public final void init(Message contents,
                       java.security.SecureRandom sr)
                throws java.lang.IllegalStateException,
                       MessageException
Initializes this builder with the given message and SecureRandom object.

Throws:
java.lang.IllegalStateException - if this message has been initialized before.
MessageException - on a variety of format specific problems.

setAttribute

public final void setAttribute(java.lang.String name,
                               java.lang.Object attr)
                        throws java.lang.IllegalStateException,
                               java.lang.IllegalArgumentException,
                               MessageException
Set a format specific attribute.

Parameters:
name - a name identifying the attribute
attr - the attribute itself
Throws:
java.lang.IllegalStateException - if this message has not been initialized before.
java.lang.IllegalArgumentException - if the attribute is not supported or the given object does not have the right type.
MessageException - on a variety of format specific problems.

addRecipient

public final void addRecipient(java.security.PublicKey publickey)
                        throws java.lang.IllegalStateException,
                               java.lang.UnsupportedOperationException,
                               MessageException
Adds a public key recipient

Throws:
InvalidStateException - if this message has not been initialized properly or if the build() method has been called
java.lang.UnsupportedOperationException - if this particular format does not support encrypting messages to public keys.
MessageException - on a variety of format specific problems.
java.lang.IllegalStateException

addRecipient

public final void addRecipient(KeyBundle bundle)
                        throws java.lang.IllegalStateException,
                               java.lang.UnsupportedOperationException,
                               MessageException
Adds a keybundle recipient

Throws:
InvalidStateException - if this message has not been initialized properly or if the build() method has been called
java.lang.UnsupportedOperationException - if this particular format does not support encrypting messages to public keys.
MessageException - on a variety of format specific problems.
java.lang.IllegalStateException

addRecipient

public final void addRecipient(javax.crypto.SecretKey symmetrickey)
                        throws java.lang.IllegalStateException,
                               java.lang.UnsupportedOperationException,
                               MessageException
Adds a symmetric key recipient

Throws:
InvalidStateException - if this message has not been initialized properly or if the build() method has been called
java.lang.UnsupportedOperationException - if this particular format does not support encrypting messages to symmetric keys.
MessageException - on a variety of format specific problems.
java.lang.IllegalStateException

addRecipient

public final void addRecipient(java.lang.String passphrase)
                        throws java.lang.IllegalStateException,
                               java.lang.UnsupportedOperationException,
                               MessageException
Adds a passphrase recipient

Throws:
InvalidStateException - if this message has not been initialized properly or if the build() method has been called
java.lang.UnsupportedOperationException - if this particular format does not support encrypting messages to passphrases.
MessageException - on a variety of format specific problems.
java.lang.IllegalStateException

build

public final Message build()
                    throws java.lang.IllegalStateException,
                           MessageException
Returns the encrypted message

Throws:
InvalidStateException - if this message has not been initialized properly, if no calls have been made to any of the addRecipient methods or if multiple calls to this build() method are made.
MessageException - on a variety of format specific problems.
java.lang.IllegalStateException

Cryptix OpenPGP

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