public class RemoteControlHttpsServer extends Thread
RequestProcessor
for every secure connection.Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
static 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 String |
KEYSTORE_FILENAME
JOSM keystore file name.
|
static StringProperty |
KEYSTORE_PASSWORD
Preference for keystore password (automatically generated by JOSM).
|
private ServerSocket |
server
The server socket
|
private SSLContext |
sslContext
SSL context information for connections
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
RemoteControlHttpsServer(int port,
boolean ipv6)
Constructs a new
RemoteControlHttpsServer . |
Modifier and Type | Method and Description |
---|---|
private static sun.security.x509.GeneralName |
createGeneralName(String t,
String v)
Creates a GeneralName object from known types.
|
private static X509Certificate |
generateCertificate(String dn,
KeyPair pair,
int days,
String algorithm,
String san)
Create a self-signed X.509 Certificate.
|
private void |
initialize()
Initializes the TLS basics.
|
static 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 Path |
setupJosmKeystore()
Setup the JOSM internal keystore, used to store HTTPS certificate and private key.
|
static boolean |
setupPlatform(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, yield
private final ServerSocket server
private static volatile RemoteControlHttpsServer instance4
private static volatile RemoteControlHttpsServer instance6
private SSLContext sslContext
private static final int HTTPS_PORT
public static final String KEYSTORE_FILENAME
public static final StringProperty KEYSTORE_PASSWORD
public static final StringProperty KEYENTRY_PASSWORD
public static final String ENTRY_ALIAS
public RemoteControlHttpsServer(int port, boolean ipv6) throws IOException, NoSuchAlgorithmException, GeneralSecurityException
RemoteControlHttpsServer
.port
- The port this server will listen onipv6
- Whether IPv6 or IPv4 server should be startedIOException
- when connection errorsNoSuchAlgorithmException
- if the JVM does not support TLS (can not happen)GeneralSecurityException
- in case of SSL setup errorsprivate static sun.security.x509.GeneralName createGeneralName(String t, String v) throws IOException
t
- one of 4 known typesv
- valueIOException
- if any I/O error occursprivate static X509Certificate generateCertificate(String dn, KeyPair pair, int days, String algorithm, String san) throws GeneralSecurityException, 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)GeneralSecurityException
- if any security error occursIOException
- if any I/O error occurspublic static Path setupJosmKeystore() throws IOException, GeneralSecurityException
IOException
- if an I/O error occursGeneralSecurityException
- if a security error occurspublic static KeyStore loadJosmKeystore() throws IOException, GeneralSecurityException
IOException
- if an I/O error occursGeneralSecurityException
- if a security error occursprivate void initialize() throws IOException, GeneralSecurityException
IOException
- if an I/O error occursGeneralSecurityException
- if a security error occurspublic static boolean setupPlatform(KeyStore josmKs) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, 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.)KeyStoreException
- if the keystore has not been initialized (loaded)NoSuchAlgorithmException
- in case of errorCertificateException
- in case of errorIOException
- in case of errorpublic static void restartRemoteControlHttpsServer()
public static void stopRemoteControlHttpsServer()
public void run()
RequestProcessor
for each connection.public void stopServer() throws IOException
IOException
- if any I/O error occurs