From 3160828378e846c7ea37bc816bbcd234f8fda89e Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 19 Oct 2003 15:09:14 +0000 Subject: Add new files created for random path creation --- .../fancydress/directory/OutgoingMMTPSection.java | 74 ++++++++++++++++++++++ .../Mix3BadArgumentsIllegalPathSpecException.java | 15 +++++ .../status/Mix3BadDirectoryFormatException.java | 14 ++++ .../status/Mix3NoServerDescriptorException.java | 16 +++++ .../status/Mix3PathProblemException.java | 14 ++++ 5 files changed, 133 insertions(+) create mode 100644 src/org/noreply/fancydress/directory/OutgoingMMTPSection.java create mode 100644 src/org/noreply/fancydress/status/Mix3BadArgumentsIllegalPathSpecException.java create mode 100644 src/org/noreply/fancydress/status/Mix3BadDirectoryFormatException.java create mode 100644 src/org/noreply/fancydress/status/Mix3NoServerDescriptorException.java create mode 100644 src/org/noreply/fancydress/status/Mix3PathProblemException.java diff --git a/src/org/noreply/fancydress/directory/OutgoingMMTPSection.java b/src/org/noreply/fancydress/directory/OutgoingMMTPSection.java new file mode 100644 index 0000000..8b9ca9b --- /dev/null +++ b/src/org/noreply/fancydress/directory/OutgoingMMTPSection.java @@ -0,0 +1,74 @@ +/* $Id$ */ +package org.noreply.fancydress.directory; + +import org.bouncycastle.util.encoders.Base64; +import org.noreply.fancydress.directory.parser.*; +import org.noreply.fancydress.misc.Util; +import org.noreply.fancydress.crypto.*; +import org.noreply.fancydress.status.*; +import java.util.*; +import java.text.ParseException; +import java.net.InetAddress; +import java.net.UnknownHostException; + +/* FIXME: parse allow/deny ACLs */ + +/** + * Represent an Outgoing/MMTP section of a server descriptor. + * + * @see ServerDescriptor + */ +public class OutgoingMMTPSection { + /* + * version we understand. + */ + private static final String VERSION = "0.1"; + + private String name; + + /* Required */ + private String version; + private String[] protocols; + + /** + * Construct an Outgoing/MMTP section. + * + * @param section the section to parse. + * @throws Mix3BadServerFormatException if the Section is syntactially invalid. + */ + public OutgoingMMTPSection(DirectorySection section) + throws Mix3BadServerFormatException + { + name = section.getName(); + parseOutgoingMMTPSection(section); + } + + /** + * Parse an Outgoing/MMTP section. + * + * @param section the section to parse. + * @throws Mix3BadServerFormatException if the Section is syntactially invalid. + */ + private void parseOutgoingMMTPSection(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(VERSION)) + /* We have to ignore unknown Versions */ + throw new Mix3BadServerUnrecognizedVersionException("Unrecognized " + name + " Version "+version); + + /* mandatory entries */ + DirectoryEntry entryProtocols = section.getEntry("Protocols"); + + /* check if mandatory entries are available */ + if (entryProtocols == null) + throw new Mix3BadServerFormatException("Protocols not in " + name + " section"); + protocols = Util.tokenize(entryProtocols.getValue(), ','); + } + + public String[] getProtocols() { + return protocols; + } +} diff --git a/src/org/noreply/fancydress/status/Mix3BadArgumentsIllegalPathSpecException.java b/src/org/noreply/fancydress/status/Mix3BadArgumentsIllegalPathSpecException.java new file mode 100644 index 0000000..01c4a6d --- /dev/null +++ b/src/org/noreply/fancydress/status/Mix3BadArgumentsIllegalPathSpecException.java @@ -0,0 +1,15 @@ +/* $Id$ */ +package org.noreply.fancydress.status; + +/** + * The operation failed because the chain specified does not fit into a single + * leg. + */ +public class Mix3BadArgumentsIllegalPathSpecException extends Mix3BadArgumentsException { + public Mix3BadArgumentsIllegalPathSpecException(String s) { + super(s); + } + public Mix3BadArgumentsIllegalPathSpecException(String s, Throwable cause) { + super(s, cause); + } +} diff --git a/src/org/noreply/fancydress/status/Mix3BadDirectoryFormatException.java b/src/org/noreply/fancydress/status/Mix3BadDirectoryFormatException.java new file mode 100644 index 0000000..3c1a7ef --- /dev/null +++ b/src/org/noreply/fancydress/status/Mix3BadDirectoryFormatException.java @@ -0,0 +1,14 @@ +/* $Id$ */ +package org.noreply.fancydress.status; + +/** + * The operation failed because the directory has an invalid format. + */ +public class Mix3BadDirectoryFormatException extends Mix3BadSignatureException { + public Mix3BadDirectoryFormatException(String s) { + super(s); + } + public Mix3BadDirectoryFormatException(String s, Throwable cause) { + super(s, cause); + } +} diff --git a/src/org/noreply/fancydress/status/Mix3NoServerDescriptorException.java b/src/org/noreply/fancydress/status/Mix3NoServerDescriptorException.java new file mode 100644 index 0000000..2e64cb4 --- /dev/null +++ b/src/org/noreply/fancydress/status/Mix3NoServerDescriptorException.java @@ -0,0 +1,16 @@ +/* $Id$ */ +package org.noreply.fancydress.status; + +/** + * No valid server descriptors found. + * + * @see org.noreply.fancydress.direcotry.Server#getDescriptor + */ +public class Mix3NoServerDescriptorException extends Mix3Exception { + public Mix3NoServerDescriptorException(String s) { + super(s); + } + public Mix3NoServerDescriptorException(String s, Throwable cause) { + super(s, cause); + } +} diff --git a/src/org/noreply/fancydress/status/Mix3PathProblemException.java b/src/org/noreply/fancydress/status/Mix3PathProblemException.java new file mode 100644 index 0000000..7877996 --- /dev/null +++ b/src/org/noreply/fancydress/status/Mix3PathProblemException.java @@ -0,0 +1,14 @@ +/* $Id$ */ +package org.noreply.fancydress.status; + +/** + * There is a problem with the path. + */ +public class Mix3PathProblemException extends Mix3Exception { + public Mix3PathProblemException(String s) { + super(s); + } + public Mix3PathProblemException(String s, Throwable cause) { + super(s, cause); + } +} -- cgit v1.2.3