SF.net SVN: tuotoo: [3] trunk
Status: Pre-Alpha
Brought to you by:
hanru
|
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] |