public class RemoteControlHttpsServer extends java.lang.Thread
RequestProcessor for every secure connection.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ENTRY_ALIAS
Unique alias used to store JOSM localhost entry, both in JOSM keystore and system/browser keystores.
|
private static int |
HTTPS_PORT |
private static RemoteControlHttpsServer |
instance4
The server instance for IPv4
|
private static RemoteControlHttpsServer |
instance6
The server instance for IPv6
|
static StringProperty |
KEYENTRY_PASSWORD
Preference for certificate password (automatically generated by JOSM).
|
static java.lang.String |
KEYSTORE_FILENAME
JOSM keystore file name.
|
static StringProperty |
KEYSTORE_PASSWORD
Preference for keystore password (automatically generated by JOSM).
|
private java.net.ServerSocket |
server
The server socket
|
private javax.net.ssl.SSLContext |
sslContext
SSL context information for connections
|
| Constructor and Description |
|---|
RemoteControlHttpsServer(int port,
boolean ipv6)
Constructs a new
RemoteControlHttpsServer. |
| Modifier and Type | Method and Description |
|---|---|
private static sun.security.x509.GeneralNameInterface |
createGeneralNameInterface(java.lang.String t,
java.lang.String v)
Creates a GeneralNameInterface object from known types.
|
private static java.security.cert.X509Certificate |
generateCertificate(java.lang.String dn,
java.security.KeyPair pair,
int days,
java.lang.String algorithm,
java.lang.String san)
Create a self-signed X.509 Certificate.
|
private void |
initialize()
Initializes the TLS basics.
|
static java.security.KeyStore |
loadJosmKeystore()
Loads the JOSM keystore.
|
static void |
restartRemoteControlHttpsServer()
Starts or restarts the HTTPS server
|
void |
run()
The main loop, spawns a
RequestProcessor for each connection. |
static java.nio.file.Path |
setupJosmKeystore()
Setup the JOSM internal keystore, used to store HTTPS certificate and private key.
|
static boolean |
setupPlatform(java.security.KeyStore josmKs)
Setup the platform-dependant certificate stuff.
|
static void |
stopRemoteControlHttpsServer()
Stops the HTTPS server
|
void |
stopServer()
Stops the HTTPS server.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprivate final java.net.ServerSocket server
private static volatile RemoteControlHttpsServer instance4
private static volatile RemoteControlHttpsServer instance6
private javax.net.ssl.SSLContext sslContext
private static final int HTTPS_PORT
public static final java.lang.String KEYSTORE_FILENAME
public static final StringProperty KEYSTORE_PASSWORD
public static final StringProperty KEYENTRY_PASSWORD
public static final java.lang.String ENTRY_ALIAS
public RemoteControlHttpsServer(int port, boolean ipv6) throws java.io.IOException, java.security.GeneralSecurityException
RemoteControlHttpsServer.port - The port this server will listen onipv6 - Whether IPv6 or IPv4 server should be startedjava.io.IOException - when connection errorsjava.security.GeneralSecurityException - in case of SSL setup errorsprivate static sun.security.x509.GeneralNameInterface createGeneralNameInterface(java.lang.String t, java.lang.String v) throws java.io.IOException
t - one of 4 known typesv - valuejava.io.IOException - if any I/O error occursprivate static java.security.cert.X509Certificate generateCertificate(java.lang.String dn, java.security.KeyPair pair, int days, java.lang.String algorithm, java.lang.String san) throws java.security.GeneralSecurityException, java.io.IOException
dn - the X.509 Distinguished Name, eg "CN=localhost, OU=JOSM, O=OpenStreetMap"pair - the KeyPairdays - how many days from now the Certificate is valid foralgorithm - the signing algorithm, eg "SHA256withRSA"san - SubjectAlternativeName extension (optional)java.security.GeneralSecurityException - if any security error occursjava.io.IOException - if any I/O error occurspublic static java.nio.file.Path setupJosmKeystore() throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException - if an I/O error occursjava.security.GeneralSecurityException - if a security error occurspublic static java.security.KeyStore loadJosmKeystore() throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException - if an I/O error occursjava.security.GeneralSecurityException - if a security error occursprivate void initialize() throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException - if an I/O error occursjava.security.GeneralSecurityException - if a security error occurspublic static boolean setupPlatform(java.security.KeyStore josmKs) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException
josmKs - The JOSM keystore, containing localhost certificate and private key.true if something has changed as a result of the call (certificate installation, etc.)java.security.KeyStoreException - if the keystore has not been initialized (loaded)java.security.NoSuchAlgorithmException - in case of errorjava.security.cert.CertificateException - in case of errorjava.io.IOException - in case of errorpublic static void restartRemoteControlHttpsServer()
public static void stopRemoteControlHttpsServer()
public void run()
RequestProcessor for each connection.run in interface java.lang.Runnablerun in class java.lang.Threadpublic void stopServer() throws java.io.IOException
java.io.IOException - if any I/O error occurs