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,127 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.license;
import javax.baja.license.Feature;
import javax.baja.license.LicenseException;
import javax.baja.log.Log;
import javax.baja.sys.Sys;
import javax.baja.util.PatternFilter;
public class Brand {
static final Log log = Log.getLog("sys.brand");
private static boolean init;
private static String brandId;
private static AcceptList acceptStationIn;
private static AcceptList acceptStationOut;
private static AcceptList acceptWbIn;
private static AcceptList acceptWbOut;
public static String getBrandId() {
Brand.init();
return brandId;
}
public static String getAcceptStationInString() {
Brand.init();
return Brand.acceptStationIn.patternString;
}
public static String getAcceptStationOutString() {
Brand.init();
return Brand.acceptStationOut.patternString;
}
public static String getAcceptWbInString() {
Brand.init();
return Brand.acceptWbIn.patternString;
}
public static String getAcceptWbOutString() {
Brand.init();
return Brand.acceptWbOut.patternString;
}
public static void checkStationIn(String string) {
Brand.init();
acceptStationIn.check(string);
}
public static void checkStationOut(String string) {
Brand.init();
acceptStationOut.check(string);
}
public static void checkWbIn(String string) {
Brand.init();
acceptWbIn.check(string);
}
public static void checkWbOut(String string) {
Brand.init();
acceptWbOut.check(string);
}
private static final void init() {
if (init) {
return;
}
Feature feature = Sys.getLicenseManager().checkFeature("tridium", "brand");
brandId = feature.get("brandId");
if (brandId == null) {
throw new LicenseException("Missing brandId in brand feature");
}
acceptStationIn = new AcceptList(feature, "accept.station.in");
acceptStationOut = new AcceptList(feature, "accept.station.out");
acceptWbIn = new AcceptList(feature, "accept.wb.in");
acceptWbOut = new AcceptList(feature, "accept.wb.out");
init = true;
}
public static class AcceptList {
String id;
PatternFilter[] patterns;
String patternString;
public void check(String string) {
if (!this.accept(string)) {
throw new LicenseException("Brand incompatibility [" + this.id + "] " + string + " != " + this.patternString);
}
}
public boolean accept(String string) {
if (log.isTraceOn()) {
log.trace("check " + this.id + ": " + string + " against " + this.patternString);
}
if (string == null) {
return true;
}
int n = 0;
while (n < this.patterns.length) {
if (this.patterns[n].accept(string)) {
return true;
}
++n;
}
return false;
}
public String toString() {
return this.id + '=' + this.patternString;
}
public AcceptList(Feature feature, String string) {
this.id = string;
this.patternString = feature.get(string, "*");
this.patterns = PatternFilter.parseList(this.patternString, ";");
}
public AcceptList(String string, String string2) {
this.id = string;
this.patternString = string2;
this.patterns = PatternFilter.parseList(string2, ";");
}
}
}
@@ -0,0 +1,86 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Base64
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
* javax.baja.xml.XParser
*/
package com.tridium.sys.license;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.NLicenseManager;
import java.io.File;
import java.security.PublicKey;
import javax.baja.nre.util.Base64;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
import javax.baja.xml.XParser;
public class CertificateFile {
File file;
String error;
String vendor;
long expiration;
PublicKey publicKey;
public void load(NLicenseManager nLicenseManager) {
try {
XElem xElem = XParser.make((File)this.file).parse();
if (!xElem.qname().equals("certificate")) {
throw new XException("Root name must be certificate", xElem);
}
this.vendor = xElem.get("vendor");
XElem xElem2 = xElem.elem("publicKey");
byte[] byArray = Base64.decode((String)xElem2.string());
this.publicKey = LicenseUtil.toPublicKey(byArray);
long l = System.currentTimeMillis();
this.expiration = LicenseUtil.parseDate(xElem.get("expiration"));
if (l > this.expiration) {
this.error = "Expired";
return;
}
XElem xElem3 = xElem.elem("signature");
byte[] byArray2 = Base64.decode((String)xElem3.string());
xElem.removeContent((XContent)xElem3);
byte[] byArray3 = LicenseUtil.encode(xElem);
if (!LicenseUtil.verify(byArray3, byArray2, LicenseUtil.getMasterPublicKey())) {
this.error = "Invalid signature";
return;
}
}
catch (XException xException) {
this.error = "Invalid XML: " + xException.getMessage();
}
catch (Throwable throwable) {
this.error = throwable.toString();
}
}
public boolean isValid() {
boolean bl = false;
if (this.error == null) {
bl = true;
}
return bl;
}
public PublicKey getPublicKey() {
return this.publicKey;
}
public String toString() {
if (this.isValid()) {
return this.file.getName() + " <" + this.vendor + "> [expires: " + LicenseUtil.formatDate(this.expiration) + "] {valid}";
}
return this.file.getName() + " {invalid: " + this.error + '}';
}
CertificateFile(File file) {
this.file = file;
}
}
@@ -0,0 +1,441 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XElem
*/
package com.tridium.sys.license;
import com.tridium.sys.license.FlrConfig;
import com.tridium.sys.license.FlrException;
import com.tridium.sys.license.LicenseFile;
import com.tridium.sys.license.NLicenseManager;
import com.tridium.sys.license.XFlrMsg;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.DigestException;
import java.security.MessageDigest;
import java.util.Random;
import java.util.StringTokenizer;
import javax.baja.license.LicenseDatabaseException;
import javax.baja.sys.BAbsTime;
import javax.baja.sys.BFacets;
import javax.baja.sys.BLong;
import javax.baja.sys.BRelTime;
import javax.baja.sys.Sys;
import javax.baja.util.Version;
import javax.baja.xml.XElem;
public class FloatingLicenseManager
extends NLicenseManager {
static final int MIN_HB_FREQ = 5;
static final int MAX_HB_FREQ;
static final int HB_MISS_LIMIT;
FlrClient client;
private Heartbeat heartbeat;
private ReleaseLicenseHook releaseHook;
private FlrConfig flrConfig;
private String licPack;
protected LicenseFile[] loadLicenses() {
try {
Runtime.getRuntime().removeShutdownHook(this.releaseHook);
LicenseFile[] licenseFileArray = this.client.getLicenses();
int n = 0;
while (n < licenseFileArray.length) {
licenseFileArray[n].load(this);
++n;
}
Runtime.getRuntime().addShutdownHook(this.releaseHook);
if (this.heartbeat == null) {
this.heartbeat = new Heartbeat(this);
this.heartbeat.start();
}
return licenseFileArray;
}
catch (LicenseDatabaseException licenseDatabaseException) {
this.setFatalLicenseFault(licenseDatabaseException.getMessage());
return new FloatingLicense[0];
}
}
public FlrConfig getConfig() {
return this.flrConfig;
}
public String getPack() {
return this.licPack;
}
boolean failover() {
log.error(this.lex.getText("flm.failover.notify", new Object[]{this.client.getBoundUrl()}));
this.reload();
if (this.isFatalLicenseFault()) {
log.error(this.lex.getText("flm.failover.fail"));
return false;
}
log.message(this.lex.getText("flm.failover.success", new Object[]{this.client.getBoundUrl()}));
return true;
}
public FloatingLicenseManager(FlrConfig flrConfig, String string) {
this.flrConfig = flrConfig;
this.licPack = string;
this.client = new FlrClient(this);
this.releaseHook = new ReleaseLicenseHook(this);
}
static {
int n = 3600;
try {
n = Integer.parseInt(System.getProperty("niagara.flm.hb.freq"));
if (n > 3600) {
n = 3600;
}
}
catch (Exception exception) {}
MAX_HB_FREQ = Math.max(5, n);
int n2 = 24;
try {
n2 = Integer.parseInt(System.getProperty("niagara.flm.hb.maxMiss"));
if (n2 > 24) {
n2 = 24;
}
}
catch (Exception exception) {}
HB_MISS_LIMIT = Math.max(1, n2);
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
private static class FlrClient {
private static final String XML_CONTENT = "text/xml; charset=\"utf-8\"";
XFlrMsg reqMsg;
private FloatingLicenseManager mgr;
private FlrCksum flrCksum;
private int boundFlr;
public boolean isBound() {
boolean bl = false;
if (this.boundFlr >= 0) {
bl = true;
}
return bl;
}
public URL getBoundUrl() {
if (!this.isBound()) {
throw new IllegalStateException("FLR is not bound");
}
return this.mgr.flrConfig.flrs()[this.boundFlr].getURL();
}
public FloatingLicense[] getLicenses() throws LicenseDatabaseException {
FlrConfig.FlrDef[] flrDefArray = this.mgr.getConfig().flrs();
int n = this.isBound() ? this.boundFlr : (this.boundFlr = 0);
while (true) {
XElem[] xElemArray;
Object object;
try {
XFlrMsg xFlrMsg = new XFlrMsg("lease");
xFlrMsg.setPayload(new XElem("lease").addAttr("pack", this.mgr.getPack()));
xFlrMsg.setMetadata("autofree", BLong.make(this.calcAutoFree()));
object = this.post(flrDefArray[this.boundFlr].getURL(), xFlrMsg);
xElemArray = ((XFlrMsg)object).getPayload().elems("license");
FloatingLicense[] floatingLicenseArray = new FloatingLicense[xElemArray.length];
int n2 = 0;
while (n2 < xElemArray.length) {
floatingLicenseArray[n2] = new FloatingLicense(xElemArray[n2]);
++n2;
}
this.reqMsg = xFlrMsg;
log.message(this.mgr.lex.getText("flm.lease.success", new Object[]{this.mgr.getPack(), flrDefArray[this.boundFlr].getURL()}));
return floatingLicenseArray;
}
catch (Exception exception) {
object = log.isTraceOn() ? "" : " -- " + exception.getMessage();
xElemArray = this.mgr.lex.getText("flm.lease.fail", new Object[]{this.mgr.getPack(), flrDefArray[this.boundFlr].getURL(), object});
if (log.isTraceOn()) {
log.trace((String)xElemArray, exception);
} else {
log.error((String)xElemArray);
}
if (flrDefArray.length != 1) {
++this.boundFlr;
this.boundFlr %= flrDefArray.length;
if (n != this.boundFlr) continue;
}
throw new LicenseDatabaseException(this.mgr.lex.getText("flm.lease.fatal", new Object[]{this.mgr.getPack()}));
}
break;
}
}
public XFlrMsg post(XFlrMsg xFlrMsg) {
return this.post(this.getBoundUrl(), xFlrMsg);
}
public XFlrMsg post(URL uRL, XFlrMsg xFlrMsg) {
try {
xFlrMsg.getChallenge().setCksum(this.flrCksum.calcCksum(xFlrMsg, true));
HttpURLConnection httpURLConnection = (HttpURLConnection)uRL.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestProperty("Content-Type", XML_CONTENT);
xFlrMsg.write(httpURLConnection.getOutputStream(), true);
XFlrMsg xFlrMsg2 = XFlrMsg.make(httpURLConnection.getInputStream());
xFlrMsg2.throwIfError();
try {
this.flrCksum.validate(xFlrMsg, xFlrMsg2);
}
catch (DigestException digestException) {
throw new SecurityException(digestException.getMessage());
}
return xFlrMsg2;
}
catch (FlrException flrException) {
throw flrException;
}
catch (Exception exception) {
throw new FlrException("Message to FLR failed: " + exception);
}
}
private final long calcAutoFree() {
return BRelTime.makeSeconds(MAX_HB_FREQ).getMillis() * (long)HB_MISS_LIMIT;
}
private final /* synthetic */ void this() {
this.flrCksum = new CksumMagic();
}
public FlrClient(FloatingLicenseManager floatingLicenseManager) {
this.this();
this.mgr = floatingLicenseManager;
this.boundFlr = -1;
}
}
private static class Heartbeat
extends Thread {
private FloatingLicenseManager mgr;
private FlrClient client;
private int missedHeartbeats;
public boolean isFlatlined() {
boolean bl = false;
if (this.missedHeartbeats >= HB_MISS_LIMIT) {
bl = true;
}
return bl;
}
private final void forceFlatline() {
this.missedHeartbeats = HB_MISS_LIMIT;
}
private final long nextHbTime() {
return BRelTime.makeSeconds((int)(Math.random() * (double)(MAX_HB_FREQ - 5 + 1)) + 5).getMillis();
}
public void run() {
while (true) {
block11: {
try {
Object object;
long l = this.nextHbTime();
if (log.isTraceOn()) {
object = BAbsTime.now().add(BRelTime.make(l)).toString(BFacets.make("showSeconds", true));
log.trace(this.mgr.lex.getText("flm.hb.next", new Object[]{object}));
}
Thread.sleep(l);
object = new XFlrMsg("heartbeat");
((XFlrMsg)object).setPayload(this.client.reqMsg.asXML());
XFlrMsg xFlrMsg = this.client.post((XFlrMsg)object);
XElem xElem = xFlrMsg.getPayload();
if (xElem.name().equals("reject")) {
log.error(this.mgr.lex.getText("flm.hb.rejected"));
this.forceFlatline();
break block11;
}
if (xElem.name().equals("licenses")) break block11;
if (xElem.name().equals("success")) {
if (this.missedHeartbeats > 0) {
log.message(this.mgr.lex.getText("flm.hb.alive"));
}
this.missedHeartbeats = 0;
break block11;
}
throw new IllegalStateException("Invalid heartbeat response: " + xElem.name());
}
catch (InterruptedException interruptedException) {
}
catch (Exception exception) {
++this.missedHeartbeats;
Integer n = new Integer(HB_MISS_LIMIT - this.missedHeartbeats);
if (log.isTraceOn()) {
log.trace(this.mgr.lex.getText("flm.hb.missed", new Object[]{n, ""}), exception);
}
log.warning(this.mgr.lex.getText("flm.hb.missed", new Object[]{n, " -- " + exception.getMessage()}));
}
}
if (!this.isFlatlined()) continue;
if (!this.mgr.failover()) break;
this.missedHeartbeats = 0;
}
if (this.isFlatlined()) {
log.error(this.mgr.lex.getText("flm.exit"));
if (Sys.getStation() != null) {
Sys.getStation().save();
}
System.exit(1);
}
}
public Heartbeat(FloatingLicenseManager floatingLicenseManager) {
super(BAbsTime.now().toString());
this.mgr = floatingLicenseManager;
this.client = floatingLicenseManager.client;
this.missedHeartbeats = 0;
}
}
private static class FloatingLicense
extends LicenseFile {
XElem license;
protected String getLicenseName() {
return "Floating License";
}
protected XElem getRoot() throws Exception {
return this.license;
}
protected boolean isLicenseHostIdValid() {
return this.hostId.equals("FLOATING");
}
public FloatingLicense(XElem xElem) {
this.license = xElem;
}
}
private static final class ReleaseLicenseHook
extends Thread {
private FloatingLicenseManager mgr;
public final void run() {
try {
XFlrMsg xFlrMsg = new XFlrMsg("checkin");
xFlrMsg.setPayload(this.mgr.client.reqMsg.asXML());
log.message(this.mgr.lex.getText("flm.checkin.begin"));
this.mgr.client.post(xFlrMsg);
log.message(this.mgr.lex.getText("flm.checkin.end"));
}
catch (Exception exception) {
log.error(this.mgr.lex.getText("flm.checkin.failed", new Object[]{" -- " + exception.getMessage()}));
log.error("Failed to check-in leased license.", exception);
}
}
public ReleaseLicenseHook(FloatingLicenseManager floatingLicenseManager) {
this.mgr = floatingLicenseManager;
}
}
public static interface FlrCksum {
public Version version();
public String calcCksum(XFlrMsg var1, boolean var2) throws DigestException;
public void validate(XFlrMsg var1, XFlrMsg var2) throws DigestException;
public void validate(XFlrMsg var1, BRelTime var2) throws DigestException;
}
private static class CksumMagic
implements FlrCksum {
private Version version = new Version("1.0");
public Version version() {
return this.version;
}
public String calcCksum(XFlrMsg xFlrMsg, boolean bl) throws DigestException {
try {
MessageDigest messageDigest = MessageDigest.getInstance("md5");
XFlrMsg.XChallenge xChallenge = xFlrMsg.getChallenge();
xChallenge.setVersion(this.version);
long l = xChallenge.getTimestamp();
String string = xChallenge.getHostid();
int[] nArray = xChallenge.parseNonce();
Random random = new Random(l >>> 2 ^ -1L);
StringTokenizer stringTokenizer = new StringTokenizer(string, "-");
String[] stringArray = new String[stringTokenizer.countTokens()];
int n = 0;
while (n < stringArray.length) {
stringArray[n] = stringTokenizer.nextToken();
++n;
}
n = 0;
StringBuffer stringBuffer = new StringBuffer();
if (bl) {
stringBuffer.append(xFlrMsg.getType()).append(this.version.toString());
}
int n2 = 0;
while (n2 < 4) {
int n3 = 0;
while (n3 < nArray.length) {
boolean bl2 = random.nextBoolean();
if (bl && bl2) {
stringBuffer.append(nArray[n3]);
} else if (!bl && !bl2) {
stringBuffer.append(nArray[n3]);
} else {
stringBuffer.append(stringArray[n++ % stringArray.length]);
}
++n3;
}
++n2;
}
if (!bl) {
stringBuffer.append(xFlrMsg.getType()).append(this.version.toString());
}
return new BigInteger(1, messageDigest.digest(stringBuffer.toString().getBytes("UTF-16LE"))).toString(16);
}
catch (Exception exception) {
throw new DigestException(exception.getMessage());
}
}
public void validate(XFlrMsg xFlrMsg, XFlrMsg xFlrMsg2) throws DigestException {
XFlrMsg.XChallenge xChallenge = xFlrMsg2.getChallenge();
this.throwIfVersionMismatch(xChallenge);
String string = this.calcCksum(xFlrMsg, false);
String string2 = xChallenge.getCksum();
if (!string.equals(string2)) {
throw new DigestException("Invalid FLR cksum");
}
}
public void validate(XFlrMsg xFlrMsg, BRelTime bRelTime) throws DigestException {
XFlrMsg.XChallenge xChallenge = xFlrMsg.getChallenge();
this.throwIfVersionMismatch(xChallenge);
xChallenge.throwIfTooOld(bRelTime);
String string = xChallenge.getCksum();
String string2 = this.calcCksum(xFlrMsg, true);
if (!string.equals(string2)) {
throw new DigestException("Cksum mismatch");
}
}
private final void throwIfVersionMismatch(XFlrMsg.XChallenge xChallenge) throws DigestException {
if (!xChallenge.getVersion().equals(this.version)) {
throw new DigestException("FLR and client have different cksum methods.");
}
}
}
}
@@ -0,0 +1,231 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
* javax.baja.xml.XParser
*/
package com.tridium.sys.license;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import javax.baja.sys.Sys;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
import javax.baja.xml.XParser;
public class FlrConfig {
public static final String filename = "flrclient.xml";
private File configFile;
private String err;
private FlrDef[] flrs;
private HashMap appToPack;
public static String aliasApp(String string) {
if (string.equals("workbench:com.tridium.workbench.shell.WbMain")) {
return "wb";
}
if (string.equals("com.tridium.sys.station.Station")) {
return "station";
}
return string;
}
public static String unaliasApp(String string) {
if (string.equals("station")) {
return "com.tridium.sys.station.Station";
}
if (string.equals("wb")) {
return "workbench:com.tridium.workbench.shell.WbMain";
}
return string;
}
public boolean exists() {
return this.configFile.exists();
}
public boolean isValid() {
boolean bl = false;
if (this.err == null) {
bl = true;
}
return bl;
}
public FlrDef[] flrs() {
return this.flrs;
}
public void addFlrDef(FlrDef flrDef) {
ArrayList<FlrDef> arrayList = new ArrayList<FlrDef>(Arrays.asList(this.flrs));
if (arrayList.contains(flrDef)) {
return;
}
arrayList.add(flrDef);
this.flrs = arrayList.toArray(new FlrDef[arrayList.size()]);
}
public void removeFlr(FlrDef flrDef) {
ArrayList<FlrDef> arrayList = new ArrayList<FlrDef>(Arrays.asList(this.flrs));
if (arrayList.remove(flrDef)) {
this.flrs = arrayList.toArray(new FlrDef[arrayList.size()]);
}
}
public String[] apps() {
return this.appToPack.keySet().toArray(new String[this.appToPack.size()]);
}
public void addPackmap(String string, String string2) {
if (string == null || string2 == null) {
return;
}
this.appToPack.put(FlrConfig.unaliasApp(string), string2);
}
public void removePackmap(String string) {
this.appToPack.remove(FlrConfig.unaliasApp(string));
}
public String getPackName(String string) {
return (String)this.appToPack.get(FlrConfig.unaliasApp(string));
}
public String toString() {
return this.err == null ? filename : this.err;
}
private final void load() {
this.configFile = new File(new File(Sys.getBajaHome(), "licenses"), filename);
if (!this.exists()) {
return;
}
try {
XElem xElem = XParser.make((File)this.configFile).parse();
if (!xElem.name().equals("flrclient")) {
throw new XException("root element must be <flrclient>");
}
this.flrs = this.parseFlrs(xElem.elems("flr"));
if (this.flrs.length == 0) {
throw new XException("No FLRs are defined");
}
this.appToPack = this.parsePacks(xElem);
}
catch (XException xException) {
this.err = "Invalid flrclient.xml XML: " + xException.getMessage();
}
catch (Exception exception) {
this.err = exception.toString();
}
}
private final FlrDef[] parseFlrs(XElem[] xElemArray) {
FlrDef[] flrDefArray = new FlrDef[xElemArray.length];
int n = 0;
while (n < xElemArray.length) {
flrDefArray[n] = new FlrDef(xElemArray[n].get("host"), xElemArray[n].geti("port"));
++n;
}
return flrDefArray;
}
private final HashMap parsePacks(XElem xElem) {
HashMap<String, String> hashMap = new HashMap<String, String>(2);
XElem[] xElemArray = xElem.elems("packmap");
int n = 0;
while (n < xElemArray.length) {
String string = FlrConfig.unaliasApp(xElemArray[n].get("app"));
String string2 = xElemArray[n].get("pack");
if (hashMap.containsKey(string)) {
throw new XException("Duplicate app defined '" + FlrConfig.aliasApp(string) + '\'', xElemArray[n]);
}
hashMap.put(FlrConfig.unaliasApp(xElemArray[n].get("app")), xElemArray[n].get("pack"));
++n;
}
return hashMap;
}
public void write() throws Exception {
XElem xElem = new XElem("flrclient");
int n = 0;
while (n < this.flrs.length) {
xElem.addContent((XContent)new XElem("flr").addAttr("host", this.flrs[n].ip).addAttr("port", Integer.toString(this.flrs[n].port)));
++n;
}
String[] stringArray = this.apps();
int n2 = 0;
while (n2 < stringArray.length) {
xElem.addContent((XContent)new XElem("packmap").addAttr("app", FlrConfig.aliasApp(stringArray[n2])).addAttr("pack", this.getPackName(stringArray[n2])));
++n2;
}
xElem.write(this.configFile);
}
public FlrConfig(FlrDef[] flrDefArray, HashMap hashMap) {
this.flrs = flrDefArray;
this.appToPack = hashMap;
}
public FlrConfig() {
this.flrs = new FlrDef[0];
this.appToPack = new HashMap();
this.load();
}
public static class FlrDef {
public final String ip;
public final int port;
public URL getURL() {
try {
return new URL("http", this.ip, this.port, "/flr/");
}
catch (MalformedURLException malformedURLException) {
malformedURLException.printStackTrace();
return null;
}
}
public int hashCode() {
int n = 1;
int n2 = 0;
if (this.ip != null) {
n2 = this.ip.hashCode();
}
n = 31 * n + n2;
n = 31 * n + this.port;
return n;
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null) {
return false;
}
if (this.getClass() != object.getClass()) {
return false;
}
FlrDef flrDef = (FlrDef)object;
if (this.ip == null ? flrDef.ip != null : !this.ip.equals(flrDef.ip)) {
return false;
}
return this.port == flrDef.port;
}
public FlrDef(String string, int n) {
this.ip = string;
this.port = n;
}
}
}
@@ -0,0 +1,23 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.license;
public class FlrException
extends RuntimeException {
public FlrException() {
}
public FlrException(String string) {
super(string);
}
public FlrException(Throwable throwable) {
super(throwable);
}
public FlrException(String string, Throwable throwable) {
super(string, throwable);
}
}
@@ -0,0 +1,175 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Base64
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
*/
package com.tridium.sys.license;
import com.tridium.sys.Nre;
import com.tridium.sys.license.CertificateFile;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.NFeature;
import com.tridium.sys.license.NLicenseManager;
import java.security.PublicKey;
import java.util.Properties;
import javax.baja.license.LicenseDatabaseException;
import javax.baja.nre.util.Base64;
import javax.baja.util.Version;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
public abstract class LicenseFile {
protected String error;
protected String hostId;
protected String vendor;
protected long generated;
protected long expiration;
protected abstract XElem getRoot() throws Exception;
protected abstract boolean isLicenseHostIdValid();
public void load(NLicenseManager nLicenseManager) {
try {
XElem[] xElemArray;
if (Nre.getHostId() == null) {
this.error = "HostId not supported";
return;
}
XElem xElem = this.getRoot();
if (xElem.qname().equals("license")) {
this.load(nLicenseManager, xElem);
return;
}
if (xElem.qname().equals("licenses") && (xElemArray = xElem.elems("license")).length > 0) {
int n = 0;
while (n < xElemArray.length) {
this.load(nLicenseManager, xElemArray[n]);
++n;
}
return;
}
throw new XException("Missing <license> element", xElem);
}
catch (XException xException) {
this.error = "Invalid XML: " + xException.getMessage();
}
catch (Throwable throwable) {
this.error = throwable.toString();
}
}
private final void load(NLicenseManager nLicenseManager, XElem xElem) throws Exception {
Object object;
Object object2;
this.vendor = xElem.get("vendor");
CertificateFile certificateFile = nLicenseManager.getCertificate(this.vendor);
PublicKey publicKey = certificateFile.publicKey;
XElem xElem2 = xElem.elem("signature");
if (xElem2 == null) {
throw new XException("Missing signature element", xElem);
}
byte[] byArray = Base64.decode((String)xElem2.string());
this.hostId = xElem.get("hostId");
if (!this.isLicenseHostIdValid()) {
if (this.error == null) {
this.error = "HostId does not match";
}
return;
}
long l = System.currentTimeMillis();
this.generated = LicenseUtil.parseDate(xElem.get("generated"));
if (l < this.generated - 86400000L) {
this.error = "Current date is earlier than license generated date";
return;
}
this.expiration = LicenseUtil.parseDate(xElem.get("expiration"));
if (l > this.expiration) {
this.error = "License file is expired";
return;
}
String string = xElem.get("vendor");
if (string != null && string.equalsIgnoreCase("Tridium")) {
object2 = new Version(xElem.get("version"));
object = new Version("3.8");
if (((Version)object2).major() != ((Version)object).major() || ((Version)object2).minor() < ((Version)object).minor()) {
this.error = "License for older version: " + object2 + " < " + object;
return;
}
}
xElem.removeContent((XContent)xElem2);
object2 = LicenseUtil.encode(xElem);
if (!LicenseUtil.verify((byte[])object2, byArray, publicKey)) {
this.error = "Invalid signature";
return;
}
object = xElem.elems("feature");
int n = 0;
while (n < ((Object)object).length) {
try {
this.loadFeature(nLicenseManager, (XElem)object[n]);
}
catch (LicenseDatabaseException licenseDatabaseException) {
this.error = licenseDatabaseException.getMessage();
throw licenseDatabaseException;
}
catch (Throwable throwable) {
System.out.println("Invalid feature in " + this.getLicenseName() + " [line " + object[n].line() + ']');
System.out.println(" " + throwable);
}
++n;
}
}
private final void loadFeature(NLicenseManager nLicenseManager, XElem xElem) throws Exception {
String string = xElem.get("name");
long l = Long.MAX_VALUE;
String string2 = xElem.get("expiration", null);
if (string2 != null) {
l = LicenseUtil.parseDate(string2);
}
if (this.expiration < l) {
l = this.expiration;
}
NFeature nFeature = new NFeature(this.vendor, string, l);
int n = 0;
while (n < xElem.attrSize()) {
String string3 = xElem.attrName(n);
String string4 = xElem.attrValue(n);
if (!string3.equals("name") && !string3.equals("expiration")) {
if (nFeature.props == NFeature.noProps) {
nFeature.props = new Properties();
}
nFeature.props.put(string3, string4);
}
++n;
}
nLicenseManager.addFeature(nFeature);
}
protected abstract String getLicenseName();
public boolean isValid() {
boolean bl = false;
if (this.error == null) {
bl = true;
}
return bl;
}
public String toString() {
if (this.isValid()) {
return this.getLicenseName() + " <" + this.vendor + "> [expires: " + LicenseUtil.formatDate(this.expiration) + "] {valid}";
}
return this.getLicenseName() + " {invalid: " + this.error + '}';
}
LicenseFile() {
}
}
@@ -0,0 +1,592 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XText
*/
package com.tridium.sys.license;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.KeyFactory;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.StringTokenizer;
import javax.baja.license.LicenseException;
import javax.baja.nre.util.TextUtil;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XText;
public class LicenseUtil {
private static PublicKey masterPublicKey;
private static byte[] masterPublicKeyData;
public static String toKey(String string, String string2) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(TextUtil.toLowerCase((String)string)).append(':').append(TextUtil.toLowerCase((String)string2));
return stringBuffer.toString();
}
public static String[] parseList(String string) throws LicenseException {
ArrayList<String> arrayList = new ArrayList<String>();
StringTokenizer stringTokenizer = new StringTokenizer(string, ";");
while (stringTokenizer.hasMoreTokens()) {
arrayList.add(stringTokenizer.nextToken().trim());
}
return arrayList.toArray(new String[arrayList.size()]);
}
public static String formatDate(long l) {
if (l == Long.MAX_VALUE) {
return "never";
}
return new SimpleDateFormat("yyyy-MM-dd").format(new Date(l));
}
public static long parseDate(String string) throws LicenseException {
if (string.equalsIgnoreCase("never")) {
return Long.MAX_VALUE;
}
try {
StringTokenizer stringTokenizer = new StringTokenizer(string, "- ");
int n = Integer.parseInt(stringTokenizer.nextToken()) - 1900;
int n2 = Integer.parseInt(stringTokenizer.nextToken()) - 1;
int n3 = Integer.parseInt(stringTokenizer.nextToken());
Date date = new GregorianCalendar(n + 1900, n2, n3, 23, 59).getTime();
return date.getTime();
}
catch (Exception exception) {
throw new LicenseException("Invalid expiration format YYYY-MM-DD: " + string);
}
}
public static byte[] encode(XElem xElem) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
LicenseUtil.encode((OutputStream)byteArrayOutputStream, xElem);
byteArrayOutputStream.flush();
return byteArrayOutputStream.toByteArray();
}
catch (Exception exception) {
throw new IllegalStateException();
}
}
private static final void encode(OutputStream outputStream, XElem xElem) throws IOException {
LicenseUtil.encode(outputStream, "<");
LicenseUtil.encode(outputStream, xElem.qname());
int n = 0;
while (n < xElem.attrSize()) {
LicenseUtil.encode(outputStream, " ");
LicenseUtil.encode(outputStream, xElem.attrName(n));
LicenseUtil.encode(outputStream, "=\"");
LicenseUtil.encode(outputStream, xElem.attrValue(n));
LicenseUtil.encode(outputStream, "\"");
++n;
}
LicenseUtil.encode(outputStream, ">\n");
n = 0;
while (n < xElem.contentSize()) {
XContent xContent = xElem.content(n);
if (xContent instanceof XElem) {
LicenseUtil.encode(outputStream, (XElem)xContent);
} else {
LicenseUtil.encode(outputStream, ((XText)xContent).string());
LicenseUtil.encode(outputStream, "\n");
}
++n;
}
LicenseUtil.encode(outputStream, "</");
LicenseUtil.encode(outputStream, xElem.qname());
LicenseUtil.encode(outputStream, ">\n");
}
private static final void encode(OutputStream outputStream, String string) throws IOException {
int n = 0;
while (n < string.length()) {
outputStream.write(string.charAt(n));
++n;
}
}
public static boolean verify(byte[] byArray, byte[] byArray2, byte[] byArray3) throws Exception {
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(byArray3);
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec);
return LicenseUtil.verify(byArray, byArray2, publicKey);
}
public static boolean verify(byte[] byArray, byte[] byArray2, PublicKey publicKey) throws Exception {
Signature signature = Signature.getInstance("DSA");
signature.initVerify(publicKey);
signature.update(byArray);
return signature.verify(byArray2);
}
static PublicKey toPublicKey(byte[] byArray) throws Exception {
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(byArray);
KeyFactory keyFactory = KeyFactory.getInstance("DSA");
return keyFactory.generatePublic(x509EncodedKeySpec);
}
static PublicKey getMasterPublicKey() throws Exception {
if (masterPublicKey == null) {
masterPublicKey = LicenseUtil.toPublicKey(masterPublicKeyData);
}
return masterPublicKey;
}
static {
byte[] byArray = new byte[444];
byArray[0] = 48;
byArray[1] = -126;
byArray[2] = 1;
byArray[3] = -72;
byArray[4] = 48;
byArray[5] = -126;
byArray[6] = 1;
byArray[7] = 44;
byArray[8] = 6;
byArray[9] = 7;
byArray[10] = 42;
byArray[11] = -122;
byArray[12] = 72;
byArray[13] = -50;
byArray[14] = 56;
byArray[15] = 4;
byArray[16] = 1;
byArray[17] = 48;
byArray[18] = -126;
byArray[19] = 1;
byArray[20] = 31;
byArray[21] = 2;
byArray[22] = -127;
byArray[23] = -127;
byArray[25] = -3;
byArray[26] = 127;
byArray[27] = 83;
byArray[28] = -127;
byArray[29] = 29;
byArray[30] = 117;
byArray[31] = 18;
byArray[32] = 41;
byArray[33] = 82;
byArray[34] = -33;
byArray[35] = 74;
byArray[36] = -100;
byArray[37] = 46;
byArray[38] = -20;
byArray[39] = -28;
byArray[40] = -25;
byArray[41] = -10;
byArray[42] = 17;
byArray[43] = -73;
byArray[44] = 82;
byArray[45] = 60;
byArray[46] = -17;
byArray[47] = 68;
byArray[49] = -61;
byArray[50] = 30;
byArray[51] = 63;
byArray[52] = -128;
byArray[53] = -74;
byArray[54] = 81;
byArray[55] = 38;
byArray[56] = 105;
byArray[57] = 69;
byArray[58] = 93;
byArray[59] = 64;
byArray[60] = 34;
byArray[61] = 81;
byArray[62] = -5;
byArray[63] = 89;
byArray[64] = 61;
byArray[65] = -115;
byArray[66] = 88;
byArray[67] = -6;
byArray[68] = -65;
byArray[69] = -59;
byArray[70] = -11;
byArray[71] = -70;
byArray[72] = 48;
byArray[73] = -10;
byArray[74] = -53;
byArray[75] = -101;
byArray[76] = 85;
byArray[77] = 108;
byArray[78] = -41;
byArray[79] = -127;
byArray[80] = 59;
byArray[81] = -128;
byArray[82] = 29;
byArray[83] = 52;
byArray[84] = 111;
byArray[85] = -14;
byArray[86] = 102;
byArray[87] = 96;
byArray[88] = -73;
byArray[89] = 107;
byArray[90] = -103;
byArray[91] = 80;
byArray[92] = -91;
byArray[93] = -92;
byArray[94] = -97;
byArray[95] = -97;
byArray[96] = -24;
byArray[97] = 4;
byArray[98] = 123;
byArray[99] = 16;
byArray[100] = 34;
byArray[101] = -62;
byArray[102] = 79;
byArray[103] = -69;
byArray[104] = -87;
byArray[105] = -41;
byArray[106] = -2;
byArray[107] = -73;
byArray[108] = -58;
byArray[109] = 27;
byArray[110] = -8;
byArray[111] = 59;
byArray[112] = 87;
byArray[113] = -25;
byArray[114] = -58;
byArray[115] = -88;
byArray[116] = -90;
byArray[117] = 21;
byArray[118] = 15;
byArray[119] = 4;
byArray[120] = -5;
byArray[121] = -125;
byArray[122] = -10;
byArray[123] = -45;
byArray[124] = -59;
byArray[125] = 30;
byArray[126] = -61;
byArray[127] = 2;
byArray[128] = 53;
byArray[129] = 84;
byArray[130] = 19;
byArray[131] = 90;
byArray[132] = 22;
byArray[133] = -111;
byArray[134] = 50;
byArray[135] = -10;
byArray[136] = 117;
byArray[137] = -13;
byArray[138] = -82;
byArray[139] = 43;
byArray[140] = 97;
byArray[141] = -41;
byArray[142] = 42;
byArray[143] = -17;
byArray[144] = -14;
byArray[145] = 34;
byArray[146] = 3;
byArray[147] = 25;
byArray[148] = -99;
byArray[149] = -47;
byArray[150] = 72;
byArray[151] = 1;
byArray[152] = -57;
byArray[153] = 2;
byArray[154] = 21;
byArray[156] = -105;
byArray[157] = 96;
byArray[158] = 80;
byArray[159] = -113;
byArray[160] = 21;
byArray[161] = 35;
byArray[162] = 11;
byArray[163] = -52;
byArray[164] = -78;
byArray[165] = -110;
byArray[166] = -71;
byArray[167] = -126;
byArray[168] = -94;
byArray[169] = -21;
byArray[170] = -124;
byArray[171] = 11;
byArray[172] = -16;
byArray[173] = 88;
byArray[174] = 28;
byArray[175] = -11;
byArray[176] = 2;
byArray[177] = -127;
byArray[178] = -127;
byArray[180] = -9;
byArray[181] = -31;
byArray[182] = -96;
byArray[183] = -123;
byArray[184] = -42;
byArray[185] = -101;
byArray[186] = 61;
byArray[187] = -34;
byArray[188] = -53;
byArray[189] = -68;
byArray[190] = -85;
byArray[191] = 92;
byArray[192] = 54;
byArray[193] = -72;
byArray[194] = 87;
byArray[195] = -71;
byArray[196] = 121;
byArray[197] = -108;
byArray[198] = -81;
byArray[199] = -69;
byArray[200] = -6;
byArray[201] = 58;
byArray[202] = -22;
byArray[203] = -126;
byArray[204] = -7;
byArray[205] = 87;
byArray[206] = 76;
byArray[207] = 11;
byArray[208] = 61;
byArray[209] = 7;
byArray[210] = -126;
byArray[211] = 103;
byArray[212] = 81;
byArray[213] = 89;
byArray[214] = 87;
byArray[215] = -114;
byArray[216] = -70;
byArray[217] = -44;
byArray[218] = 89;
byArray[219] = 79;
byArray[220] = -26;
byArray[221] = 113;
byArray[222] = 7;
byArray[223] = 16;
byArray[224] = -127;
byArray[225] = -128;
byArray[226] = -76;
byArray[227] = 73;
byArray[228] = 22;
byArray[229] = 113;
byArray[230] = 35;
byArray[231] = -24;
byArray[232] = 76;
byArray[233] = 40;
byArray[234] = 22;
byArray[235] = 19;
byArray[236] = -73;
byArray[237] = -49;
byArray[238] = 9;
byArray[239] = 50;
byArray[240] = -116;
byArray[241] = -56;
byArray[242] = -90;
byArray[243] = -31;
byArray[244] = 60;
byArray[245] = 22;
byArray[246] = 122;
byArray[247] = -117;
byArray[248] = 84;
byArray[249] = 124;
byArray[250] = -115;
byArray[251] = 40;
byArray[252] = -32;
byArray[253] = -93;
byArray[254] = -82;
byArray[255] = 30;
byArray[256] = 43;
byArray[257] = -77;
byArray[258] = -90;
byArray[259] = 117;
byArray[260] = -111;
byArray[261] = 110;
byArray[262] = -93;
byArray[263] = 127;
byArray[264] = 11;
byArray[265] = -6;
byArray[266] = 33;
byArray[267] = 53;
byArray[268] = 98;
byArray[269] = -15;
byArray[270] = -5;
byArray[271] = 98;
byArray[272] = 122;
byArray[273] = 1;
byArray[274] = 36;
byArray[275] = 59;
byArray[276] = -52;
byArray[277] = -92;
byArray[278] = -15;
byArray[279] = -66;
byArray[280] = -88;
byArray[281] = 81;
byArray[282] = -112;
byArray[283] = -119;
byArray[284] = -88;
byArray[285] = -125;
byArray[286] = -33;
byArray[287] = -31;
byArray[288] = 90;
byArray[289] = -27;
byArray[290] = -97;
byArray[291] = 6;
byArray[292] = -110;
byArray[293] = -117;
byArray[294] = 102;
byArray[295] = 94;
byArray[296] = -128;
byArray[297] = 123;
byArray[298] = 85;
byArray[299] = 37;
byArray[300] = 100;
byArray[301] = 1;
byArray[302] = 76;
byArray[303] = 59;
byArray[304] = -2;
byArray[305] = -49;
byArray[306] = 73;
byArray[307] = 42;
byArray[308] = 3;
byArray[309] = -127;
byArray[310] = -123;
byArray[312] = 2;
byArray[313] = -127;
byArray[314] = -127;
byArray[316] = -117;
byArray[317] = -24;
byArray[318] = 19;
byArray[319] = 70;
byArray[320] = 80;
byArray[321] = -13;
byArray[322] = -91;
byArray[323] = 91;
byArray[324] = 33;
byArray[325] = -33;
byArray[326] = 99;
byArray[327] = -67;
byArray[328] = 97;
byArray[329] = -80;
byArray[330] = 1;
byArray[331] = -34;
byArray[332] = -33;
byArray[333] = 25;
byArray[334] = -80;
byArray[335] = 27;
byArray[336] = 121;
byArray[337] = -11;
byArray[338] = 71;
byArray[339] = 26;
byArray[340] = -70;
byArray[341] = -126;
byArray[342] = -85;
byArray[343] = -95;
byArray[344] = -106;
byArray[345] = -84;
byArray[346] = 45;
byArray[347] = -73;
byArray[348] = -9;
byArray[349] = 71;
byArray[350] = -87;
byArray[351] = -43;
byArray[352] = 113;
byArray[353] = 70;
byArray[354] = -59;
byArray[355] = -24;
byArray[356] = -122;
byArray[357] = 31;
byArray[358] = 58;
byArray[359] = 100;
byArray[360] = 3;
byArray[361] = -95;
byArray[362] = 91;
byArray[363] = -27;
byArray[364] = -104;
byArray[365] = -99;
byArray[366] = -119;
byArray[367] = 16;
byArray[368] = -42;
byArray[369] = 85;
byArray[370] = -36;
byArray[371] = -67;
byArray[372] = -102;
byArray[373] = -52;
byArray[374] = 78;
byArray[375] = -93;
byArray[376] = -95;
byArray[377] = 94;
byArray[378] = 67;
byArray[379] = 53;
byArray[380] = -34;
byArray[381] = 13;
byArray[382] = -13;
byArray[383] = 72;
byArray[384] = -57;
byArray[385] = -115;
byArray[386] = 82;
byArray[387] = 56;
byArray[388] = 82;
byArray[389] = 60;
byArray[390] = -23;
byArray[391] = 98;
byArray[392] = 113;
byArray[393] = -128;
byArray[394] = -56;
byArray[395] = -105;
byArray[396] = 81;
byArray[397] = -4;
byArray[398] = 63;
byArray[399] = -75;
byArray[400] = 81;
byArray[401] = 3;
byArray[402] = 38;
byArray[403] = 38;
byArray[404] = 103;
byArray[405] = -48;
byArray[406] = -33;
byArray[407] = -108;
byArray[408] = -128;
byArray[409] = -1;
byArray[410] = 25;
byArray[411] = 83;
byArray[412] = -112;
byArray[413] = -61;
byArray[414] = 57;
byArray[415] = 84;
byArray[416] = 68;
byArray[417] = -94;
byArray[418] = -24;
byArray[419] = 15;
byArray[420] = -80;
byArray[421] = -44;
byArray[422] = -106;
byArray[423] = -19;
byArray[424] = 55;
byArray[425] = 5;
byArray[426] = 14;
byArray[427] = 40;
byArray[428] = 75;
byArray[429] = 35;
byArray[430] = 42;
byArray[431] = -17;
byArray[432] = 47;
byArray[433] = 53;
byArray[434] = -15;
byArray[435] = 77;
byArray[436] = 56;
byArray[437] = -106;
byArray[438] = -63;
byArray[439] = 100;
byArray[440] = -11;
byArray[441] = -96;
byArray[442] = -114;
byArray[443] = -106;
masterPublicKeyData = byArray;
}
}
@@ -0,0 +1,113 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.license;
import com.tridium.sys.license.LicenseUtil;
import java.util.Properties;
import javax.baja.license.Feature;
import javax.baja.license.FeatureLicenseExpiredException;
import javax.baja.license.FeatureNotLicensedException;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Clock;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class NFeature
implements Feature {
static Properties noProps = new Properties();
final String key;
final String vendorName;
final String featureName;
long expiration;
Properties props;
public String getVendorName() {
return this.vendorName;
}
public String getFeatureName() {
return this.featureName;
}
public boolean isExpired() {
boolean bl = false;
if (this.expiration < Clock.millis()) {
bl = true;
}
return bl;
}
public void check() throws FeatureNotLicensedException {
if (this.isExpired()) {
throw new FeatureLicenseExpiredException(this.toString());
}
}
public long getExpiration() {
return this.expiration;
}
public String[] list() {
return this.props.keySet().toArray(new String[this.props.size()]);
}
public String get(String string) {
return this.props.getProperty(string);
}
public String get(String string, String string2) {
return this.props.getProperty(string, string2);
}
public boolean getb(String string, boolean bl) {
String string2 = this.props.getProperty(string);
if (string2 == null) {
return bl;
}
if ((string2 = TextUtil.toLowerCase((String)string2)).equals("true")) {
return true;
}
if (string2.equals("false")) {
return false;
}
throw new IllegalStateException("Invalid boolean " + string2);
}
public int geti(String string, int n) {
String string2 = this.props.getProperty(string);
if (string2 == null) {
return n;
}
return Integer.parseInt(string2);
}
public String toString() {
String string = this.expiration == Long.MAX_VALUE ? "never" : LicenseUtil.formatDate(this.expiration);
if (this.isExpired()) {
return this.key + " [EXPIRED: " + string + ']';
}
return this.key + " [expires: " + string + ']';
}
void merge(NFeature nFeature) {
this.expiration = Math.max(this.expiration, nFeature.expiration);
}
private final /* synthetic */ void this() {
this.props = noProps;
}
NFeature(String string, String string2, long l) {
this.this();
this.key = LicenseUtil.toKey(string, string2);
this.vendorName = string;
this.featureName = string2;
this.expiration = l;
}
}
@@ -0,0 +1,286 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.SortUtil
*/
package com.tridium.sys.license;
import com.tridium.sys.Nre;
import com.tridium.sys.license.Brand;
import com.tridium.sys.license.CertificateFile;
import com.tridium.sys.license.FloatingLicenseManager;
import com.tridium.sys.license.FlrConfig;
import com.tridium.sys.license.LicenseFile;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.NFeature;
import com.tridium.sys.license.NodeLockedLicenseManager;
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import javax.baja.license.Feature;
import javax.baja.license.FeatureNotLicensedException;
import javax.baja.license.LicenseDatabaseException;
import javax.baja.license.LicenseManager;
import javax.baja.log.Log;
import javax.baja.nre.util.SortUtil;
import javax.baja.spy.Spy;
import javax.baja.spy.SpyWriter;
import javax.baja.sys.Sys;
import javax.baja.util.Lexicon;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public abstract class NLicenseManager
implements LicenseManager {
protected static final Log log = Log.getLog("sys.license");
final String TRIDIUM_BRAND_KEY;
protected Lexicon lex;
private HashMap features;
private CertificateFile[] certificates;
private LicenseFile[] licenses;
private String fatalLicenseFault;
public static NLicenseManager make() {
NLicenseManager nLicenseManager = new NodeLockedLicenseManager();
if (Nre.args == null || Nre.args.parameters.length == 0) {
return nLicenseManager;
}
FlrConfig flrConfig = new FlrConfig();
if (flrConfig.exists()) {
if (flrConfig.isValid()) {
String string = Nre.args.getOption("pack");
if (string == null && (string = flrConfig.getPackName(Nre.args.parameters[0])) == null) {
log.warning("No license pack is mapped for app '" + FlrConfig.aliasApp(Nre.args.parameters[0]) + "'. Looking for a node-locked license.");
} else {
nLicenseManager = new FloatingLicenseManager(flrConfig, string);
}
} else {
log.error("flrclient.xml file exists, but is not valid: { " + flrConfig + " }. Looking for a node-locked license.");
}
}
return nLicenseManager;
}
public Feature getFeature(String string, String string2) throws FeatureNotLicensedException, LicenseDatabaseException {
if (this.fatalLicenseFault != null) {
throw new LicenseDatabaseException(this.fatalLicenseFault);
}
String string3 = LicenseUtil.toKey(string, string2);
Feature feature = (Feature)this.features.get(string3);
if (feature == null) {
throw new FeatureNotLicensedException(string3);
}
return feature;
}
public Feature checkFeature(String string, String string2) throws FeatureNotLicensedException, LicenseDatabaseException {
if (this.fatalLicenseFault != null) {
throw new LicenseDatabaseException(this.fatalLicenseFault);
}
String string3 = LicenseUtil.toKey(string, string2);
Feature feature = (Feature)this.features.get(string3);
if (feature == null) {
throw new FeatureNotLicensedException(string3);
}
feature.check();
return feature;
}
public Feature[] getFeatures() throws LicenseDatabaseException {
if (this.fatalLicenseFault != null) {
throw new LicenseDatabaseException(this.fatalLicenseFault);
}
Object[] objectArray = this.features.values().toArray(new NFeature[this.features.size()]);
Object[] objectArray2 = new String[objectArray.length];
int n = 0;
while (n < objectArray2.length) {
objectArray2[n] = ((NFeature)objectArray[n]).key;
++n;
}
SortUtil.sort((Object[])objectArray2, (Object[])objectArray, (boolean)true);
return objectArray;
}
public final CertificateFile getCertificate(String string) throws LicenseDatabaseException {
int n = 0;
while (n < this.certificates.length) {
CertificateFile certificateFile = this.certificates[n];
if (string.equals(certificateFile.vendor)) {
if (!certificateFile.isValid()) {
throw new LicenseDatabaseException("Invalid certificate for vendor: " + string);
}
return certificateFile;
}
++n;
}
throw new LicenseDatabaseException("No certificate for vendor: " + string);
}
protected final void setFatalLicenseFault(String string) {
this.fatalLicenseFault = string;
}
protected final boolean isFatalLicenseFault() {
boolean bl = false;
if (this.fatalLicenseFault != null) {
bl = true;
}
return bl;
}
protected final CertificateFile[] getCertificates() {
return this.certificates;
}
protected final void setCertificates(CertificateFile[] certificateFileArray) {
this.certificates = certificateFileArray;
}
protected final LicenseFile[] getLicenses() {
return this.licenses;
}
protected final void setLicenses(LicenseFile[] licenseFileArray) {
this.licenses = licenseFileArray;
}
public void reload() {
this.load();
}
protected final void load() {
this.features = new HashMap();
this.setCertificates(this.loadCertificates());
this.setLicenses(this.loadLicenses());
}
protected CertificateFile[] loadCertificates() {
ArrayList<CertificateFile> arrayList = new ArrayList<CertificateFile>();
File file = new File(Sys.getBajaHome(), "certificates");
File[] fileArray = file.listFiles();
int n = 0;
while (fileArray != null && n < fileArray.length) {
if (fileArray[n].getName().toLowerCase().endsWith(".certificate")) {
CertificateFile certificateFile = new CertificateFile(fileArray[n]);
certificateFile.load(this);
arrayList.add(certificateFile);
}
++n;
}
return arrayList.toArray(new CertificateFile[arrayList.size()]);
}
protected abstract LicenseFile[] loadLicenses();
protected void addFeature(NFeature nFeature) throws LicenseDatabaseException {
String string = nFeature.key;
NFeature nFeature2 = (NFeature)this.features.get(string);
if (nFeature2 != null) {
if (this.TRIDIUM_BRAND_KEY.equals(string)) {
this.fatalLicenseFault = "Cannot have multiple branded licenses";
throw new LicenseDatabaseException(this.fatalLicenseFault);
}
nFeature2.merge(nFeature);
} else {
this.features.put(nFeature.key, nFeature);
}
}
public void dump() {
PrintWriter printWriter = new PrintWriter(System.out);
this.dump(printWriter);
printWriter.flush();
}
public void dump(PrintWriter printWriter) {
printWriter.println("");
printWriter.println("Niagara Licensing");
printWriter.println("HostId=" + Nre.getHostId());
printWriter.println("");
printWriter.println("Certificates");
if (this.certificates.length == 0) {
printWriter.println(" none");
}
int n = 0;
while (n < this.certificates.length) {
printWriter.println(" " + this.certificates[n]);
++n;
}
printWriter.println("");
printWriter.print("Licenses ");
printWriter.println(this instanceof NodeLockedLicenseManager ? "(node-locked)" : "(floating)");
if (this.licenses.length == 0) {
printWriter.println(" none");
}
n = 0;
while (n < this.licenses.length) {
printWriter.println(" " + this.licenses[n]);
++n;
}
if (this.fatalLicenseFault != null) {
return;
}
printWriter.println("");
printWriter.println("Features");
Feature[] featureArray = this.getFeatures();
if (featureArray.length == 0) {
printWriter.println(" none");
}
int n2 = 0;
while (n2 < featureArray.length) {
NFeature nFeature = (NFeature)featureArray[n2];
printWriter.println(" " + nFeature);
String[] stringArray = nFeature.list();
int n3 = 0;
while (n3 < stringArray.length) {
printWriter.println(" " + stringArray[n3] + '=' + nFeature.get(stringArray[n3]));
++n3;
}
++n2;
}
try {
printWriter.println("");
printWriter.println("Brand");
printWriter.println(" brandId = " + Brand.getBrandId());
printWriter.println(" accept.station.in = " + Brand.getAcceptStationInString());
printWriter.println(" accept.station.out = " + Brand.getAcceptStationOutString());
printWriter.println(" accept.wb.in = " + Brand.getAcceptWbInString());
printWriter.println(" accept.wb.out = " + Brand.getAcceptWbOutString());
}
catch (Exception exception) {}
}
public void postInit() {
this.lex = Lexicon.make("baja");
this.load();
if (Nre.spySysManagers.find("licenseManager") != null) {
Nre.spySysManagers.remove("licenseManager");
}
Nre.spySysManagers.add("licenseManager", new Page());
}
private final /* synthetic */ void this() {
this.TRIDIUM_BRAND_KEY = LicenseUtil.toKey("tridium", "brand");
this.fatalLicenseFault = null;
}
protected NLicenseManager() {
this.this();
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Page
extends Spy {
public void write(SpyWriter spyWriter) throws Exception {
spyWriter.print("<pre>");
NLicenseManager.this.dump(spyWriter);
spyWriter.print("</pre>");
}
}
}
@@ -0,0 +1,64 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XElem
* javax.baja.xml.XParser
*/
package com.tridium.sys.license;
import com.tridium.sys.Nre;
import com.tridium.sys.license.LicenseFile;
import com.tridium.sys.license.NLicenseManager;
import com.tridium.sys.license.dom.LicenseDatabase;
import java.io.File;
import java.util.ArrayList;
import javax.baja.sys.Sys;
import javax.baja.xml.XElem;
import javax.baja.xml.XParser;
public class NodeLockedLicenseManager
extends NLicenseManager {
protected LicenseFile[] loadLicenses() {
LicenseDatabase.LOCAL_INSTANCE.getHostIds();
ArrayList<NodeLockedLicense> arrayList = new ArrayList<NodeLockedLicense>();
File file = new File(Sys.getBajaHome(), "licenses");
File[] fileArray = file.listFiles();
int n = 0;
while (fileArray != null && n < fileArray.length) {
if (fileArray[n].getName().toLowerCase().endsWith(".license")) {
NodeLockedLicense nodeLockedLicense = new NodeLockedLicense(fileArray[n]);
nodeLockedLicense.load(this);
arrayList.add(nodeLockedLicense);
}
++n;
}
return arrayList.toArray(new LicenseFile[arrayList.size()]);
}
private static class NodeLockedLicense
extends LicenseFile {
File file;
protected String getLicenseName() {
return this.file.getName();
}
protected XElem getRoot() throws Exception {
return XParser.make((File)this.file).parse();
}
protected boolean isLicenseHostIdValid() {
boolean bl = false;
if (this.hostId.equals(Nre.getHostId()) || this.hostId.equals("*")) {
bl = true;
}
return bl;
}
public NodeLockedLicense(File file) {
this.file = file;
}
}
}
@@ -0,0 +1,248 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XParser
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license;
import com.tridium.sys.Nre;
import com.tridium.sys.license.FlrException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.StringTokenizer;
import javax.baja.data.BIDataValue;
import javax.baja.sys.BFacets;
import javax.baja.sys.BRelTime;
import javax.baja.sys.Clock;
import javax.baja.util.Lexicon;
import javax.baja.util.Version;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XParser;
import javax.baja.xml.XWriter;
public class XFlrMsg {
private static final Lexicon lex = Lexicon.make("baja");
private String type;
private XChallenge challenge;
private XElem payload;
private BFacets metadata;
public static XFlrMsg make(InputStream inputStream) throws Exception {
return new XFlrMsg(XParser.make((InputStream)inputStream).parse());
}
public static XFlrMsg error(Exception exception) {
XFlrMsg xFlrMsg = new XFlrMsg("error");
XElem xElem = new XElem("error").addContent((XContent)new XElem("exception").addText(exception == null ? "?" : exception.toString()));
if (exception != null && exception.getCause() != null) {
xElem.addContent((XContent)new XElem("cause").addText(exception.getCause().toString()));
}
xFlrMsg.setPayload(xElem);
return xFlrMsg;
}
public String getType() {
return this.type;
}
public void setType(String string) {
this.type = string;
}
public XChallenge getChallenge() {
return this.challenge;
}
public void setChallenge(XChallenge xChallenge) {
this.challenge = xChallenge;
}
public BFacets getMetadata() {
return this.metadata;
}
public XFlrMsg setMetadata(String string, BIDataValue bIDataValue) {
this.metadata = BFacets.make(this.metadata, BFacets.make(string, bIDataValue));
return this;
}
public XElem getPayload() {
return this.payload;
}
public void setPayload(XElem xElem) {
this.payload = xElem;
}
public void throwIfError() throws FlrException {
XElem xElem = this.getPayload();
if (xElem == null) {
throw new FlrException("Null payload.");
}
if (!xElem.name().equals("error")) {
return;
}
StringBuffer stringBuffer = new StringBuffer().append(xElem.elem("exception").text());
XElem xElem2 = xElem.elem("cause");
if (xElem2 != null) {
stringBuffer.append(" -- ").append(xElem2.text());
}
throw new FlrException(stringBuffer.toString());
}
public boolean isError() {
XElem xElem = this.getPayload();
boolean bl = false;
if (xElem == null || xElem.name().equals("error")) {
bl = true;
}
return bl;
}
public void write(OutputStream outputStream) throws IOException {
this.write(outputStream, false);
}
public void write(OutputStream outputStream, boolean bl) throws IOException {
XWriter xWriter = new XWriter(outputStream);
this.asXML().write(xWriter);
outputStream.flush();
if (bl) {
xWriter.close();
}
}
public XElem asXML() {
String string = "";
try {
string = this.metadata.encodeToString();
}
catch (Exception exception) {}
return new XElem("msg").addAttr("type", this.type).addAttr("metadata", string).addContent((XContent)this.challenge.asXML()).addContent((XContent)new XElem("payload").addContent((XContent)this.payload.copy()));
}
public void dump() {
this.asXML().dump();
}
public XFlrMsg(String string) {
this.type = string;
this.challenge = new XChallenge();
this.payload = new XElem("empty");
}
public XFlrMsg(XElem xElem) {
this.type = xElem.get("type", "");
this.challenge = new XChallenge(xElem.elem("challenge"));
this.metadata = BFacets.DEFAULT;
try {
this.metadata = BFacets.make(xElem.get("metadata"));
}
catch (Exception exception) {}
this.payload = xElem.elem("payload").elem(0);
}
public static final class XChallenge {
private Version version;
private String hostid;
private long timestamp;
private String nonce;
private String cksum;
public final String getHostid() {
return this.hostid;
}
public final long getTimestamp() {
return this.timestamp;
}
public final String getCksum() {
return this.cksum;
}
public final void setCksum(String string) {
this.cksum = string;
}
public final Version getVersion() {
return this.version;
}
public final void setVersion(Version version) {
this.version = version;
}
public final int[] parseNonce() {
try {
StringTokenizer stringTokenizer = new StringTokenizer(this.nonce, ":");
int[] nArray = new int[stringTokenizer.countTokens()];
int n = 0;
while (n < nArray.length) {
nArray[n] = Integer.parseInt(stringTokenizer.nextToken());
++n;
}
return nArray;
}
catch (Exception exception) {
return new int[]{1, 2, 3, 4, 5};
}
}
public final XElem asXML() {
return new XElem("challenge").addAttr("version", this.version.toString()).addAttr("hostid", this.hostid).addAttr("timestamp", Long.toString(this.timestamp)).addAttr("nonce", this.nonce).addAttr("cksum", this.cksum);
}
public final void throwIfTooOld(BRelTime bRelTime) throws FlrException {
long l = Clock.millis();
long l2 = bRelTime.getMillis();
if (this.getTimestamp() < l - l2 || this.getTimestamp() > l + l2) {
throw new FlrException(lex.getText("flm.msg.errGracePeriod"));
}
}
public XChallenge() {
this.version = Version.ZERO;
this.hostid = Nre.getHostId();
this.timestamp = Clock.millis();
Random random = new Random();
int n = random.nextInt(20) + 5;
StringBuffer stringBuffer = new StringBuffer();
int n2 = 0;
while (n2 < n) {
if (n2 > 0) {
stringBuffer.append(":");
}
stringBuffer.append(random.nextInt());
++n2;
}
this.nonce = stringBuffer.toString();
try {
MessageDigest messageDigest = MessageDigest.getInstance("md5");
this.cksum = new BigInteger(messageDigest.digest(this.nonce.getBytes())).toString(16);
}
catch (NoSuchAlgorithmException noSuchAlgorithmException) {
this.cksum = "F00BA5";
}
}
XChallenge(XElem xElem) {
this.version = new Version(xElem.get("version", Version.ZERO.toString()));
this.hostid = xElem.get("hostid", "");
this.timestamp = xElem.getl("timestamp", 0L);
this.nonce = xElem.get("nonce", "1:2:3:4:5");
this.cksum = xElem.get("cksum");
}
}
}
@@ -0,0 +1,273 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.CertificateSet;
import com.tridium.sys.license.dom.VendorCertificate;
import java.io.InputStream;
import java.io.OutputStream;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BFileSystem;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class CertificateDatabase
extends CertificateSet {
public static final CertificateDatabase LOCAL_INSTANCE = new LocalCertificateDatabase();
protected BDirectory certDbRoot;
static /* synthetic */ Class class$com$tridium$sys$license$dom$VendorCertificate;
static /* synthetic */ Class class$java$lang$String;
public VendorCertificate[] getCertificates() throws Exception {
Class clazz = class$com$tridium$sys$license$dom$VendorCertificate;
if (clazz == null) {
clazz = class$com$tridium$sys$license$dom$VendorCertificate = CertificateDatabase.class("[Lcom.tridium.sys.license.dom.VendorCertificate;", false);
}
Array array = new Array(clazz);
BDirectory bDirectory = (BDirectory)this.getSpace().findFile(this.getRootPath());
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("certificate".equals(bIFileArray[n].getExtension())) {
array.add((Object)VendorCertificate.make(bIFileArray[n]));
break;
}
++n;
}
}
return (VendorCertificate[])array.trim();
}
public boolean add(VendorCertificate vendorCertificate) throws Exception {
VendorCertificate vendorCertificate2 = this.getCertificate(vendorCertificate.getVendor());
if (vendorCertificate2 == null || vendorCertificate.getGenerated() >= vendorCertificate2.getGenerated()) {
BIFile bIFile = this.getSpace().makeFile(this.getFilePath(vendorCertificate.getVendor()));
OutputStream outputStream = bIFile.getOutputStream();
this.writeCertificate(vendorCertificate, outputStream);
try {
outputStream.close();
}
catch (Exception exception) {}
boolean bl = false;
if (vendorCertificate2 != null) {
bl = true;
}
return bl;
}
return false;
}
public boolean remove(VendorCertificate vendorCertificate) throws Exception {
return this.removeCertificate(vendorCertificate.getVendor());
}
public void clear() throws Exception {
BDirectory bDirectory = this.getSpace().makeDir(this.getRootPath(), null);
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("certificate".equals(bIFileArray[n].getExtension())) {
bIFileArray[n].delete();
}
++n;
}
}
public String[] getVendors() {
this.init();
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = CertificateDatabase.class("[Ljava.lang.String;", false);
}
Array array = new Array(clazz);
BDirectory bDirectory = (BDirectory)this.getSpace().findFile(this.getRootPath());
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("certificate".equals(bIFileArray[n].getExtension())) {
array.add((Object)bIFileArray[n].getFileName());
break;
}
++n;
}
}
return (String[])array.trim();
}
public VendorCertificate getCertificate(String string) throws Exception {
this.init();
BIFile bIFile = this.getSpace().findFile(this.getFilePath(string));
return bIFile == null ? null : VendorCertificate.make(bIFile);
}
public boolean removeCertificate(String string) throws Exception {
this.init();
BIFile bIFile = this.getSpace().findFile(this.getFilePath(string));
if (bIFile == null) {
return false;
}
bIFile.delete();
return true;
}
public void importFile(BIFile bIFile) throws Exception {
if ("lar".equals(bIFile.getExtension())) {
this.importCertificates(bIFile);
} else if ("certificate".equals(bIFile.getExtension())) {
this.add(VendorCertificate.make(bIFile));
} else {
throw new IllegalArgumentException("importFile argument must be a certificate file or license archive");
}
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void importCertificates(BIFile bIFile) throws Exception {
InputStream inputStream = bIFile.getInputStream();
try {
this.importLicenses(inputStream);
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
inputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
inputStream.close();
}
/*
* Exception decompiling
*/
public void importLicenses(InputStream var1_1) throws Exception {
/*
* 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 2[TRYBLOCK] [2 : 101->105)] 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");
}
/*
* Exception decompiling
*/
public void exportLicenses(OutputStream var1_1) throws Exception {
/*
* 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 2[TRYBLOCK] [3 : 187->191)] 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");
}
protected BFileSpace getSpace() {
return this.certDbRoot.getFileSpace();
}
protected FilePath getRootPath() {
return this.certDbRoot.getFilePath();
}
protected FilePath getFilePath(String string) {
return this.getRootPath().merge(TextUtil.capitalize((String)string) + ".certificate");
}
protected void init() {
}
protected void writeCertificate(VendorCertificate vendorCertificate, OutputStream outputStream) throws Exception {
XWriter xWriter = new XWriter(outputStream);
vendorCertificate.save(xWriter);
xWriter.flush();
}
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());
}
}
public CertificateDatabase(BDirectory bDirectory) {
this.certDbRoot = bDirectory;
}
protected CertificateDatabase() {
}
private static class LocalCertificateDatabase
extends CertificateDatabase {
public LocalCertificateDatabase() {
try {
this.certDbRoot = BFileSystem.INSTANCE.makeDir(new FilePath("!certificates"));
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException(exception);
}
}
}
}
@@ -0,0 +1,80 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.VendorCertificate;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import javax.baja.file.BDirectory;
import javax.baja.file.BIFile;
import javax.baja.nre.util.TextUtil;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class CertificateSet {
private ArrayList list;
public VendorCertificate[] getCertificates() throws Exception {
VendorCertificate[] vendorCertificateArray = new VendorCertificate[this.list.size()];
this.list.toArray(vendorCertificateArray);
return vendorCertificateArray;
}
public boolean add(VendorCertificate vendorCertificate) throws Exception {
this.list.add(vendorCertificate);
return false;
}
public boolean remove(VendorCertificate vendorCertificate) throws Exception {
return this.list.remove(vendorCertificate);
}
public void clear() throws Exception {
this.list.clear();
}
public void load(BDirectory bDirectory) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (bIFileArray != null && n < bIFileArray.length) {
BIFile bIFile = bIFileArray[n];
if (!bIFile.isDirectory() && "certificate".equals(bIFile.getExtension())) {
try {
this.add(VendorCertificate.make(bIFile));
}
catch (Exception exception) {
System.out.println("ERROR: Cannot read \"" + bIFile + '\"');
exception.printStackTrace();
}
}
++n;
}
}
public void dump() throws Exception {
this.dump(new PrintWriter(System.out));
}
public void dump(PrintWriter printWriter) throws Exception {
printWriter.println(TextUtil.getClassName(this.getClass()));
Iterator iterator = this.list.iterator();
while (iterator.hasNext()) {
((VendorCertificate)iterator.next()).dump(printWriter);
}
}
private final /* synthetic */ void this() {
this.list = new ArrayList();
}
public CertificateSet() {
this.this();
}
}
@@ -0,0 +1,215 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
* javax.baja.xml.XElem
* javax.baja.xml.XException
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.PrintWriter;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Clock;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class Feature
implements Comparable {
private final VendorLicense parent;
private final String name;
private final String key;
private XElem xml;
static /* synthetic */ Class class$java$lang$String;
static Feature make(VendorLicense vendorLicense, String string) {
if (string.equalsIgnoreCase("brand")) {
return new Brand(vendorLicense);
}
return new Feature(vendorLicense, string);
}
static String toKey(String string) {
return TextUtil.toLowerCase((String)string);
}
public VendorLicense getParent() {
return this.parent;
}
public String getKey() {
return this.key;
}
public String getName() {
return this.name;
}
public boolean isExpired() {
boolean bl = false;
if (Clock.millis() > this.getExpiration() || this.parent.isExpired()) {
bl = true;
}
return bl;
}
public long getExpiration() {
String string = this.xml.get("expiration", null);
return string == null ? Long.MAX_VALUE : LicenseUtil.parseDate(string);
}
public void setExpiration(long l) {
this.modify();
this.xml.setAttr("expiration", LicenseUtil.formatDate(l));
}
public int compareTo(Object object) {
String string = ((Feature)object).name;
if (this.name.equals("about")) {
return -1;
}
if (this.name.equals("brand")) {
return string.equals("about") ? 1 : -1;
}
return this.name.compareTo(string);
}
public String toString() {
return this.parent.getVendor() + ':' + this.getName();
}
public String get(String string) {
return this.xml.get(string, null);
}
public String get(String string, String string2) {
return this.xml.get(string, string2);
}
public boolean getb(String string, boolean bl) {
return this.xml.getb(string, bl);
}
public int geti(String string, int n) {
return this.xml.geti(string, n);
}
public String[] list() {
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = Feature.class("[Ljava.lang.String;", false);
}
Array array = new Array(clazz, this.xml.attrSize());
int n = 0;
while (n < this.xml.attrSize()) {
String string = this.xml.attrName(n);
if (!string.equals("name") && !string.equals("expiration")) {
array.add((Object)string);
}
++n;
}
return (String[])array.trim();
}
public void set(String string, String string2) {
this.xml.setAttr(string, string2);
}
public final void set(String string, boolean bl) {
this.set(string, String.valueOf(bl));
}
public final void set(String string, int n) {
this.set(string, String.valueOf(n));
}
public final void remove(String string) {
this.xml.removeAttr(string);
}
void load(XElem xElem) throws Exception {
if (!xElem.qname().equals("feature")) {
throw new XException("Root element must be <feature> element", xElem);
}
this.xml = xElem.copy();
}
XElem save() {
return this.xml.copy();
}
public void dump(PrintWriter printWriter) {
printWriter.println(" " + this.name);
printWriter.println(" expiration: " + LicenseUtil.formatDate(this.getExpiration()));
String[] stringArray = this.list();
int n = 0;
while (n < stringArray.length) {
printWriter.println(" " + TextUtil.pad((String)(stringArray[n] + ": "), (int)20) + this.get(stringArray[n]));
++n;
}
printWriter.flush();
}
public void modify() {
this.getParent().modify();
}
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());
}
}
private Feature(VendorLicense vendorLicense, String string) {
if (vendorLicense == null) {
throw new NullPointerException();
}
this.parent = vendorLicense;
this.name = string;
this.key = Feature.toKey(string);
this.xml = new XElem("feature");
this.xml.setAttr("name", string);
}
public static class Brand
extends Feature {
public String getBrandId() {
return this.get("brandId");
}
public String getStationIn() {
return this.get("accept.station.in");
}
public String getStationOut() {
return this.get("accept.station.out");
}
public String getWbIn() {
return this.get("accept.wb.in");
}
public String getWbOut() {
return this.get("accept.wb.out");
}
Brand(VendorLicense vendorLicense) {
super(vendorLicense, "brand");
}
}
}
@@ -0,0 +1,36 @@
/*
* Decompiled with CFR 0.152.
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.Feature;
import com.tridium.sys.license.dom.LicenseSet;
import com.tridium.sys.license.dom.VendorLicense;
import java.util.Iterator;
public class HostLicenseSet
extends LicenseSet {
public String getHostId() throws Exception {
Iterator iterator = this.iterator();
return iterator.hasNext() ? ((VendorLicense)iterator.next()).getHostId() : null;
}
public VendorLicense getVendorLicense(String string) throws Exception {
Iterator iterator = this.iterator();
while (iterator.hasNext()) {
VendorLicense vendorLicense = (VendorLicense)iterator.next();
if (!string.equalsIgnoreCase(vendorLicense.getVendor())) continue;
return vendorLicense;
}
return null;
}
public VendorLicense getTridiumLicense() throws Exception {
return this.getVendorLicense("tridium");
}
public Feature.Brand getBrandFeature() throws Exception {
return this.getTridiumLicense().getBrandFeature();
}
}
@@ -0,0 +1,579 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.HostLicenseSet;
import com.tridium.sys.license.dom.LicenseSet;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BFileSystem;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.log.Log;
import javax.baja.nre.util.Array;
import javax.baja.sys.BajaRuntimeException;
import javax.baja.sys.Sys;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class LicenseDatabase
extends LicenseSet {
public static final LicenseDatabase LOCAL_INSTANCE = new LocalLicenseDatabase();
protected BDirectory licenseDbRoot;
static /* synthetic */ Class class$java$lang$String;
static /* synthetic */ Class class$com$tridium$sys$license$dom$VendorLicense;
public Iterator iterator() throws Exception {
return new LicenseDatabaseIterator();
}
public boolean add(VendorLicense vendorLicense) throws Exception {
if (vendorLicense.getHostId().equals("*")) {
return false;
}
VendorLicense vendorLicense2 = this.getLicense(vendorLicense.getHostId(), vendorLicense.getVendor(), vendorLicense.getBrandId());
if (vendorLicense2 == null || vendorLicense.getGenerated() >= vendorLicense2.getGenerated()) {
BDirectory bDirectory = this.makeHostDirectory(vendorLicense.getHostId());
BIFile bIFile = this.getSpace().makeFile(bDirectory.getFilePath().merge(vendorLicense.getLicenseName() + ".license"));
OutputStream outputStream = bIFile.getOutputStream();
this.writeLicense(vendorLicense, outputStream);
try {
outputStream.close();
}
catch (Exception exception) {}
return true;
}
return false;
}
public boolean remove(VendorLicense vendorLicense) throws Exception {
return this.removeLicense(vendorLicense.getHostId(), vendorLicense.getVendor(), vendorLicense.getBrandId());
}
public void clear() throws Exception {
BDirectory bDirectory = this.getSpace().makeDir(this.getRootPath(), null);
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if (bIFileArray[n] instanceof BDirectory) {
BIFile[] bIFileArray2 = ((BDirectory)bIFileArray[n]).listFiles();
boolean bl = true;
int n2 = 0;
while (n2 < bIFileArray2.length) {
if ("license".equals(bIFileArray2[n2].getExtension())) {
bIFileArray2[n2].delete();
} else {
bl = false;
}
++n2;
}
if (bl) {
bIFileArray[n].delete();
}
}
++n;
}
}
public HostLicenseSet toHostLicenseSet(String string, String string2) throws Exception {
HostLicenseSet hostLicenseSet = null;
this.init();
BDirectory bDirectory = this.getHostDirectory(string);
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("license".equals(bIFileArray[n].getExtension())) {
VendorLicense vendorLicense = VendorLicense.make(bIFileArray[n]);
if (string2 == null || vendorLicense.getBrandId() == null || vendorLicense.getBrandId().equals(string2)) {
if (hostLicenseSet == null) {
hostLicenseSet = new HostLicenseSet();
}
if (hostLicenseSet.getVendorLicense(vendorLicense.getVendor()) != null) {
throw new RuntimeException("Duplicate licenses for same hostId and vendor: " + vendorLicense.getVendor());
}
hostLicenseSet.add(vendorLicense);
}
}
++n;
}
}
return hostLicenseSet;
}
public String[] getHostIds() {
this.init();
Class clazz = class$java$lang$String;
if (clazz == null) {
clazz = class$java$lang$String = LicenseDatabase.class("[Ljava.lang.String;", false);
}
Array array = new Array(clazz);
BDirectory bDirectory = (BDirectory)this.getSpace().findFile(this.getRootPath());
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if (bIFileArray[n] instanceof BDirectory) {
BIFile[] bIFileArray2 = ((BDirectory)bIFileArray[n]).listFiles();
int n2 = 0;
while (n2 < bIFileArray2.length) {
if ("license".equals(bIFileArray2[n2].getExtension())) {
array.add((Object)bIFileArray[n].getFileName());
break;
}
++n2;
}
}
++n;
}
}
return (String[])array.trim();
}
public VendorLicense[] getLicenses(String string) {
return this.getLicenses(string, null);
}
public VendorLicense[] getLicenses(String string, String string2) {
this.init();
String string3 = string2;
Class clazz = class$com$tridium$sys$license$dom$VendorLicense;
if (clazz == null) {
clazz = class$com$tridium$sys$license$dom$VendorLicense = LicenseDatabase.class("[Lcom.tridium.sys.license.dom.VendorLicense;", false);
}
Array array = new Array(clazz);
BDirectory bDirectory = this.getHostDirectory(string);
if (bDirectory != null) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("license".equals(bIFileArray[n].getExtension())) {
try {
VendorLicense vendorLicense = VendorLicense.make(bIFileArray[n]);
if (string3 == null || vendorLicense.getBrandId() == null || string3.equals(vendorLicense.getBrandId())) {
array.add((Object)vendorLicense);
string3 = vendorLicense.getBrandId();
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
++n;
}
}
return (VendorLicense[])array.trim();
}
public VendorLicense getLicense(String string, String string2, String string3) {
this.init();
BDirectory bDirectory = this.getHostDirectory(string);
if (bDirectory != null) {
String string4 = "tridium".equalsIgnoreCase(string2) && string3 != null ? string3 : string2;
BIFile bIFile = (BIFile)bDirectory.getNavChild(string4 + ".license");
try {
return bIFile == null ? null : VendorLicense.make(bIFile);
}
catch (Exception exception) {
exception.printStackTrace();
}
}
return null;
}
public boolean removeLicense(String string, String string2, String string3) throws Exception {
String string4;
BIFile bIFile;
BDirectory bDirectory = this.getHostDirectory(string);
if (bDirectory != null && (bIFile = (BIFile)bDirectory.getNavChild((string4 = "tridium".equalsIgnoreCase(string2) && string3 != null ? string3 : string2) + ".license")) != null) {
bIFile.delete();
if (bDirectory.listFiles().length == 0) {
bDirectory.delete();
}
return true;
}
return false;
}
public void importFile(BIFile bIFile) throws Exception {
if ("lar".equals(bIFile.getExtension())) {
this.importLicenses(bIFile);
} else if ("license".equals(bIFile.getExtension())) {
this.add(VendorLicense.make(bIFile));
} else {
throw new IllegalArgumentException("importFile argument must be a license file or license archive");
}
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void importLicenses(BIFile bIFile) throws Exception {
InputStream inputStream = bIFile.getInputStream();
try {
this.importLicenses(inputStream);
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
inputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
inputStream.close();
}
/*
* Exception decompiling
*/
public void importLicenses(InputStream var1_1) throws Exception {
/*
* 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 2[TRYBLOCK] [2 : 101->105)] 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");
}
/*
* Exception decompiling
*/
public void exportLicenses(OutputStream var1_1) throws Exception {
/*
* 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 2[TRYBLOCK] [3 : 239->243)] 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");
}
/*
* Exception decompiling
*/
public void exportLicenses(String[] var1_1, OutputStream var2_2) throws Exception {
/*
* 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 2[TRYBLOCK] [3 : 235->239)] 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");
}
protected BDirectory getHostDirectory(String string) {
return (BDirectory)this.getSpace().findFile(this.getRootPath().merge(string));
}
protected BDirectory makeHostDirectory(String string) throws Exception {
return this.getSpace().makeDir(this.getRootPath().merge(string));
}
protected BFileSpace getSpace() {
return this.licenseDbRoot.getFileSpace();
}
protected FilePath getRootPath() {
return this.licenseDbRoot.getFilePath();
}
protected void init() {
}
protected void writeLicense(VendorLicense vendorLicense, OutputStream outputStream) throws Exception {
XWriter xWriter = new XWriter(outputStream);
vendorLicense.save(xWriter);
xWriter.flush();
}
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());
}
}
public LicenseDatabase(BDirectory bDirectory) {
this.licenseDbRoot = bDirectory;
}
protected LicenseDatabase() {
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
private class LicenseDatabaseIterator
implements Iterator {
private String[] hostIds;
private int hostIdx;
private VendorLicense[] licensesForHost;
private int licenseIdx;
/*
* Unable to fully structure code
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public boolean hasNext() {
try {
while (true) {
if (this.licensesForHost != null) ** GOTO lbl13
if (this.hostIdx + 1 >= this.hostIds.length) {
this.licensesForHost = null;
this.licenseIdx = -1;
return false;
}
++this.hostIdx;
this.licensesForHost = LicenseDatabase.this.getLicenses(this.hostIds[this.hostIdx]);
this.licenseIdx = 0;
continue;
lbl13:
// 1 sources
if (this.licenseIdx < this.licensesForHost.length) {
return true;
}
this.licensesForHost = null;
this.licenseIdx = -1;
continue;
break;
}
}
catch (RuntimeException var1_1) {
throw var1_1;
}
catch (Exception var1_2) {
throw new BajaRuntimeException(var1_2);
}
}
public Object next() {
if (this.hasNext()) {
VendorLicense vendorLicense = this.licensesForHost[this.licenseIdx];
++this.licenseIdx;
return vendorLicense;
}
throw new IllegalStateException("Called next() when hasNext==false");
}
public void remove() {
throw new UnsupportedOperationException();
}
public LicenseDatabaseIterator() throws Exception {
this.hostIds = LicenseDatabase.this.getHostIds();
this.hostIdx = -1;
this.licensesForHost = null;
this.licenseIdx = -1;
}
}
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
private static class LocalLicenseDatabase
extends LicenseDatabase {
private boolean initialized;
private String brandId;
private ArrayList copyList;
protected void init() {
if (this.initialized) {
return;
}
this.initialized = true;
Log log = Log.getLog("sys.license");
try {
this.brandId = this.getBrand();
this.importDir(BFileSystem.INSTANCE.makeDir(new FilePath("!licenses")), false);
this.importDir(BFileSystem.INSTANCE.makeDir(new FilePath("!licenses/inbox")), true);
this.exportNewLicenses();
}
catch (Exception exception) {
log.error("Error initializing local license database", exception);
exception.printStackTrace();
}
}
/*
* Exception decompiling
*/
private final String getBrand() {
/*
* 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 3[TRYBLOCK] [4 : 96->99)] 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.analyseInnerClassesPass1(ClassFile.java:923)
* at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1035)
* 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");
}
protected void importDir(BDirectory bDirectory, boolean bl) throws Exception {
Log log = Log.getLog("sys.license");
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (n < bIFileArray.length) {
if ("license".equals(bIFileArray[n].getExtension())) {
VendorLicense vendorLicense = VendorLicense.make(bIFileArray[n]);
this.add(vendorLicense);
if (bl || !vendorLicense.getHostId().equals(Sys.getHostId()) && !"*".equals(vendorLicense.getHostId())) {
try {
bIFileArray[n].delete();
log.message("moved " + bIFileArray[n]);
}
catch (Exception exception) {
log.warning("error deleting " + bIFileArray[n], exception);
}
}
} else if ("lar".equals(bIFileArray[n].getExtension())) {
this.importFile(bIFileArray[n]);
try {
bIFileArray[n].delete();
log.message("imported and removed license archive " + bIFileArray[n]);
}
catch (Exception exception) {
log.warning("error deleting " + bIFileArray[n], exception);
}
}
++n;
}
}
public boolean add(VendorLicense vendorLicense) throws Exception {
boolean bl = super.add(vendorLicense);
if (!bl) {
return bl;
}
String string = vendorLicense.getSource();
if (Sys.getHostId().equals(vendorLicense.getHostId()) && ("lar".equals(string) || string.indexOf("licenses/inbox/") > 0)) {
this.copyList.add(vendorLicense);
}
if (this.brandId == null && Sys.getHostId().equals(vendorLicense.getHostId()) && vendorLicense.getBrandId() != null) {
this.brandId = vendorLicense.getBrandId();
}
return bl;
}
private final void exportNewLicenses() {
Log log = Log.getLog("sys.license");
if (this.brandId == null) {
log.error("Could not determine brand");
return;
}
Iterator iterator = this.copyList.iterator();
while (iterator.hasNext()) {
VendorLicense vendorLicense = (VendorLicense)iterator.next();
if (vendorLicense.getBrandId() != null && !vendorLicense.getBrandId().equals(this.brandId)) continue;
try {
FilePath filePath = new FilePath("!licenses/" + vendorLicense.getLicenseName() + ".license");
BIFile bIFile = BFileSystem.INSTANCE.makeFile(filePath);
log.message("LicenseDatabase is exporting new license to " + bIFile);
vendorLicense.save(bIFile);
}
catch (IOException iOException) {
log.error("LicenseDatabase could not copy license file to !licenses", iOException);
}
}
this.copyList.clear();
}
private final /* synthetic */ void this() {
this.initialized = false;
this.copyList = new ArrayList();
}
public LocalLicenseDatabase() {
this.this();
try {
this.licenseDbRoot = BFileSystem.INSTANCE.makeDir(new FilePath("!licenses/db"));
}
catch (RuntimeException runtimeException) {
throw runtimeException;
}
catch (Exception exception) {
throw new BajaRuntimeException(exception);
}
}
}
}
@@ -0,0 +1,100 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.TextUtil
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.dom.HostLicenseSet;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import javax.baja.file.BDirectory;
import javax.baja.file.BIFile;
import javax.baja.nre.util.TextUtil;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class LicenseSet {
private ArrayList list;
public Iterator iterator() throws Exception {
return this.list.iterator();
}
public boolean add(VendorLicense vendorLicense) throws Exception {
this.list.add(vendorLicense);
return false;
}
public boolean remove(VendorLicense vendorLicense) throws Exception {
return this.list.remove(vendorLicense);
}
public void clear() throws Exception {
this.list.clear();
}
public HostLicenseSet toHostLicenseSet(String string) throws Exception {
return this.toHostLicenseSet(string, null);
}
public HostLicenseSet toHostLicenseSet(String string, String string2) throws Exception {
HostLicenseSet hostLicenseSet = null;
Iterator iterator = this.iterator();
while (iterator.hasNext()) {
VendorLicense vendorLicense = (VendorLicense)iterator.next();
if (!string.equals(vendorLicense.getHostId()) || string2 != null && vendorLicense.getBrandId() != null && !vendorLicense.getBrandId().equals(string2)) continue;
if (hostLicenseSet == null) {
hostLicenseSet = new HostLicenseSet();
}
if (hostLicenseSet.getVendorLicense(vendorLicense.getVendor()) != null) {
throw new RuntimeException("Duplicate licenses for same hostId and vendor: " + vendorLicense.getVendor());
}
hostLicenseSet.add(vendorLicense);
}
return hostLicenseSet;
}
public void load(BDirectory bDirectory) {
BIFile[] bIFileArray = bDirectory.listFiles();
int n = 0;
while (bIFileArray != null && n < bIFileArray.length) {
BIFile bIFile = bIFileArray[n];
if (!bIFile.isDirectory() && "license".equals(bIFile.getExtension())) {
try {
this.add(VendorLicense.make(bIFile));
}
catch (Exception exception) {
System.out.println("ERROR: Cannot read \"" + bIFile + '\"');
exception.printStackTrace();
}
}
++n;
}
}
public void dump() throws Exception {
this.dump(new PrintWriter(System.out));
}
public void dump(PrintWriter printWriter) throws Exception {
printWriter.println(TextUtil.getClassName(this.getClass()));
Iterator iterator = this.iterator();
while (iterator.hasNext()) {
((VendorLicense)iterator.next()).dump(printWriter);
}
}
private final /* synthetic */ void this() {
this.list = new ArrayList();
}
public LicenseSet() {
this.this();
}
}
@@ -0,0 +1,326 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.NreLib;
import com.tridium.sys.license.dom.Feature;
import com.tridium.sys.license.dom.HostLicenseSet;
import com.tridium.sys.license.dom.LicenseSet;
import com.tridium.sys.license.dom.VendorLicense;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSystem;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.util.Version;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class LicenseTest {
static final long NEVER = Long.MAX_VALUE;
int verifies;
VendorLicense trid;
public static void main(String[] stringArray) throws Exception {
LicenseTest licenseTest = new LicenseTest();
licenseTest.readTridium();
licenseTest.fromScratch();
licenseTest.licenseSet();
System.out.println("ALL TESTS PASSED [" + licenseTest.verifies + ']');
}
public void readTridium() throws Exception {
BIFile bIFile = BFileSystem.INSTANCE.findFile(new FilePath("!licenses/Tridium.license"));
if (bIFile == null) {
bIFile = BFileSystem.INSTANCE.findFile(new FilePath("!licenses/Vykon.license"));
}
VendorLicense vendorLicense = this.trid = new VendorLicense();
vendorLicense.load(bIFile);
boolean bl = false;
if (vendorLicense.getExpiration() == Long.MAX_VALUE) {
bl = true;
}
this.verify(bl);
this.verify(vendorLicense.getHostId().equals(NreLib.getHostId()));
this.verify(vendorLicense.getVendor().equals("Tridium"));
boolean bl2 = false;
if (vendorLicense.getVersion() != null) {
bl2 = true;
}
this.verify(bl2);
Feature feature = vendorLicense.getFeature("about");
boolean bl3 = false;
if (feature == vendorLicense.getFeature("AbOuT")) {
bl3 = true;
}
this.verify(bl3);
this.verify(feature.getName().equals("about"));
this.verify(feature.getKey().equals("about"));
boolean bl4 = false;
if (feature.getExpiration() == Long.MAX_VALUE) {
bl4 = true;
}
this.verify(bl4);
boolean bl5 = false;
if (feature.get("owner") != null) {
bl5 = true;
}
this.verify(bl5);
boolean bl6 = false;
if (feature.get("project") != null) {
bl6 = true;
}
this.verify(bl6);
boolean bl7 = false;
if (feature.get("foobar") == null) {
bl7 = true;
}
this.verify(bl7);
boolean bl8 = false;
if (feature.get("foobar", "rocking") == "rocking") {
bl8 = true;
}
this.verify(bl8);
Feature.Brand brand = vendorLicense.getBrandFeature();
this.verifyEq(brand.getStationIn(), "*");
this.verifyEq(brand.getStationOut(), "*");
this.verifyEq(brand.getWbIn(), "*");
this.verifyEq(brand.getWbOut(), "*");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
vendorLicense.save(byteArrayOutputStream);
this.roundRobinIO(this.trid);
}
public void fromScratch() throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.setVendor("brianco");
vendorLicense.setVersion(new Version("3.2"));
vendorLicense.setHostId("win-host-id");
vendorLicense.setSignature("abcdefghijklmnopqrstuvwxyz");
this.roundRobinIO(vendorLicense);
Feature feature = vendorLicense.addFeature("kickIt");
boolean bl = false;
if (vendorLicense.getFeature("KickIt") == feature) {
bl = true;
}
this.verify(bl);
boolean bl2 = false;
if (feature.getParent() == vendorLicense) {
bl2 = true;
}
this.verify(bl2);
this.verify(feature.getName().equals("kickIt"));
boolean bl3 = false;
if (feature.list().length == 0) {
bl3 = true;
}
this.verify(bl3);
this.roundRobinIO(vendorLicense);
feature.set("alpha", "bravo");
feature.set("charlie", "delta");
feature.set("bool", false);
feature.set("int", 77);
boolean bl4 = false;
if (feature.list().length == 4) {
bl4 = true;
}
this.verify(bl4);
this.verifyEq(feature.get("alpha"), "bravo");
this.verifyEq(feature.get("charlie"), "delta");
this.verify(feature.getb("bool", true) ^ true);
boolean bl5 = false;
if (feature.geti("int", 99) == 77) {
bl5 = true;
}
this.verify(bl5);
this.roundRobinIO(vendorLicense);
vendorLicense.removeFeature("kickIt");
boolean bl6 = false;
if (vendorLicense.getFeature("KickIt") == null) {
bl6 = true;
}
this.verify(bl6);
this.roundRobinIO(vendorLicense);
}
public void licenseSet() throws Exception {
BDirectory bDirectory = BFileSystem.INSTANCE.makeDir(new FilePath("!licenses/test"), null);
VendorLicense vendorLicense = this.makeLic(bDirectory, "A", "tridium", "vykon", null);
VendorLicense vendorLicense2 = this.makeLic(bDirectory, "A", "acme", null, null);
VendorLicense vendorLicense3 = this.makeLic(bDirectory, "B", "tridium", "vykon", null);
VendorLicense vendorLicense4 = this.makeLic(bDirectory, "C", "tridium", "vykon", "C-tridium-1.license");
VendorLicense vendorLicense5 = this.makeLic(bDirectory, "C", "tridium", "vykon", "C-tridium-2.license");
VendorLicense vendorLicense6 = this.makeLic(bDirectory, "D", "tridium", "tridium", "D-tridium-1.license");
VendorLicense vendorLicense7 = this.makeLic(bDirectory, "D", "tridium", "vykon", "D-tridium-2.license");
LicenseSet licenseSet = new LicenseSet();
licenseSet.load(bDirectory);
HostLicenseSet hostLicenseSet = licenseSet.toHostLicenseSet("no way", "vykon");
boolean bl = false;
if (hostLicenseSet == null) {
bl = true;
}
this.verify(bl);
hostLicenseSet = licenseSet.toHostLicenseSet("A", "vykon");
this.verifyEq(hostLicenseSet.getHostId(), "A");
this.verifyEq(hostLicenseSet.getVendorLicense("acme"), vendorLicense2);
this.verifyEq(hostLicenseSet.getVendorLicense("tridium"), vendorLicense);
this.verifyEq(hostLicenseSet.getTridiumLicense(), vendorLicense);
this.verifyEq(hostLicenseSet.getBrandFeature().getBrandId(), "vykon");
hostLicenseSet = licenseSet.toHostLicenseSet("B", "vykon");
this.verifyEq(hostLicenseSet.getHostId(), "B");
this.verifyEq(hostLicenseSet.getTridiumLicense(), vendorLicense3);
this.verifyEq(hostLicenseSet.getBrandFeature().getBrandId(), "vykon");
Exception exception = null;
try {
hostLicenseSet = licenseSet.toHostLicenseSet("C", "vykon");
}
catch (Exception exception2) {
exception = exception2;
}
boolean bl2 = false;
if (exception != null) {
bl2 = true;
}
this.verify(bl2);
hostLicenseSet = licenseSet.toHostLicenseSet("D", "tridium");
this.verifyEq(hostLicenseSet.getHostId(), "D");
this.verifyEq(hostLicenseSet.getTridiumLicense(), vendorLicense6);
this.verifyEq(hostLicenseSet.getBrandFeature().getBrandId(), "tridium");
hostLicenseSet = licenseSet.toHostLicenseSet("D", "vykon");
this.verifyEq(hostLicenseSet.getHostId(), "D");
this.verifyEq(hostLicenseSet.getTridiumLicense(), vendorLicense7);
this.verifyEq(hostLicenseSet.getBrandFeature().getBrandId(), "vykon");
}
VendorLicense makeLic(BIFile bIFile, String string, String string2, String string3, String string4) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.setHostId(string);
vendorLicense.setVendor(string2);
vendorLicense.setVersion(new Version("3.3"));
vendorLicense.setSignature("sig");
if (string2.equals("tridium")) {
Feature feature = vendorLicense.addFeature("brand");
feature.set("brandId", string3 == null ? "vykon" : string3);
}
if (string4 == null) {
string4 = string + '-' + string2 + ".license";
}
vendorLicense.save(BFileSystem.INSTANCE.makeFile(bIFile.getFilePath().merge(string4), null));
return vendorLicense;
}
public void roundRobinIO(VendorLicense vendorLicense) throws Exception {
byte[] byArray = this.saveToBuf(vendorLicense);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byArray);
VendorLicense vendorLicense2 = new VendorLicense();
vendorLicense2.load(vendorLicense.getSource(), byteArrayInputStream);
this.verifyEq(vendorLicense, vendorLicense2);
}
public void verifyEq(VendorLicense vendorLicense, VendorLicense vendorLicense2) throws Exception {
this.verifyEq(vendorLicense.getVendor(), vendorLicense2.getVendor());
this.verifyEq(vendorLicense.getExpiration(), vendorLicense2.getExpiration());
this.verifyEq(vendorLicense.getHostId(), vendorLicense2.getHostId());
Feature[] featureArray = vendorLicense.getFeatures();
Feature[] featureArray2 = vendorLicense2.getFeatures();
boolean bl = false;
if (featureArray.length == featureArray2.length) {
bl = true;
}
this.verify(bl);
int n = 0;
while (n < featureArray.length) {
this.verifyEq(featureArray[n], featureArray2[n]);
++n;
}
this.verifyEq(this.saveToBuf(vendorLicense), this.saveToBuf(vendorLicense2));
}
public void verifyEq(Feature feature, Feature feature2) {
this.verifyEq(feature.getName(), feature2.getName());
this.verifyEq(feature.getExpiration(), feature2.getExpiration());
String[] stringArray = feature.list();
String[] stringArray2 = feature2.list();
boolean bl = false;
if (stringArray.length == stringArray2.length) {
bl = true;
}
this.verify(bl);
int n = 0;
while (n < stringArray.length) {
this.verifyEq(stringArray[n], stringArray2[n]);
this.verifyEq(feature.get(stringArray[n]), feature2.get(stringArray2[n]));
++n;
}
}
public void verifyEq(String string, String string2) {
if (string == null) {
boolean bl = false;
if (string2 == null) {
bl = true;
}
this.verify(bl);
} else {
this.verify(string.equals(string2));
}
}
public void verifyEq(long l, long l2) {
boolean bl = false;
if (l == l2) {
bl = true;
}
this.verify(bl);
}
public void verifyEq(byte[] byArray, byte[] byArray2) {
boolean bl = false;
if (byArray.length == byArray2.length) {
bl = true;
}
this.verify(bl);
boolean bl2 = true;
int n = 0;
while (n < byArray.length) {
if (byArray[n] != byArray2[n]) {
bl2 = false;
break;
}
++n;
}
this.verify(bl2);
}
public void verify(boolean bl) {
if (bl) {
++this.verifies;
} else {
throw new RuntimeException("Test failed");
}
}
public byte[] saveToBuf(VendorLicense vendorLicense) throws Exception {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
XWriter xWriter = new XWriter((OutputStream)byteArrayOutputStream);
vendorLicense.save(xWriter);
return byteArrayOutputStream.toByteArray();
}
private final /* synthetic */ void this() {
this.verifies = 0;
}
public LicenseTest() {
this.this();
}
}
@@ -0,0 +1,326 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
* javax.baja.xml.XParser
* javax.baja.xml.XText
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.LicenseUtil;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import javax.baja.file.BIFile;
import javax.baja.sys.Clock;
import javax.baja.util.Version;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
import javax.baja.xml.XParser;
import javax.baja.xml.XText;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class VendorCertificate {
private String source;
private XElem xml;
private String signature;
private boolean modified;
public static VendorCertificate make(BIFile bIFile) throws Exception {
VendorCertificate vendorCertificate = new VendorCertificate();
vendorCertificate.load(bIFile);
return vendorCertificate;
}
public static VendorCertificate make(String string, InputStream inputStream) throws Exception {
VendorCertificate vendorCertificate = new VendorCertificate();
vendorCertificate.load(string, inputStream);
return vendorCertificate;
}
public static VendorCertificate make(String string, InputStream inputStream, boolean bl) throws Exception {
VendorCertificate vendorCertificate = new VendorCertificate();
vendorCertificate.load(string, inputStream, bl);
return vendorCertificate;
}
public static VendorCertificate make(String string, XElem xElem) throws Exception {
VendorCertificate vendorCertificate = new VendorCertificate();
vendorCertificate.load(string, xElem);
return vendorCertificate;
}
public String getSource() {
return this.source;
}
public String getVendor() {
return this.xml.get("vendor");
}
public void setVendor(String string) {
this.modify();
this.xml.setAttr("vendor", string);
}
public boolean isExpired() {
boolean bl = false;
if (Clock.millis() > this.getExpiration()) {
bl = true;
}
return bl;
}
public long getExpiration() {
return LicenseUtil.parseDate(this.xml.get("expiration"));
}
public void setExpiration(long l) {
this.modify();
this.xml.setAttr("expiration", LicenseUtil.formatDate(l));
}
public long getGenerated() {
return LicenseUtil.parseDate(this.xml.get("generated"));
}
public Version getVersion() {
return new Version(this.xml.get("version"));
}
public void setVersion(Version version) {
this.modify();
this.xml.setAttr("version", version.toString());
}
public String getSignature() {
return this.signature;
}
public void setSignature(String string) {
this.modify();
this.signature = string;
}
public String getPublicKey() {
XElem xElem = this.xml.elem("publicKey");
return xElem == null ? null : xElem.string();
}
public void setPublicKey(String string) {
this.modify();
XElem xElem = this.xml.elem("publicKey");
if (xElem != null) {
this.xml.removeContent((XContent)xElem);
}
xElem = new XElem("publicKey");
xElem.addContent((XContent)new XText(string));
this.xml.addContent((XContent)xElem);
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void load(BIFile bIFile) throws Exception {
InputStream inputStream = bIFile.getInputStream();
try {
this.load(bIFile.toString(), XParser.make((InputStream)inputStream).parse());
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
inputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
inputStream.close();
}
public void load(String string, InputStream inputStream) throws Exception {
this.load(string, inputStream, true);
}
public void load(String string, InputStream inputStream, boolean bl) throws Exception {
this.load(string, XParser.make((InputStream)inputStream).parse(bl));
}
public void load(String string, XElem xElem) throws Exception {
this.source = string == null ? string : "Unknown";
this.parse(xElem);
}
private final void parse(XElem xElem) throws Exception {
XElem xElem2;
XElem xElem3;
if (!xElem.qname().equals("certificate")) {
throw new XException("Root element must be <certificate> element", xElem);
}
this.modified = false;
this.xml = new XElem("certificate");
int n = 0;
while (n < xElem.attrSize()) {
this.xml.addAttr(xElem.attrName(n), xElem.attrValue(n));
++n;
}
if (xElem.get("generated", null) == null) {
this.xml.addAttr("generated", LicenseUtil.formatDate(Clock.millis()));
}
if ((xElem3 = xElem.elem("signature")) != null) {
this.signature = xElem3.string();
}
if ((xElem2 = xElem.elem("publicKey")) != null) {
this.xml.addContent((XContent)xElem2.copy());
}
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void save(BIFile bIFile) throws IOException {
OutputStream outputStream = bIFile.getOutputStream();
try {
VendorCertificate.format(this.save(), new XWriter(outputStream));
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
outputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
outputStream.close();
}
public void save(OutputStream outputStream) throws IOException {
this.save(outputStream, true);
}
public void save(OutputStream outputStream, boolean bl) throws IOException {
XWriter xWriter = new XWriter(outputStream);
this.save(xWriter);
xWriter.flush();
if (bl) {
xWriter.close();
}
}
public void save(XWriter xWriter) throws IOException {
VendorCertificate.format(this.save(), xWriter);
}
public XElem save() {
if (this.modified) {
this.xml.setAttr("generated", LicenseUtil.formatDate(Clock.millis()));
this.modified = false;
}
XElem xElem = this.xml.copy();
if (this.signature != null) {
XElem xElem2 = new XElem("signature");
xElem2.addContent((XContent)new XText(this.signature));
xElem.addContent((XContent)xElem2);
}
return xElem;
}
public static void format(XElem xElem, XWriter xWriter) {
VendorCertificate.formatr(xElem, xWriter, "");
xWriter.flush();
}
private static final void formatr(XElem xElem, XWriter xWriter, String string) {
xWriter.w((Object)string).w('<').w((Object)xElem.name());
int n = xElem.attrSize();
int n2 = 0;
while (n2 < n) {
xWriter.w((Object)" ").attr(xElem.attrName(n2), xElem.attrValue(n2));
++n2;
}
if (xElem.contentSize() == 0) {
xWriter.w((Object)"/>").nl();
return;
}
xWriter.w('>');
XElem[] xElemArray = xElem.elems();
if (xElemArray.length > 0) {
xWriter.nl();
}
int n3 = 0;
while (n3 < xElemArray.length) {
VendorCertificate.formatr(xElemArray[n3], xWriter, string + ' ');
++n3;
}
if (xElem.text() != null) {
xElem.text().write(xWriter);
}
if (xElemArray.length > 0) {
xWriter.w((Object)string);
}
xWriter.w((Object)"</").w((Object)xElem.name()).w('>').nl();
}
protected void modify() {
this.signature = null;
this.modified = true;
}
public void dump() {
this.dump(new PrintWriter(System.out));
}
public void dump(PrintWriter printWriter) {
printWriter.println(" VendorCertificate");
printWriter.println(" source: " + this.source);
printWriter.println(" vendor: " + this.getVendor());
printWriter.println(" version: " + this.getVersion());
printWriter.println(" expiration: " + LicenseUtil.formatDate(this.getExpiration()));
printWriter.println(" generated: " + LicenseUtil.formatDate(this.getGenerated()));
printWriter.flush();
}
private final /* synthetic */ void this() {
this.source = "Unknown";
this.signature = null;
this.modified = false;
}
public VendorCertificate() {
this.this();
this.xml = new XElem("certificate");
this.xml.setAttr("generated", LicenseUtil.formatDate(Clock.millis()));
this.modified = true;
}
}
@@ -0,0 +1,436 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.nre.util.Array
* javax.baja.nre.util.TextUtil
* javax.baja.xml.XContent
* javax.baja.xml.XElem
* javax.baja.xml.XException
* javax.baja.xml.XParser
* javax.baja.xml.XText
* javax.baja.xml.XWriter
*/
package com.tridium.sys.license.dom;
import com.tridium.sys.license.LicenseUtil;
import com.tridium.sys.license.dom.Feature;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import javax.baja.file.BIFile;
import javax.baja.nre.util.Array;
import javax.baja.nre.util.TextUtil;
import javax.baja.sys.Clock;
import javax.baja.util.Version;
import javax.baja.xml.XContent;
import javax.baja.xml.XElem;
import javax.baja.xml.XException;
import javax.baja.xml.XParser;
import javax.baja.xml.XText;
import javax.baja.xml.XWriter;
/*
* Illegal identifiers - consider using --renameillegalidents true
*/
public class VendorLicense {
private String source;
private XElem xml;
private Array features;
private String signature;
private boolean modified;
static /* synthetic */ Class class$com$tridium$sys$license$dom$Feature;
public static VendorLicense make(BIFile bIFile) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.load(bIFile);
return vendorLicense;
}
public static VendorLicense make(String string, InputStream inputStream) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.load(string, inputStream);
return vendorLicense;
}
public static VendorLicense make(String string, InputStream inputStream, boolean bl) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.load(string, inputStream, bl);
return vendorLicense;
}
public static VendorLicense make(String string, XElem xElem) throws Exception {
VendorLicense vendorLicense = new VendorLicense();
vendorLicense.load(string, xElem);
return vendorLicense;
}
public String getSource() {
return this.source;
}
public String getHostId() {
return this.xml.get("hostId");
}
public void setHostId(String string) {
this.modify();
this.xml.setAttr("hostId", string);
}
public String getVendor() {
return this.xml.get("vendor");
}
public void setVendor(String string) {
this.modify();
this.xml.setAttr("vendor", string);
}
public boolean isExpired() {
boolean bl = false;
if (Clock.millis() > this.getExpiration()) {
bl = true;
}
return bl;
}
public long getExpiration() {
return LicenseUtil.parseDate(this.xml.get("expiration"));
}
public void setExpiration(long l) {
this.modify();
this.xml.setAttr("expiration", LicenseUtil.formatDate(l));
}
public long getGenerated() {
return LicenseUtil.parseDate(this.xml.get("generated"));
}
public Version getVersion() {
return new Version(this.xml.get("version"));
}
public void setVersion(Version version) {
this.modify();
this.xml.setAttr("version", version.toString());
}
public String getSignature() {
return this.signature;
}
public void setSignature(String string) {
this.modify();
this.signature = string;
}
public Feature getFeature(String string) {
int n = 0;
while (n < this.features.size()) {
Feature feature = (Feature)this.features.get(n);
if (feature.getKey().equals(Feature.toKey(string))) {
return feature;
}
++n;
}
return null;
}
public Feature.Brand getBrandFeature() {
return (Feature.Brand)this.getFeature("brand");
}
public String getBrandId() {
if ("tridium".equalsIgnoreCase(this.getVendor())) {
Feature.Brand brand = this.getBrandFeature();
return brand == null ? null : brand.getBrandId();
}
return null;
}
public String getLicenseName() {
if ("tridium".equalsIgnoreCase(this.getVendor())) {
Feature.Brand brand = this.getBrandFeature();
return brand == null ? "Tridium" : TextUtil.capitalize((String)brand.getBrandId());
}
return TextUtil.capitalize((String)this.getVendor());
}
public Feature[] getFeatures() {
return (Feature[])this.features.trim();
}
public String[] getFeatureNames() {
Feature[] featureArray = this.getFeatures();
String[] stringArray = new String[featureArray.length];
int n = 0;
while (n < stringArray.length) {
stringArray[n] = featureArray[n].getName();
++n;
}
return stringArray;
}
public Feature addFeature(String string) {
if (this.getFeature(string) != null) {
throw new RuntimeException("Feature already exists");
}
Feature feature = Feature.make(this, string);
this.features.add((Object)feature);
return feature;
}
public Feature removeFeature(String string) {
int n = 0;
while (n < this.features.size()) {
Feature feature = (Feature)this.features.get(n);
if (feature.getKey().equals(Feature.toKey(string))) {
this.features.remove(n);
return feature;
}
++n;
}
return null;
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void load(BIFile bIFile) throws Exception {
InputStream inputStream = bIFile.getInputStream();
try {
this.load(bIFile.toString(), XParser.make((InputStream)inputStream).parse());
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
inputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
inputStream.close();
}
public void load(String string, InputStream inputStream) throws Exception {
this.load(string, inputStream, true);
}
public void load(String string, InputStream inputStream, boolean bl) throws Exception {
this.load(string, XParser.make((InputStream)inputStream).parse(bl));
}
public void load(String string, XElem xElem) throws Exception {
this.source = string != null ? string : "Unknown";
this.parse(xElem);
}
private final void parse(XElem xElem) throws Exception {
if (!xElem.qname().equals("license")) {
throw new XException("Root element must be <license> element", xElem);
}
this.modified = false;
this.xml = new XElem("license");
int n = 0;
while (n < xElem.attrSize()) {
this.xml.addAttr(xElem.attrName(n), xElem.attrValue(n));
++n;
}
if (xElem.get("generated", null) == null) {
this.xml.addAttr("generated", LicenseUtil.formatDate(Clock.millis()));
}
XElem[] xElemArray = xElem.elems("feature");
Class clazz = class$com$tridium$sys$license$dom$Feature;
if (clazz == null) {
clazz = class$com$tridium$sys$license$dom$Feature = VendorLicense.class("[Lcom.tridium.sys.license.dom.Feature;", false);
}
this.features = new Array(clazz);
int n2 = 0;
while (n2 < xElemArray.length) {
XElem xElem2 = xElemArray[n2];
Feature feature = Feature.make(this, xElem2.get("name"));
feature.load(xElemArray[n2]);
this.features.add((Object)feature);
++n2;
}
XElem xElem3 = xElem.elem("signature");
if (xElem3 != null) {
this.signature = xElem3.string();
}
}
/*
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
*/
public void save(BIFile bIFile) throws IOException {
OutputStream outputStream = bIFile.getOutputStream();
try {
VendorLicense.format(this.save(), new XWriter(outputStream));
}
catch (Throwable throwable) {
Object var4_4 = null;
try {
outputStream.close();
throw throwable;
}
catch (Exception exception) {}
throw throwable;
}
{
Object var4_5 = null;
}
try {}
catch (Exception exception) {
return;
}
outputStream.close();
}
public void save(OutputStream outputStream) throws IOException {
this.save(outputStream, true);
}
public void save(OutputStream outputStream, boolean bl) throws IOException {
XWriter xWriter = new XWriter(outputStream);
this.save(xWriter);
xWriter.flush();
if (bl) {
xWriter.close();
}
}
public void save(XWriter xWriter) throws IOException {
VendorLicense.format(this.save(), xWriter);
}
public XElem save() {
if (this.modified) {
this.xml.setAttr("generated", LicenseUtil.formatDate(Clock.millis()));
this.modified = false;
}
XElem xElem = this.xml.copy();
int n = 0;
while (n < this.features.size()) {
xElem.addContent((XContent)((Feature)this.features.get(n)).save());
++n;
}
if (this.signature != null) {
XElem xElem2 = new XElem("signature");
xElem2.addContent((XContent)new XText(this.signature));
xElem.addContent((XContent)xElem2);
}
return xElem;
}
public static void format(XElem xElem, XWriter xWriter) {
VendorLicense.formatr(xElem, xWriter, "");
xWriter.flush();
}
private static final void formatr(XElem xElem, XWriter xWriter, String string) {
xWriter.w((Object)string).w('<').w((Object)xElem.name());
int n = xElem.attrSize();
int n2 = 0;
while (n2 < n) {
xWriter.w((Object)" ").attr(xElem.attrName(n2), xElem.attrValue(n2));
++n2;
}
if (xElem.contentSize() == 0) {
xWriter.w((Object)"/>").nl();
return;
}
xWriter.w('>');
XElem[] xElemArray = xElem.elems();
if (xElemArray.length > 0) {
xWriter.nl();
}
int n3 = 0;
while (n3 < xElemArray.length) {
VendorLicense.formatr(xElemArray[n3], xWriter, string + ' ');
++n3;
}
if (xElem.text() != null) {
xElem.text().write(xWriter);
}
if (xElemArray.length > 0) {
xWriter.w((Object)string);
}
xWriter.w((Object)"</").w((Object)xElem.name()).w('>').nl();
}
protected void modify() {
this.signature = null;
this.modified = true;
}
public void dump() {
this.dump(new PrintWriter(System.out));
}
public void dump(PrintWriter printWriter) {
printWriter.println(" VendorLicense");
printWriter.println(" source: " + this.source);
printWriter.println(" hostId: " + this.getHostId());
printWriter.println(" vendor: " + this.getVendor());
printWriter.println(" version: " + this.getVersion());
printWriter.println(" expiration: " + LicenseUtil.formatDate(this.getExpiration()));
printWriter.println(" generated: " + LicenseUtil.formatDate(this.getGenerated()));
Feature[] featureArray = this.getFeatures();
int n = 0;
while (n < featureArray.length) {
featureArray[n].dump(printWriter);
++n;
}
printWriter.flush();
}
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());
}
}
private final /* synthetic */ void this() {
this.source = "Unknown";
Class clazz = class$com$tridium$sys$license$dom$Feature;
if (clazz == null) {
clazz = class$com$tridium$sys$license$dom$Feature = VendorLicense.class("[Lcom.tridium.sys.license.dom.Feature;", false);
}
this.features = new Array(clazz);
this.signature = null;
this.modified = false;
}
public VendorLicense() {
this.this();
this.xml = new XElem("license");
this.xml.setAttr("generated", LicenseUtil.formatDate(Clock.millis()));
this.xml.setAttr("expiration", "never");
this.modified = true;
}
}