Obtain our system properties in a security manager aware manner.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2940 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-01-24 05:58:16 +00:00
parent 2552fd471b
commit e8c355dff8
@@ -1,5 +1,5 @@
//
// $Id: MiCasaApp.java,v 1.10 2002/07/23 03:17:50 mdb Exp $
// $Id: MiCasaApp.java,v 1.11 2004/01/24 05:58:16 mdb Exp $
package com.threerings.micasa.client;
@@ -26,7 +26,7 @@ public class MiCasaApp
_frame = new MiCasaFrame();
// create our client instance
String cclass = System.getProperty("client");
String cclass = getProperty("client");
if (cclass == null) {
cclass = MiCasaClient.class.getName();
}
@@ -53,12 +53,12 @@ public class MiCasaApp
Client client = _client.getContext().getClient();
// read our server and port settings
String server = System.getProperty("server");
String server = getProperty("server");
if (server == null) {
server = "localhost";
}
int port = Client.DEFAULT_SERVER_PORT;
String portstr = System.getProperty("port");
String portstr = getProperty("port");
if (portstr != null) {
try {
port = Integer.parseInt(portstr);
@@ -71,8 +71,8 @@ public class MiCasaApp
client.setServer(server, port);
// configure the client with some credentials and logon
String username = System.getProperty("username");
String password = System.getProperty("password");
String username = getProperty("username");
String password = getProperty("password");
if (username != null && password != null) {
// create and set our credentials
Credentials creds = new UsernamePasswordCreds(username, password);
@@ -81,6 +81,20 @@ public class MiCasaApp
}
}
/**
* Attempts to get a property but doesn't freak out if we fail
* security check.
*/
protected String getProperty (String key)
{
try {
return System.getProperty(key);
} catch (Throwable t) {
Log.info("Can't fetch '" + key + "' system property.");
return null;
}
}
public static void main (String[] args)
{
MiCasaApp app = new MiCasaApp();