tuotoo-commit Mailing List for Tuotoo
Status: Pre-Alpha
Brought to you by:
hanru
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(5) |
Dec
|
|---|
|
From: <ha...@us...> - 2007-11-26 11:02:11
|
Revision: 7
http://tuotoo.svn.sourceforge.net/tuotoo/?rev=7&view=rev
Author: hanru
Date: 2007-11-26 03:02:15 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
imporve a bit on this class.
Modified Paths:
--------------
trunk/src/org/tuotoo/logging/LogHolder.java
Modified: trunk/src/org/tuotoo/logging/LogHolder.java
===================================================================
--- trunk/src/org/tuotoo/logging/LogHolder.java 2007-11-26 08:29:55 UTC (rev 6)
+++ trunk/src/org/tuotoo/logging/LogHolder.java 2007-11-26 11:02:15 UTC (rev 7)
@@ -162,15 +162,15 @@
return;
}
- if (isLogged(a_logLevel, a_logType)) {
+ if (canLogged(a_logLevel, a_logType)) {
String message = "";
if (a_message != null && a_message.length() > 0) {
message = a_message;
}
if (m_messageDetailLevel <= DETAIL_LEVEL_LOWEST) {
- getInstance().getLogInstance().log(a_logLevel, a_logType,
- a_throwable.getMessage());
+ ms_logInstance.log(a_logLevel, a_logType, a_throwable
+ .getMessage());
} else if (m_messageDetailLevel > DETAIL_LEVEL_LOWEST
&& m_messageDetailLevel < DETAIL_LEVEL_HIGHEST) {
if (message.length() == 0) {
@@ -180,8 +180,8 @@
+ a_throwable.getMessage();
}
- getInstance().getLogInstance().log(a_logLevel, a_logType,
- a_throwable.toString());
+ ms_logInstance.log(a_logLevel, a_logType, a_throwable
+ .toString());
} else if (m_messageDetailLevel == DETAIL_LEVEL_HIGH) {
if (message.length() == 0) {
message = a_throwable.toString();
@@ -189,12 +189,10 @@
message += "\n" + LOGGED_THROWABLE + a_throwable.toString();
}
- getInstance().getLogInstance().log(
- a_logLevel,
- a_logType,
- Util.normaliseString(getCallingClassFile(false) + ": ",
- LINE_LENGTH_HIGH_DETAIL)
- + message);
+ ms_logInstance.log(a_logLevel, a_logType, Util.normaliseString(
+ getCallingClassFile(false) + ": ",
+ LINE_LENGTH_HIGH_DETAIL)
+ + message);
} else if (m_messageDetailLevel >= DETAIL_LEVEL_HIGHEST) {
if (message.length() == 0) {
message = Util.getStackTrace(a_throwable);
@@ -203,12 +201,10 @@
+ Util.getStackTrace(a_throwable);
}
- getInstance().getLogInstance().log(
- a_logLevel,
- a_logType,
- Util.normaliseString(getCallingMethod(false) + ": ",
- LINE_LENGTH_HIGHEST_DETAIL)
- + message);
+ ms_logInstance.log(a_logLevel, a_logType, Util.normaliseString(
+ getCallingMethod(false) + ": ",
+ LINE_LENGTH_HIGHEST_DETAIL)
+ + message);
}
}
}
@@ -230,7 +226,7 @@
*/
public static void log(int logLevel, int logType, String message,
boolean a_bAddCallingClass) {
- if (isLogged(logLevel, logType)) {
+ if (canLogged(logLevel, logType)) {
if (m_messageDetailLevel <= DETAIL_LEVEL_LOWEST) {
ms_logInstance.log(logLevel, logType, message);
} else if (m_messageDetailLevel == DETAIL_LEVEL_LOWER) {
@@ -281,9 +277,9 @@
* The instance of a Log implementation.
*/
public static synchronized void setLogInstance(Log logInstance) {
- getInstance().ms_logInstance = logInstance;
- if (getInstance().ms_logInstance == null) {
- getInstance().ms_logInstance = new DummyLog();
+ ms_logInstance = logInstance;
+ if (ms_logInstance == null) {
+ ms_logInstance = new DummyLog();
}
}
@@ -310,7 +306,7 @@
return ms_logInstance;
}
- private static boolean isLogged(int a_logLevel, int a_logType) {
+ private static boolean canLogged(int a_logLevel, int a_logType) {
return (a_logLevel <= ms_logInstance.getLogLevel())
&& ((a_logType & ms_logInstance.getLogType()) == a_logType);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-11-26 08:29:54
|
Revision: 6
http://tuotoo.svn.sourceforge.net/tuotoo/?rev=6&view=rev
Author: hanru
Date: 2007-11-26 00:29:55 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
some trivial changes.
Modified Paths:
--------------
trunk/src/org/tuotoo/logging/LogLevel.java
trunk/src/org/tuotoo/logging/LogType.java
trunk/src/org/tuotoo/tor/Config.java
trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java
trunk/src/org/tuotoo/tor/ordescription/ORList.java
trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java
trunk/test/org/tuotoo/tor/test/Proxy.java
Removed Paths:
-------------
trunk/src/org/tuotoo/logging/ChainedLog.java
Deleted: trunk/src/org/tuotoo/logging/ChainedLog.java
===================================================================
--- trunk/src/org/tuotoo/logging/ChainedLog.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/logging/ChainedLog.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -1,57 +0,0 @@
-/*
- Copyright (c) 2000 - 2004, The JAP-Team
- All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
-
- - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
- may be used to endorse or promote products derived from this software without specific
- prior written permission.
-
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
- */
-package org.tuotoo.logging;
-
-/** Writes log output to two Log instances */
-public class ChainedLog implements Log {
- Log m_Log1, m_Log2;
-
- public ChainedLog(Log log1, Log log2) {
- m_Log1 = log1;
- m_Log2 = log2;
- }
-
- public synchronized void log(int level, int type, String mesg) {
- m_Log1.log(level, type, mesg);
- m_Log2.log(level, type, mesg);
- }
-
- public void setLogType(int type) {
- }
-
- public int getLogType() {
- return LogType.ALL;
- }
-
- public void setLogLevel(int level) {
- }
-
- public int getLogLevel() {
- return LogLevel.DEBUG;
- }
-}
Modified: trunk/src/org/tuotoo/logging/LogLevel.java
===================================================================
--- trunk/src/org/tuotoo/logging/LogLevel.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/logging/LogLevel.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -38,9 +38,7 @@
* Indicates level type of message: For instance to use when catching
* Exeption to output a debug message.
*/
- public final static int EXCEPTION = 2; // 2000-07-31(HF): CRIT zu EXCEPTION
- // geaendert, wegen besserem
- // Verstaendnis
+ public final static int EXCEPTION = 2;
/** Indicates level type of message: Error message */
public final static int ERR = 3;
@@ -61,7 +59,8 @@
public final static int DEBUG = 7;
public final static String STR_Levels[] = { "Emergency", "Alert ",
- "Exception", "Error ", "Warning ", "Notice ", "Info ",
- "Debug " };
+ "Exception", "Error ", "Warning ", "Notice ", "Info ",
+ "Debug "
+ };
}
Modified: trunk/src/org/tuotoo/logging/LogType.java
===================================================================
--- trunk/src/org/tuotoo/logging/LogType.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/logging/LogType.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -43,8 +43,8 @@
* here, too.
*/
private static final String[] STR_LOG_TYPES = { "NUL", "GUI", "NET",
- "THREAD", "MISC", "PAY", "TOR", "CRYPTO", "FILTER", "AGREEMENT",
- "ALL" };
+ "THREAD", "MISC", "PAY", "TOR", "CRYPTO", "FILTER", "ALL"
+ };
/** The concatenation string of the human readable log types. */
private static final String STR_ADD_LOG_TYPE = "+";
@@ -66,15 +66,15 @@
/** Indicates a misc message (binary: <code>00001000</code>) */
public static final int MISC = LOG_TYPES[4];
- /** Indicates a pay message (binary: <code>00001000</code>) */
+ /** Indicates a pay message (binary: <code>00010000</code>) */
public static final int PAY = LOG_TYPES[5];
- /** Indicates a TOR message (binary: <code>00010000</code>) */
+ /** Indicates a TOR message (binary: <code>00100000</code>) */
public static final int TOR = LOG_TYPES[6];
/**
* Indicates a message related to cryptographic operations (binary:
- * <code>00100000</code>)
+ * <code>01000000</code>)
*/
public static final int CRYPTO = LOG_TYPES[7];
@@ -84,9 +84,6 @@
/** Indicates messages from the http filter system */
public static final int FILTER = LOG_TYPES[8];
- /** Indicates messages from the paw filter system */
- public static final int AGREEMENT = LOG_TYPES[9];
-
/** Indicates all messages */
public static final int ALL = createLogTypeALL();
Modified: trunk/src/org/tuotoo/tor/Config.java
===================================================================
--- trunk/src/org/tuotoo/tor/Config.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/tor/Config.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -36,6 +36,7 @@
// initialize default properties
defProps.setProperty("proxy.SocksPort", "9150");
+ defProps.setProperty("data.Directory", getDefaultDataDir());
// ...
m_props = new Properties(defProps);
@@ -96,4 +97,10 @@
return System.getProperty("user.home")
+ System.getProperty("file.separator") + "tuotoo.conf";
}
+
+ private static String getDefaultDataDir() {
+ return System.getProperty("user.home")
+ + System.getProperty("file.separator") + ".tuotoo"
+ + System.getProperty("file.separator");
+ }
}
Modified: trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java
===================================================================
--- trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -291,8 +291,7 @@
ORDescriptor or = (ORDescriptor) onionrouter;
if (m_address.equals(or.getAddress())
- && m_name.equals(or.getName())
- && (m_port == or.getPort())) {
+ && m_name.equals(or.getName()) && (m_port == or.getPort())) {
return true;
}
// routers in the same family are also equal
@@ -457,7 +456,7 @@
ORDescriptor ord = new ORDescriptor(adr, nickname,
Integer.parseInt(orport), strSoftware);
if (!ord.setOnionKey(key)
- || !ord.setSigningKey(signingkey)) {
+ || !ord.setSigningKey(signingkey)) {
return null;
}
ord.setAcl(acl);
@@ -487,8 +486,8 @@
public String toString() {
return "ORRouter: " + this.m_name + " on " + this.m_address + ":"
- + this.m_port + " Software : " + this.m_strSoftware
- + " isExitNode:" + this.m_bIsExitNode;
+ + this.m_port + " Software : " + this.m_strSoftware
+ + " isExitNode:" + this.m_bIsExitNode;
}
private static String calcHash(String desc) {
Modified: trunk/src/org/tuotoo/tor/ordescription/ORList.java
===================================================================
--- trunk/src/org/tuotoo/tor/ordescription/ORList.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/tor/ordescription/ORList.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -100,7 +100,7 @@
}
/**
- * Updates the list of available ORRouters.
+ * Updates the list of available OR Routers.
*
* @return true if it was ok, false otherwise
*/
@@ -108,12 +108,8 @@
try {
byte[] buff = null;
if (size() == 0
- || (buff = m_orlistFetcher.getRouterStatus()) == null)// either
- // first
- // time
- // list
- // retrival
- // or
+ || (buff = m_orlistFetcher.getRouterStatus()) == null)
+ // either first time list retrival or
// getting information for differential update failed
{
buff = m_orlistFetcher.getAllDescriptors();
@@ -397,8 +393,8 @@
String digest = Base16.encode((Base64.decode(hashDescriptor)));
if ((ord == null)
- || ((ord.getHash() == null) || (!digest.equals(ord
- .getHash())))) {
+ || ((ord.getHash() == null) || (!digest.equals(ord
+ .getHash())))) {
b = m_orlistFetcher.getDescriptor(digest);
if (b != null) {
if (ord != null && ord.getHibernate()) {
@@ -436,8 +432,8 @@
LineNumberReader reader = new LineNumberReader(new InputStreamReader(
new ByteArrayInputStream(document)));
Date published = new Date();// workaround for a while until we are able
- // to get the real published date of the tor
- // list
+ // to get the real published date of the tor
+ // list
reader.mark(200);
String curLine = reader.readLine();
@@ -472,8 +468,9 @@
}
LogHolder.log(LogLevel.DEBUG, LogType.TOR, "Exit Nodes : "
- + m_exitnodes.size() + " Non-Exit Nodes : "
- + m_middlenodes.size());
+ + m_exitnodes.size()
+ + " Non-Exit Nodes : "
+ + m_middlenodes.size());
m_datePublished = published;
return true;
Modified: trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java
===================================================================
--- trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -85,8 +85,8 @@
*/
private byte[] getDocument(String path) {
try {
- LogHolder.log(LogLevel.DEBUG, LogType.TOR, "fetching " + path
- + " from directory server");
+ LogHolder.log(LogLevel.DEBUG, LogType.TOR,
+ "fetching " + path + " from directory server");
HTTPConnection http = new HTTPConnection(m_ORListServer,
m_ORListPort);
HTTPResponse resp = http.Get(path);
@@ -101,8 +101,9 @@
return null;
return doc;
} catch (Throwable t) {
- LogHolder.log(LogLevel.DEBUG, LogType.TOR, "error while fetching "
- + path + " from directory server: " + t.getMessage());
+ LogHolder.log(LogLevel.DEBUG, LogType.TOR,
+ "error while fetching " + path + " from directory server: "
+ + t.getMessage());
return null;
}
}
Modified: trunk/test/org/tuotoo/tor/test/Proxy.java
===================================================================
--- trunk/test/org/tuotoo/tor/test/Proxy.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/test/org/tuotoo/tor/test/Proxy.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -28,6 +28,11 @@
private static Tor tor;
public Proxy() {
+ SystemErrLog log = new SystemErrLog();
+ log.setLogType(LogType.TOR);
+ log.setLogLevel(LogLevel.DEBUG);
+ LogHolder.setLogInstance(log);
+
tor = Tor.getInstance();
tor.initialize(new TorAnonServerDescription(), null);
port = 9150;
@@ -38,11 +43,6 @@
new Proxy();
try {
- SystemErrLog log = new SystemErrLog();
- log.setLogType(LogType.TOR);
- log.setLogLevel(LogLevel.EMERG);
- LogHolder.setLogInstance(new SystemErrLog());
-
ServerSocket ss = new ServerSocket(port);
while (true) {
Socket s = ss.accept();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-11-24 08:28:42
|
Revision: 5
http://tuotoo.svn.sourceforge.net/tuotoo/?rev=5&view=rev
Author: hanru
Date: 2007-11-24 00:28:46 -0800 (Sat, 24 Nov 2007)
Log Message:
-----------
Set $HOME/tuotoo.conf as the default config file, also add a new getInstance() method to retrive non-default config file.
Modified Paths:
--------------
trunk/src/org/tuotoo/tor/Config.java
Modified: trunk/src/org/tuotoo/tor/Config.java
===================================================================
--- trunk/src/org/tuotoo/tor/Config.java 2007-11-22 12:29:19 UTC (rev 4)
+++ trunk/src/org/tuotoo/tor/Config.java 2007-11-24 08:28:46 UTC (rev 5)
@@ -48,6 +48,12 @@
return ms_instance;
}
+ public static Config getInstance(String conf) {
+ if (ms_instance == null)
+ ms_instance = new Config(conf);
+ return ms_instance;
+ }
+
public String getConfig(String key) {
return m_props.getProperty(key);
}
@@ -67,8 +73,6 @@
LogHolder.log(LogLevel.NOTICE, LogType.TOR, confFile
+ " not exists, creating an empty one.");
File f = new File(confFile);
- File pf = f.getParentFile();
- pf.mkdirs();
f.createNewFile();
} catch (Exception ex) {
ex.printStackTrace();
@@ -90,7 +94,6 @@
private static String getDefaultConfigLocation() {
return System.getProperty("user.home")
- + System.getProperty("file.separator") + ".tuotoo"
+ System.getProperty("file.separator") + "tuotoo.conf";
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-11-22 12:29:14
|
Revision: 4
http://tuotoo.svn.sourceforge.net/tuotoo/?rev=4&view=rev
Author: hanru
Date: 2007-11-22 04:29:19 -0800 (Thu, 22 Nov 2007)
Log Message:
-----------
A simple config class for holding all future config items.
Added Paths:
-----------
trunk/src/org/tuotoo/tor/Config.java
Added: trunk/src/org/tuotoo/tor/Config.java
===================================================================
--- trunk/src/org/tuotoo/tor/Config.java (rev 0)
+++ trunk/src/org/tuotoo/tor/Config.java 2007-11-22 12:29:19 UTC (rev 4)
@@ -0,0 +1,96 @@
+package org.tuotoo.tor;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.util.Properties;
+
+import org.tuotoo.logging.LogHolder;
+import org.tuotoo.logging.LogLevel;
+import org.tuotoo.logging.LogType;
+
+public class Config {
+
+ private static Config ms_instance = null;
+
+ private Properties m_props;
+
+ private String confFile;
+
+ public static String[] defaultDirServers = {
+ "moria1 128.31.0.34 9031 FFCB46DB1339DA84674C70D7CB586434C4370441",
+ "moria2 128.31.0.34 9032 719BE45DE224B607C53707D0E2143E2D423E74CF",
+ "tor26 86.59.21.38 80 847B1F850344D7876491A54892F904934E4EB85D",
+ "lefkada 140.247.60.64 80 38D4F5FCF7B1023228B895EA56EDE7D5CCDCAF32",
+ "dizum 194.109.206.212 80 7EA6EAD6FD83083C538F44038BBFA077587DD755",
+ };
+
+ private Config() {
+ this(getDefaultConfigLocation());
+ }
+
+ private Config(String conf) {
+ confFile = conf;
+ Properties defProps = new Properties();
+
+ // initialize default properties
+ defProps.setProperty("proxy.SocksPort", "9150");
+ // ...
+
+ m_props = new Properties(defProps);
+ load();
+ }
+
+ public static Config getInstance() {
+ if (ms_instance == null)
+ ms_instance = new Config();
+ return ms_instance;
+ }
+
+ public String getConfig(String key) {
+ return m_props.getProperty(key);
+ }
+
+ public void setConfig(String key, String value) {
+ m_props.setProperty(key, value);
+ }
+
+ private void load() {
+ try {
+ FileInputStream in = new FileInputStream(confFile);
+ m_props.load(in);
+ in.close();
+ } catch (FileNotFoundException e) {
+ // 'confFile' not exists, create an empty one
+ try {
+ LogHolder.log(LogLevel.NOTICE, LogType.TOR, confFile
+ + " not exists, creating an empty one.");
+ File f = new File(confFile);
+ File pf = f.getParentFile();
+ pf.mkdirs();
+ f.createNewFile();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void save() {
+ try {
+ FileOutputStream out = new FileOutputStream(confFile);
+ m_props.store(out, "");
+ out.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static String getDefaultConfigLocation() {
+ return System.getProperty("user.home")
+ + System.getProperty("file.separator") + ".tuotoo"
+ + System.getProperty("file.separator") + "tuotoo.conf";
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2007-11-20 12:35:15
|
Revision: 3
http://tuotoo.svn.sourceforge.net/tuotoo/?rev=3&view=rev
Author: hanru
Date: 2007-11-20 04:35:10 -0800 (Tue, 20 Nov 2007)
Log Message:
-----------
Code format change, not actual change.
Modified Paths:
--------------
trunk/src/org/tuotoo/AnonChannel.java
trunk/src/org/tuotoo/AnonServerDescription.java
trunk/src/org/tuotoo/AnonService.java
trunk/src/org/tuotoo/AnonServiceEventListener.java
trunk/src/org/tuotoo/ErrorCodes.java
trunk/src/org/tuotoo/IServiceContainer.java
trunk/src/org/tuotoo/crypto/AbstractPrivateKey.java
trunk/src/org/tuotoo/crypto/AbstractPublicKey.java
trunk/src/org/tuotoo/crypto/AbstractX509AlternativeName.java
trunk/src/org/tuotoo/crypto/AbstractX509Extension.java
trunk/src/org/tuotoo/crypto/AsymmetricCryptoKeyPair.java
trunk/src/org/tuotoo/crypto/ByteSignature.java
trunk/src/org/tuotoo/crypto/CertPath.java
trunk/src/org/tuotoo/crypto/CertificateContainer.java
trunk/src/org/tuotoo/crypto/CertificateInfoStructure.java
trunk/src/org/tuotoo/crypto/CertificateStore.java
trunk/src/org/tuotoo/crypto/CertificationRequest.java
trunk/src/org/tuotoo/crypto/CertificationRequestInfo.java
trunk/src/org/tuotoo/crypto/DSAKeyPair.java
trunk/src/org/tuotoo/crypto/ICertificate.java
trunk/src/org/tuotoo/crypto/IMyPrivateKey.java
trunk/src/org/tuotoo/crypto/IMyPublicKey.java
trunk/src/org/tuotoo/crypto/IMySignature.java
trunk/src/org/tuotoo/crypto/ISignatureCreationAlgorithm.java
trunk/src/org/tuotoo/crypto/ISignatureVerificationAlgorithm.java
trunk/src/org/tuotoo/crypto/IVerifyable.java
trunk/src/org/tuotoo/crypto/JAPCertificate.java
trunk/src/org/tuotoo/crypto/MyAES.java
trunk/src/org/tuotoo/crypto/MyDSAParams.java
trunk/src/org/tuotoo/crypto/MyDSAPrivateKey.java
trunk/src/org/tuotoo/crypto/MyDSAPublicKey.java
trunk/src/org/tuotoo/crypto/MyDSASignature.java
trunk/src/org/tuotoo/crypto/MyRSA.java
trunk/src/org/tuotoo/crypto/MyRSAPrivateKey.java
trunk/src/org/tuotoo/crypto/MyRSAPublicKey.java
trunk/src/org/tuotoo/crypto/MyRSASignature.java
trunk/src/org/tuotoo/crypto/MyRandom.java
trunk/src/org/tuotoo/crypto/PKCS10CertificationRequest.java
trunk/src/org/tuotoo/crypto/PKCS12.java
trunk/src/org/tuotoo/crypto/RSAKeyPair.java
trunk/src/org/tuotoo/crypto/SignatureCreator.java
trunk/src/org/tuotoo/crypto/SignatureVerifier.java
trunk/src/org/tuotoo/crypto/Validity.java
trunk/src/org/tuotoo/crypto/X509DistinguishedName.java
trunk/src/org/tuotoo/crypto/X509Extensions.java
trunk/src/org/tuotoo/crypto/X509IssuerAlternativeName.java
trunk/src/org/tuotoo/crypto/X509SubjectAlternativeName.java
trunk/src/org/tuotoo/crypto/X509SubjectKeyIdentifier.java
trunk/src/org/tuotoo/crypto/X509UnknownExtension.java
trunk/src/org/tuotoo/crypto/XMLSignature.java
trunk/src/org/tuotoo/crypto/tinytls/AbstractTLSRecord.java
trunk/src/org/tuotoo/crypto/tinytls/TLSException.java
trunk/src/org/tuotoo/crypto/tinytls/TLSHandshakeRecord.java
trunk/src/org/tuotoo/crypto/tinytls/TLSPlaintextRecord.java
trunk/src/org/tuotoo/crypto/tinytls/TinyTLS.java
trunk/src/org/tuotoo/crypto/tinytls/TinyTLSServer.java
trunk/src/org/tuotoo/crypto/tinytls/TinyTLSServerSocket.java
trunk/src/org/tuotoo/crypto/tinytls/ciphersuites/CipherSuite.java
trunk/src/org/tuotoo/crypto/tinytls/ciphersuites/DHE_DSS_WITH_3DES_CBC_SHA.java
trunk/src/org/tuotoo/crypto/tinytls/ciphersuites/DHE_DSS_WITH_AES_128_CBC_SHA.java
trunk/src/org/tuotoo/crypto/tinytls/ciphersuites/DHE_DSS_WITH_DES_CBC_SHA.java
trunk/src/org/tuotoo/crypto/tinytls/ciphersuites/DHE_RSA_WITH_3DES_CBC_SHA.java
trunk/src/org/tuotoo/crypto/tinytls/ciphersuites/DHE_RSA_WITH_AES_128_CBC_SHA.java
trunk/src/org/tuotoo/crypto/tinytls/ciphersuites/DHE_RSA_WITH_DES_CBC_SHA.java
trunk/src/org/tuotoo/crypto/tinytls/keyexchange/DHE_DSS_Key_Exchange.java
trunk/src/org/tuotoo/crypto/tinytls/keyexchange/DHE_RSA_Key_Exchange.java
trunk/src/org/tuotoo/crypto/tinytls/keyexchange/Key_Exchange.java
trunk/src/org/tuotoo/crypto/tinytls/util/PRF.java
trunk/src/org/tuotoo/crypto/tinytls/util/P_Hash.java
trunk/src/org/tuotoo/crypto/tinytls/util/hash.java
trunk/src/org/tuotoo/infoservice/AbstractDatabaseEntry.java
trunk/src/org/tuotoo/infoservice/Database.java
trunk/src/org/tuotoo/infoservice/DatabaseMessage.java
trunk/src/org/tuotoo/infoservice/HTTPConnectionFactory.java
trunk/src/org/tuotoo/infoservice/IDistributable.java
trunk/src/org/tuotoo/infoservice/IDistributor.java
trunk/src/org/tuotoo/infoservice/IMutableProxyInterface.java
trunk/src/org/tuotoo/infoservice/ImmutableListenerInterface.java
trunk/src/org/tuotoo/infoservice/ImmutableProxyInterface.java
trunk/src/org/tuotoo/infoservice/ListenerInterface.java
trunk/src/org/tuotoo/infoservice/ProxyInterface.java
trunk/src/org/tuotoo/logging/AbstractLog4jLog.java
trunk/src/org/tuotoo/logging/ChainedLog.java
trunk/src/org/tuotoo/logging/DummyLog.java
trunk/src/org/tuotoo/logging/FileLog.java
trunk/src/org/tuotoo/logging/Log.java
trunk/src/org/tuotoo/logging/LogHolder.java
trunk/src/org/tuotoo/logging/LogLevel.java
trunk/src/org/tuotoo/logging/LogType.java
trunk/src/org/tuotoo/logging/SystemErrLog.java
trunk/src/org/tuotoo/shared/AbstractChannel.java
trunk/src/org/tuotoo/shared/ChannelInputStream.java
trunk/src/org/tuotoo/shared/ChannelOutputStream.java
trunk/src/org/tuotoo/shared/IOQueue.java
trunk/src/org/tuotoo/shared/ProxyConnection.java
trunk/src/org/tuotoo/tor/CellQueue.java
trunk/src/org/tuotoo/tor/Circuit.java
trunk/src/org/tuotoo/tor/FirstOnionRouterConnection.java
trunk/src/org/tuotoo/tor/FirstOnionRouterConnectionFactory.java
trunk/src/org/tuotoo/tor/FirstOnionRouterConnectionThread.java
trunk/src/org/tuotoo/tor/OnionRouter.java
trunk/src/org/tuotoo/tor/Tor.java
trunk/src/org/tuotoo/tor/TorChannel.java
trunk/src/org/tuotoo/tor/TorSocksChannel.java
trunk/src/org/tuotoo/tor/cells/Cell.java
trunk/src/org/tuotoo/tor/cells/CreateCell.java
trunk/src/org/tuotoo/tor/cells/CreatedCell.java
trunk/src/org/tuotoo/tor/cells/DestroyCell.java
trunk/src/org/tuotoo/tor/cells/ExtendCell.java
trunk/src/org/tuotoo/tor/cells/ExtendedCell.java
trunk/src/org/tuotoo/tor/cells/PaddingCell.java
trunk/src/org/tuotoo/tor/cells/RelayCell.java
trunk/src/org/tuotoo/tor/ordescription/ORAcl.java
trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java
trunk/src/org/tuotoo/tor/ordescription/ORList.java
trunk/src/org/tuotoo/tor/ordescription/ORListFetcher.java
trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java
trunk/src/org/tuotoo/util/AbstractMessage.java
trunk/src/org/tuotoo/util/Base16.java
trunk/src/org/tuotoo/util/Base64.java
trunk/src/org/tuotoo/util/BusyFlag.java
trunk/src/org/tuotoo/util/ByteArrayUtil.java
trunk/src/org/tuotoo/util/ClassUtil.java
trunk/src/org/tuotoo/util/CondVar.java
trunk/src/org/tuotoo/util/DNSCacheEntry.java
trunk/src/org/tuotoo/util/Hash.java
trunk/src/org/tuotoo/util/IMiscPasswordReader.java
trunk/src/org/tuotoo/util/IPasswordReader.java
trunk/src/org/tuotoo/util/IResourceInstantiator.java
trunk/src/org/tuotoo/util/IXMLEncodable.java
trunk/src/org/tuotoo/util/ResourceLoader.java
trunk/src/org/tuotoo/util/SingleStringPasswordReader.java
trunk/src/org/tuotoo/util/ThreadPool.java
trunk/src/org/tuotoo/util/Util.java
trunk/src/org/tuotoo/util/XMLParseException.java
trunk/src/org/tuotoo/util/XMLUtil.java
trunk/src/org/tuotoo/util/ZLibTools.java
trunk/test/org/tuotoo/crypto/tinytls/test/tlsclienttest.java
trunk/test/org/tuotoo/tor/ordescription/test/AllTests.java
trunk/test/org/tuotoo/tor/ordescription/test/ORListTest.java
trunk/test/org/tuotoo/tor/ordescription/test/PlainORListFetcherTest.java
trunk/test/org/tuotoo/tor/test/AllTests.java
trunk/test/org/tuotoo/tor/test/Proxy.java
trunk/test/org/tuotoo/tor/test/TorTest.java
Modified: trunk/src/org/tuotoo/AnonChannel.java
===================================================================
--- trunk/src/org/tuotoo/AnonChannel.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/AnonChannel.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -5,15 +5,15 @@
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
+ this list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
- Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
- may be used to endorse or promote products derived from this software without specific
- prior written permission.
+ may be used to endorse or promote products derived from this software without specific
+ prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
@@ -31,47 +31,57 @@
import java.io.OutputStream;
/**
- * An AnonChannel could be used to send and receive data. There are different types of
- * channels and the transmitted data must match the (proxy-)protocol implied by the type
- * of the channel. A new channel is created via {@link AnonService#createChannel(int) createChannel()}
- *
+ * An AnonChannel could be used to send and receive data. There are different
+ * types of channels and the transmitted data must match the (proxy-)protocol
+ * implied by the type of the channel. A new channel is created via
+ * {@link AnonService#createChannel(int) createChannel()}
+ *
* @version 1.0
*/
-public interface AnonChannel
-{
- /// Constant for the channel type: HTTP-Proxy. Such a channel could be used to transmit
- /// data which conforms to the HTTP-Porxy-Protocol
- public final static int HTTP = 0;
+public interface AnonChannel {
+ /**
+ * Constant for the channel type: HTTP-Proxy. Such a channel could be used
+ * to transmit data which conforms to the HTTP-Porxy-Protocol
+ */
+ public final static int HTTP = 0;
- /// Constant for the channel type: SOCKS-Proxy. Such a channel could be used to transmit
- /// data which conforms to the SOCKS-Proxy-Protocol
- public final static int SOCKS = 1;
+ /**
+ * Constant for the channel type: SOCKS-Proxy. Such a channel could be used
+ * to transmit data which conforms to the SOCKS-Proxy-Protocol
+ */
+ public final static int SOCKS = 1;
- /// Constant for the channel type: SMTP-Proxy. Such a channel could be used to transmit
- /// data which conforms to the SMTP-Protocol
- public final static int SMTP = 2;
+ /**
+ * Constant for the channel type: SMTP-Proxy. Such a channel could be used
+ * to transmit data which conforms to the SMTP-Protocol
+ */
+ public final static int SMTP = 2;
- /**
+ /**
* The returned InputStream could be used to receive data.
- * @return InputStream, useful for receiving data
- */
- public InputStream getInputStream();
+ *
+ * @return InputStream, useful for receiving data
+ */
+ public InputStream getInputStream();
- /**
+ /**
* The returned OutputStream could be used to send data.
- * @return OutputStream, useful for sending data
- */
- public OutputStream getOutputStream();
+ *
+ * @return OutputStream, useful for sending data
+ */
+ public OutputStream getOutputStream();
- /**
- * Returns a value that indicates the current optimum size of data to write.. Because often
- * anon services transport the data splited into packets for optimum performance
- * it may be good to send data according to the packet size to avoid unneccessary overheads.
- *
- * @return the current optimum size for output data. If 1 is returned the size does not matter.
- */
- public int getOutputBlockSize();
+ /**
+ * Returns a value that indicates the current optimum size of data to
+ * write.. Because often anon services transport the data splited into
+ * packets for optimum performance it may be good to send data according to
+ * the packet size to avoid unneccessary overheads.
+ *
+ * @return the current optimum size for output data. If 1 is returned the
+ * size does not matter.
+ */
+ public int getOutputBlockSize();
- /** Closes the channel and releases all resources used. */
- public void close();
+ /** Closes the channel and releases all resources used. */
+ public void close();
}
Modified: trunk/src/org/tuotoo/AnonServerDescription.java
===================================================================
--- trunk/src/org/tuotoo/AnonServerDescription.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/AnonServerDescription.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -5,15 +5,15 @@
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
+ this list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
- Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
- may be used to endorse or promote products derived from this software without specific
- prior written permission.
+ may be used to endorse or promote products derived from this software without specific
+ prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
@@ -27,7 +27,9 @@
*/
package org.tuotoo;
-/** This interface is used for initializing an AnonService with the necessary parameters */
-public interface AnonServerDescription
-{
+/**
+ * This interface is used for initializing an AnonService with the necessary
+ * parameters.
+ */
+public interface AnonServerDescription {
}
Modified: trunk/src/org/tuotoo/AnonService.java
===================================================================
--- trunk/src/org/tuotoo/AnonService.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/AnonService.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -5,15 +5,15 @@
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
+ this list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
- Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
- may be used to endorse or promote products derived from this software without specific
- prior written permission.
+ may be used to endorse or promote products derived from this software without specific
+ prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
@@ -29,64 +29,92 @@
import java.net.ConnectException;
-//import org.tuotoo.infoservice.ImmutableProxyInterface;
+// import org.tuotoo.infoservice.ImmutableProxyInterface;
import org.tuotoo.infoservice.IMutableProxyInterface;
-/** This class is used for accessing the AnonService. An instance is created
- * via AnonServiceFactory.
+/**
+ * This class is used for accessing the AnonService. An instance is created via
+ * AnonServiceFactory.
*/
-public interface AnonService
-{
- ///The version of the AnonLib
- String ANONLIB_VERSION = "00.04.002";
+public interface AnonService {
+ // /The version of the AnonLib
+ String ANONLIB_VERSION = "00.04.002";
- /** Initializes this AnonService. Depending on the AnonService, this may establish a connection to
- * an AnonServer, which is described through the
- * anonService parameter. This method must be called before any Channels could be created.
- * @param anonServer AnonServer to use
- * @return E_SUCCESS, if the connection could be estblished
- * @return E_ALREADY_CONNECTED, if this AnonService is already connected to a server
- * @return E_INVALID_SERVICE, if anonService is not a valid server
- * @return E_PROTOCOL_NOT_SUPPORTED, if the chosen AnonService uses a Protocol, which this version of
- * the Anon-Lib does not understand
- * @return E_CONNECT, if a general connection error occured
- *
- */
- int initialize(AnonServerDescription anonServer, IServiceContainer a_serviceContainer);
+ /**
+ * Initializes this AnonService. Depending on the AnonService, this may
+ * establish a connection to an AnonServer, which is described through the
+ * anonService parameter. This method must be called before any Channels
+ * could be created.
+ *
+ * @param anonServer
+ * AnonServer to use
+ * @return E_SUCCESS, if the connection could be estblished<br>
+ * E_ALREADY_CONNECTED, if this AnonService is already connected to
+ * a server<br>
+ * E_INVALID_SERVICE, if anonService is not a valid server<br>
+ * E_PROTOCOL_NOT_SUPPORTED, if the chosen AnonService uses a
+ * Protocol, which this version of the Anon-Lib does not understand<br>
+ * E_CONNECT, if a general connection error occured
+ */
+ int initialize(AnonServerDescription anonServer,
+ IServiceContainer a_serviceContainer);
- /** Sets the settings of the proxy, which should be used to establish network connections
- * @return E_SUCCESS, if ok
- * @return E_UNKNOWN, if an error occured
- */
- int setProxy(IMutableProxyInterface a_Proxy);
+ /**
+ * Sets the settings of the proxy, which should be used to establish network
+ * connections.
+ *
+ * @return E_SUCCESS, if ok<br>
+ * E_UNKNOWN, if an error occured
+ */
+ int setProxy(IMutableProxyInterface a_Proxy);
- /** Disconnects form the server.*/
- void shutdown(boolean a_bResetTransferredBytes);
+ /** Disconnects form the server. */
+ void shutdown(boolean a_bResetTransferredBytes);
- /** Returns true if this Anon Service is connected, e.g. initialized and useable*/
- boolean isConnected();
+ /**
+ * Returns true if this Anon Service is connected, e.g. initialized and
+ * useable.
+ */
+ boolean isConnected();
- /** Creates a new AnonChannel, which could be used for transmitting data. There is a
- * limit of 50 channels per AnonService-connection, in order to prevent Denial of Service-attacks
- * See {@link AnonChannel AnonChannel} for more information.
- * @param type the type of the created channel
- * @return AnonChannel, usefull for data transmisson
- * @throws ConnectException, if the Channel could not be created
- * @throws ToManyOpenChannels, if there a to many open channels for this AnonService
- */
- AnonChannel createChannel(int type) throws ConnectException;
+ /**
+ * Creates a new AnonChannel, which could be used for transmitting data.
+ * There is a limit of 50 channels per AnonService-connection, in order to
+ * prevent Denial of Service-attacks See {@link AnonChannel AnonChannel} for
+ * more information.
+ *
+ * @param type
+ * the type of the created channel
+ * @return AnonChannel, usefull for data transmisson
+ * @throws ConnectException,
+ * if the Channel could not be created
+ * @throws TooManyOpenChannels,
+ * if there are too many open channels for this AnonService
+ */
+ AnonChannel createChannel(int type) throws ConnectException;
- /** Adds an AnonServiceEventListener. This listener will receive events like:
- * ... For more information see {@link AnonServiceEventListener AnonServiceEventListener}.
- * @param l Listener to add
- */
- void addEventListener(AnonServiceEventListener l);
+ /**
+ * Adds an AnonServiceEventListener. This listener will receive events like:
+ * ... For more information see
+ * {@link AnonServiceEventListener AnonServiceEventListener}.
+ *
+ * @param l
+ * Listener to add
+ */
+ void addEventListener(AnonServiceEventListener l);
- /** Removes an AnonServiceEventListener. This Listener will not receive any Events anymore.
- * @param l Listener, which will be removed
- */
- void removeEventListener(AnonServiceEventListener l);
+ /**
+ * Removes an AnonServiceEventListener. This Listener will not receive any
+ * Events anymore.
+ *
+ * @param l
+ * Listener, which will be removed
+ */
+ void removeEventListener(AnonServiceEventListener l);
- void removeEventListeners();
+ /**
+ * Removes all listeners.
+ */
+ void removeEventListeners();
}
Modified: trunk/src/org/tuotoo/AnonServiceEventListener.java
===================================================================
--- trunk/src/org/tuotoo/AnonServiceEventListener.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/AnonServiceEventListener.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -5,15 +5,15 @@
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
+ this list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
- Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
- may be used to endorse or promote products derived from this software without specific
- prior written permission.
+ may be used to endorse or promote products derived from this software without specific
+ prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
@@ -27,18 +27,17 @@
*/
package org.tuotoo;
-public interface AnonServiceEventListener
-{
- public void connectionError();
+public interface AnonServiceEventListener {
+ public void connectionError();
- public void disconnected();
+ public void disconnected();
- public void connecting(AnonServerDescription a_serverDescription);
+ public void connecting(AnonServerDescription a_serverDescription);
- public void connectionEstablished(AnonServerDescription a_serverDescription);
+ public void connectionEstablished(AnonServerDescription a_serverDescription);
- public void packetMixed(long a_totalBytes);
+ public void packetMixed(long a_totalBytes);
- public void dataChainErrorSignaled();
+ public void dataChainErrorSignaled();
}
Modified: trunk/src/org/tuotoo/ErrorCodes.java
===================================================================
--- trunk/src/org/tuotoo/ErrorCodes.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/ErrorCodes.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -5,15 +5,15 @@
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
+ this list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
- Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
- may be used to endorse or promote products derived from this software without specific
- prior written permission.
+ may be used to endorse or promote products derived from this software without specific
+ prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
@@ -27,21 +27,34 @@
*/
package org.tuotoo;
-public final class ErrorCodes
-{
+public final class ErrorCodes {
public final static int E_SUCCESS = 0;
+
public final static int E_UNKNOWN = -1;
+
public final static int E_ALREADY_CONNECTED = -4;
+
public final static int E_INVALID_SERVICE = -5;
+
public final static int E_CONNECT = -6;
+
public final static int E_NOT_CONNECTED = -9;
+
public final static int E_PROTOCOL_NOT_SUPPORTED = -10;
+
public final static int E_INVALID_CERTIFICATE = -20;
+
public final static int E_INVALID_KEY = -21;
+
public final static int E_SIGNATURE_CHECK_FIRSTMIX_FAILED = -22;
+
public final static int E_SIGNATURE_CHECK_OTHERMIX_FAILED = -23;
+
public final static int E_INTERRUPTED = -24;
+
public final static int E_NOT_TRUSTED = -26;
+
public final static int E_NOT_PARSABLE = -27;
- public final static int E_SPACE=-31;
+
+ public final static int E_SPACE = -31;
}
\ No newline at end of file
Modified: trunk/src/org/tuotoo/IServiceContainer.java
===================================================================
--- trunk/src/org/tuotoo/IServiceContainer.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/IServiceContainer.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -31,24 +31,26 @@
*/
package org.tuotoo;
-//import anon.client.ITrustModel;
-
/**
- * This interface is needed to pass through the keepCurrentService method in order to
- * disallow reusing the current cascade in case of an unrecoverable error (e.g. payment).
- *
+ * This interface is needed to pass through the keepCurrentService method in
+ * order to disallow reusing the current cascade in case of an unrecoverable
+ * error (e.g. payment).
+ *
* @author Rolf Wendolsky
*/
-public interface IServiceContainer //extends ITrustModel
-{
- /**
- * Allows to return the current Service that was returned also the next time this method is called.
- * @param a_bKeepCurrentService allows or dissallows to keep the current service for the next call
- */
- public void keepCurrentService(boolean a_bKeepCurrentService);
+public interface IServiceContainer {
+ /**
+ * Allows to return the current Service that was returned also the next time
+ * this method is called.
+ *
+ * @param a_bKeepCurrentService
+ * allows or dissallows to keep the current service for the next
+ * call
+ */
+ public void keepCurrentService(boolean a_bKeepCurrentService);
- public boolean isServiceAutoSwitched();
+ public boolean isServiceAutoSwitched();
- public boolean isReconnectedAutomatically();
+ public boolean isReconnectedAutomatically();
}
Modified: trunk/src/org/tuotoo/crypto/AbstractPrivateKey.java
===================================================================
--- trunk/src/org/tuotoo/crypto/AbstractPrivateKey.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/crypto/AbstractPrivateKey.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -4,14 +4,14 @@
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright notice,
+ - Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright notice,
+ - Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
- - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
+ - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
may be used to endorse or promote products derived from this software without specific
prior written permission.
@@ -35,46 +35,43 @@
/**
* This class is an abstract implementation of a private key.
+ *
* @author Rolf Wendolsky
*/
-public abstract class AbstractPrivateKey implements IMyPrivateKey
-{
- /**
- * Creates a new (empty) private key;
- */
- protected AbstractPrivateKey()
- {
- }
+public abstract class AbstractPrivateKey implements IMyPrivateKey {
+ /**
+ * Creates a new (empty) private key;
+ */
+ protected AbstractPrivateKey() {
+ }
- /**
- * Creates a private key from a PrivateKeyInfo. Every private key class should implement
- * this constructor.
- * @param a_keyInfo a PrivateKeyInfo
- */
- public AbstractPrivateKey(PrivateKeyInfo a_keyInfo)
- {
- }
+ /**
+ * Creates a private key from a PrivateKeyInfo. Every private key class
+ * should implement this constructor.
+ *
+ * @param a_keyInfo
+ * a PrivateKeyInfo
+ */
+ public AbstractPrivateKey(PrivateKeyInfo a_keyInfo) {
+ }
- /**
- * Returns the key in a byte encoded form that is defined be the result of the method
- * <Code> getAsPrivateKeyInfo() </Code>.
- * @return the key in a byte encoded form
- * @see getAsPrivateKeyInfo()
- */
- public final byte[] getEncoded()
- {
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- DEROutputStream dOut = new DEROutputStream(bOut);
+ /**
+ * Returns the key in a byte encoded form that is defined be the result of
+ * the method <Code>getAsPrivateKeyInfo()</Code>.
+ *
+ * @return the key in a byte encoded form
+ * @see getAsPrivateKeyInfo()
+ */
+ public final byte[] getEncoded() {
+ ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+ DEROutputStream dOut = new DEROutputStream(bOut);
- try
- {
- dOut.writeObject(getAsPrivateKeyInfo());
- dOut.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("IOException while encoding private key");
- }
- return bOut.toByteArray();
- }
+ try {
+ dOut.writeObject(getAsPrivateKeyInfo());
+ dOut.close();
+ } catch (IOException e) {
+ throw new RuntimeException("IOException while encoding private key");
+ }
+ return bOut.toByteArray();
+ }
}
Modified: trunk/src/org/tuotoo/crypto/AbstractPublicKey.java
===================================================================
--- trunk/src/org/tuotoo/crypto/AbstractPublicKey.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/crypto/AbstractPublicKey.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -4,14 +4,14 @@
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright notice,
+ - Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright notice,
+ - Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
- - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
+ - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
may be used to endorse or promote products derived from this software without specific
prior written permission.
@@ -35,56 +35,57 @@
/**
* This class is an abstract implementation of a private key.
+ *
* @author Rolf Wendolsky
*/
-public abstract class AbstractPublicKey implements IMyPublicKey
-{
- protected AbstractPublicKey()
- {
- }
+public abstract class AbstractPublicKey implements IMyPublicKey {
+ protected AbstractPublicKey() {
+ }
- /**
- * Creates a public key from a PrivateKeyInfo. Every public key class should implement
- * this constructor.
- * @param a_keyInfo a SubjectPublicKeyInfo
- */
- public AbstractPublicKey(SubjectPublicKeyInfo a_keyInfo)
- {
- }
+ /**
+ * Creates a public key from a PrivateKeyInfo. Every public key class should
+ * implement this constructor.
+ *
+ * @param a_keyInfo
+ * a SubjectPublicKeyInfo
+ */
+ public AbstractPublicKey(SubjectPublicKeyInfo a_keyInfo) {
+ }
- /**
- * Returns the key in a byte encoded form that is defined to be the result of the method
- * <Code> getAsSubjectPublicKeyInfo() </Code>.
- * @return the key in a byte encoded form
- * @see getAsSubjectPublicKeyInfo()
- */
- public final byte[] getEncoded()
- {
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- DEROutputStream dOut = new DEROutputStream(bOut);
- try
- {
- dOut.writeObject(getAsSubjectPublicKeyInfo());
- dOut.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException("IOException while encoding public key");
- }
- return bOut.toByteArray();
- }
+ /**
+ * Returns the key in a byte encoded form that is defined to be the result
+ * of the method <Code>getAsSubjectPublicKeyInfo()</Code>.
+ *
+ * @return the key in a byte encoded form
+ * @see getAsSubjectPublicKeyInfo()
+ */
+ public final byte[] getEncoded() {
+ ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+ DEROutputStream dOut = new DEROutputStream(bOut);
+ try {
+ dOut.writeObject(getAsSubjectPublicKeyInfo());
+ dOut.close();
+ } catch (IOException e) {
+ throw new RuntimeException("IOException while encoding public key");
+ }
+ return bOut.toByteArray();
+ }
- /**
- * @return the public key`s hash code
- * @see java.lang.Object#hashCode()
- */
- public abstract int hashCode();
+ /**
+ * @return the public key`s hash code
+ * @see java.lang.Object#hashCode()
+ */
+ public abstract int hashCode();
- /**
- * This method returns if two public keys have the same public key parameters.
- * @param a_publicKey an other public key
- * @return true if the keys have the same public key parameters; false otherwise
- */
- public abstract boolean equals(Object a_publicKey);
+ /**
+ * This method returns if two public keys have the same public key
+ * parameters.
+ *
+ * @param a_publicKey
+ * an other public key
+ * @return true if the keys have the same public key parameters; false
+ * otherwise
+ */
+ public abstract boolean equals(Object a_publicKey);
}
Modified: trunk/src/org/tuotoo/crypto/AbstractX509AlternativeName.java
===================================================================
--- trunk/src/org/tuotoo/crypto/AbstractX509AlternativeName.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/crypto/AbstractX509AlternativeName.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -4,14 +4,14 @@
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright notice,
+ - Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright notice,
+ - Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
- - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
+ - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
may be used to endorse or promote products derived from this software without specific
prior written permission.
@@ -48,322 +48,314 @@
import org.tuotoo.infoservice.ListenerInterface;
/**
- * The SubjectAlternativeName extension represents an alias to distinguished name (DN).
- * It may contain several values and is often used for IPs, DNS-Names, URLs and E-Mail addresses.
+ * The SubjectAlternativeName extension represents an alias to distinguished
+ * name (DN). It may contain several values and is often used for IPs,
+ * DNS-Names, URLs and E-Mail addresses.
+ *
* @author Rolf Wendolsky
* @see http://www.faqs.org/rfcs/rfc2538.html
*/
-public abstract class AbstractX509AlternativeName extends AbstractX509Extension
-{
- public static final Integer TAG_OTHER = new Integer(0);
- public static final Integer TAG_EMAIL = new Integer(1);
- public static final Integer TAG_DNS = new Integer(2);
- //public static final Integer TAG_X400ADDRESS = new Integer(3);
- //public static final Integer TAG_DIRECTORY_NAME = new Integer(4);
- //public static final Integer TAG_EDI_PARTY_NAME = new Integer(5);
- public static final Integer TAG_URL = new Integer(6);
- public static final Integer TAG_IP = new Integer(7);
- //public static final Integer TAG_REGISTERED_ID = new Integer(8);
+public abstract class AbstractX509AlternativeName extends AbstractX509Extension {
+ public static final Integer TAG_OTHER = new Integer(0);
- private Vector m_values;
- private Vector m_tags;
+ public static final Integer TAG_EMAIL = new Integer(1);
- /**
- * Constructs a new X509AlternativeName from a value. A value with commas (,) is interpreted
- * as multiple values.
- * @param a_identifier the identifier of this extension
- * @param a_value a value
- * @param a_tag the type tag for this value
- */
- public AbstractX509AlternativeName(String a_identifier, String a_value, Integer a_tag)
- {
- this (a_identifier, Util.toVector(a_value), Util.toVector(a_tag));
- }
+ public static final Integer TAG_DNS = new Integer(2);
- /**
- * Constructs a new X509AlternativeName from a value. A value with commas (,) is interpreted
- * as multiple values.
- * @param a_identifier the identifier of this extension
- * @param a_critical true if the X509AlternativeName is critical; false otherwise
- * @param a_value a value
- * @param a_tag the type tag for this value
- */
- public AbstractX509AlternativeName(String a_identifier,
- boolean a_critical, String a_value, Integer a_tag)
- {
- this (a_identifier, a_critical, Util.toVector(a_value), Util.toVector(a_tag));
- }
+ // public static final Integer TAG_X400ADDRESS = new Integer(3);
+ // public static final Integer TAG_DIRECTORY_NAME = new Integer(4);
+ // public static final Integer TAG_EDI_PARTY_NAME = new Integer(5);
+ public static final Integer TAG_URL = new Integer(6);
- /**
- * Constructs a new X509AlternativeName from values.
- * @param a_identifier the identifier of this extension
- * @param a_values values for the X509AlternativeName
- * @param a_tags the type tags for the values
- */
- public AbstractX509AlternativeName(String a_identifier, Vector a_values, Vector a_tags)
- {
- this (a_identifier, false, a_values, a_tags);
- }
+ public static final Integer TAG_IP = new Integer(7);
- /**
- * Constructs a new X509AlternativeName from values.
- * @param a_identifier the identifier of this extension
- * @param a_critical true if the extension is critical; false otherwise
- * @param a_values values for the X509AlternativeName
- * @param a_tags the type tags for the values
- */
- public AbstractX509AlternativeName(String a_identifier,
- boolean a_critical, Vector a_values, Vector a_tags)
- {
- super(a_identifier, a_critical, createValue(a_values, a_tags));
- m_values = (Vector)a_values.clone();
- m_tags = (Vector)a_tags.clone();
- }
+ // public static final Integer TAG_REGISTERED_ID = new Integer(8);
- /**
- * Creates an X509AlternativeName from a BouncyCastle DER sequence. For internal use only.
- * @param a_extension a DERSequence
- */
- public AbstractX509AlternativeName(DERSequence a_extension)
- {
- super(a_extension);
+ private Vector m_values;
- ASN1Sequence values;
- Enumeration enumValues;
- DERTaggedObject taggedValue;
- byte[] value;
- Integer tag;
+ private Vector m_tags;
- m_values = new Vector();
- m_tags = new Vector();
- try
- {
- values = (ASN1Sequence)(new ASN1InputStream(
- new ByteArrayInputStream(getDEROctets()))).readObject();
- }
- catch (IOException a_e)
- {
- throw new RuntimeException("Could not read object from DER sequence!");
- }
+ /**
+ * Constructs a new X509AlternativeName from a value. A value with commas
+ * (,) is interpreted as multiple values.
+ *
+ * @param a_identifier
+ * the identifier of this extension
+ * @param a_value
+ * a value
+ * @param a_tag
+ * the type tag for this value
+ */
+ public AbstractX509AlternativeName(String a_identifier, String a_value,
+ Integer a_tag) {
+ this(a_identifier, Util.toVector(a_value), Util.toVector(a_tag));
+ }
- enumValues = values.getObjects();
- while (enumValues.hasMoreElements())
- {
- taggedValue = (DERTaggedObject)enumValues.nextElement();
- tag = new Integer(taggedValue.getTagNo());
- value = ((DEROctetString) taggedValue.getObject()).getOctets();
- if (tag.equals(TAG_IP))
- {
- String ipaddress = "";
- for (int i = 0; i < value.length; i++)
- {
- ipaddress += (255 & (int)value[i]);
- if (i + 1 < value.length)
- {
- ipaddress += ".";
- }
- }
- m_values.addElement(ipaddress);
- }
- else
- {
- m_values.addElement(new String(value));
- }
- m_tags.addElement(tag);
- }
+ /**
+ * Constructs a new X509AlternativeName from a value. A value with commas
+ * (,) is interpreted as multiple values.
+ *
+ * @param a_identifier
+ * the identifier of this extension
+ * @param a_critical
+ * true if the X509AlternativeName is critical; false otherwise
+ * @param a_value
+ * a value
+ * @param a_tag
+ * the type tag for this value
+ */
+ public AbstractX509AlternativeName(String a_identifier, boolean a_critical,
+ String a_value, Integer a_tag) {
+ this(a_identifier, a_critical, Util.toVector(a_value), Util
+ .toVector(a_tag));
+ }
- }
+ /**
+ * Constructs a new X509AlternativeName from values.
+ *
+ * @param a_identifier
+ * the identifier of this extension
+ * @param a_values
+ * values for the X509AlternativeName
+ * @param a_tags
+ * the type tags for the values
+ */
+ public AbstractX509AlternativeName(String a_identifier, Vector a_values,
+ Vector a_tags) {
+ this(a_identifier, false, a_values, a_tags);
+ }
- /**
- * Verifies if a given String is a valid IP address (IPv4 or IPv6)
- * @param a_ipAddress an IP address as String
- * @return if a given String is a valid IP address; false otherwise
- */
- public static boolean isValidIP(String a_ipAddress)
- {
- return ListenerInterface.isValidIP(a_ipAddress);
- }
+ /**
+ * Constructs a new X509AlternativeName from values.
+ *
+ * @param a_identifier
+ * the identifier of this extension
+ * @param a_critical
+ * true if the extension is critical; false otherwise
+ * @param a_values
+ * values for the X509AlternativeName
+ * @param a_tags
+ * the type tags for the values
+ */
+ public AbstractX509AlternativeName(String a_identifier, boolean a_critical,
+ Vector a_values, Vector a_tags) {
+ super(a_identifier, a_critical, createValue(a_values, a_tags));
+ m_values = (Vector) a_values.clone();
+ m_tags = (Vector) a_tags.clone();
+ }
- /**
- * Verifies if a given String is a valid email address (IPv4 or IPv6). There may be more than
- * one addresses in the string, separated by commas (,).
- * @param a_email an email address as String
- * @return if a given String is a valid email address; false otherwise
- */
- public static boolean isValidEMail(String a_email)
- {
- if (a_email == null)
- {
- return false;
- }
+ /**
+ * Creates an X509AlternativeName from a BouncyCastle DER sequence. For
+ * internal use only.
+ *
+ * @param a_extension
+ * a DERSequence
+ */
+ public AbstractX509AlternativeName(DERSequence a_extension) {
+ super(a_extension);
- StringTokenizer tokenizer = new StringTokenizer(a_email, ",");
- String email;
+ ASN1Sequence values;
+ Enumeration enumValues;
+ DERTaggedObject taggedValue;
+ byte[] value;
+ Integer tag;
- if (!tokenizer.hasMoreElements())
- {
- return false;
- }
- while (tokenizer.hasMoreElements())
- {
- email = tokenizer.nextToken().trim();
- if (email.length() == 0)
- {
- return false;
- }
+ m_values = new Vector();
+ m_tags = new Vector();
+ try {
+ values = (ASN1Sequence) (new ASN1InputStream(
+ new ByteArrayInputStream(getDEROctets()))).readObject();
+ } catch (IOException a_e) {
+ throw new RuntimeException(
+ "Could not read object from DER sequence!");
+ }
- int dot = email.lastIndexOf('.');
- int len = email.length();
- int at = email.indexOf('@');
+ enumValues = values.getObjects();
+ while (enumValues.hasMoreElements()) {
+ taggedValue = (DERTaggedObject) enumValues.nextElement();
+ tag = new Integer(taggedValue.getTagNo());
+ value = ((DEROctetString) taggedValue.getObject()).getOctets();
+ if (tag.equals(TAG_IP)) {
+ String ipaddress = "";
+ for (int i = 0; i < value.length; i++) {
+ ipaddress += (255 & (int) value[i]);
+ if (i + 1 < value.length) {
+ ipaddress += ".";
+ }
+ }
+ m_values.addElement(ipaddress);
+ } else {
+ m_values.addElement(new String(value));
+ }
+ m_tags.addElement(tag);
+ }
- if (len == 0 || at == -1 || dot == -1 || at == 0 || dot < at)
- {
- return false;
- }
- if (!((dot + 2) < len))
- {
- return false;
- }
- }
- return true;
- }
+ }
- /**
- * Returns all values of this X509AlternativeName.
- * @return all values of this X509AlternativeName
- */
- public Vector getValues()
- {
- return (Vector)m_values.clone();
- }
+ /**
+ * Verifies if a given String is a valid IP address (IPv4 or IPv6)
+ *
+ * @param a_ipAddress
+ * an IP address as String
+ * @return if a given String is a valid IP address; false otherwise
+ */
+ public static boolean isValidIP(String a_ipAddress) {
+ return ListenerInterface.isValidIP(a_ipAddress);
+ }
- /**
- * Returns the tags corresponding to the values as Integer objects.
- * @return the tags corresponding to the values as Integer objects
- */
- public Vector getTags()
- {
- return (Vector)m_tags.clone();
- }
+ /**
+ * Verifies if a given String is a valid email address (IPv4 or IPv6). There
+ * may be more than one addresses in the string, separated by commas (,).
+ *
+ * @param a_email
+ * an email address as String
+ * @return if a given String is a valid email address; false otherwise
+ */
+ public static boolean isValidEMail(String a_email) {
+ if (a_email == null) {
+ return false;
+ }
- private static byte[] createValue(Vector a_values, Vector a_tags)
- {
- ByteArrayOutputStream out;
- DEREncodableVector values;
- Integer tag;
- byte[] value = null;
- String strValue;
- Vector tempTags, tempValues;
- StringTokenizer tokenizer;
+ StringTokenizer tokenizer = new StringTokenizer(a_email, ",");
+ String email;
- values = new DEREncodableVector();
+ if (!tokenizer.hasMoreElements()) {
+ return false;
+ }
+ while (tokenizer.hasMoreElements()) {
+ email = tokenizer.nextToken().trim();
+ if (email.length() == 0) {
+ return false;
+ }
- if (a_values != null || a_values.size() != 0)
- {
- if (a_tags == null || a_values.size() != a_tags.size())
- {
- throw new IllegalArgumentException("Tags have an invalid size!");
- }
- // interpret comma-separated values as multiple values
- tempTags = new Vector();
- tempValues = new Vector();
- for (int i = 0; i < a_values.size(); i++)
- {
- if (! (a_values.elementAt(i) instanceof String))
- {
- throw new IllegalArgumentException("Values must be Strings!");
- }
- tokenizer = new StringTokenizer((String)a_values.elementAt(i), ",");
- while (tokenizer.hasMoreTokens())
- {
- tempTags.addElement(a_tags.elementAt(i));
- tempValues.addElement(tokenizer.nextToken().trim());
- }
- }
- a_tags = tempTags;
- a_values = tempValues;
+ int dot = email.lastIndexOf('.');
+ int len = email.length();
+ int at = email.indexOf('@');
- for (int i = 0; i < a_values.size(); i++)
- {
- strValue = (String) a_values.elementAt(i);
- if (strValue == null || strValue.length() == 0)
- {
- continue;
- }
+ if (len == 0 || at == -1 || dot == -1 || at == 0 || dot < at) {
+ return false;
+ }
+ if (!((dot + 2) < len)) {
+ return false;
+ }
+ }
+ return true;
+ }
- if (a_tags.elementAt(i) == null || ! (a_tags.elementAt(i) instanceof Integer))
- {
- throw new IllegalArgumentException("Unsupported tag: " + a_tags.elementAt(i));
- }
- tag = (Integer) a_tags.elementAt(i);
+ /**
+ * Returns all values of this X509AlternativeName.
+ *
+ * @return all values of this X509AlternativeName
+ */
+ public Vector getValues() {
+ return (Vector) m_values.clone();
+ }
- if (tag.equals(TAG_IP))
- {
- if (!isValidIP(strValue))
- {
- throw new IllegalArgumentException("Invalid IP address: " + strValue);
- }
- try
- {
- value = InetAddress.getByName(strValue).getAddress();
- }
- catch (java.net.UnknownHostException a_e)
- {
- // should be impossible
- throw new RuntimeException("An IP address was not recognized as such!");
- }
- }
- else if (tag.equals(TAG_EMAIL))
- {
- if (!isValidEMail(strValue))
- {
- throw new IllegalArgumentException("Invalid email address: " + strValue);
- }
- }
- else if (tag.equals(TAG_URL))
- {
- try
- {
- new URL(strValue);
- }
- catch (Exception a_e)
- {
- throw new IllegalArgumentException(a_e.getMessage());
- }
- }
- else if (tag.equals(TAG_DNS))
- {
- // todo...
- }
- else if (tag.equals(TAG_OTHER))
- {
- // OK, you may write everything...
- }
- else
- {
- throw new IllegalArgumentException("Unsupported tag: " + tag);
- }
+ /**
+ * Returns the tags corresponding to the values as Integer objects.
+ *
+ * @return the tags corresponding to the values as Integer objects
+ */
+ public Vector getTags() {
+ return (Vector) m_tags.clone();
+ }
- if (value == null)
- {
- value = strValue.getBytes();
- }
+ private static byte[] createValue(Vector a_values, Vector a_tags) {
+ ByteArrayOutputStream out;
+ DEREncodableVector values;
+ Integer tag;
+ byte[] value = null;
+ String strValue;
+ Vector tempTags, tempValues;
+ StringTokenizer tokenizer;
- values.add(new DERTaggedObject(tag.intValue(), new DEROctetString(value)));
- value = null;
- }
- }
- out = new ByteArrayOutputStream();
- try
- {
- new DEROutputStream(out).writeObject(new DERSequence(values));
- }
- catch (IOException a_e)
- {
- // should be impossible
- throw new RuntimeException("Error while writing object to byte array.");
- }
+ values = new DEREncodableVector();
- return out.toByteArray();
- }
+ if (a_values != null || a_values.size() != 0) {
+ if (a_tags == null || a_values.size() != a_tags.size()) {
+ throw new IllegalArgumentException("Tags have an invalid size!");
+ }
+ // interpret comma-separated values as multiple values
+ tempTags = new Vector();
+ tempValues = new Vector();
+ for (int i = 0; i < a_values.size(); i++) {
+ if (!(a_values.elementAt(i) instanceof String)) {
+ throw new IllegalArgumentException(
+ "Values must be Strings!");
+ }
+ tokenizer = new StringTokenizer((String) a_values.elementAt(i),
+ ",");
+ while (tokenizer.hasMoreTokens()) {
+ tempTags.addElement(a_tags.elementAt(i));
+ tempValues.addElement(tokenizer.nextToken().trim());
+ }
+ }
+ a_tags = tempTags;
+ a_values = tempValues;
+
+ for (int i = 0; i < a_values.size(); i++) {
+ strValue = (String) a_values.elementAt(i);
+ if (strValue == null || strValue.length() == 0) {
+ continue;
+ }
+
+ if (a_tags.elementAt(i) == null
+ || !(a_tags.elementAt(i) instanceof Integer)) {
+ throw new IllegalArgumentException("Unsupported tag: "
+ + a_tags.elementAt(i));
+ }
+ tag = (Integer) a_tags.elementAt(i);
+
+ if (tag.equals(TAG_IP)) {
+ if (!isValidIP(strValue)) {
+ throw new IllegalArgumentException(
+ "Invalid IP address: " + strValue);
+ }
+ try {
+ value = InetAddress.getByName(strValue).getAddress();
+ } catch (java.net.UnknownHostException a_e) {
+ // should be impossible
+ throw new RuntimeException(
+ "An IP address was not recognized as such!");
+ }
+ } else if (tag.equals(TAG_EMAIL)) {
+ if (!isValidEMail(strValue)) {
+ throw new IllegalArgumentException(
+ "Invalid email address: " + strValue);
+ }
+ } else if (tag.equals(TAG_URL)) {
+ try {
+ new URL(strValue);
+ } catch (Exception a_e) {
+ throw new IllegalArgumentException(a_e.getMessage());
+ }
+ } else if (tag.equals(TAG_DNS)) {
+ // todo...
+ } else if (tag.equals(TAG_OTHER)) {
+ // OK, you may write everything...
+ } else {
+ throw new IllegalArgumentException("Unsupported tag: "
+ + tag);
+ }
+
+ if (value == null) {
+ value = strValue.getBytes();
+ }
+
+ values.add(new DERTaggedObject(tag.intValue(),
+ new DEROctetString(value)));
+ value = null;
+ }
+ }
+ out = new ByteArrayOutputStream();
+ try {
+ new DEROutputStream(out).writeObject(new DERSequence(values));
+ } catch (IOException a_e) {
+ // should be impossible
+ throw new RuntimeException(
+ "Error while writing object to byte array.");
+ }
+
+ return out.toByteArray();
+ }
}
Modified: trunk/src/org/tuotoo/crypto/AbstractX509Extension.java
===================================================================
--- trunk/src/org/tuotoo/crypto/AbstractX509Extension.java 2007-11-13 10:12:52 UTC (rev 2)
+++ trunk/src/org/tuotoo/crypto/AbstractX509Extension.java 2007-11-20 12:35:10 UTC (rev 3)
@@ -4,14 +4,14 @@
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright notice,
+ - Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright notice,
+ - Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
- - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
+ - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
may be used to endorse or promote products derived from this software without specific
prior written permission.
@@ -42,231 +42,232 @@
import org.tuotoo.logging.LogType;
/**
- * Represents and creates an X509 V3 extensions. The concrete extensions are subclasses of this
- * class and must (!) implement the IDENTIFIER String constant and a public (!) constructor that
- * takes a DERSequence.
+ * Represents and creates an X509 V3 extensions. The concrete extensions are
+ * subclasses of this class and must (!) implement the IDENTIFIER String
+ * constant and a public (!) constructor that takes a DERSequence.
+ *
* @see http://www.faqs.org/rfcs/rfc3280.html
* @author Rolf Wendolsky
*/
-public abstract class AbstractX509Extension
-{
- /** Each subclass must contain this individual identifier. */
- public static final String IDENTIFIER = null;
+public abstract class AbstractX509Extension {
+ /** Each subclass must contain this individual identifier. */
+ public static final String IDENTIFIER = null;
- private static Class[] AVAILABLE_EXTENSIONS = new Class[]
- {X509UnknownExtension.class, X509SubjectKeyIdentifier.class,
- X509SubjectAlternativeName.class, X509IssuerAlternativeName.class};
+ private static Class[] AVAILABLE_EXTENSIONS = new Class[] {
+ X509UnknownExtension.class, X509SubjectKeyIdentifier.class,
+ X509SubjectAlternativeName.class, X509IssuerAlternativeName.class };
- private static Vector ms_classExtensions;
+ private static Vector ms_classExtensions;
- private DERObjectIdentifier m_identifier;
- private boolean m_critical;
- private byte[] m_value;
- private DERSequence m_extension;
+ private DERObjectIdentifier m_identifier;
- /**
- * Create a new X509 V3 extension.
- * @param a_identifier the identifier of this extension
- * @param a_critical boolean
- * @param a_value the extension's value
- */
- public AbstractX509Extension(String a_identifier, boolean a_critical, byte[] a_value)
- {
- D...
[truncated message content] |