link start!

This commit is contained in:
cherubin
2026-03-17 13:31:18 -07:00
commit 08abe87cfb
5910 changed files with 386288 additions and 0 deletions
@@ -0,0 +1,299 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.sys.Nre
* javax.baja.security.BICredentials
* javax.baja.sys.Clock
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.FoxConnection;
import com.tridium.fox.session.FoxSession;
import com.tridium.fox.session.ServerException;
import com.tridium.fox.session.Tuner;
import com.tridium.sys.Nre;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Vector;
import javax.baja.security.BICredentials;
public class Fox {
public static final int BASIC_AUTHENTICATION = 0;
public static final int DIGEST_AUTHENTICATION = 1;
public static final int TRANSACTIONAL_AUTHENTICATION = 2;
public static String MULTICAST_ADDRESS = "224.0.1.84";
public static String IPV6_MULTICAST_ADDRESS = "FF02::137";
public static final int MULTICAST_PORT = 1911;
public static final String UNKNOWN_STRING = "unknown";
public static long sessionCloseTimeout = 10000L;
public static boolean ipv4Enabled = true;
public static boolean ipv6Enabled = false;
public static boolean multicastEnabled = true;
public static int requestTimeout = 60000;
public static int keepAliveInterval = 5000;
public static int soTimeout = 60000;
public static boolean tcpNoDelay = true;
public static boolean failsafeTimeouts = true;
public static int maxServerSessions = 100;
public static int maxQueueSize = 1000;
public static int circuitChunkSize = 4096;
public static int circuitMaxReceiveBuffer = 102400;
public static int multicastTimeToLive = 4;
public static boolean traceWriteFrame = false;
public static boolean traceReadFrame = false;
public static boolean traceSessionStates = false;
public static boolean traceMulticast = false;
public static boolean tunnelingEnabled = true;
public static boolean onlyTunnelKnownStations = false;
public static String appName = "unknown";
public static String appVersion = "unknown";
public static String vmName = System.getProperty("java.vm.name", "unknown");
public static String vmVersion = System.getProperty("java.vm.version", "unknown");
public static String osName = System.getProperty("os.name", "unknown");
public static String osVersion = System.getProperty("os.version", "unknown");
public static String hostAddress = "";
public static String hostName;
public static ExceptionTranslator exceptionTranslator;
public static Clock clock;
public static final ThreadGroup threadGroup;
private static Vector sessions;
private static int serverSessionCount;
public static volatile int deadlocks;
static /* synthetic */ Class class$com$tridium$fox$session$Fox;
private static boolean getBoolean(String string, boolean bl) {
String string2 = System.getProperty(string);
if (string2 == null) {
return bl;
}
return string2.equals("true");
}
private static int getInt(String string, int n) {
String string2 = System.getProperty(string);
if (string2 == null) {
return n;
}
return Integer.parseInt(string2);
}
private static Object getInstance(String string, Object object) {
try {
String string2 = System.getProperty(string);
if (string2 == null) {
return object;
}
return (class$com$tridium$fox$session$Fox == null ? (class$com$tridium$fox$session$Fox = Fox.class$("com.tridium.fox.session.Fox")) : class$com$tridium$fox$session$Fox).getClassLoader().loadClass(string2).newInstance();
}
catch (Throwable throwable) {
throwable.printStackTrace();
return object;
}
}
public static FoxSession open(FoxConnection foxConnection, Socket socket, String string, String string2) throws Exception {
return Fox.open(foxConnection, socket, string, string2, FoxSession.nullListeners);
}
public static FoxSession open(FoxConnection foxConnection, Socket socket, String string, String string2, FoxSession.IFoxSessionListener[] iFoxSessionListenerArray) throws Exception {
return Tuner.openClient(foxConnection, socket, string, string2, iFoxSessionListenerArray);
}
public static FoxSession open(FoxConnection foxConnection, Socket socket, BICredentials bICredentials, FoxSession.IFoxSessionListener[] iFoxSessionListenerArray) throws Exception {
return Tuner.openClient(foxConnection, socket, bICredentials, iFoxSessionListenerArray);
}
public static FoxSession getSession(int n) {
for (int i = 0; i < sessions.size(); ++i) {
FoxSession foxSession = (FoxSession)sessions.elementAt(i);
if (foxSession.getId() != n) continue;
return foxSession;
}
return null;
}
public static int getServerSessionCount() {
return serverSessionCount;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public static FoxSession[] getSessions() {
Vector vector = sessions;
synchronized (vector) {
Object[] objectArray = new FoxSession[sessions.size()];
sessions.copyInto(objectArray);
return objectArray;
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
static void register(FoxSession foxSession) {
Vector vector = sessions;
synchronized (vector) {
sessions.addElement(foxSession);
if (foxSession.isServer()) {
++serverSessionCount;
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
static void unregister(FoxSession foxSession) {
Vector vector = sessions;
synchronized (vector) {
for (int i = 0; i < sessions.size(); ++i) {
if (sessions.elementAt(i) != foxSession) continue;
if (foxSession.isServer()) {
--serverSessionCount;
}
sessions.removeElementAt(i);
break;
}
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
static {
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
catch (Exception exception) {
// empty catch block
}
hostName = "";
try {
hostName = InetAddress.getLocalHost().getHostName();
}
catch (Exception exception) {
// empty catch block
}
exceptionTranslator = new ExceptionTranslator();
try {
clock = new DefaultClock();
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
threadGroup = new ThreadGroup(Nre.findMainThreadGroup((ThreadGroup)Thread.currentThread().getThreadGroup()), "fox");
try {
soTimeout = Fox.getInt("niagara.fox.soTimeout", soTimeout);
tcpNoDelay = Fox.getBoolean("niagara.fox.tcpNoDelay", tcpNoDelay);
keepAliveInterval = Fox.getInt("niagara.fox.keepAliveInterval", keepAliveInterval);
requestTimeout = Fox.getInt("niagara.fox.requestTimeout", requestTimeout);
maxServerSessions = Fox.getInt("niagara.fox.maxServerSessions", maxServerSessions);
maxQueueSize = Fox.getInt("niagara.fox.maxQueueSize", maxQueueSize);
circuitChunkSize = Fox.getInt("niagara.fox.circuitChunkSize", circuitChunkSize);
circuitMaxReceiveBuffer = Fox.getInt("niagara.fox.circuitMaxReceiveBuffer", circuitMaxReceiveBuffer);
failsafeTimeouts = Fox.getBoolean("niagara.fox.failsafeTimeouts", failsafeTimeouts);
multicastTimeToLive = Fox.getInt("niagara.fox.multicastTimeToLive", multicastTimeToLive);
exceptionTranslator = (ExceptionTranslator)Fox.getInstance("niagara.fox.exceptionTranslator", exceptionTranslator);
traceWriteFrame = Fox.getBoolean("niagara.fox.traceWriteFrame", traceWriteFrame);
traceReadFrame = Fox.getBoolean("niagara.fox.traceReadFrame", traceReadFrame);
traceSessionStates = Fox.getBoolean("niagara.fox.traceSessionStates", traceSessionStates);
traceMulticast = Fox.getBoolean("niagara.fox.traceMulticast", traceMulticast);
tunnelingEnabled = Fox.getBoolean("niagara.fox.tunnelingEnabled", tunnelingEnabled);
onlyTunnelKnownStations = Fox.getBoolean("niagara.fox.onlyTunnelKnownStations", onlyTunnelKnownStations);
ipv6Enabled = Fox.getBoolean("niagara.ipv6Enabled", ipv6Enabled);
multicastEnabled = Fox.getBoolean("niagara.fox.multicastEnabled", multicastEnabled);
sessionCloseTimeout = Long.getLong("niagara.fox.sessionCloseTimeout", sessionCloseTimeout);
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
FailsafeTimeoutThread failsafeTimeoutThread = new FailsafeTimeoutThread();
failsafeTimeoutThread.setDaemon(true);
failsafeTimeoutThread.start();
sessions = new Vector();
deadlocks = 0;
}
static class FailsafeTimeoutThread
extends Thread {
FailsafeTimeoutThread() {
super(threadGroup, "Fox:FailsafeTimeout");
}
/*
* Unable to fully structure code
*/
public void run() {
while (true) {
try {
block3: while (true) {
Thread.sleep(10000L);
if (!Fox.failsafeTimeouts) continue;
var1_1 = Fox.getSessions();
var2_3 = 0;
while (true) {
if (var2_3 < var1_1.length) ** break;
continue block3;
var3_4 = var1_1[var2_3];
var4_5 = Fox.clock.ticks() - var3_4.getLastReadTicks();
var6_6 = Fox.clock.ticks() - var3_4.getLastWriteTicks();
if (var4_5 > (long)Fox.soTimeout) {
var8_7 = new IOException("Failsafe timeout on read " + var4_5 + " > " + Fox.soTimeout);
System.out.println("ERROR: " + var8_7.getMessage());
var3_4.close(var8_7);
} else if (var6_6 > (long)Fox.soTimeout) {
var8_7 = new IOException("Failsafe timeout on write " + var6_6 + " > " + Fox.soTimeout);
System.out.println("ERROR: " + var8_7.getMessage());
var3_4.close(var8_7);
}
++var2_3;
}
break;
}
}
catch (Exception var1_2) {
var1_2.printStackTrace();
continue;
}
break;
}
}
}
private static class DefaultClock
extends Clock {
private DefaultClock() {
}
public long ticks() {
return javax.baja.sys.Clock.ticks();
}
}
public static abstract class Clock {
public abstract long ticks();
}
public static class ExceptionTranslator {
public FoxMessage exceptionToMessage(Throwable throwable) {
FoxMessage foxMessage = new FoxMessage();
foxMessage.add("exception", throwable.toString());
return foxMessage;
}
public Exception messageToException(FoxMessage foxMessage) throws IOException {
return new ServerException(foxMessage.getString("exception"));
}
}
}
@@ -0,0 +1,12 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.FoxSession;
public interface FoxAsyncCallbacks {
public void asyncMessageSent(FoxSession var1, FoxMessage var2);
}
@@ -0,0 +1,38 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.FoxSession;
public class FoxAuthenticationException
extends Exception {
public String method = null;
public String fatal = null;
public FoxSession session;
public FoxMessage data = new FoxMessage();
public FoxAuthenticationException(String string, String string2, String string3, FoxSession foxSession) {
super(string);
this.method = string2;
this.fatal = string3;
this.session = foxSession;
}
public FoxAuthenticationException(String string, String string2, FoxSession foxSession) {
super(string);
this.method = string2;
this.session = foxSession;
}
public FoxAuthenticationException(String string, FoxSession foxSession) {
super(string);
this.session = foxSession;
}
public FoxAuthenticationException(FoxSession foxSession) {
this.session = foxSession;
}
}
@@ -0,0 +1,31 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
public class FoxAuthenticationUtil {
public static final String FOX_VERSION = "1.0.1";
public static final String FOX_MTD_BASIC_AUTH = "basic";
public static final String FOX_MTD_DIGEST_AUTH = "digest";
public static final String FOX_MTD_DIGEST_AUTH_LEGACY = "digest-md5";
public static final String FOX_MTD_KERBEROS_AUTH = "kerberos";
public static final String CMD_LOGIN = "login";
public static final String CMD_RESET = "accountReset";
public static final String CMD_AUTH_FIRST_MESSAGE = "authMessage1";
public static final String CMD_AUTH_SECOND_MESSAGE = "authMessage2";
public static final String KEY_AUTH_INPUT = "authInput";
public static final String KEY_AUTH_INPUT_HTTP = "authInputHttp";
public static final String KEY_AUTH_INPUT_SCRAM = "authInputScram";
public static final String KEY_AUTH_INPUT_RETRIEVE = "authInputRetrieve";
public static final String KEY_HANDSHAKE_ONE = "authHandshake1";
public static final String KEY_HANDSHAKE_TWO = "authHandshake2";
public static final String KEY_AUTH_INPUT_LOCAL = "authInputLocal";
public static final String KEY_AUTH_INPUT_KERB = "authInputKerb";
public static final String KEY_CREDENTIALS = "credentials";
public static final String KEY_NONCE = "nonce";
public static final String KEY_DIGEST = "digest";
public static final String KEY_PASSWORD = "password";
public static final String KEY_USERNAME = "username";
public static final String KEY_EMAIL = "email";
}
@@ -0,0 +1,9 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
public class FoxBusyException
extends Exception {
}
@@ -0,0 +1,353 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.message.MessageReader;
import com.tridium.fox.message.MessageWriter;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxAsyncCallbacks;
import com.tridium.fox.session.FoxRequest;
import com.tridium.fox.session.FoxSession;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
public class FoxCircuit {
private static final boolean TRACE = false;
public final int id;
public final String channel;
public final String command;
boolean open = true;
FoxSession session;
CircuitOutputStream out;
CircuitInputStream in;
Object outgoingLock = new Object();
byte[] outgoing = new byte[Fox.circuitChunkSize];
int nOutgoing;
Object incomingLock = new Object();
BufferEntry incomingHead = null;
BufferEntry incomingTail = null;
int nIncoming;
FoxCircuit(int n, FoxSession foxSession, String string, String string2) {
this.id = n;
this.session = foxSession;
this.channel = string;
this.command = string2;
this.out = new CircuitOutputStream();
this.in = new CircuitInputStream();
}
public boolean isOpen() {
return this.open;
}
public FoxSession session() {
return this.session;
}
public InputStream getInputStream() {
return this.in;
}
public OutputStream getOutputStream() {
return this.out;
}
public FoxMessage readMessage() throws Exception {
MessageReader messageReader = new MessageReader(this.in);
FoxMessage foxMessage = new FoxMessage();
foxMessage.readValue(messageReader);
return foxMessage;
}
public void writeMessage(FoxMessage foxMessage) throws Exception {
MessageWriter messageWriter = new MessageWriter(this.out);
foxMessage.writeValue(messageWriter);
messageWriter.flush();
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public FoxMessage write(byte[] byArray, int n, int n2, FoxAsyncCallbacks foxAsyncCallbacks) throws Exception {
if (foxAsyncCallbacks == null) {
this.out.write(byArray, n, n2);
return null;
}
Object object = this.outgoingLock;
synchronized (object) {
int n3;
this.flush();
byte[] byArray2 = new byte[n2];
System.arraycopy(byArray, n, byArray2, 0, n2);
FoxRequest foxRequest = null;
int n4 = n2;
for (int i = 0; i != n4; i += n3) {
int n5 = n4 - i;
foxRequest = this.sendStream(byArray2, i, n3, (n3 = Math.min(Fox.circuitChunkSize, n5)) == n5 ? foxAsyncCallbacks : null);
}
return foxRequest;
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void close() {
if (!this.open) {
return;
}
try {
this.flush();
}
catch (IOException iOException) {
// empty catch block
}
this.session.closeCircuit(this);
this.open = false;
Object object = this.incomingLock;
synchronized (object) {
this.incomingLock.notifyAll();
}
object = this.outgoingLock;
synchronized (object) {
this.outgoingLock.notifyAll();
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void writeOut(byte[] byArray, int n, int n2) throws IOException {
this.assertOpen();
Object object = this.outgoingLock;
synchronized (object) {
while (this.open && n2 > 0) {
int n3 = Math.min(this.outgoing.length - this.nOutgoing, n2);
System.arraycopy(byArray, n, this.outgoing, this.nOutgoing, n3);
this.nOutgoing += n3;
n += n3;
n2 -= n3;
if (this.nOutgoing < this.outgoing.length) continue;
this.flush();
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void flush() throws IOException {
Object object = this.outgoingLock;
synchronized (object) {
if (this.open && this.nOutgoing > 0) {
try {
this.sendStream(this.outgoing, this.nOutgoing);
this.outgoing = new byte[Fox.circuitChunkSize];
this.nOutgoing = 0;
}
catch (IOException iOException) {
throw iOException;
}
catch (Exception exception) {
exception.printStackTrace();
throw new IOException(exception.toString());
}
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void pushIn(byte[] byArray) throws InterruptedException {
if (byArray.length == 0) {
return;
}
Object object = this.incomingLock;
synchronized (object) {
while (this.open && this.incomingHead != null && this.nIncoming + byArray.length > Fox.circuitMaxReceiveBuffer) {
this.incomingLock.wait();
}
BufferEntry bufferEntry = new BufferEntry(byArray);
if (this.incomingHead == null) {
this.incomingHead = bufferEntry;
}
if (this.incomingTail != null) {
this.incomingTail.next = bufferEntry;
}
this.incomingTail = bufferEntry;
this.nIncoming += byArray.length;
this.incomingLock.notifyAll();
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
int pullIn(byte[] byArray, int n, int n2) throws IOException {
Object object = this.incomingLock;
synchronized (object) {
BufferEntry bufferEntry;
while (this.nIncoming <= 0) {
if (!this.open) {
return -1;
}
try {
this.incomingLock.wait();
}
catch (InterruptedException interruptedException) {
throw new InterruptedIOException();
}
}
int n3 = 0;
while (n2 > 0 && (bufferEntry = this.incomingHead) != null) {
int n4 = Math.min(bufferEntry.avail, n2);
System.arraycopy(bufferEntry.data, bufferEntry.data.length - bufferEntry.avail, byArray, n, n4);
n3 += n4;
n += n4;
n2 -= n4;
bufferEntry.avail -= n4;
if (bufferEntry.avail > 0) continue;
this.incomingHead = bufferEntry.next;
if (this.incomingTail == bufferEntry) {
this.incomingTail = null;
}
bufferEntry.next = null;
}
this.nIncoming -= n3;
this.incomingLock.notifyAll();
return n3;
}
}
private void assertOpen() throws IOException {
if (!this.open) {
throw new IOException("circuit closed");
}
}
void sendOpen() throws Exception {
FoxRequest foxRequest = new FoxRequest("circuit", "open");
foxRequest.add("id", this.id);
foxRequest.add("channel", this.channel);
foxRequest.add("command", this.command);
this.session.sendAsync(foxRequest);
}
void sendStream(byte[] byArray, int n) throws Exception {
FoxRequest foxRequest = new FoxRequest("circuit", "stream");
foxRequest.add("id", this.id);
foxRequest.add("data", byArray, n);
this.session.sendAsync(foxRequest);
}
FoxRequest sendStream(byte[] byArray, int n, int n2, FoxAsyncCallbacks foxAsyncCallbacks) throws Exception {
FoxRequest foxRequest = new FoxRequest("circuit", "stream");
foxRequest.add("id", this.id);
foxRequest.add("data", byArray, n, n2);
this.session.sendAsync(foxRequest, foxAsyncCallbacks);
return foxRequest;
}
void sendClose() throws Exception {
if (this.open && !this.session.isClosed()) {
FoxRequest foxRequest = new FoxRequest("circuit", "close");
foxRequest.add("id", this.id);
this.session.sendAsync(foxRequest);
}
}
public String toString() {
return "Circuit [" + this.session.getId() + "] " + this.channel + "." + this.command + " out=" + this.nOutgoing + " in=" + this.nIncoming + " open=" + this.open;
}
public void dumpIncomingList() {
System.out.println("Incoming List:");
System.out.println(" head=" + this.incomingHead);
System.out.println(" tail=" + this.incomingTail);
System.out.println(" chain=");
BufferEntry bufferEntry = this.incomingHead;
while (bufferEntry != null) {
System.out.println(" " + bufferEntry);
bufferEntry = bufferEntry.next;
}
}
private static void trace(String string) {
System.out.println(string);
}
static class BufferEntry {
byte[] data;
int avail;
BufferEntry next;
BufferEntry(byte[] byArray) {
this.data = byArray;
this.avail = byArray.length;
}
public String toString() {
return Integer.toString(System.identityHashCode(this), 36) + " avail=" + this.avail + " length=" + this.data.length;
}
}
class CircuitInputStream
extends InputStream {
byte[] temp = new byte[1];
CircuitInputStream() {
}
public int read() throws IOException {
return this.read(this.temp, 0, 1) <= 0 ? -1 : this.temp[0] & 0xFF;
}
public int read(byte[] byArray) throws IOException {
return this.read(byArray, 0, byArray.length);
}
public int read(byte[] byArray, int n, int n2) throws IOException {
return FoxCircuit.this.pullIn(byArray, n, n2);
}
public void close() throws IOException {
FoxCircuit.this.close();
}
}
class CircuitOutputStream
extends OutputStream {
byte[] temp = new byte[1];
CircuitOutputStream() {
}
public void write(int n) throws IOException {
this.temp[0] = (byte)n;
this.write(this.temp, 0, 1);
}
public void write(byte[] byArray) throws IOException {
this.write(byArray, 0, byArray.length);
}
public void write(byte[] byArray, int n, int n2) throws IOException {
FoxCircuit.this.writeOut(byArray, n, n2);
}
public void flush() throws IOException {
FoxCircuit.this.flush();
}
public void close() {
FoxCircuit.this.close();
}
}
}
@@ -0,0 +1,36 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.FoxCircuit;
import com.tridium.fox.session.FoxRequest;
import com.tridium.fox.session.FoxResponse;
import com.tridium.fox.session.FoxSession;
import java.net.Socket;
public interface FoxConnection {
public void initHello(FoxMessage var1) throws Exception;
public void sessionOpened(FoxSession var1);
public FoxResponse process(FoxRequest var1) throws Throwable;
public void circuitOpened(FoxCircuit var1) throws Throwable;
public void sessionClosed(FoxSession var1, Throwable var2);
public void error(String var1, Throwable var2);
public Thread makeThread(ThreadGroup var1, Runnable var2, String var3);
public boolean isTunnelClientConnection();
public boolean isTunnelServerConnection();
public String[] getTunnelAuthorities();
public Socket createTunnelSocket(String var1, boolean var2) throws Exception;
}
@@ -0,0 +1,96 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.message.MessageReader;
import com.tridium.fox.message.MessageWriter;
import com.tridium.fox.session.FoxAsyncCallbacks;
import com.tridium.fox.session.FoxRequest;
import com.tridium.fox.session.FoxResponse;
import java.io.IOException;
import java.io.OutputStream;
public class FoxFrame {
public static final int SYNC = 115;
public static final int ASYNC = 97;
public static final int REPLY = 114;
public static final int ERROR = 101;
public static final int NULL = 110;
public static final int KEEPALIVE = 107;
public final int frameType;
public final int sequenceNumber;
public final int replyNumber;
public final String channel;
public final String command;
public final FoxMessage message;
FoxAsyncCallbacks callbacks;
FoxFrame next;
public FoxFrame(int n, int n2, int n3, String string, String string2, FoxMessage foxMessage) {
this.frameType = n;
this.sequenceNumber = n2;
this.replyNumber = n3;
this.channel = string;
this.command = string2;
this.message = foxMessage;
}
public final void write(MessageWriter messageWriter) throws IOException {
this.writeHeader(messageWriter);
this.message.writeValue(messageWriter);
this.writeFooter(messageWriter);
}
private final void writeHeader(MessageWriter messageWriter) throws IOException {
messageWriter.write(102).write(111).write(120).write(32).write(this.frameType).write(32).writeInt(this.sequenceNumber).write(32).writeInt(this.replyNumber).write(32).writeName(this.channel).write(32).writeName(this.command).write(10);
}
private final void writeFooter(MessageWriter messageWriter) throws IOException {
messageWriter.write(59).write(59).write(10);
}
public static FoxFrame read(MessageReader messageReader) throws IOException {
messageReader.consume("fox ");
int n = messageReader.read();
messageReader.consume(32);
int n2 = messageReader.readInt();
messageReader.consume(32);
int n3 = messageReader.readInt();
messageReader.consume(32);
String string = messageReader.readName().intern();
messageReader.consume(32);
String string2 = messageReader.readName().intern();
messageReader.consume(10);
FoxMessage foxMessage = n == 97 || n == 115 ? new FoxRequest(string, string2) : (n == 114 ? new FoxResponse() : new FoxMessage());
foxMessage.readValue(messageReader);
messageReader.consume(59);
messageReader.consume(59);
messageReader.consume(10);
return new FoxFrame(n, n2, n3, string, string2, foxMessage);
}
public String toString() {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(this.frameType).append(' ').append(this.sequenceNumber).append(' ').append(this.replyNumber).append(' ').append(this.channel).append(' ').append(this.command);
return stringBuffer.toString();
}
public void dump(OutputStream outputStream) {
try {
MessageWriter messageWriter = new MessageWriter(outputStream, true);
this.write(messageWriter);
messageWriter.flush();
}
catch (IOException iOException) {
iOException.printStackTrace();
throw new RuntimeException(iOException.toString());
}
}
public void dump() {
this.dump(System.out);
}
}
@@ -0,0 +1,19 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
public class FoxRequest
extends FoxMessage {
public final String channel;
public final String command;
public FoxRequest(String string, String string2) {
super(string + "." + string2);
this.channel = string;
this.command = string2;
}
}
@@ -0,0 +1,17 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.FoxRequest;
public class FoxResponse
extends FoxMessage {
public FoxResponse(FoxRequest foxRequest) {
}
public FoxResponse() {
}
}
@@ -0,0 +1,252 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.log.Log
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxConnection;
import com.tridium.fox.session.FoxSession;
import com.tridium.fox.session.MulticastServer;
import com.tridium.fox.session.Tuner;
import java.io.IOException;
import java.net.BindException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.baja.log.Log;
public abstract class FoxServer {
private static final String FOX = "fox";
private static final String FOXS = "foxs";
private static Log log = Log.getLog((String)"fox");
protected int foxPort = -1;
protected int foxsPort = -1;
private boolean alive = true;
private Thread foxThread;
private ServerSocket foxServerSocket;
private boolean foxRunning = false;
private Thread foxsThread;
private ServerSocket foxsServerSocket;
private boolean foxsRunning = false;
private MulticastServer multicastServer;
public FoxServer() {
this.foxPort = 1911;
this.foxsPort = 4911;
}
public FoxServer(int n, int n2) {
this.foxPort = n;
this.foxsPort = n2;
}
public MulticastServer getMulticastServer() {
return this.multicastServer;
}
public void run() throws Exception {
if (this.foxThread != null || this.foxsThread != null) {
throw new IllegalStateException("Server already running");
}
this.alive = true;
if (this.foxPort >= 0) {
this.foxThread = new Thread(new MainLoop(FOX), "Fox:Server");
this.foxThread.start();
}
if (this.foxsPort >= 0) {
this.foxsThread = new Thread(new MainLoop(FOXS), "Foxs:Server");
this.foxsThread.start();
}
try {
if (Fox.multicastEnabled) {
this.multicastServer = new MulticastServer(this);
this.multicastServer.start();
} else {
log.message("Multicast disabled (no station discovery supported)");
}
}
catch (Exception exception) {
System.out.println("ERROR: Cannot open Fox multicast socket: " + exception);
}
}
private void runFox() {
this.foxRunning = true;
this.run(FOX);
this.foxRunning = false;
}
private void runFoxs() {
this.foxsRunning = true;
this.run(FOXS);
this.foxsRunning = false;
}
public boolean isServing() {
return this.foxServerSocket != null || this.foxsServerSocket != null;
}
public boolean isRunning() {
return this.foxRunning || this.foxsRunning;
}
public boolean isFoxRunning() {
return this.foxRunning;
}
public boolean isFoxsRunning() {
return this.foxsRunning;
}
public ServerSocket getFoxServerSocket() throws IOException {
return new ServerSocket(this.foxPort);
}
public ServerSocket getFoxsServerSocket() throws IOException {
throw new UnsupportedOperationException("FOXS not supported.");
}
private void run(String string) {
ServerSocket serverSocket = null;
int n = 1911;
block13: while (this.alive) {
try {
if (string.equalsIgnoreCase(FOX)) {
n = this.foxPort;
serverSocket = this.foxServerSocket = this.getFoxServerSocket();
} else {
n = this.foxsPort;
serverSocket = this.foxsServerSocket = this.getFoxsServerSocket();
}
}
catch (BindException bindException) {
log.error(string.toUpperCase() + " server failed to bind to port [" + n + "] " + bindException);
serverSocket = null;
try {
Thread.sleep(5000L);
}
catch (InterruptedException interruptedException) {}
}
catch (IllegalArgumentException illegalArgumentException) {
if (log.isTraceOn()) {
log.error(string.toUpperCase() + " server failed to start on port [" + n + "]\n ", (Throwable)illegalArgumentException);
} else {
log.error(string.toUpperCase() + " server failed to start on port [" + n + "]\n " + illegalArgumentException.getLocalizedMessage());
}
return;
}
catch (IOException iOException) {
if (log.isTraceOn()) {
log.error(string.toUpperCase() + " server failed to start on port. [" + n + "]\n ", (Throwable)iOException);
} else {
log.error(string.toUpperCase() + " server failed to start on port. [" + n + "]\n " + iOException.getLocalizedMessage());
}
return;
}
if (serverSocket == null) continue;
try {
log.message(string.toUpperCase() + " server started on port [" + n + "]");
Socket socket = null;
while (this.alive) {
try {
socket = serverSocket.accept();
if (!this.alive) continue block13;
Tuner.openServer(this, socket, string);
}
catch (IOException iOException) {
if (this.alive && (iOException.getClass().getName().equals("javax.net.ssl.SSLHandshakeException") || iOException.getClass().getName().equals("iaik.security.ssl.SSLException"))) {
if (log.isTraceOn()) {
log.warning("Server accept " + iOException.getClass().getName() + ": " + iOException.getLocalizedMessage(), (Throwable)iOException);
continue;
}
log.warning("Server accept " + iOException.getClass().getName() + ": " + iOException.getLocalizedMessage());
continue;
}
if (!this.alive) continue;
log.message("Server accept exception: " + iOException.getLocalizedMessage());
}
catch (Throwable throwable) {}
}
}
catch (Throwable throwable) {
if (!this.alive) continue;
log.error(string + ": Error in main loop.", throwable);
}
}
log.message(string.toUpperCase() + " server stopped on port [" + n + "]");
if (serverSocket != null) {
try {
serverSocket.close();
}
catch (Exception exception) {
// empty catch block
}
}
}
public void stop() {
if (this.foxThread != null) {
this.alive = false;
this.foxThread.interrupt();
this.foxThread = null;
if (this.foxServerSocket != null) {
try {
this.foxServerSocket.close();
}
catch (Exception exception) {
// empty catch block
}
this.foxServerSocket = null;
}
}
if (this.foxsThread != null) {
this.alive = false;
this.foxsThread.interrupt();
this.foxsThread = null;
if (this.foxsServerSocket != null) {
try {
this.foxsServerSocket.close();
}
catch (Exception exception) {
// empty catch block
}
this.foxsServerSocket = null;
}
}
if (this.multicastServer != null) {
this.multicastServer.kill();
this.multicastServer = null;
}
}
public abstract FoxConnection makeConnection(FoxSession var1, FoxMessage var2) throws Exception;
public abstract FoxMessage getAnnouncement();
public abstract int getAuthenticationPolicy();
public abstract boolean authenticateBasic(FoxSession var1, String var2, String var3) throws Exception;
public abstract boolean authenticateDigest(FoxSession var1, String var2, byte[] var3, byte[] var4) throws Exception;
private class MainLoop
implements Runnable {
private String scheme;
public MainLoop(String string) {
this.scheme = string;
}
public void run() {
if (this.scheme.equals(FoxServer.FOX)) {
FoxServer.this.runFox();
} else {
FoxServer.this.runFoxs();
}
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
public class FoxsRedirectException
extends Exception {
private int port = 4911;
public FoxsRedirectException(int n) {
this.port = n;
}
public int getPort() {
return this.port;
}
}
@@ -0,0 +1,99 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxFrame;
public final class FrameQueue {
private FoxFrame head;
private FoxFrame tail;
private int size;
private int peak;
private String blocked;
private boolean isAlive = true;
public final int size() {
return this.size;
}
public final int peak() {
return this.peak;
}
public final int max() {
return Fox.maxQueueSize;
}
public final synchronized void kill() {
this.isAlive = false;
this.notifyAll();
}
public synchronized FoxFrame dequeue(int n) throws InterruptedException {
FoxFrame foxFrame;
while (this.isAlive && this.size == 0) {
if (n == -1) {
this.wait();
continue;
}
this.wait(n);
break;
}
if ((foxFrame = this.head) == null) {
return null;
}
this.head = foxFrame.next;
if (this.head == null) {
this.tail = null;
}
foxFrame.next = null;
--this.size;
this.notifyAll();
return foxFrame;
}
public synchronized void enqueue(FoxFrame foxFrame) throws InterruptedException {
while (this.isAlive && this.size >= this.max()) {
try {
this.blocked = Thread.currentThread().getName();
}
catch (Exception exception) {
// empty catch block
}
this.wait();
}
this.blocked = null;
if (foxFrame.next != null) {
throw new IllegalStateException();
}
if (this.tail == null) {
this.head = this.tail = foxFrame;
} else {
this.tail.next = foxFrame;
this.tail = foxFrame;
}
++this.size;
if (this.size > this.peak) {
this.peak = this.size;
}
this.notifyAll();
}
public synchronized void clear() {
this.size = 0;
this.head = null;
this.tail = null;
this.notifyAll();
}
public String toString() {
String string = "FrameQueue size=" + this.size + " peak=" + this.peak + " max=" + this.max();
if (this.blocked != null) {
string = string + " blocked=" + this.blocked;
}
return string;
}
}
@@ -0,0 +1,128 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
public class IntMap {
private Entry[] table = new Entry[31];
private int count;
private int threshold = (int)(31.0f * this.loadFactor);
private float loadFactor = 75.0f;
public int size() {
return this.count;
}
public Object get(int n) {
Entry[] entryArray = this.table;
int n2 = (n & Integer.MAX_VALUE) % entryArray.length;
Entry entry = entryArray[n2];
while (entry != null) {
if (entry.hash == n) {
return entry.value;
}
entry = entry.next;
}
return null;
}
private void rehash() {
int n = this.table.length;
Entry[] entryArray = this.table;
int n2 = n * 2 + 1;
Entry[] entryArray2 = new Entry[n2];
this.threshold = (int)((float)n2 * this.loadFactor);
this.table = entryArray2;
int n3 = n;
while (n3-- > 0) {
Entry entry = entryArray[n3];
while (entry != null) {
Entry entry2 = entry;
entry = entry.next;
int n4 = (entry2.hash & Integer.MAX_VALUE) % n2;
entry2.next = entryArray2[n4];
entryArray2[n4] = entry2;
}
}
}
public Object put(int n, Object object) {
if (object == null) {
throw new NullPointerException();
}
Entry[] entryArray = this.table;
int n2 = (n & Integer.MAX_VALUE) % entryArray.length;
Entry entry = entryArray[n2];
while (entry != null) {
if (entry.hash == n) {
Object object2 = entry.value;
entry.value = object;
return object2;
}
entry = entry.next;
}
if (this.count >= this.threshold) {
this.rehash();
return this.put(n, object);
}
entry = new Entry();
entry.hash = n;
entry.value = object;
entry.next = entryArray[n2];
entryArray[n2] = entry;
++this.count;
return null;
}
public Object remove(int n) {
Entry[] entryArray = this.table;
int n2 = (n & Integer.MAX_VALUE) % entryArray.length;
Entry entry = entryArray[n2];
Entry entry2 = null;
while (entry != null) {
if (entry.hash == n) {
if (entry2 != null) {
entry2.next = entry.next;
} else {
entryArray[n2] = entry.next;
}
--this.count;
return entry.value;
}
entry2 = entry;
entry = entry.next;
}
return null;
}
public void clear() {
Entry[] entryArray = this.table;
int n = entryArray.length;
while (--n >= 0) {
entryArray[n] = null;
}
this.count = 0;
}
public Object[] toArray(Object[] objectArray) {
int n = 0;
for (int i = 0; i < this.table.length; ++i) {
Entry entry = this.table[i];
while (entry != null && n < this.count) {
objectArray[n++] = entry.value;
entry = entry.next;
}
}
return objectArray;
}
static class Entry {
int hash;
Object value;
Entry next;
Entry() {
}
}
}
@@ -0,0 +1,12 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
public class InvalidChannelException
extends RuntimeException {
public InvalidChannelException(String string) {
super(string);
}
}
@@ -0,0 +1,12 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
public class InvalidCommandException
extends RuntimeException {
public InvalidCommandException(String string) {
super(string);
}
}
@@ -0,0 +1,145 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.sys.LocalizableRuntimeException
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxFrame;
import com.tridium.fox.session.FoxServer;
import com.tridium.fox.session.MulticastUtil;
import java.io.IOException;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.util.Vector;
import javax.baja.sys.LocalizableRuntimeException;
public class MulticastServer
extends Thread {
private FoxServer server;
private boolean isAlive = true;
private MulticastSocket socket;
private Object rollcallLock = new Object();
private Vector announcements;
public MulticastServer(FoxServer foxServer) throws IOException {
super(Fox.threadGroup, "Fox:MulticastServer");
if (!Fox.multicastEnabled) {
throw new LocalizableRuntimeException("fox", "error.multicastDisabled");
}
this.server = foxServer;
this.socket = new MulticastSocket(1911);
Throwable throwable = null;
Throwable throwable2 = null;
boolean bl = false;
boolean bl2 = false;
if (Fox.ipv4Enabled) {
try {
this.socket.joinGroup(InetAddress.getByName(Fox.MULTICAST_ADDRESS));
bl = true;
}
catch (IOException iOException) {
System.err.println("WARNING: Could not join IPv4 multicast group: " + iOException);
throwable = iOException;
bl = false;
}
}
if (Fox.ipv6Enabled) {
try {
this.socket.joinGroup(InetAddress.getByName(Fox.IPV6_MULTICAST_ADDRESS));
bl2 = true;
}
catch (IOException iOException) {
System.err.println("WARNING: Could not join IPv6 multicast group: " + iOException);
throwable2 = iOException;
bl2 = false;
}
}
if (!bl2 && !bl) {
String string = Fox.ipv4Enabled && throwable != null ? throwable.getMessage() : null;
String string2 = Fox.ipv6Enabled && throwable2 != null ? throwable2.getMessage() : null;
String string3 = "OK";
if (string != null) {
string3 = string;
}
if (string2 != null) {
string3 = string == null ? string2 : string3 + ", " + string2;
}
throw new IOException(string3);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public FoxMessage[] rollcall(FoxMessage foxMessage, long l, RollcallCallback rollcallCallback) throws Exception {
Object object = this.rollcallLock;
synchronized (object) {
Vector vector = this.announcements = new Vector();
MulticastUtil.send("rollcall", foxMessage, 3);
long l2 = l / 100L;
for (int i = 0; i < 100; ++i) {
Thread.sleep(l2);
if (rollcallCallback == null) continue;
rollcallCallback.completed(i);
}
this.announcements = null;
Object[] objectArray = new FoxMessage[vector.size()];
vector.copyInto(objectArray);
return objectArray;
}
}
public void sendAnnouncement() throws Exception {
FoxMessage foxMessage;
if (this.server != null && (foxMessage = this.server.getAnnouncement()) != null) {
MulticastUtil.send("announcement", foxMessage, 3);
}
}
private void receiveAnnouncement(FoxMessage foxMessage) {
Vector vector = this.announcements;
if (vector != null) {
vector.addElement(foxMessage);
}
}
public void kill() {
this.isAlive = false;
this.interrupt();
if (this.socket != null) {
this.socket.close();
this.socket = null;
}
}
public void run() {
while (this.isAlive) {
try {
FoxFrame foxFrame = MulticastUtil.receive(this.socket);
if (Fox.traceMulticast) {
System.out.println("-- Fox.multicast.recevied");
foxFrame.dump();
}
if (foxFrame.command == "rollcall") {
this.sendAnnouncement();
continue;
}
if (foxFrame.command != "announcement") continue;
this.receiveAnnouncement(foxFrame.message);
}
catch (Throwable throwable) {
if (!this.isAlive) continue;
throwable.printStackTrace();
}
}
}
public static interface RollcallCallback {
public void completed(int var1);
}
}
@@ -0,0 +1,113 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxBoolean;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.message.FoxTuple;
import com.tridium.fox.message.MessageReader;
import com.tridium.fox.message.MessageWriter;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxFrame;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.MulticastSocket;
public class MulticastUtil {
public static FoxFrame makeFrame(String string, FoxMessage foxMessage) {
return new FoxFrame(109, -1, -1, "fox", string, foxMessage);
}
public static void send(String string, FoxMessage foxMessage, int n) throws Exception {
MulticastUtil.send(MulticastUtil.makeFrame(string, foxMessage), n);
}
public static void send(FoxFrame foxFrame, int n) throws Exception {
int n2;
if (!Fox.ipv4Enabled && !Fox.ipv6Enabled || !Fox.multicastEnabled) {
return;
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(256);
MessageWriter messageWriter = new MessageWriter(byteArrayOutputStream);
foxFrame.write(messageWriter);
byte[] byArray = byteArrayOutputStream.toByteArray();
DatagramPacket datagramPacket = Fox.ipv4Enabled ? new DatagramPacket(byArray, byArray.length, InetAddress.getByName(Fox.MULTICAST_ADDRESS), 1911) : null;
DatagramPacket datagramPacket2 = Fox.ipv6Enabled ? new DatagramPacket(byArray, byArray.length, InetAddress.getByName(Fox.IPV6_MULTICAST_ADDRESS), 1911) : null;
MulticastSocket multicastSocket = new MulticastSocket();
multicastSocket.setTimeToLive(Fox.multicastTimeToLive);
IOException iOException = null;
IOException iOException2 = null;
boolean bl = false;
boolean bl2 = false;
try {
if (datagramPacket != null) {
for (n2 = 0; n2 < n; ++n2) {
Thread.sleep(100L);
multicastSocket.send(datagramPacket);
}
bl = true;
}
}
catch (IOException iOException3) {
System.err.println("WARNING: Could not send IPv4 multicast packet: " + iOException3);
bl = false;
iOException = iOException3;
}
try {
if (datagramPacket2 != null) {
for (n2 = 0; n2 < n; ++n2) {
Thread.sleep(100L);
multicastSocket.send(datagramPacket2);
}
bl2 = true;
}
}
catch (IOException iOException4) {
System.err.println("WARNING: Could not send IPv6 multicast packet: " + iOException4);
bl2 = false;
iOException2 = iOException4;
}
if (!bl2 && !bl) {
String string = Fox.ipv4Enabled && iOException != null ? iOException.getMessage() : null;
String string2 = Fox.ipv6Enabled && iOException2 != null ? iOException2.getMessage() : null;
String string3 = "OK";
if (string != null) {
string3 = string;
}
if (string2 != null) {
string3 = string == null ? string2 : string3 + ", " + string2;
}
throw new IOException("ERROR: Could not send Fox multicast packet(s): (" + string3 + ")");
}
}
public static FoxFrame receive(DatagramSocket datagramSocket) throws Exception {
byte[] byArray = new byte[1024];
DatagramPacket datagramPacket = new DatagramPacket(byArray, byArray.length);
datagramSocket.receive(datagramPacket);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(datagramPacket.getData(), 0, datagramPacket.getLength());
MessageReader messageReader = new MessageReader(byteArrayInputStream);
FoxFrame foxFrame = FoxFrame.read(messageReader);
if (datagramPacket.getAddress() instanceof Inet6Address) {
foxFrame.message.add("IPv6FoxFrameMulticastReceived", true);
}
return foxFrame;
}
public static boolean isIpv6Message(FoxMessage foxMessage) {
FoxTuple[] foxTupleArray = foxMessage.list("IPv6FoxFrameMulticastReceived");
boolean bl = false;
if (foxTupleArray != null && foxTupleArray.length != 0) {
FoxBoolean foxBoolean = (FoxBoolean)foxTupleArray[foxTupleArray.length - 1];
bl = foxBoolean.value;
}
return bl;
}
}
@@ -0,0 +1,12 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
public class ServerException
extends RuntimeException {
public ServerException(String string) {
super(string);
}
}
@@ -0,0 +1,113 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxFrame;
import java.io.InterruptedIOException;
public class SessionBedroom {
private Bed[] bedTable = new Bed[4];
synchronized Bed getBed(Thread thread) {
Bed[] bedArray;
int n;
for (n = 0; n < this.bedTable.length && this.bedTable[n] != null; ++n) {
}
if (n == this.bedTable.length) {
bedArray = new Bed[this.bedTable.length * 2];
System.arraycopy(this.bedTable, 0, bedArray, 0, this.bedTable.length);
this.bedTable = bedArray;
}
bedArray = new Bed();
bedArray.replyNumber = n;
bedArray.thread = thread;
this.bedTable[n] = bedArray;
return bedArray;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void sleep(Bed bed) throws InterruptedIOException {
try {
Bed bed2 = bed;
synchronized (bed2) {
long l = Fox.clock.ticks();
while (!bed.haveReply && Fox.clock.ticks() - l < (long)Fox.requestTimeout) {
long l2 = (long)Fox.requestTimeout - (Fox.clock.ticks() - l);
if (l2 < 50L) {
l2 = 50L;
}
bed.wait(l2);
}
}
}
catch (InterruptedException interruptedException) {
throw new InterruptedIOException();
}
finally {
SessionBedroom sessionBedroom = this;
synchronized (sessionBedroom) {
bed.thread = null;
this.bedTable[bed.replyNumber] = null;
}
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void wake(FoxFrame foxFrame) throws Exception {
Bed bed = null;
Object object = this;
synchronized (object) {
bed = this.bedTable[foxFrame.replyNumber];
}
if (bed == null) {
return;
}
object = bed;
synchronized (object) {
bed.haveReply = true;
bed.reply = foxFrame;
bed.notify();
return;
}
}
synchronized void wakeAll() {
for (int i = 0; i < this.bedTable.length; ++i) {
Bed bed = this.bedTable[i];
if (bed == null) continue;
bed.thread.interrupt();
bed.thread = null;
}
}
public synchronized String toString() {
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < this.bedTable.length; ++i) {
Bed bed = this.bedTable[i];
if (bed == null) continue;
stringBuffer.append(bed.replyNumber).append(": ").append(bed.thread).append('\n');
}
if (stringBuffer.length() == 0) {
return "empty";
}
stringBuffer.setLength(stringBuffer.length() - 1);
return stringBuffer.toString();
}
static class Bed {
int replyNumber;
FoxFrame reply;
boolean haveReply = false;
Thread thread;
Bed() {
}
}
}
@@ -0,0 +1,262 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxCircuit;
import com.tridium.fox.session.FoxFrame;
import com.tridium.fox.session.FoxSession;
import com.tridium.fox.session.IntMap;
import com.tridium.fox.session.InvalidCommandException;
public class SessionCircuits {
static final int THREAD_POOL_SIZE = 2;
private FoxSession session;
private IntMap circuits = new IntMap();
private int nextId;
private ServiceThread[] threadPool = new ServiceThread[2];
private int nonPoolServiceCount;
SessionCircuits(FoxSession foxSession) {
this.session = foxSession;
this.nextId = foxSession.isServer() ? 0 : 1;
}
synchronized FoxCircuit alloc(String string, String string2) {
int n = this.nextId;
this.nextId += 2;
FoxCircuit foxCircuit = new FoxCircuit(n, this.session, string, string2);
this.circuits.put(n, foxCircuit);
return foxCircuit;
}
synchronized void free(FoxCircuit foxCircuit) {
this.circuits.remove(foxCircuit.id);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void kill() {
FoxCircuit[] foxCircuitArray = (FoxCircuit[])this.circuits.toArray(new FoxCircuit[this.circuits.size()]);
for (int i = 0; i < foxCircuitArray.length; ++i) {
try {
foxCircuitArray[i].close();
continue;
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
}
ServiceThread[] serviceThreadArray = this.threadPool;
synchronized (this.threadPool) {
for (int i = 0; i < this.threadPool.length; ++i) {
if (this.threadPool[i] == null) continue;
try {
this.threadPool[i].kill();
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
this.threadPool[i] = null;
}
// ** MonitorExit[var2_3] (shouldn't be in output)
return;
}
}
void circuitRequestReceived(FoxFrame foxFrame) throws Exception {
String string = foxFrame.command;
if (string == "open") {
this.processOpen(foxFrame.message);
return;
}
if (string == "stream") {
this.processStream(foxFrame.message);
return;
}
if (string == "close") {
this.processClose(foxFrame.message);
return;
}
throw new InvalidCommandException(string);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void processOpen(FoxMessage foxMessage) throws Exception {
int n = foxMessage.getInt("id");
String string = foxMessage.getString("channel").intern();
String string2 = foxMessage.getString("command").intern();
FoxCircuit foxCircuit = new FoxCircuit(n, this.session, string, string2);
SessionCircuits sessionCircuits = this;
synchronized (sessionCircuits) {
if (this.circuits.get(n) != null) {
throw new IllegalStateException("Circuit already allocated: " + n);
}
this.circuits.put(n, foxCircuit);
}
this.runCircuit(foxCircuit);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void processStream(FoxMessage foxMessage) throws Exception {
int n = foxMessage.getInt("id");
byte[] byArray = foxMessage.getBlob("data");
FoxCircuit foxCircuit = null;
SessionCircuits sessionCircuits = this;
synchronized (sessionCircuits) {
foxCircuit = (FoxCircuit)this.circuits.get(n);
}
if (foxCircuit != null) {
foxCircuit.pushIn(byArray);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void processClose(FoxMessage foxMessage) throws Exception {
int n = foxMessage.getInt("id");
FoxCircuit foxCircuit = null;
SessionCircuits sessionCircuits = this;
synchronized (sessionCircuits) {
foxCircuit = (FoxCircuit)this.circuits.get(n);
}
if (foxCircuit != null) {
foxCircuit.close();
}
}
public synchronized String toString() {
int n;
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("ThreadPool\n");
for (n = 0; n < this.threadPool.length; ++n) {
stringBuffer.append(" pool[").append(n).append("] = ");
if (this.threadPool[n] == null) {
stringBuffer.append("null");
} else {
stringBuffer.append(this.threadPool[n].serviceCount);
}
stringBuffer.append('\n');
}
stringBuffer.append(" nonPoolServiceCount = " + this.nonPoolServiceCount).append('\n');
stringBuffer.append("Circuits\n");
if (this.circuits.size() == 0) {
stringBuffer.append(" none\n");
} else {
for (n = 0; n < this.circuits.size(); ++n) {
FoxCircuit foxCircuit = (FoxCircuit)this.circuits.get(n);
if (foxCircuit == null) continue;
stringBuffer.append(" ").append(foxCircuit).append('\n');
}
}
return stringBuffer.toString();
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
void runCircuit(FoxCircuit foxCircuit) {
ServiceThread[] serviceThreadArray = this.threadPool;
synchronized (this.threadPool) {
for (int i = 0; i < this.threadPool.length; ++i) {
if (this.threadPool[i] == null) {
this.threadPool[i] = new ServiceThread(this.session, "Fox:Circuit:" + this.session.getId() + " (Pooled:" + i + ")", true);
this.threadPool[i].start();
}
if (!this.threadPool[i].isAvailable()) continue;
this.threadPool[i].runCircuit(foxCircuit);
// ** MonitorExit[var2_2] (shouldn't be in output)
return;
}
++this.nonPoolServiceCount;
ServiceThread serviceThread = new ServiceThread(this.session, "Fox:Circuit:" + this.session.getId() + " (Non-pooled)", false);
serviceThread.start();
serviceThread.runCircuit(foxCircuit);
// ** MonitorExit[var2_2] (shouldn't be in output)
return;
}
}
static class ServiceThread
implements Runnable {
Thread thread;
boolean isAlive = true;
boolean pooled;
FoxCircuit circuit;
int serviceCount;
ServiceThread(FoxSession foxSession, String string, boolean bl) {
this.thread = foxSession.conn.makeThread(Fox.threadGroup, this, string);
this.pooled = bl;
}
public void start() {
this.thread.start();
}
public synchronized void kill() {
this.isAlive = false;
this.notify();
}
public synchronized boolean isAvailable() {
return this.circuit == null;
}
public synchronized void runCircuit(FoxCircuit foxCircuit) {
if (this.circuit != null) {
throw new IllegalStateException();
}
this.circuit = foxCircuit;
this.notify();
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void run() {
while (this.isAlive) {
ServiceThread serviceThread = this;
synchronized (serviceThread) {
while (this.circuit == null) {
if (!this.isAlive) {
return;
}
try {
this.wait();
}
catch (InterruptedException interruptedException) {
interruptedException.printStackTrace();
}
}
}
++this.serviceCount;
try {
this.circuit.session().conn().circuitOpened(this.circuit);
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
finally {
this.circuit.close();
}
serviceThread = this;
synchronized (serviceThread) {
this.circuit = null;
if (!this.pooled) {
return;
}
}
}
}
}
}
@@ -0,0 +1,81 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxFrame;
import com.tridium.fox.session.FoxRequest;
import com.tridium.fox.session.FoxResponse;
import com.tridium.fox.session.FoxSession;
import com.tridium.fox.session.FrameQueue;
public class SessionDispatcher
implements Runnable {
private FoxSession session;
private String name;
private boolean isAlive;
private Thread thread;
private FrameQueue queue;
public SessionDispatcher(FoxSession foxSession) {
this.name = "Fox:Dispatcher:" + foxSession.getId();
this.session = foxSession;
this.queue = new FrameQueue();
this.isAlive = true;
}
public void enqueue(FoxFrame foxFrame) throws InterruptedException {
if (this.session.isClosed()) {
throw new InterruptedException("FoxSession is closed");
}
this.queue.enqueue(foxFrame);
}
public void start() {
this.thread = this.session.conn.makeThread(Fox.threadGroup, this, this.name);
this.thread.start();
}
public void kill() {
this.isAlive = false;
if (this.thread != null) {
this.thread.interrupt();
this.thread = null;
}
this.queue.kill();
}
public void run() {
while (this.isAlive && !this.session.isClosed()) {
try {
FoxFrame foxFrame = this.queue.dequeue(-1);
this.dispatch(foxFrame);
}
catch (InterruptedException interruptedException) {
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
private void dispatch(FoxFrame foxFrame) throws InterruptedException {
block2: {
try {
FoxResponse foxResponse = foxFrame.channel == "fox" ? this.session.processFoxChannelRequest((FoxRequest)foxFrame.message) : this.session.conn().process((FoxRequest)foxFrame.message);
this.session.sendReply(foxFrame, foxResponse);
}
catch (Throwable throwable) {
if (!this.isAlive) break block2;
throwable.printStackTrace();
this.session.sendError(foxFrame, throwable);
}
}
}
public String toString() {
return this.name + " {" + this.queue + "}";
}
}
@@ -0,0 +1,61 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxFrame;
import com.tridium.fox.session.FoxSession;
public class SessionReceiver
implements Runnable {
FoxSession session;
String name;
volatile boolean isAlive;
Thread thread;
public SessionReceiver(FoxSession foxSession) {
this.session = foxSession;
this.name = "Fox:Receiver:" + foxSession.getId();
this.isAlive = true;
}
public void start() {
this.thread = this.session.conn.makeThread(Fox.threadGroup, this, this.name);
this.thread.start();
}
public void kill() {
this.isAlive = false;
if (this.thread != null) {
this.thread.interrupt();
this.thread = null;
}
}
public void run() {
while (this.isAlive && !this.session.isClosed()) {
try {
FoxFrame foxFrame = this.session.readFrame();
if (this.session.isClosed()) break;
if (foxFrame == null) continue;
if (foxFrame.frameType == 115 || foxFrame.frameType == 97) {
this.session.requestReceived(foxFrame);
continue;
}
this.session.replyReceived(foxFrame);
}
catch (Throwable throwable) {
if (this.isAlive) {
this.session.close(throwable);
}
return;
}
}
}
public String toString() {
return this.name;
}
}
@@ -0,0 +1,101 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxFrame;
import com.tridium.fox.session.FoxSession;
import com.tridium.fox.session.FrameQueue;
import java.io.IOException;
public class SessionSender
implements Runnable {
private static FoxFrame keepAlive = new FoxFrame(107, -1, -1, "fox", "keepalive", new FoxMessage());
private FoxSession session;
private String name;
private volatile boolean isAlive;
private Thread thread;
private FrameQueue queue;
private volatile boolean running = false;
public SessionSender(FoxSession foxSession) {
this.name = "Fox:Sender:" + foxSession.getId();
this.session = foxSession;
this.queue = new FrameQueue();
this.isAlive = true;
}
public void enqueue(FoxFrame foxFrame) throws InterruptedException {
this.queue.enqueue(foxFrame);
}
public void start() {
this.thread = this.session.conn.makeThread(Fox.threadGroup, this, this.name);
this.thread.start();
}
public void kill() {
this.isAlive = false;
if (this.thread != null) {
this.thread.interrupt();
this.thread = null;
}
this.queue.kill();
}
public boolean isRunning() {
return this.running;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void run() {
Object object;
try {
this.running = true;
while (this.isAlive && !this.session.isClosed()) {
try {
object = this.queue.dequeue(Fox.keepAliveInterval);
if (this.session.isClosed()) {
break;
}
if (object == null) {
object = keepAlive;
}
this.session.writeFrame((FoxFrame)object);
}
catch (InterruptedException interruptedException) {
}
catch (IOException iOException) {
this.session.close(iOException);
}
catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
finally {
this.running = false;
Object object2 = object = this.session.getSessionStateLock();
synchronized (object2) {
object.notifyAll();
}
if (this.session.getState().equals("closed")) {
try {
if (this.session.getSocket() != null) {
this.session.getSocket().close();
}
}
catch (Exception exception) {}
}
}
}
public String toString() {
return this.name + " {" + this.queue + "}";
}
}
@@ -0,0 +1,271 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.nre.auth.ScramSha256Client
* com.tridium.user.BRetrievePasswordCredential
* com.tridium.util.ValueByteBuffer
* javax.baja.log.Log
* javax.baja.security.BHttpFoxCredentials
* javax.baja.security.BICredentials
* javax.baja.security.BUsernameAndPassword
* javax.baja.sys.BObject
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.user.BUserService
*/
package com.tridium.fox.session;
import com.tridium.fox.kerberos.KerberosAuthenticator;
import com.tridium.fox.message.FoxMessage;
import com.tridium.fox.session.Fox;
import com.tridium.fox.session.FoxAuthenticationException;
import com.tridium.fox.session.FoxConnection;
import com.tridium.fox.session.FoxFrame;
import com.tridium.fox.session.FoxServer;
import com.tridium.fox.session.FoxSession;
import com.tridium.fox.session.FoxsRedirectException;
import com.tridium.fox.sys.BFoxDefaultAuthAgent;
import com.tridium.fox.sys.BFoxService;
import com.tridium.fox.sys.BIFoxAuthAgent;
import com.tridium.nre.auth.ScramSha256Client;
import com.tridium.user.BRetrievePasswordCredential;
import com.tridium.util.ValueByteBuffer;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.security.MessageDigest;
import javax.baja.log.Log;
import javax.baja.security.BHttpFoxCredentials;
import javax.baja.security.BICredentials;
import javax.baja.security.BUsernameAndPassword;
import javax.baja.sys.BObject;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.user.BUserService;
public class Tuner
extends Thread {
private FoxServer server;
private FoxSession session;
private String scheme;
static FoxSession openClient(FoxConnection foxConnection, Socket socket, String string, String string2, FoxSession.IFoxSessionListener[] iFoxSessionListenerArray) throws Exception {
BUsernameAndPassword bUsernameAndPassword = new BUsernameAndPassword(string, string2);
return Tuner.openClient(foxConnection, socket, (BICredentials)bUsernameAndPassword, iFoxSessionListenerArray);
}
/*
* Enabled force condition propagation
* Lifted jumps to return sites
*/
static FoxSession openClient(FoxConnection foxConnection, Socket socket, BICredentials bICredentials, FoxSession.IFoxSessionListener[] iFoxSessionListenerArray) throws Exception {
byte[] byArray = ValueByteBuffer.marshal((BObject)((BObject)bICredentials));
FoxSession foxSession = new FoxSession(socket, foxConnection, iFoxSessionListenerArray);
foxSession.setState("client.tune open credentials.len=" + byArray.length);
Fox.register(foxSession);
try {
foxSession.setState("client.tune sendHello");
foxSession.sendHello(null);
foxSession.setState("client.tune receiveHello");
foxSession.receiveHello();
foxSession.setState("client.tune receiveChallenge");
FoxMessage foxMessage = foxSession.receiveTuning("challenge");
String string = foxMessage.getString("method");
foxSession.setState("client.tune receivedChallenge method=" + string);
if (string.equals("basic")) {
FoxMessage foxMessage2 = new FoxMessage();
if (bICredentials instanceof BUsernameAndPassword) {
BUsernameAndPassword bUsernameAndPassword = (BUsernameAndPassword)bICredentials;
foxMessage2.add("username", bUsernameAndPassword.getUsername());
foxMessage2.add("password", bUsernameAndPassword.getPassword().getValue());
} else if (bICredentials instanceof BRetrievePasswordCredential) {
BRetrievePasswordCredential bRetrievePasswordCredential = (BRetrievePasswordCredential)bICredentials;
foxMessage2.add("username", bRetrievePasswordCredential.getUsername());
foxMessage2.add("email", bRetrievePasswordCredential.getEmail());
} else {
if (!(bICredentials instanceof BHttpFoxCredentials)) throw new IllegalStateException();
BHttpFoxCredentials bHttpFoxCredentials = (BHttpFoxCredentials)bICredentials;
byte[] byArray2 = byArray;
foxMessage2.add("username", bHttpFoxCredentials.getUsername());
foxMessage2.add("credentials", byArray2);
}
foxSession.setState("client.tune sendLogin");
foxSession.sendTuning("login", foxMessage2);
Tuner.receiveWelcome(foxSession, string);
} else if (string.equals("digest-md5")) {
if (foxSession.getRemoteHello().getString("fox.version", "1.0").compareTo("1.0.1") < 0) {
FoxMessage foxMessage3 = new FoxMessage();
BUsernameAndPassword bUsernameAndPassword = (BUsernameAndPassword)bICredentials;
byte[] byArray3 = foxMessage.getBlob("nonce");
String string2 = bUsernameAndPassword.getUsername();
byte[] byArray4 = Tuner.generateDigest(string2, bUsernameAndPassword.getPassword().getValue(), byArray3);
foxMessage3.add("username", string2);
foxMessage3.add("digest", byArray4);
foxSession.setState("client.tune sendLogin");
foxSession.sendTuning("login", foxMessage3);
Tuner.receiveWelcome(foxSession, string);
}
} else if (string.equals("digest")) {
if (bICredentials instanceof BUsernameAndPassword) {
try {
FoxMessage foxMessage4 = new FoxMessage();
foxMessage4.add("authInput", "authInputScram");
BUsernameAndPassword bUsernameAndPassword = (BUsernameAndPassword)bICredentials;
ScramSha256Client scramSha256Client = new ScramSha256Client(bUsernameAndPassword.getUsername(), bUsernameAndPassword.getPassword().getValue());
foxMessage4.add("authHandshake1", scramSha256Client.createClientFirstMessage());
foxSession.setState("client.tune send scramsha1-clientFirstMessage");
foxSession.sendTuning("authMessage1", foxMessage4);
FoxMessage foxMessage5 = foxSession.receiveTuning("authMessage1");
foxMessage4 = new FoxMessage();
String string3 = foxMessage5.getString("authHandshake1");
foxMessage4.add("authHandshake2", scramSha256Client.createClientFinalMessage(string3));
foxSession.setState("client.tune send scramsha1-clientFinalMessage");
foxSession.sendTuning("authMessage2", foxMessage4);
foxMessage5 = foxSession.receiveTuning("authMessage2");
String string4 = foxMessage5.getString("authHandshake2");
foxSession.setState("client.tune process scramsha1-serverFinalMessage");
scramSha256Client.processServerFinalMessage(string4);
}
catch (Exception exception) {
throw new FoxAuthenticationException("Rejected", string, null, foxSession);
}
Tuner.receiveWelcome(foxSession, string);
} else if (bICredentials instanceof BRetrievePasswordCredential) {
FoxMessage foxMessage6 = new FoxMessage();
foxMessage6.add("authInput", "authInputRetrieve");
BRetrievePasswordCredential bRetrievePasswordCredential = (BRetrievePasswordCredential)bICredentials;
foxMessage6.add("username", bRetrievePasswordCredential.getUsername());
foxMessage6.add("email", bRetrievePasswordCredential.getEmail());
foxSession.setState("client.tune sendFirstMessage");
foxSession.sendTuning("authMessage1", foxMessage6);
Tuner.receiveWelcome(foxSession, string);
} else {
if (!(bICredentials instanceof BHttpFoxCredentials)) throw new IllegalStateException();
FoxMessage foxMessage7 = new FoxMessage();
foxMessage7.add("authInput", "authInputHttp");
BHttpFoxCredentials bHttpFoxCredentials = (BHttpFoxCredentials)bICredentials;
byte[] byArray5 = byArray;
foxMessage7.add("username", bHttpFoxCredentials.getUsername());
foxMessage7.add("credentials", byArray5);
foxSession.setState("client.tune sendFirstMessage");
foxSession.sendTuning("authMessage1", foxMessage7);
Tuner.receiveWelcome(foxSession, string);
}
} else {
if (!string.equals("kerberos")) throw new FoxAuthenticationException("Unknown challenge method ", string, foxSession);
if (System.getProperty("java.vm.name").equalsIgnoreCase("J9")) {
throw new FoxAuthenticationException("Unsupported challenge method: ", string, foxSession);
}
if (bICredentials instanceof BHttpFoxCredentials) {
FoxMessage foxMessage8 = new FoxMessage();
foxMessage8.add("authInput", "authInputHttp");
BHttpFoxCredentials bHttpFoxCredentials = (BHttpFoxCredentials)bICredentials;
byte[] byArray6 = byArray;
foxMessage8.add("username", bHttpFoxCredentials.getUsername());
foxMessage8.add("credentials", byArray6);
foxSession.setState("client.tune sendFirstMessage");
foxSession.sendTuning("authMessage1", foxMessage8);
Tuner.receiveWelcome(foxSession, string);
} else {
KerberosAuthenticator.authenticate(foxSession, foxMessage, bICredentials);
Tuner.receiveWelcome(foxSession, string);
}
}
foxSession.setState("client.tune starting");
foxSession.start();
return foxSession;
}
catch (Error error) {
foxSession.close(error);
throw error;
}
catch (Exception exception) {
foxSession.close(exception);
throw exception;
}
}
private static void receiveWelcome(FoxSession foxSession, String string) throws IOException, FoxAuthenticationException {
foxSession.setState("client.tune receiveWelcome");
FoxFrame foxFrame = foxSession.readFrame();
if (foxFrame.command != "welcome") {
foxSession.setState("client.tune receivedRejected");
String string2 = foxFrame.message.getString("fatal", null);
String string3 = foxFrame.message.getString("msg", null);
FoxAuthenticationException foxAuthenticationException = null != string3 ? new FoxAuthenticationException(string3, string, string2, foxSession) : new FoxAuthenticationException("Rejected", string, string2, foxSession);
try {
foxAuthenticationException.data = foxFrame.message.getMessage("data");
}
catch (IOException iOException) {
foxAuthenticationException.data = null;
}
throw foxAuthenticationException;
}
foxSession.remoteWelcome = foxFrame.message;
foxSession.setState("client.tune receivedWelcome");
}
static void openServer(FoxServer foxServer, Socket socket, String string) throws Exception {
FoxSession foxSession = new FoxSession(socket, foxServer.makeConnection(null, null));
int n = Math.max(1, Fox.maxServerSessions);
if (Fox.getServerSessionCount() >= n) {
Log.getLog((String)"fox").warning("past fox.maxServerSessions limit: " + n);
foxSession.sendBusy();
}
Fox.register(foxSession);
foxSession.setState("server.tune spawning");
new Tuner(foxServer, foxSession, string).start();
}
private Tuner(FoxServer foxServer, FoxSession foxSession, String string) {
super("Fox:Tuner:" + foxSession.getId());
this.server = foxServer;
this.session = foxSession;
this.scheme = string;
}
public void run() {
try {
this.session.setState("server.tune receiveHello");
if (!this.session.receiveHello()) {
this.session.start();
return;
}
this.session.setState("server.tune makeConnection");
this.session.conn = this.server.makeConnection(this.session, this.session.getRemoteHello());
BFoxService bFoxService = (BFoxService)Sys.getService((Type)BFoxService.TYPE);
if (this.scheme.equalsIgnoreCase("fox") && bFoxService.getFoxsOnly() && bFoxService.getFoxsEnabled()) {
this.session.setState("server.tune sendRedirect");
this.session.sendRedirect(bFoxService.getFoxsPort());
throw new FoxsRedirectException(bFoxService.getFoxsPort());
}
this.session.setState("server.tune sendHello");
this.session.sendHello(null);
BUserService bUserService = (BUserService)Sys.getService((Type)BUserService.TYPE);
BIFoxAuthAgent bIFoxAuthAgent = (BIFoxAuthAgent)bUserService.getAuthAgent(BIFoxAuthAgent.TYPE);
if (null != bIFoxAuthAgent) {
bIFoxAuthAgent.authenticate(this.session, this.server);
} else {
BFoxDefaultAuthAgent.INSTANCE.authenticate(this.session, this.server);
}
}
catch (Throwable throwable) {
this.session.close(throwable);
}
}
public static byte[] generateDigest(String string, String string2, byte[] byArray) throws Exception {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
dataOutputStream.writeUTF(string);
dataOutputStream.writeUTF(string2);
dataOutputStream.write(byArray);
byte[] byArray2 = byteArrayOutputStream.toByteArray();
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(byArray2);
return messageDigest.digest();
}
}
@@ -0,0 +1,33 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.fox.session;
import com.tridium.fox.session.FoxFrame;
import com.tridium.fox.session.FoxSession;
import com.tridium.fox.session.SessionReceiver;
public class TunnelReceiver
extends SessionReceiver {
public TunnelReceiver(FoxSession foxSession) {
super(foxSession);
this.name = "Fox:TunnelReceiver:" + foxSession.getId();
}
public void run() {
while (this.isAlive && !this.session.isClosed()) {
try {
FoxFrame foxFrame = this.session.readTunnelFrame();
if (this.session.isClosed()) break;
this.session.writeFrame(foxFrame);
}
catch (Throwable throwable) {
if (this.isAlive) {
this.session.close(throwable);
}
return;
}
}
}
}