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:
@@ -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;
|
package com.threerings.micasa.client;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public class MiCasaApp
|
|||||||
_frame = new MiCasaFrame();
|
_frame = new MiCasaFrame();
|
||||||
|
|
||||||
// create our client instance
|
// create our client instance
|
||||||
String cclass = System.getProperty("client");
|
String cclass = getProperty("client");
|
||||||
if (cclass == null) {
|
if (cclass == null) {
|
||||||
cclass = MiCasaClient.class.getName();
|
cclass = MiCasaClient.class.getName();
|
||||||
}
|
}
|
||||||
@@ -53,12 +53,12 @@ public class MiCasaApp
|
|||||||
Client client = _client.getContext().getClient();
|
Client client = _client.getContext().getClient();
|
||||||
|
|
||||||
// read our server and port settings
|
// read our server and port settings
|
||||||
String server = System.getProperty("server");
|
String server = getProperty("server");
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
server = "localhost";
|
server = "localhost";
|
||||||
}
|
}
|
||||||
int port = Client.DEFAULT_SERVER_PORT;
|
int port = Client.DEFAULT_SERVER_PORT;
|
||||||
String portstr = System.getProperty("port");
|
String portstr = getProperty("port");
|
||||||
if (portstr != null) {
|
if (portstr != null) {
|
||||||
try {
|
try {
|
||||||
port = Integer.parseInt(portstr);
|
port = Integer.parseInt(portstr);
|
||||||
@@ -71,8 +71,8 @@ public class MiCasaApp
|
|||||||
client.setServer(server, port);
|
client.setServer(server, port);
|
||||||
|
|
||||||
// configure the client with some credentials and logon
|
// configure the client with some credentials and logon
|
||||||
String username = System.getProperty("username");
|
String username = getProperty("username");
|
||||||
String password = System.getProperty("password");
|
String password = getProperty("password");
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
// create and set our credentials
|
// create and set our credentials
|
||||||
Credentials creds = new UsernamePasswordCreds(username, password);
|
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)
|
public static void main (String[] args)
|
||||||
{
|
{
|
||||||
MiCasaApp app = new MiCasaApp();
|
MiCasaApp app = new MiCasaApp();
|
||||||
|
|||||||
Reference in New Issue
Block a user