import jalview.schemes.UserColourScheme;
import jalview.structure.StructureImportSettings;
import jalview.urls.IdOrgSettings;
+import jalview.util.ChannelProperties;
import jalview.util.ColorUtils;
import jalview.util.MessageManager;
import jalview.util.Platform;
* when shading by annotation</li>
* <li>ANNOTATIONCOLOUR_MAX (red) Shade used for maximum value of annotation
* when shading by annotation</li>
- * <li>www.jalview.org (http://www.jalview.org) a property enabling all HTTP
- * requests to be redirected to a mirror of http://www.jalview.org</li>
+ * <li>www.jalview.org (https://www.jalview.org) a property enabling all HTTP
+ * requests to be redirected to a mirror of https://www.jalview.org</li>
* <li>FIGURE_AUTOIDWIDTH (false) Expand the left hand column of an exported
* alignment figure to accommodate even the longest sequence ID or annotation
* label.</li>
}
};
+ /* build Properties (not all saved to .jalview_properties) */
+ public static Properties buildProperties = new Properties();
+
/** Default file is ~/.jalview_properties */
static String propertiesFile;
// lcastor.addAppender(ap);
// jalview.bin.Cache.log.addAppender(ap);
// Tell the user that debug is enabled
- jalview.bin.Cache.log.debug("Jalview Debugging Output Follows.");
+ jalview.bin.Cache.log.debug(ChannelProperties.getProperty("app_name")
+ + " Debugging Output Follows.");
} catch (Exception ex)
{
System.err.println("Problems initializing the log4j system\n");
}
/**
- * Loads properties from the given properties file. Any existing properties
- * are first cleared.
+ * Loads properties from the given properties file. Any existing properties are
+ * first cleared.
*/
public static void loadProperties(String propsFile)
{
propertiesFile = propsFile;
+ String releasePropertiesFile = null;
+ boolean defaultProperties = false;
if (propsFile == null && !propsAreReadOnly)
{
+ String channelPrefsFilename = ChannelProperties
+ .getProperty("preferences.filename");
+ String releasePrefsFilename = ".jalview_properties";
propertiesFile = System.getProperty("user.home") + File.separatorChar
- + ".jalview_properties";
+ + channelPrefsFilename;
+ releasePropertiesFile = System.getProperty("user.home")
+ + File.separatorChar + releasePrefsFilename;
+ defaultProperties = true;
}
else
{
InputStream fis;
try
{
+ // props file provided as URL
fis = new URL(propertiesFile).openStream();
System.out.println(
"Loading jalview properties from : " + propertiesFile);
System.out.println(
"Disabling Jalview writing to user's local properties file.");
propsAreReadOnly = true;
-
} catch (Exception ex)
{
fis = null;
}
if (fis == null)
{
- fis = new FileInputStream(propertiesFile);
+ String readPropertiesFile = propertiesFile;
+ // if we're using the usual properties file and the channel properties
+ // file doesn't exist, read .jalview_properties
+ // (but we'll still save to the channel properties file).
+ if (defaultProperties && (!new File(propertiesFile).exists())
+ && (new File(releasePropertiesFile).exists()))
+ {
+ readPropertiesFile = releasePropertiesFile;
+ }
+ fis = new FileInputStream(readPropertiesFile);
}
applicationProperties.clear();
applicationProperties.load(fis);
DEFAULT_CACHE_THRESHOLD_IN_DAYS));
IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL",
- "http://www.jalview.org/services/identifiers"));
+ "https://www.jalview.org/services/identifiers"));
IdOrgSettings.setDownloadLocation(ID_ORG_FILE);
StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache
class VersionChecker extends Thread
{
+
@Override
public void run()
{
+ String remoteBuildPropertiesUrl = Cache
+ .getAppbaseBuildProperties();
+
String orgtimeout = System
.getProperty("sun.net.client.defaultConnectTimeout");
if (orgtimeout == null)
{
System.setProperty("sun.net.client.defaultConnectTimeout",
"5000");
- java.net.URL url = new java.net.URL(Cache
- .getDefault("www.jalview.org", "http://www.jalview.org")
- + "/webstart/jalview.jnlp");
+ java.net.URL url = new java.net.URL(remoteBuildPropertiesUrl);
+
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
- String line = null;
- while ((line = in.readLine()) != null)
- {
- if (line.indexOf("jalview.version") == -1)
- {
- continue;
- }
- line = line.substring(line.indexOf("value=") + 7);
- line = line.substring(0, line.lastIndexOf("\""));
- remoteVersion = line;
- break;
- }
+ Properties remoteBuildProperties = new Properties();
+ remoteBuildProperties.load(in);
+ remoteVersion = remoteBuildProperties.getProperty("VERSION");
} catch (Exception ex)
{
- System.out.println(
- "Non-fatal exception when checking version at www.jalview.org :");
+ System.out
+ .println("Non-fatal exception when checking version at "
+ + remoteBuildPropertiesUrl + ":");
System.out.println(ex);
remoteVersion = getProperty("VERSION");
}
String buildDetails = resolveResourceURLFor("/.build_properties");
URL localJarFileURL = new URL(buildDetails);
InputStream in = localJarFileURL.openStream();
- applicationProperties.load(in);
+ buildProperties.load(in);
in.close();
+ if (buildProperties.getProperty("BUILD_DATE", null) != null)
+ {
+ applicationProperties.put("BUILD_DATE",
+ buildProperties.getProperty("BUILD_DATE"));
+ }
+ if (buildProperties.getProperty("INSTALLATION", null) != null)
+ {
+ applicationProperties.put("INSTALLATION",
+ buildProperties.getProperty("INSTALLATION"));
+ }
+ if (buildProperties.getProperty("VERSION", null) != null)
+ {
+ applicationProperties.put("VERSION",
+ buildProperties.getProperty("VERSION"));
+ }
} catch (Exception ex)
{
System.out.println("Error reading build details: " + ex);
new BuildDetails(codeVersion, null, codeInstallation);
if (printVersion && reportVersion)
{
- System.out.println(
- "Jalview Version: " + codeVersion + codeInstallation);
+ System.out.println(ChannelProperties.getProperty("app_name")
+ + " Version: " + codeVersion + codeInstallation);
}
}
}
/**
- * Gets Jalview application property of given key. Returns null if key not
- * found
+ * Gets Jalview application property of given key. Returns null if key not found
*
* @param key
- * Name of property
+ * Name of property
*
* @return Property value
*/
}
/**
- * These methods are used when checking if the saved preference is different
- * to the default setting
+ * These methods are used when checking if the saved preference is different to
+ * the default setting
*/
public static boolean getDefault(String property, boolean def)
}
/**
- * Answers the value of the given property, or the supplied default value if
- * the property is not set
+ * Answers the value of the given property, or the supplied default value if the
+ * property is not set
*/
public static String getDefault(String property, String def)
{
* Stores property in the file "HOME_DIR/.jalview_properties"
*
* @param key
- * Name of object
+ * Name of object
* @param obj
- * String value of property
+ * String value of property
*
* @return previous value of property (or null)
*/
lvclient.addAppender(log.getAppender("JalviewLogger"));
// Tell the user that debug is enabled
- lvclient.debug("Jalview Vamsas Client Debugging Output Follows.");
+ lvclient.debug(ChannelProperties.getProperty("app_name")
+ + " Vamsas Client Debugging Output Follows.");
}
} catch (Exception e)
{
lgclient.addAppender(log.getAppender("JalviewLogger"));
// Tell the user that debug is enabled
- lgclient.debug("Jalview Groovy Client Debugging Output Follows.");
+ lgclient.debug(ChannelProperties.getProperty("app_name")
+ + " Groovy Client Debugging Output Follows.");
}
} catch (Error e)
{
.getConstructor(new Class[]
{ String.class, String.class, String.class })
.newInstance(new Object[]
- { "Jalview Desktop",
+ { ChannelProperties.getProperty("app_name") + " Desktop",
(vrs = jalview.bin.Cache.getProperty("VERSION") + "_"
+ jalview.bin.Cache.getDefault("BUILD_DATE",
"unknown")),
* Loads in user colour schemes from files.
*
* @param files
- * a '|'-delimited list of file paths
+ * a '|'-delimited list of file paths
*/
public static void initUserColourSchemes(String files)
{
public static String getVersionDetailsForConsole()
{
StringBuilder sb = new StringBuilder();
- sb.append("Jalview Version: ");
+ sb.append(ChannelProperties.getProperty("app_name"))
+ .append(" Version: ");
sb.append(jalview.bin.Cache.getDefault("VERSION", "TEST"));
sb.append("\n");
- sb.append("Jalview Installation: ");
+ sb.append(ChannelProperties.getProperty("app_name"))
+ .append(" Installation: ");
sb.append(jalview.bin.Cache.getDefault("INSTALLATION", "unknown"));
sb.append("\n");
sb.append("Build Date: ");
{
appendIfNotNull(sb, "Getdown appdir: ",
System.getProperty("getdownappdir"), "\n", null);
+ appendIfNotNull(sb, "Getdown appbase: ",
+ System.getProperty("getdownappbase"), "\n", null);
appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"),
"\n", "unknown");
}
Arrays.fill(displayHttpPw, '*');
Cache.debug("CACHE Proxy: setting new Authenticator with httpUser='"
+ httpUser + "' httpPassword='" + displayHttpPw + "'");
- Authenticator.setDefault(new Authenticator()
+ if (!Platform.isJS())
+ /* *
+ * java.net.Authenticator not implemented in SwingJS yet
+ *
+ * @j2sIgnore
+ *
+ */
{
- @Override
- protected PasswordAuthentication getPasswordAuthentication()
+ Authenticator.setDefault(new Authenticator()
{
- if (getRequestorType() == RequestorType.PROXY)
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication()
{
- String protocol = getRequestingProtocol();
- boolean needProxyPasswordSet = false;
- if (customProxySet &&
- // we have a username but no password for the scheme being
- // requested
- (protocol.equalsIgnoreCase("http")
- && (httpUser != null && httpUser.length() > 0
- && (httpPassword == null
- || httpPassword.length == 0)))
- || (protocol.equalsIgnoreCase("https")
- && (httpsUser != null
- && httpsUser.length() > 0
- && (httpsPassword == null
- || httpsPassword.length == 0))))
- {
- // open Preferences -> Connections
- String message = MessageManager
- .getString("label.proxy_password_required");
- Preferences.openPreferences(Preferences.CONNECTIONS_TAB,
- message);
- Preferences.getInstance()
- .proxyAuthPasswordCheckHighlight(true, true);
- }
- else
+ if (getRequestorType() == RequestorType.PROXY)
{
- try
+ String protocol = getRequestingProtocol();
+ boolean needProxyPasswordSet = false;
+ if (customProxySet &&
+ // we have a username but no password for the scheme being
+ // requested
+ (protocol.equalsIgnoreCase("http")
+ && (httpUser != null && httpUser.length() > 0
+ && (httpPassword == null
+ || httpPassword.length == 0)))
+ || (protocol.equalsIgnoreCase("https")
+ && (httpsUser != null
+ && httpsUser.length() > 0
+ && (httpsPassword == null
+ || httpsPassword.length == 0))))
{
- if (protocol.equalsIgnoreCase("http")
- && getRequestingHost().equalsIgnoreCase(httpHost)
- && getRequestingPort() == Integer
- .valueOf(httpPort))
+ // open Preferences -> Connections
+ String message = MessageManager
+ .getString("label.proxy_password_required");
+ Preferences.openPreferences(
+ Preferences.TabRef.CONNECTIONS_TAB, message);
+ Preferences.getInstance()
+ .proxyAuthPasswordCheckHighlight(true, true);
+ }
+ else
+ {
+ try
{
- Cache.debug(
- "AUTHENTICATOR returning PasswordAuthentication(\""
- + httpUser + "\", '"
- + new String(displayHttpPw) + "')");
- return new PasswordAuthentication(httpUser,
- httpPassword);
- }
- if (protocol.equalsIgnoreCase("https")
- && getRequestingHost().equalsIgnoreCase(httpsHost)
- && getRequestingPort() == Integer
- .valueOf(httpsPort))
+ if (protocol.equalsIgnoreCase("http")
+ && getRequestingHost()
+ .equalsIgnoreCase(httpHost)
+ && getRequestingPort() == Integer
+ .valueOf(httpPort))
+ {
+ Cache.debug(
+ "AUTHENTICATOR returning PasswordAuthentication(\""
+ + httpUser + "\", '"
+ + new String(displayHttpPw) + "')");
+ return new PasswordAuthentication(httpUser,
+ httpPassword);
+ }
+ if (protocol.equalsIgnoreCase("https")
+ && getRequestingHost()
+ .equalsIgnoreCase(httpsHost)
+ && getRequestingPort() == Integer
+ .valueOf(httpsPort))
+ {
+ char[] displayHttpsPw = new char[httpPassword.length];
+ Arrays.fill(displayHttpsPw, '*');
+ Cache.debug(
+ "AUTHENTICATOR returning PasswordAuthentication(\""
+ + httpsUser + "\", '" + displayHttpsPw
+ + "'");
+ return new PasswordAuthentication(httpsUser,
+ httpsPassword);
+ }
+ } catch (NumberFormatException e)
{
- char[] displayHttpsPw = new char[httpPassword.length];
- Arrays.fill(displayHttpsPw, '*');
- Cache.debug(
- "AUTHENTICATOR returning PasswordAuthentication(\""
- + httpsUser + "\", '" + displayHttpsPw
- + "'");
- return new PasswordAuthentication(httpsUser,
- httpsPassword);
+ Cache.error("Problem with proxy port values [http:"
+ + httpPort + ", https:" + httpsPort + "]");
}
- } catch (NumberFormatException e)
- {
- Cache.error("Problem with proxy port values [http:"
- + httpPort + ", https:" + httpsPort + "]");
+ Cache.debug(
+ "AUTHENTICATOR after trying to get PasswordAuthentication");
}
- Cache.debug(
- "AUTHENTICATOR after trying to get PasswordAuthentication");
}
+ // non proxy request
+ Cache.debug("AUTHENTICATOR returning null");
+ return null;
}
- // non proxy request
- Cache.debug("AUTHENTICATOR returning null");
- return null;
- }
- });
+ });
+ } // end of j2sIgnore for java.net.Authenticator
+
// required to re-enable basic authentication (should be okay for a
// local proxy)
Cache.debug(
/* as noted above, due to bug in java this doesn't work if the sun.net.www.protocol.http.AuthCache
* has working credentials. No workaround for Java 11.
*/
- Cache.debug("AUTHENTICATOR setting default Authenticator to null");
- Authenticator.setDefault(null);
+ if (!Platform.isJS())
+ /* *
+ * java.net.Authenticator not implemented in SwingJS yet
+ *
+ * @j2sIgnore
+ *
+ */
+ {
+ Cache.debug("AUTHENTICATOR setting default Authenticator to null");
+ Authenticator.setDefault(null);
+ }
}
// nonProxyHosts not currently configurable in Preferences
{
println(ERROR, message);
}
-}
\ No newline at end of file
+
+ /**
+ * Getdown appbase methods
+ */
+
+ private static final String releaseAppbase;
+
+ private static String getdownAppbase;
+
+ private static String getdownDistDir;
+
+ static
+ {
+ if (!Platform.isJS())
+ {
+ Float specversion = Float
+ .parseFloat(System.getProperty("java.specification.version"));
+ releaseAppbase = (specversion < 9)
+ ? "https://www.jalview.org/getdown/release/1.8"
+ : "https://www.jalview.org/getdown/release/11";
+ }
+ else
+ {
+ // this value currenly made up, can be changed to URL that will be
+ // "https://www.jalview.org/jalview-js/swingjs/j2s/build_properties"
+ releaseAppbase = "https://www.jalview.org/jalview-js";
+ getdownAppbase = releaseAppbase;
+ getdownDistDir = "/swingjs/j2s";
+ }
+ }
+
+ // look for properties (passed in by getdown) otherwise default to release
+ private static void setGetdownAppbase()
+ {
+ if (getdownAppbase != null)
+ {
+ return;
+ }
+ String appbase = System.getProperty("getdownappbase");
+ String distDir = System.getProperty("getdowndistdir");
+ if (appbase == null)
+ {
+ appbase = buildProperties.getProperty("GETDOWNAPPBASE");
+ distDir = buildProperties.getProperty("GETDOWNAPPDISTDIR");
+ }
+ if (appbase == null)
+ {
+ appbase = releaseAppbase;
+ distDir = "release";
+ }
+ if (appbase.endsWith("/"))
+ {
+ appbase = appbase.substring(0, appbase.length() - 1);
+ }
+ if (distDir == null)
+ {
+ distDir = appbase.equals(releaseAppbase) ? "release" : "alt";
+ }
+ getdownAppbase = appbase;
+ getdownDistDir = distDir;
+ }
+
+ public static String getGetdownAppbase()
+ {
+ setGetdownAppbase();
+ return getdownAppbase;
+ }
+
+ public static String getAppbaseBuildProperties()
+ {
+ String appbase = getGetdownAppbase();
+ return appbase + "/" + getdownDistDir + "/build_properties";
+ }
+}