Fields Summary |
---|
private String | localAddress |
private byte[] | myKey |
private int | instanceStatusServer instance status. Its value is one of the constant
kInstanceStartingCode, kInstanceRunningCode or kInstanceStoppingCode
from the class com.sun.enterprise.admin.common.Status . |
private boolean | restartNeededIs restart needed on this server instance to sync it up with persistent
configuration. |
private int | conflictedPort |
private static final String | CLIENT_HOST_NULL |
private static final String | LOCAL_ACCESS |
private static final String | ADDR_MISMATCH |
private static final String | NO_LOCAL_HOST |
private static final String | KEY_MISMATCH |
private static com.sun.enterprise.util.i18n.StringManager | localStrings |
Methods Summary |
---|
private boolean | addressMatches(java.lang.String addr)Check whether local address of the server object is same as specified
address.
String localAddr = getLocalAddress();
if (localAddr == null) {
return false;
}
return addr.equals(localAddr);
|
private boolean | checkAccess()Verify that client is coming from the same IP address as the server.
boolean allowed = true;
String addr = null;
if (AdminChannel.LOCAL_ONLY_ACCESS.equals(AdminChannel.getAccessLevel())) {
boolean matchAddress = true;
try {
addr = this.getClientHost();
if (addr == null) {
AdminChannel.warn(CLIENT_HOST_NULL);
allowed = false;
matchAddress = false;
}
} catch (ServerNotActiveException snae) {
AdminChannel.warn(LOCAL_ACCESS);
AdminChannel.debug(snae);
matchAddress = false;
}
if (matchAddress) {
allowed = addressMatches(addr);
}
}
if (!allowed) {
AdminChannel.debug(ADDR_MISMATCH,
new Object[] {addr, getLocalAddress()});
}
return allowed;
|
private boolean | checkKeyLength(byte[] key)Check whether specified key is of correct length.
return (key.length == AdminChannel.SEED_LENGTH);
|
public int | getConflictedPort(byte[] key)Returns the port number that caused conflict. This could be
0, if port-conflict is not the cause of failure.
if (!checkAccess()) {
String msg = localStrings.getString( "admin.server.core.channel.unauthorized_access" );
throw new SecurityException( msg );
}
if (!keyMatches(key)) {
String msg = localStrings.getString( "admin.server.core.channel.invalid_key" );
throw new IllegalArgumentException( msg );
}
return conflictedPort;
|
private java.lang.String | getLocalAddress()Get local address for the server object. If local address has not been
initialized, it is initialized using InetAddress.getLocalHost()
.
if (localAddress == null) {
InetAddress inetAddr = null;
try {
inetAddr = InetAddress.getLocalHost();
} catch (UnknownHostException uhe) {
AdminChannel.warn(NO_LOCAL_HOST);
AdminChannel.debug(uhe);
}
if (inetAddr != null) {
localAddress = inetAddr.getHostAddress();
}
}
return localAddress;
|
java.rmi.server.RemoteStub | getRemoteStub()Get remote stub for the server object.
return (RemoteStub)RemoteObject.toStub(this);
|
public int | getServerStatusCode(byte[] key)Get server status code. This method will return one of the following
constants from class com.sun.enterprise.admin.common.Status
-- kInstanceStartingCode, kInstanceRunningCode or
kInstanceStoppingCode representing starting, running and stopping
condition for the instance.
if (!checkAccess()) {
String msg = localStrings.getString( "admin.server.core.channel.unauthorized_access" );
throw new SecurityException( msg );
}
if (!keyMatches(key)) {
String msg = localStrings.getString( "admin.server.core.channel.invalid_key" );
throw new IllegalArgumentException( msg );
}
return instanceStatus;
|
public boolean | isRestartNeeded(byte[] key)Is restart needed to use persistent server configuration. After a
notification, the server may be in inconsistenet state with respect
to persistent configuration because all changes to configuration can
not be handled dynamically - A restart is needed in such cases to
synchronize server with persistent configuration.
if (!checkAccess()) {
String msg = localStrings.getString( "admin.server.core.channel.unauthorized_access" );
throw new SecurityException( msg );
}
if (!keyMatches(key)) {
String msg = localStrings.getString( "admin.server.core.channel.invalid_key" );
throw new IllegalArgumentException( msg );
}
return restartNeeded;
|
private boolean | keyMatches(byte[] key)Check whether shared secret for the server object matches the specified
key.
boolean matches = true;
if (AdminChannel.ENFORCE.equals(AdminChannel.getKeyCheckLevel())) {
matches = checkKeyLength(key);
for (int i = 0; matches && i < AdminChannel.SEED_LENGTH; i++) {
if (key[i] != myKey[i]) {
matches = false;
}
}
} else if (AdminChannel.REQUIRE_KEY.equals(AdminChannel.getKeyCheckLevel())) {
matches = checkKeyLength(key);
}
if (!matches) {
AdminChannel.debug(KEY_MISMATCH,
new Object[] {new String(key), new String(myKey)});
}
return matches;
|
public boolean | pingServer(byte[] key)Ping server. If the method call succeeds, notifications can be sent.
if (!checkAccess()) {
String msg = localStrings.getString( "admin.server.core.channel.unauthorized_access" );
throw new SecurityException( msg );
}
if (!keyMatches(key)) {
String msg = localStrings.getString( "admin.server.core.channel.invalid_key" );
throw new IllegalArgumentException( msg );
}
return true;
|
public com.sun.enterprise.admin.event.AdminEventResult | sendNotification(byte[] key, com.sun.enterprise.admin.event.AdminEvent event)Send event notification.
if (!checkAccess()) {
String msg = localStrings.getString( "admin.server.core.channel.unauthorized_access" );
throw new SecurityException( msg );
}
if (!keyMatches(key)) {
String msg = localStrings.getString( "admin.server.core.channel.invalid_key" );
throw new IllegalArgumentException( msg );
}
return AdminEventMulticaster.multicastEvent(event);
|
void | setChannelAborting(int conflictedPort)Set the channel to failed state.
this.conflictedPort = conflictedPort;
this.instanceStatus = Status.kInstanceFailedCode;
|
void | setChannelReady()Set channel to ready (running) state.
this.instanceStatus = Status.kInstanceRunningCode;
|
void | setChannelStarting()Set channel to starting state.
this.instanceStatus = Status.kInstanceStartingCode;
|
void | setChannelStopping()Set channel to stopping state.
this.instanceStatus = Status.kInstanceStoppingCode;
|
void | setLocalAddress(java.net.InetAddress address)Set the address that clients will be checked against. This is set at
startup.
localAddress = address.getHostAddress();
|
public void | setRestartNeeded(byte[] key, boolean needRestart)Set restart needed status on server instance.
if (!checkAccess()) {
String msg = localStrings.getString( "admin.server.core.channel.unauthorized_access" );
throw new SecurityException( msg );
}
if (!keyMatches(key)) {
String msg = localStrings.getString( "admin.server.core.channel.invalid_key" );
throw new IllegalArgumentException( msg );
}
try {
// persists the state to a file
RRStateFactory.saveState(needRestart);
} catch (IOException ioe) {
String msg = localStrings.getString(
"admin.server.core.channel.unable_saving_state_file");
throw new RuntimeException(msg, ioe);
}
restartNeeded = needRestart;
|
void | setSharedInfo(byte[] seed)Set shared secret that clients must specify in every remote call. This
is set at startup.
myKey = seed;
|
public void | triggerServerExit(byte[] key)Client will exit after calling this method. Notify the lock held
in ASSocketService.
if (!checkAccess()) {
String msg = localStrings.getString( "admin.server.core.channel.unauthorized_access" );
throw new SecurityException( msg );
}
if (!keyMatches(key)) {
String msg = localStrings.getString( "admin.server.core.channel.invalid_key" );
throw new IllegalArgumentException( msg );
}
ASSocketService.triggerServerExit();
|