summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-10-27 19:05:26 +0000
committerPeter Palfrader <peter@palfrader.org>2003-10-27 19:05:26 +0000
commit09cc39b5ffde8b790535929e278ff5c295af88e9 (patch)
tree0df08fe4e886f026ca9e344d59d053434b183a11 /src
parentad06bd4094c3aec1a2c8e1cbcb1120df88fa1f6a (diff)
Add MBOX routing. Moo
Diffstat (limited to 'src')
-rw-r--r--src/org/noreply/fancydress/type3/routing/RoutingMBOX.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/org/noreply/fancydress/type3/routing/RoutingMBOX.java b/src/org/noreply/fancydress/type3/routing/RoutingMBOX.java
new file mode 100644
index 0000000..2016228
--- /dev/null
+++ b/src/org/noreply/fancydress/type3/routing/RoutingMBOX.java
@@ -0,0 +1,64 @@
+/* $Id$ */
+package org.noreply.fancydress.type3.routing;
+
+import org.noreply.fancydress.misc.Util;
+import org.noreply.fancydress.crypto.*;
+
+/**
+ * The MBOX routing as specified in the type III spec.
+ *
+ * MBOX packets are delivered by email by the handling server.
+ *
+ * The payload of a MBOX packet should be constructed according
+ * to the E2E spec.
+ *
+ * @see org.noreply.fancydress.type3.Payload
+ */
+public class RoutingMBOX extends RoutingDestination {
+ /**
+ * Recipient mailbox.
+ */
+ String mailbox;
+
+ /**
+ * Construct an MBOX routing.
+ */
+ public RoutingMBOX(String mailbox) {
+ super (RoutingType.MBOX);
+
+ // FIXME: syntax check mailbox
+
+ this.mailbox = mailbox;
+ }
+
+ /**
+ * Return the total length in octets of the routing information.
+ *
+ * @return total length in octets of the routing information
+ */
+ public int getRoutingInformationLength() {
+ return DECODINGHANDLE_LEN + mailbox.length();
+ }
+
+ /**
+ * Get the routing type of this instance.
+ *
+ * @return routing type
+ */
+ public byte[] getRoutingInformation() {
+ int length = getRoutingInformationLength();
+ byte[] result = new byte[length];
+ int pos = 0;
+
+ System.arraycopy(CryptoPrimitives.rand(DECODINGHANDLE_LEN), 0, result, pos, DECODINGHANDLE_LEN);
+ pos += DECODINGHANDLE_LEN;
+ System.arraycopy(Util.toOctets(mailbox), 0, result, pos, mailbox.length());
+ pos += mailbox.length();
+
+ if (pos != length)
+ throw new Error("Did not fill in expected amount of bytes!");
+
+ return result;
+ }
+}
+