java.lang.Object
net.i2p.router.client.ClientListenerRunner
net.i2p.router.client.SSLClientListenerRunner
- All Implemented Interfaces:
Runnable
SSL version of ClientListenerRunner.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SSLServerSocketFactoryFactory for the encrypted listener's sockets.private static final StringFile the certificate is written out as text.private static final StringAlias of the key in the keystore.private static final StringProperty holding the key's password.private static final StringProperty holding the keystore's password.Fields inherited from class ClientListenerRunner
_bindAllInterfaces, _context, _listening, _log, _manager, _port, _running, _socket, BIND_ALL_INTERFACES, CONNECT_TIMEOUTModifier and TypeFieldDescriptionprotected final booleanWhether to bind on all interfaces.protected final RouterContextRouter context.protected booleanWhether the socket is currently listening.protected final LogLogger for this class.protected final ClientManagerClient manager.protected final intPort to listen on.protected booleanWhether the runner is running.protected ServerSocketServer socket for accepting connections.static final StringProperty to control binding to all interfaces.protected static final intGive the i2cp client 5 seconds to show that they're really i2cp clients.Constructor Summary
ConstructorsConstructorDescriptionSSLClientListenerRunner(RouterContext context, ClientManager manager, int port) Creates an SSL listener on the given port, opening the client manager.Method Summary
Private MethodsModifier and TypeMethodDescriptionprivate booleancreateKeyStore(File ks) Call out to keytool to create a new keystore with a keypair in it.private voidexportCert(File ks) Pull the cert back OUT of the keystore and save it as ascii so the clients can get to it.protected ServerSocketA SSLServerSocket from the configured socket factory.private booleanThe SSLContext and socket factory set up from the given keystore.protected voidCreate (if necessary) and load the key store, then run.protected booleanOverridden because SSL handshake may need more time, and available() in super doesn't work.private booleanverifyKeyStore(File ks) Verify the keystore exists and is usable, creating it if necessary.Methods inherited from class ClientListenerRunner
isListening, run, runConnection, stopListeningModifier and TypeMethodDescriptionbooleanCheck if the listener is currently running and listening.voidrun()protected voidrunConnection(Socket socket) Handle the connection by passing it off to aClientConnectionRunner.voidStop listening for connections.
Field Details
_factory
Factory for the encrypted listener's sockets.PROP_KEYSTORE_PASSWORD
Property holding the keystore's password.- See Also:
PROP_KEY_PASSWORD
Property holding the key's password.- See Also:
KEY_ALIAS
Alias of the key in the keystore.- See Also:
ASCII_KEYFILE
File the certificate is written out as text.- See Also:
Constructor Details
SSLClientListenerRunner
Creates an SSL listener on the given port, opening the client manager.- Parameters:
context- the router contextmanager- the client manager to attach to the listenerport- the SSL port to listen on
Method Details
verifyKeyStore
Verify the keystore exists and is usable, creating it if necessary.- Parameters:
ks- the keystore file to verify- Returns:
- success if it exists and we have a password, or it was created successfully.
createKeyStore
Call out to keytool to create a new keystore with a keypair in it. Trying to do this programatically is a nightmare, requiring either BouncyCastle libs or using proprietary Sun libs, and it's a huge mess. If successful, stores the keystore password and key password inrouter.config.- Parameters:
ks- the keystore file to create- Returns:
- true if the keystore was created and its passwords saved
exportCert
Pull the cert back OUT of the keystore and save it as ascii so the clients can get to it.- Parameters:
ks- the keystore to export the certificate from
initializeFactory
The SSLContext and socket factory set up from the given keystore.- Parameters:
ks- the keystore to read the key material from- Returns:
- true if the factory was built and stored, false if the keystore could not be read
getServerSocket
A SSLServerSocket from the configured socket factory.- Overrides:
getServerSocketin classClientListenerRunner- Returns:
- the server socket
- Throws:
IOException- if the socket cannot be created
runServer
protected void runServer()Create (if necessary) and load the key store, then run.- Overrides:
runServerin classClientListenerRunner
validate
Overridden because SSL handshake may need more time, and available() in super doesn't work. The handshake doesn't start until a read().- Overrides:
validatein classClientListenerRunner- Parameters:
socket- the accepted connection to probe for the I2CP protocol byte- Returns:
- true if the first byte is the I2CP protocol byte