public class PlatformHookWindows extends java.lang.Object implements PlatformHook
PlatformHook
implementation for Microsoft Windows systems.Modifier and Type | Class and Description |
---|---|
static class |
PlatformHookWindows.FontEntry
Simple data class to hold information about a font.
|
Modifier and Type | Field and Description |
---|---|
private static byte[] |
INSECURE_PUBLIC_KEY |
private static java.lang.String |
WINDOWS_ROOT |
Constructor and Description |
---|
PlatformHookWindows() |
Modifier and Type | Method and Description |
---|---|
void |
afterPrefStartupHook()
The afterPrefStartupHook will be called early, but after
the preferences have been loaded and basic processing of
command line arguments is finished.
|
protected void |
extendFontconfig(java.lang.String templateFileName)
Add more fallback fonts to the Java runtime, in order to get
support for more scripts.
|
protected java.util.Collection<PlatformHookWindows.FontEntry> |
getAdditionalFonts()
Get default list of additional fonts to add to the configuration.
|
java.io.File |
getDefaultCacheDirectory()
Returns the platform-dependent default cache directory.
|
java.io.File |
getDefaultPrefDirectory()
Returns the platform-dependent default preferences directory.
|
java.lang.String |
getDefaultStyle()
Returns the default LAF to be used on this platform to look almost as a native application.
|
java.io.File |
getDefaultUserDataDirectory()
Returns the platform-dependent default user data directory.
|
protected java.util.Collection<java.lang.String> |
getInstalledFonts()
Get a list of fonts that are installed on the system.
|
java.lang.String |
getOSDescription()
Returns a detailed OS description (at least family + version).
|
static java.security.KeyStore |
getRootKeystore()
Loads Windows-ROOT keystore.
|
void |
initSystemShortcuts()
The initSystemShortcuts hook will be called by the
Shortcut class after the modifier groups have been read
from the config, but before any shortcuts are read from
it or registered from within the application.
|
void |
openUrl(java.lang.String url)
The openURL hook will be used to open an URL in the
default web browser.
|
static void |
removeInsecureCertificates()
Removes potential insecure certificates installed with previous versions of JOSM on Windows.
|
boolean |
rename(java.io.File from,
java.io.File to)
Renames a file.
|
boolean |
setupHttpsCertificate(java.lang.String entryAlias,
java.security.KeyStore.TrustedCertificateEntry trustedCert)
Setup system keystore to add JOSM HTTPS certificate (for remote control).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canFullscreen, makeTooltip, preStartupHook, startupHook
private static final byte[] INSECURE_PUBLIC_KEY
private static final java.lang.String WINDOWS_ROOT
public PlatformHookWindows()
public void afterPrefStartupHook()
PlatformHook
afterPrefStartupHook
in interface PlatformHook
public void openUrl(java.lang.String url) throws java.io.IOException
PlatformHook
openUrl
in interface PlatformHook
url
- The URL to openjava.io.IOException
- if any I/O error occurspublic void initSystemShortcuts()
PlatformHook
initSystemShortcuts
in interface PlatformHook
public java.lang.String getDefaultStyle()
PlatformHook
getDefaultStyle
in interface PlatformHook
public boolean rename(java.io.File from, java.io.File to)
PlatformHook
rename
in interface PlatformHook
from
- Source fileto
- Target filetrue
if the file has been renamed, false
otherwisepublic java.lang.String getOSDescription()
PlatformHook
getOSDescription
in interface PlatformHook
public static java.security.KeyStore getRootKeystore() throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException, java.security.KeyStoreException
java.security.NoSuchAlgorithmException
- if the algorithm used to check the integrity of the keystore cannot be foundjava.security.cert.CertificateException
- if any of the certificates in the keystore could not be loadedjava.io.IOException
- if there is an I/O or format problem with the keystore data, if a password is required but not givenjava.security.KeyStoreException
- if no Provider supports a KeyStore implementation for the type "Windows-ROOT"public static void removeInsecureCertificates() throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException, java.io.IOException
java.security.NoSuchAlgorithmException
- on unsupported signature algorithmsjava.security.cert.CertificateException
- if any of the certificates in the Windows keystore could not be loadedjava.security.KeyStoreException
- if no Provider supports a KeyStoreSpi implementation for the type "Windows-ROOT"java.io.IOException
- if there is an I/O or format problem with the keystore data, if a password is required but not givenpublic boolean setupHttpsCertificate(java.lang.String entryAlias, java.security.KeyStore.TrustedCertificateEntry trustedCert) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.io.IOException
PlatformHook
setupHttpsCertificate
in interface PlatformHook
entryAlias
- The entry alias to usetrustedCert
- the JOSM certificate for localhosttrue
if something has changed as a result of the call (certificate installation, etc.)java.security.KeyStoreException
- in case of errorjava.security.NoSuchAlgorithmException
- in case of errorjava.security.cert.CertificateException
- in case of errorjava.io.IOException
- in case of errorpublic java.io.File getDefaultCacheDirectory()
PlatformHook
getDefaultCacheDirectory
in interface PlatformHook
public java.io.File getDefaultPrefDirectory()
PlatformHook
getDefaultPrefDirectory
in interface PlatformHook
public java.io.File getDefaultUserDataDirectory()
PlatformHook
getDefaultUserDataDirectory
in interface PlatformHook
protected void extendFontconfig(java.lang.String templateFileName)
Add more fallback fonts to the Java runtime, in order to get support for more scripts.
The font configuration in Java doesn't include some Indic scripts, even though MS Windows ships with fonts that cover these unicode ranges.
To fix this, the fontconfig.properties template is copied to the JOSM cache folder. Then, the additional entries are added to the font configuration. Finally the system property "sun.awt.fontconfig" is set to the customized fontconfig.properties file.
This is a crude hack, but better than no font display at all for these languages. There is no guarantee, that the template file ($JAVA_HOME/lib/fontconfig.properties.src) matches the default configuration (which is in a binary format). Furthermore, the system property "sun.awt.fontconfig" is undocumented and may no longer work in future versions of Java.
Related Java bug: JDK-8008572
templateFileName
- file name of the fontconfig.properties template fileprotected java.util.Collection<java.lang.String> getInstalledFonts()
extendFontconfig(java.lang.String)
, have to set system
property first, which is then read by sun.awt.FontConfiguration upon initialization.)protected java.util.Collection<PlatformHookWindows.FontEntry> getAdditionalFonts()