blob: b969841a921c069b9398af7553da68235d2eb71b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* $Id$ */
package org.noreply.fancydress.type3.routing;
import org.noreply.fancydress.misc.Util;
import org.noreply.fancydress.crypto.*;
/**
* The SMTP routing as specified in the type III spec.
*
* SMTP packets are delivered by email by the handling server.
*
* The payload of a SMTP packet should be constructed according
* to the E2E spec.
*
* @see org.noreply.fancydress.type3.Payload
*/
public class RoutingSMTP extends RoutingDestination {
/**
* Recipient mailbox.
*/
String mailbox;
/**
* Construct an SMTP routing.
*/
public RoutingSMTP(String mailbox) {
super (RoutingType.SMTP);
// 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;
if (decodingHandle == null)
System.arraycopy(CryptoPrimitives.rand(DECODINGHANDLE_LEN), 0, result, pos, DECODINGHANDLE_LEN);
else
System.err.println("Using set decoding handle for "+mailbox);
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;
}
}
|