blob: aafa895e1899bd4822e0ec854c2c29bbfd6b4c2f (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/* $Id$ */
package org.noreply.fancydress.directory;
import org.noreply.fancydress.directory.parser.*;
import org.noreply.fancydress.misc.Util;
import org.noreply.fancydress.status.*;
import java.util.*;
import java.text.ParseException;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* Base class for both DeliveryMBOXSection and DeliverySMTP Section.
*
* This is a base class for the DeliveryMBOXSection and the DeliverySMTP class.
* Since both are very similar it makes sense to pool their functionality into
* a single class from which both inheritate.
*
* @see ServerDescriptor
*/
public class DeliveryMBOXSMTPSection {
private String name;
/* Required */
/**
* The version number of this section.
*/
private String version;
/**
* The maximum message size (in Kb) that is accepted at this node.
*/
private int maximumSize;
/**
* Whether this exit node allows user supplied From: lines.
*/
private boolean allowFrom;
/**
* Construct a Delivery/MBOX or Delivery/SMTP section.
*
* @param section the section to parse.
* @throws Mix3BadServerUnrecognizedVersionException if the Version in the section is not recognized.
* @throws Mix3BadServerFormatException if the Section is syntactially invalid.
*/
public DeliveryMBOXSMTPSection(DirectorySection section)
throws Mix3BadServerFormatException
{
name = section.getName();
parseDeliveryMBOXSMTPSection(section);
}
/**
* Parse a Delivery/MBOX or the Delivery/SMTP section.
*
* @param section the section to parse.
* @throws Mix3BadServerUnrecognizedVersionException if the Version in the section is not recognized.
* @throws Mix3BadServerFormatException if the Section is syntactially invalid.
*/
private void parseDeliveryMBOXSMTPSection(DirectorySection section) throws Mix3BadServerFormatException {
/* Check Version */
DirectoryEntry entryVersion = section.getEntry("Version");
if (entryVersion == null)
throw new Mix3BadServerFormatException("Version not in " + name + " section");
version = entryVersion.getValue();
if (! version.equals("0.1"))
/* We have to ignore unknown Versions */
throw new Mix3BadServerUnrecognizedVersionException("Unrecognized " + name + " Version "+version);
/* mandatory entries */
DirectoryEntry entryMaximumSize = section.getEntry("Maximum-size");
DirectoryEntry entryAllowFrom = section.getEntry("Allow-From");
/* FIXME
if (entryMaximumSize == null)
throw new Mix3BadServerFormatException("Maximum-size not in " + name + " section");
*/
if (entryAllowFrom == null)
throw new Mix3BadServerFormatException("Allow-From not in " + name + " section");
/* FIXME
try {
Integer p = new Integer(entryMaximumSize.getValue());
maximumSize = p.intValue();
} catch (NumberFormatException e) {
throw new Mix3BadServerFormatException("Maximum-size is not a valid integer in " + name + " section", e);
};
if (maximumSize < 32)
throw new Mix3BadServerFormatException("Maximum-size is smaller than 32 in " + name + " section");
*/
try {
allowFrom = Util.parseBoolean(entryAllowFrom.getValue());
} catch (ParseException e) {
throw new Mix3BadServerFormatException("Allow-From is not a valid boolean in " + name + " section", e);
};
}
}
|