189 lines
7.6 KiB
Java
189 lines
7.6 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.tridium.nre.util.LegacyStorageUtil
|
|
* com.tridium.sys.Nre
|
|
* javax.baja.log.Log
|
|
* javax.baja.nre.util.TextUtil
|
|
* javax.baja.security.BUsernameAndPassword
|
|
* javax.baja.sys.Sys
|
|
*/
|
|
package com.tridium.platform.daemon;
|
|
|
|
import com.tridium.nre.util.LegacyStorageUtil;
|
|
import com.tridium.platform.daemon.BDaemonSession;
|
|
import com.tridium.platform.daemon.DaemonSessionListener;
|
|
import com.tridium.sys.Nre;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.net.ConnectException;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.security.MessageDigest;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.util.Properties;
|
|
import javax.baja.log.Log;
|
|
import javax.baja.nre.util.TextUtil;
|
|
import javax.baja.security.BUsernameAndPassword;
|
|
import javax.baja.sys.Sys;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class LocalSessionUtil {
|
|
public static final Object MONITOR = "monitor";
|
|
private static BDaemonSession localDaemonSession;
|
|
public static Log log;
|
|
private static boolean warnedOnce;
|
|
private static DaemonSessionListener LOCAL_LISTENER;
|
|
static /* synthetic */ Class class$javax$baja$net$HttpConnection;
|
|
|
|
/*
|
|
* Exception decompiling
|
|
*/
|
|
public static BDaemonSession getLocalSession() {
|
|
/*
|
|
* This method has failed to decompile. When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
|
|
*
|
|
* org.benf.cfr.reader.util.ConfusedCFRException: Back jump on a try block [egrp 1[TRYBLOCK] [3 : 33->366)] java.lang.Throwable
|
|
* at org.benf.cfr.reader.bytecode.analysis.opgraph.Op02WithProcessedDataAndRefs.insertExceptionBlocks(Op02WithProcessedDataAndRefs.java:2283)
|
|
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:415)
|
|
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
|
|
* at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
|
|
* at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
|
|
* at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
|
|
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
|
|
* at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
|
|
* at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
|
|
* at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
|
|
* at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
|
|
* at org.benf.cfr.reader.Main.main(Main.java:54)
|
|
*/
|
|
throw new IllegalStateException("Decompilation failed");
|
|
}
|
|
|
|
private static final BUsernameAndPassword parseUsername(String string) throws NoSuchAlgorithmException, IOException {
|
|
String[] stringArray = TextUtil.split((String)LegacyStorageUtil.decode((String)string), (char)':');
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
stringBuffer.append(stringArray[2]);
|
|
stringBuffer.append(":");
|
|
stringBuffer.append(stringArray[0]);
|
|
stringBuffer.append(":suNkiNg");
|
|
StringBuffer stringBuffer2 = new StringBuffer();
|
|
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
|
|
byte[] byArray = messageDigest.digest(stringBuffer.toString().getBytes());
|
|
int n = 0;
|
|
while (n < byArray.length) {
|
|
stringBuffer2.append(TextUtil.toLowerCase((String)TextUtil.byteToHexString((int)byArray[n])));
|
|
++n;
|
|
}
|
|
return new BUsernameAndPassword(string, stringBuffer2.toString());
|
|
}
|
|
|
|
/*
|
|
* WARNING - Removed try catching itself - possible behaviour change.
|
|
* Enabled aggressive block sorting
|
|
* Enabled unnecessary exception pruning
|
|
* Enabled aggressive exception aggregation
|
|
*/
|
|
public static void resetLocalSession() {
|
|
Object object = MONITOR;
|
|
synchronized (object) {
|
|
localDaemonSession = null;
|
|
LocalSessionUtil.getLocalSession();
|
|
return;
|
|
}
|
|
}
|
|
|
|
private static final Properties getProperties() throws IOException {
|
|
Properties properties = new Properties();
|
|
File file = new File(Sys.getBajaHome() + File.separator + "daemon" + File.separator + "daemon.properties");
|
|
if (file.exists()) {
|
|
FileInputStream fileInputStream = new FileInputStream(file);
|
|
properties.load(fileInputStream);
|
|
try {
|
|
fileInputStream.close();
|
|
}
|
|
catch (Exception exception) {}
|
|
}
|
|
return properties;
|
|
}
|
|
|
|
public static boolean localDaemonIsAvailable() {
|
|
HttpURLConnection httpURLConnection = null;
|
|
boolean bl = false;
|
|
try {
|
|
BDaemonSession bDaemonSession = LocalSessionUtil.getLocalSession();
|
|
if (bDaemonSession == null) {
|
|
return false;
|
|
}
|
|
httpURLConnection = (HttpURLConnection)new URL("http", bDaemonSession.getHost().getHostname(), bDaemonSession.getPort(), "/check").openConnection();
|
|
StringBuffer stringBuffer = new StringBuffer("Niagara/");
|
|
Class clazz = class$javax$baja$net$HttpConnection;
|
|
if (clazz == null) {
|
|
clazz = class$javax$baja$net$HttpConnection = LocalSessionUtil.class("[Ljavax.baja.net.HttpConnection;", false);
|
|
}
|
|
httpURLConnection.setRequestProperty("User-Agent", stringBuffer.append(Nre.moduleManager.getModuleForClass(clazz).getVendorVersion()).toString());
|
|
boolean bl2 = false;
|
|
if (httpURLConnection.getResponseCode() < 500) {
|
|
bl2 = true;
|
|
}
|
|
bl = bl2;
|
|
}
|
|
catch (ConnectException connectException) {
|
|
}
|
|
catch (Exception exception) {
|
|
log.error("error checking for running daemon", (Throwable)exception);
|
|
}
|
|
if (httpURLConnection != null) {
|
|
httpURLConnection.disconnect();
|
|
}
|
|
return bl;
|
|
}
|
|
|
|
static /* synthetic */ Class class(String string, boolean bl) {
|
|
try {
|
|
Class<?> clazz = Class.forName(string);
|
|
if (!bl) {
|
|
clazz = clazz.getComponentType();
|
|
}
|
|
return clazz;
|
|
}
|
|
catch (ClassNotFoundException classNotFoundException) {
|
|
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
|
}
|
|
}
|
|
|
|
static {
|
|
log = Log.getLog((String)"platform");
|
|
warnedOnce = false;
|
|
LOCAL_LISTENER = new DaemonSessionListener(){
|
|
|
|
public final void sessionConnected(BDaemonSession bDaemonSession) {
|
|
}
|
|
|
|
public final void sessionDisconnected(BDaemonSession bDaemonSession) {
|
|
}
|
|
|
|
/*
|
|
* WARNING - Removed try catching itself - possible behaviour change.
|
|
* Enabled aggressive block sorting
|
|
* Enabled unnecessary exception pruning
|
|
* Enabled aggressive exception aggregation
|
|
*/
|
|
public final void sessionConnectionError(BDaemonSession bDaemonSession, Throwable throwable) {
|
|
Object object = MONITOR;
|
|
synchronized (object) {
|
|
if (bDaemonSession == localDaemonSession) {
|
|
localDaemonSession = null;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|