250 lines
9.4 KiB
Java
250 lines
9.4 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.tridium.fox.message.FoxMessage
|
|
* com.tridium.fox.message.FoxTuple
|
|
* com.tridium.fox.session.FoxCircuit
|
|
* com.tridium.fox.session.FoxRequest
|
|
* com.tridium.fox.session.FoxResponse
|
|
* com.tridium.fox.session.InvalidCommandException
|
|
* com.tridium.fox.sys.BFoxChannel
|
|
* com.tridium.fox.sys.file.BFileChannel
|
|
* com.tridium.fox.sys.file.BFoxFileSpace
|
|
* com.tridium.fox.sys.file.BFoxFileStore
|
|
* javax.baja.file.BFileSystem
|
|
* javax.baja.file.BIDirectory
|
|
* javax.baja.file.BIFile
|
|
* javax.baja.file.BIFileStore
|
|
* javax.baja.file.FilePath
|
|
* javax.baja.file.FileUtil
|
|
* javax.baja.security.BPermissions
|
|
* javax.baja.sys.Sys
|
|
* javax.baja.sys.Type
|
|
*/
|
|
package com.tridium.platform.fox;
|
|
|
|
import com.tridium.fox.message.FoxMessage;
|
|
import com.tridium.fox.message.FoxTuple;
|
|
import com.tridium.fox.session.FoxCircuit;
|
|
import com.tridium.fox.session.FoxRequest;
|
|
import com.tridium.fox.session.FoxResponse;
|
|
import com.tridium.fox.session.InvalidCommandException;
|
|
import com.tridium.fox.sys.BFoxChannel;
|
|
import com.tridium.fox.sys.file.BFileChannel;
|
|
import com.tridium.fox.sys.file.BFoxFileSpace;
|
|
import com.tridium.fox.sys.file.BFoxFileStore;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import javax.baja.file.BFileSystem;
|
|
import javax.baja.file.BIDirectory;
|
|
import javax.baja.file.BIFile;
|
|
import javax.baja.file.BIFileStore;
|
|
import javax.baja.file.FilePath;
|
|
import javax.baja.file.FileUtil;
|
|
import javax.baja.security.BPermissions;
|
|
import javax.baja.sys.Sys;
|
|
import javax.baja.sys.Type;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class BLicenseChannel
|
|
extends BFoxChannel {
|
|
public static final Type TYPE;
|
|
static /* synthetic */ Class class$com$tridium$platform$fox$BLicenseChannel;
|
|
|
|
public Type getType() {
|
|
return TYPE;
|
|
}
|
|
|
|
public FoxResponse process(FoxRequest foxRequest) throws Exception {
|
|
String string = foxRequest.command;
|
|
if (string == "listcertificates") {
|
|
return this.listcertificates(foxRequest);
|
|
}
|
|
if (string == "listlicenses") {
|
|
return this.listlicenses(foxRequest);
|
|
}
|
|
throw new InvalidCommandException(string);
|
|
}
|
|
|
|
public void circuitOpened(FoxCircuit foxCircuit) throws Exception {
|
|
String string = foxCircuit.command;
|
|
if (string == "read") {
|
|
this.read(foxCircuit);
|
|
return;
|
|
}
|
|
throw new InvalidCommandException(string);
|
|
}
|
|
|
|
public BIFile[] listcertificates(BFoxFileSpace bFoxFileSpace) throws Exception {
|
|
if (this.isTraceOn()) {
|
|
this.trace("c:listcertificates");
|
|
}
|
|
FoxRequest foxRequest = this.makeRequest("listcertificates");
|
|
FoxResponse foxResponse = this.sendSync(foxRequest);
|
|
FoxTuple[] foxTupleArray = foxResponse.list("file");
|
|
BFoxFileStore[] bFoxFileStoreArray = new BFoxFileStore[foxTupleArray.length];
|
|
int n = 0;
|
|
while (n < bFoxFileStoreArray.length) {
|
|
FoxMessage foxMessage = (FoxMessage)foxTupleArray[n];
|
|
String string = foxMessage.getString("name");
|
|
bFoxFileStoreArray[n] = BFileChannel.msgToStore((BFoxFileSpace)bFoxFileSpace, (FilePath)new FilePath("!certificates").merge(string), (FoxMessage)foxMessage);
|
|
++n;
|
|
}
|
|
BIFile[] bIFileArray = new BIFile[bFoxFileStoreArray.length];
|
|
int n2 = 0;
|
|
while (n2 < bIFileArray.length) {
|
|
bIFileArray[n2] = bFoxFileSpace.makeFile((BIFileStore)bFoxFileStoreArray[n2]);
|
|
++n2;
|
|
}
|
|
return bIFileArray;
|
|
}
|
|
|
|
public FoxResponse listcertificates(FoxRequest foxRequest) throws Exception {
|
|
if (this.isTraceOn()) {
|
|
this.trace("s:listcertificates");
|
|
}
|
|
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
|
FilePath filePath = new FilePath("!certificates");
|
|
BIFile bIFile = BFileSystem.INSTANCE.resolveFile(filePath);
|
|
if (bIFile instanceof BIDirectory) {
|
|
BIDirectory bIDirectory = (BIDirectory)bIFile;
|
|
BIFile[] bIFileArray = bIDirectory.listFiles();
|
|
int n = 0;
|
|
while (n < bIFileArray.length) {
|
|
BPermissions bPermissions = this.getPermissionsFor(bIFileArray[n]);
|
|
FoxMessage foxMessage = new FoxMessage("file");
|
|
BFileChannel.storeToMsg((BIFileStore)bIFileArray[n].getStore(), (BPermissions)bPermissions, (FoxMessage)foxMessage);
|
|
foxResponse.add((FoxTuple)foxMessage);
|
|
++n;
|
|
}
|
|
}
|
|
return foxResponse;
|
|
}
|
|
|
|
public BIFile[] listlicenses(BFoxFileSpace bFoxFileSpace) throws Exception {
|
|
if (this.isTraceOn()) {
|
|
this.trace("c:listlicenses");
|
|
}
|
|
FoxRequest foxRequest = this.makeRequest("listlicenses");
|
|
FoxResponse foxResponse = this.sendSync(foxRequest);
|
|
FoxTuple[] foxTupleArray = foxResponse.list("file");
|
|
BFoxFileStore[] bFoxFileStoreArray = new BFoxFileStore[foxTupleArray.length];
|
|
int n = 0;
|
|
while (n < bFoxFileStoreArray.length) {
|
|
FoxMessage foxMessage = (FoxMessage)foxTupleArray[n];
|
|
String string = foxMessage.getString("name");
|
|
bFoxFileStoreArray[n] = BFileChannel.msgToStore((BFoxFileSpace)bFoxFileSpace, (FilePath)new FilePath("!licenses").merge(string), (FoxMessage)foxMessage);
|
|
++n;
|
|
}
|
|
BIFile[] bIFileArray = new BIFile[bFoxFileStoreArray.length];
|
|
int n2 = 0;
|
|
while (n2 < bIFileArray.length) {
|
|
bIFileArray[n2] = bFoxFileSpace.makeFile((BIFileStore)bFoxFileStoreArray[n2]);
|
|
++n2;
|
|
}
|
|
return bIFileArray;
|
|
}
|
|
|
|
public FoxResponse listlicenses(FoxRequest foxRequest) throws Exception {
|
|
if (this.isTraceOn()) {
|
|
this.trace("s:listlicenses");
|
|
}
|
|
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
|
FilePath filePath = new FilePath("!licenses");
|
|
BIFile bIFile = BFileSystem.INSTANCE.resolveFile(filePath);
|
|
if (bIFile instanceof BIDirectory) {
|
|
BIDirectory bIDirectory = (BIDirectory)bIFile;
|
|
BIFile[] bIFileArray = bIDirectory.listFiles();
|
|
int n = 0;
|
|
while (n < bIFileArray.length) {
|
|
BPermissions bPermissions = this.getPermissionsFor(bIFileArray[n]);
|
|
FoxMessage foxMessage = new FoxMessage("file");
|
|
BFileChannel.storeToMsg((BIFileStore)bIFileArray[n].getStore(), (BPermissions)bPermissions, (FoxMessage)foxMessage);
|
|
foxResponse.add((FoxTuple)foxMessage);
|
|
++n;
|
|
}
|
|
}
|
|
return foxResponse;
|
|
}
|
|
|
|
public InputStream read(BFoxFileStore bFoxFileStore) throws Exception {
|
|
FilePath filePath = bFoxFileStore.getFilePath();
|
|
if (this.isTraceOn()) {
|
|
this.trace("c:read \"" + filePath.getBody() + '\"');
|
|
}
|
|
if (!filePath.getBody().startsWith("!certificates") && !filePath.getBody().startsWith("!licenses")) {
|
|
return null;
|
|
}
|
|
FoxCircuit foxCircuit = this.openCircuit("read");
|
|
FoxMessage foxMessage = new FoxMessage();
|
|
foxMessage.add("path", bFoxFileStore.getFilePath().getBody());
|
|
foxCircuit.writeMessage(foxMessage);
|
|
foxCircuit.flush();
|
|
return foxCircuit.getInputStream();
|
|
}
|
|
|
|
/*
|
|
* 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 read(FoxCircuit foxCircuit) throws Exception {
|
|
FoxMessage foxMessage = foxCircuit.readMessage();
|
|
FilePath filePath = new FilePath(foxMessage.getString("path"));
|
|
if (!filePath.getBody().startsWith("!certificates") && !filePath.getBody().startsWith("!licenses")) {
|
|
return;
|
|
}
|
|
if (this.isTraceOn()) {
|
|
this.trace("s:read \"" + filePath.getBody() + '\"');
|
|
}
|
|
BIFile bIFile = BFileSystem.INSTANCE.resolveFile(filePath);
|
|
long l = bIFile.getSize();
|
|
InputStream inputStream = bIFile.getInputStream();
|
|
OutputStream outputStream = foxCircuit.getOutputStream();
|
|
try {
|
|
FileUtil.pipe((InputStream)inputStream, (long)l, (OutputStream)outputStream);
|
|
}
|
|
catch (Throwable throwable) {
|
|
Object var10_9 = null;
|
|
inputStream.close();
|
|
foxCircuit.close();
|
|
throw throwable;
|
|
}
|
|
{
|
|
Object var10_10 = null;
|
|
}
|
|
inputStream.close();
|
|
foxCircuit.close();
|
|
}
|
|
|
|
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 BLicenseChannel() {
|
|
super("license");
|
|
}
|
|
|
|
static {
|
|
Class clazz = class$com$tridium$platform$fox$BLicenseChannel;
|
|
if (clazz == null) {
|
|
clazz = class$com$tridium$platform$fox$BLicenseChannel = BLicenseChannel.class("[Lcom.tridium.platform.fox.BLicenseChannel;", false);
|
|
}
|
|
TYPE = Sys.loadType((Class)clazz);
|
|
}
|
|
}
|
|
|