Methods Summary |
---|
private static final void | assertAdminServerChannelNotNull()Assert than Admin server channel is not null.
if (server == null) {
String msg = localStrings.getString( "admin.server.core.channel.admin_server_channel_not_initialized" );
throw new RuntimeException( msg );
}
|
public static synchronized void | createRMIChannel()Create a RMI channel. This method creates a server object and exposes
the stub on local filesystem.
try {
server = createServerObject();
saveStubToFile(server.getRemoteStub());
} catch (Exception e) {
warn(SERVER_CREATION_ERRCODE);
debug(e);
throw new ServerLifecycleException(e);
}
|
private static AdminChannelServer | createServerObject()Create server object that serves RMI client. If local loopback address
can be determined the server object listens on only local loopback
address, otherwise it listens on all interfaces (default RMI behavior).
AdminChannelServer server = null;
InetAddress localAddress = getLocalLoopbackAddress();
if (localAddress == null) {
server = new AdminChannelServer();
} else {
LocalRMIClientSocketFactory csf =
new LocalRMIClientSocketFactory(localAddress);
LocalRMIServerSocketFactory ssf =
new LocalRMIServerSocketFactory(localAddress);
int port = 0;
port = Integer.getInteger(
PROP_SERVER_PORT, new Integer(port)).intValue();
server = new AdminChannelServer(port, csf, ssf);
server = new AdminChannelServer(0, csf, ssf);
server.setLocalAddress(localAddress);
}
return server;
|
public static synchronized void | createSharedSecret()Create a shared secret. The shared secret is saved on the filesystem
and is verified during every call on admin channel.
assertAdminServerChannelNotNull();
String fileName = getSeedFileName();
File seedFile = new File(fileName);
byte[] prevSeed = getPreviousSeed(seedFile);
SecureRandom sr = new SecureRandom(prevSeed);
byte[] seed = new byte[SEED_LENGTH];
sr.nextBytes(seed);
saveSeedToFile(seed, seedFile);
server.setSharedInfo(seed);
server.setChannelStarting();
|
static void | debug(java.lang.String s)
logger.fine(s);
|
static void | debug(java.lang.String msgkey, java.lang.String obj1)
logger.log(Level.FINE, msgkey, obj1);
|
static void | debug(java.lang.String msgkey, java.lang.Object[] objarr)
logger.log(Level.FINE, msgkey, objarr);
|
static void | debug(java.lang.Throwable t)
logger.log(Level.FINE, t.getMessage(), t);
|
private static void | deleteStubFile()Cleanup stub file (is invoked on shutdown)
String fileName = getStubFileName();
new File(fileName).delete();
|
public static synchronized void | destroyRMIChannel()Remove RMI channel. Remove the server object from JVM (do not accept
any more calls and abort in process calls) and clean up the stub
exposed on filesystem.
if (server != null) {
server.setChannelStopping();
try {
UnicastRemoteObject.unexportObject(server, true);
} catch (NoSuchObjectException nsoe) {
throw new ServerLifecycleException(nsoe);
}
}
deleteStubFile();
|
public static void | enableWebCoreReconfig()Enable reconfiguration of Sun ONE Web Server core.
try {
ReconfigHelper.enableWebCoreReconfig();
} catch (Throwable t) {
// If reconfiguration could not be enabled log a warning
// message and continue
warn(RECONFIG_ENABLE_ERROR );
debug(t);
}
|
static java.lang.String | getAccessLevel()Get access level. FIX to use config parameter
return LOCAL_ONLY_ACCESS;
|
static boolean | getClientAutoRefreshEnabled()Is Auto Refresh enabled for RMIClient objects (so they will keep on
scanning file system for changes to stub file and reset themselves).
FIX to use config parameter
return true;
|
static long | getClientAutoRefreshInterval()How frequently should the RMI client objects refresh themselves (in
milliseconds). FIX to use config parameter
// 1 minute
return (1 * 60 * 1000);
|
static java.lang.String | getInstanceRoot()
//Begin EE: 4921345 instanceRoot cannot be statically initialized since it relies on
//a system property which may not be set until startup time. This removes the
//dependency ond AdminService.
if (instanceRoot == null) {
instanceRoot = System.getProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY);
}
return instanceRoot;
|
static java.lang.String | getKeyCheckLevel()Get key check level. FIX to use config parameter.
return ENFORCE;
|
private static java.net.InetAddress | getLocalLoopbackAddress()Get local loopback address.
InetAddress localAddr = null;
try {
localAddr = InetAddress.getByName(null);
if (!localAddr.isLoopbackAddress()) {
localAddr = null;
}
} catch (Throwable t) {
// Catch all exceptions and return null to the caller
localAddr = null;
}
return localAddr;
|
private static byte[] | getPreviousSeed(java.io.File seedFile)Get previous seed. This seed is read either from previous session's
shared secret file or initialized using SecureRandom.getSeed (if the
shared secret file does not exist). This seed is then used with
SecureRandom to generate next key value.
boolean haveSeed = false;
byte[] prevSeed = new byte[SEED_LENGTH];
// Using secure.seed bits to mix in a few extra bits of randomness
// since we cannot use SecureRandoms built-in seeding.
// Read bugs 4703002 and 4709460 for some background on this.
SecureRandom sr =
com.sun.enterprise.server.J2EEServer.secureRandom;
assert (sr != null); // was initialized early on startup
sr.setSeed(System.currentTimeMillis());
if (seedFile.exists() && seedFile.canRead()) {
FileInputStream fis = null;
try {
fis = new FileInputStream(seedFile);
fis.read(prevSeed);
sr.setSeed(prevSeed);
sr.nextBytes(prevSeed);
haveSeed = true;
} catch (IOException ioe) {
warn(KEY_READ_ERROR);
debug(ioe);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ioe) {
}
}
}
}
if (!haveSeed) {
sr.nextBytes(prevSeed);
}
return prevSeed;
|
public static synchronized RMIClient | getRMIClient(java.lang.String instanceName)Get RMI client for specified instance.
//KE FIXME: All of this code is obsolete whent the stub file
//is removed.
RMIClient client = (RMIClient)rmiClientMap.get(instanceName);
if (client == null) {
client = new RMIClient(getStubFileName(),
getSeedFileName());
rmiClientMap.put(instanceName, client);
}
return client;
|
static java.lang.String | getSeedFileName()
return getInstanceRoot() + fileSeparator
+ Constants.CONFIG_DIR_NAME + fileSeparator
+ seedFileName;
|
static java.lang.String | getStubFileName()
return getInstanceRoot() + fileSeparator
+ Constants.CONFIG_DIR_NAME + fileSeparator
+ stubFileName;
|
private static void | saveSeedToFile(byte[] seed, java.io.File seedFile)Save shared secret in file (so that it becomes shared)
FileOutputStream fos = null;
try {
fos = new FileOutputStream(seedFile);
fos.write(seed);
} catch (IOException ioe) {
warn(KEY_WRITE_ERROR);
debug(ioe);
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException ioe) {
}
}
}
|
private static void | saveStubToFile(java.rmi.server.RemoteStub stub)Save remote stub for admin channel server to file.
String fileName = getStubFileName();
try {
File file = new File(fileName);
FileOutputStream fos = new FileOutputStream(file);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(stub);
fos.close();
} catch (Exception e) {
String msg = localStrings.getString( "admin.server.core.channel.unable_saving_stub_to_file", fileName );
throw new RuntimeException( msg, e );
}
|
public static void | setRMIChannelAborting(int port)Set the channel to failed state. If the client detects this state, then
it will try to get the port number that caused failure from the channel.
assertAdminServerChannelNotNull();
server.setChannelAborting(port);
|
public static synchronized void | setRMIChannelReady()Set channel to ready state. This means that the server instance that
initialized the channel is ready to serve client requests.
assertAdminServerChannelNotNull();
server.setChannelReady();
|
public static synchronized void | setRMIChannelStopping()
assertAdminServerChannelNotNull();
server.setChannelStopping();
|
static void | trace(java.lang.Throwable t)
logger.log(Level.FINEST, t.getMessage(), t);
|
static void | warn(java.lang.String s)
logger.warning(s);
|
static void | warn(java.lang.String msgkey, java.lang.String obj1)
logger.log(Level.WARNING, msgkey, obj1);
|