274 lines
11 KiB
Java
274 lines
11 KiB
Java
/*
|
|
* 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|