From: adam Date: Tue, 3 Aug 2004 07:23:16 +0000 (+0000) Subject: added Confirmation.java X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=266a951dc005261d529da58438a755eaa603adda;p=org.ibex.mail.git added Confirmation.java darcs-hash:20040803072316-5007d-909e0671698ce01c8a5ca0bca905ea8c8ef9cf8a.gz --- diff --git a/src/org/ibex/mail/Confirmation.java b/src/org/ibex/mail/Confirmation.java new file mode 100644 index 0000000..dc1cf3e --- /dev/null +++ b/src/org/ibex/mail/Confirmation.java @@ -0,0 +1,136 @@ +package org.ibex.mail; +import java.lang.reflect.*; +import org.prevayler.*; +import org.ibex.crypto.*; +import org.ibex.util.*; +import org.ibex.mail.protocol.*; +import org.ibex.io.*; +import java.util.*; +import java.util.zip.*; +import java.net.*; +import java.io.*; + +/** + * A convenient way to verify that the agent requesting an action + * owns a particular email address. Extend this class; the + * Transaction.executeOn() method will be invoked when the user + * clicks through. + */ +public abstract class Confirmation implements Externalizable { + + public static final long serialVersionUID = 0x981879f18a11ffeeL; + public static final Address FROM = Address.parse("adam@megacz.com"); // FIXME + + public transient Address who = null; + public long expiration; + public abstract String getDescription(); + + protected Confirmation(Address who, long expiration) { this.who = who; this.expiration = expiration; } + + public void readExternal(ObjectInput s) throws IOException { + try { + int numfields = s.readInt(); + Class c = this.getClass(); + for(int i=0; i cve.expiration) throw new Expired(); + return cve; + } catch (ClassNotFoundException e) { + Log.error(Confirmation.class, e); + throw new InvalidSignature(); + } catch (IOException e) { + Log.error(Confirmation.class, e); + throw new InvalidSignature(); + } + } + + public static class Exn extends RuntimeException { } + public static class Expired extends Exn { } + public static class InvalidSignature extends Exn { } +}