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,377 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.file.BDirectory
* javax.baja.file.BFileSpace
* javax.baja.file.BFileSystem
* javax.baja.file.BIFile
* javax.baja.file.FilePath
* javax.baja.file.FileUtil
* javax.baja.file.IFileFilter
* javax.baja.gx.BImage
* javax.baja.nre.util.Array
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BDialog
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.CommandArtifact
* javax.baja.ui.file.ExtFileFilter
* javax.baja.ui.table.TableModel
* javax.baja.util.Lexicon
*/
package com.tridium.platform.ui.pki;
import com.tridium.platform.daemon.DaemonFileUtil;
import com.tridium.platform.daemon.file.BDaemonFileSpace;
import com.tridium.platform.daemon.message.FileTransferMessage;
import com.tridium.platform.pki.PemCertInfo;
import com.tridium.platform.ui.util.BCommandBoundTable;
import com.tridium.platform.ui.util.BCommandEnablePolicy;
import com.tridium.platform.ui.util.BFileChooserDialog;
import com.tridium.platform.ui.util.BIndentPane;
import com.tridium.platform.ui.util.CommandBindings;
import com.tridium.platform.ui.util.CommandUtil;
import com.tridium.platform.ui.util.FavoriteDirectory;
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.file.FileUtil;
import javax.baja.file.IFileFilter;
import javax.baja.gx.BImage;
import javax.baja.nre.util.Array;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BDialog;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.file.ExtFileFilter;
import javax.baja.ui.table.TableModel;
import javax.baja.util.Lexicon;
public class BCACertsTable
extends BCommandBoundTable
implements CommandBindings.Support {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$pki$BCACertsTable == null ? (class$com$tridium$platform$ui$pki$BCACertsTable = BCACertsTable.class$("com.tridium.platform.ui.pki.BCACertsTable")) : class$com$tridium$platform$ui$pki$BCACertsTable));
public static final Lexicon LEX = Lexicon.make((String)"platform");
public static final ExtFileFilter PEM_FILTER = new ExtFileFilter("", "pem,crt,cer");
protected BDirectory dir;
protected FilePath dirPath;
protected BFileSpace space;
public static final int COL_SOURCE = 0;
public static final int COL_ISSUER = 1;
public static final int COL_SUBJECT = 2;
public static final int COL_START = 3;
public static final int COL_END = 4;
public static final int COL_ALG = 5;
protected boolean readonly = false;
static /* synthetic */ Class class$com$tridium$platform$ui$pki$BCACertsTable;
static /* synthetic */ Class class$com$tridium$platform$pki$PemCertInfo;
static /* synthetic */ Class class$java$lang$String;
public Type getType() {
return TYPE;
}
public BCACertsTable() {
throw new UnsupportedOperationException();
}
public BCACertsTable(FilePath filePath, BFileSpace bFileSpace, CommandBindings.TableController tableController) throws Exception {
super(new CACertModel(), tableController);
this.dirPath = filePath;
this.space = bFileSpace;
this.dir = this.initDir(filePath);
this.initCommands();
}
public BCACertsTable(FilePath filePath, BFileSpace bFileSpace) throws Exception {
super(new CACertModel());
this.dirPath = filePath;
this.space = bFileSpace;
this.dir = this.initDir(filePath);
this.initCommands();
}
public void load() throws Exception {
this.caCertModel().load(this.dir);
}
protected void initCommands() {
this.getCommandBindings().setSupport(this);
this.addCommand(new ImportCommand(), BCommandEnablePolicy.always);
this.addCommand(new ExportCommand(), BCommandEnablePolicy.anySelection);
ViewCommand viewCommand = new ViewCommand();
this.addCommand(viewCommand, BCommandEnablePolicy.singleSelection);
this.setDoubleClickCommand(viewCommand);
this.addCommand(new DeleteCommand(), BCommandEnablePolicy.anySelection);
}
protected CACertModel caCertModel() {
return (CACertModel)this.getModel();
}
protected BDirectory initDir(FilePath filePath) throws Exception {
if (this.space instanceof BDaemonFileSpace) {
BDirectory bDirectory = (BDirectory)this.space.findFile(filePath);
if (bDirectory == null) {
this.initDir(filePath.getParent());
BDaemonFileSpace bDaemonFileSpace = (BDaemonFileSpace)this.space;
DaemonFileUtil.transfer(bDaemonFileSpace.getDaemonSession(), FileTransferMessage.makeMkDir(filePath, bDaemonFileSpace), null);
bDirectory = (BDirectory)this.space.findFile(filePath);
}
return bDirectory;
}
return this.space.makeDir(this.dirPath);
}
protected Object beginFileTransfer() {
if (this.space instanceof BDaemonFileSpace) {
return new FileTransferMessage((BDaemonFileSpace)this.space);
}
return null;
}
protected void installCertFile(BIFile bIFile, Object object) throws Exception {
FilePath filePath = this.dir.getFilePath().merge(FileUtil.getBase((String)bIFile.getFileName()) + ".pem");
if (this.space instanceof BDaemonFileSpace) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
fileTransferMessage.addFile(bIFile, filePath);
} else {
BIFile bIFile2 = this.dir.getFileSpace().makeFile(filePath);
FileUtil.pipe((BIFile)bIFile, (BIFile)bIFile2);
}
}
protected void deleteCertFile(BIFile bIFile, Object object) throws Exception {
if (this.space instanceof BDaemonFileSpace) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
fileTransferMessage.addDelete(bIFile.getFilePath());
} else {
bIFile.delete();
}
}
protected void commitFileTransfer(Object object) throws Exception {
if (object != null) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
DaemonFileUtil.transfer(fileTransferMessage.getTargetFileSpace().getDaemonSession(), (FileTransferMessage)object, null);
}
}
public boolean isReadonly() {
return this.readonly;
}
public void setReadonly(boolean bl) {
this.readonly = bl;
this.setCommandEnabledStates();
}
public void setBoundCommandEnabled(Command command, boolean bl) {
if (this.readonly && (command instanceof ImportCommand || command instanceof DeleteCommand)) {
command.setEnabled(false);
} else {
command.setEnabled(bl);
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
protected class ExportCommand
extends Command {
public ExportCommand() {
super((BWidget)BCACertsTable.this, LEX, "CACertsTable.export");
}
public CommandArtifact doInvoke() {
try {
BDirectory bDirectory = FavoriteDirectory.loadByPath(BCACertsTable.this.getType().toString(), "exportDir", null);
BDirectory bDirectory2 = (BDirectory)BFileChooserDialog.chooseFile(this.getOwner(), null, LEX.getText("CACertsTable.export.dlgTitle"), LEX.getText("CACertsTable.export.dlgMessage"), (BIFile)bDirectory, IFileFilter.directory, null, null);
if (bDirectory2 != null) {
int[] nArray = BCACertsTable.this.getSelection().getRows();
for (int i = 0; i < nArray.length; ++i) {
BIFile bIFile = BCACertsTable.this.caCertModel().cert((int)nArray[i]).file;
BIFile bIFile2 = BFileSystem.INSTANCE.makeFile(bDirectory2.getFilePath().merge(bIFile.getFileName()));
FileUtil.pipe((BIFile)bIFile, (BIFile)bIFile2);
}
FavoriteDirectory.savePath(BCACertsTable.this.getType().toString(), "exportDir", bDirectory2.getFilePath().getParent());
}
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
return null;
}
}
protected class ViewCommand
extends Command {
public ViewCommand() {
super((BWidget)BCACertsTable.this, LEX, "CACertsTable.view");
}
public CommandArtifact doInvoke() {
return null;
}
}
protected class DeleteCommand
extends Command {
public DeleteCommand() {
super((BWidget)BCACertsTable.this, LEX, "CACertsTable.delete");
}
public CommandArtifact doInvoke() {
try {
if (4 == BDialog.confirm((BWidget)BCACertsTable.this, (String)LEX.getText("CACertsTable.delete.dlgTitle"), (Object)LEX.getText("CACertsTable.delete.dlgMessage"), (int)12)) {
int[] nArray = BCACertsTable.this.getSelection().getRows();
Object object = BCACertsTable.this.beginFileTransfer();
for (int i = 0; i < nArray.length; ++i) {
BCACertsTable.this.deleteCertFile(BCACertsTable.this.caCertModel().cert((int)nArray[i]).file, object);
}
BCACertsTable.this.commitFileTransfer(object);
BCACertsTable.this.caCertModel().load(BCACertsTable.this.dir);
}
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
return null;
}
}
protected class ImportCommand
extends Command {
public ImportCommand() {
super((BWidget)BCACertsTable.this, LEX, "CACertsTable.import");
}
public CommandArtifact doInvoke() {
try {
BDirectory bDirectory = FavoriteDirectory.loadByPath(BCACertsTable.this.getType().toString(), "caCertDir", null);
BIFile[] bIFileArray = BFileChooserDialog.chooseFiles(this.getOwner(), BImage.make((String)LEX.getText("CACertsTable.import.dlgIcon")), LEX.getText("CACertsTable.import.dlgTitle"), LEX.getText("CACertsTable.import.dlgMessage"), (BIFile)bDirectory, (IFileFilter)PEM_FILTER, (IFileFilter)PEM_FILTER);
if (bIFileArray == null || bIFileArray.length == 0) {
return null;
}
PemCertInfo[] pemCertInfoArray = PemCertInfo.makeCertificates(bIFileArray);
Object object = BCACertsTable.this.beginFileTransfer();
Array array = new Array(class$java$lang$String == null ? (class$java$lang$String = BCACertsTable.class$("java.lang.String")) : class$java$lang$String);
for (int i = 0; i < pemCertInfoArray.length; ++i) {
if (pemCertInfoArray[i].cert == null) {
array.add((Object)pemCertInfoArray[i].file.getFileName());
continue;
}
BCACertsTable.this.installCertFile(pemCertInfoArray[i].file, object);
}
BCACertsTable.this.commitFileTransfer(object);
if (array.size() > 0) {
BIndentPane bIndentPane = new BIndentPane();
bIndentPane.add(LEX.getText("CACerts.import.invalidFile.header"));
bIndentPane.indent();
for (int i = 0; i < array.size(); ++i) {
bIndentPane.add(array.get(i).toString());
}
BDialog.warning((BWidget)this.getOwner(), (String)LEX.getText("CACertsTable.import.invalidFile.dlgTitle"), (Object)((Object)bIndentPane));
}
BCACertsTable.this.caCertModel().load(BCACertsTable.this.dir);
if (bIFileArray.length > 0) {
FavoriteDirectory.savePath(BCACertsTable.this.getType().toString(), "caCertDir", bIFileArray[0].getFilePath().getParent());
}
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
return null;
}
}
protected static class CACertModel
extends TableModel {
private Array certs = new Array(class$com$tridium$platform$pki$PemCertInfo == null ? (class$com$tridium$platform$pki$PemCertInfo = BCACertsTable.class$("com.tridium.platform.pki.PemCertInfo")) : class$com$tridium$platform$pki$PemCertInfo);
protected CACertModel() {
}
public void load(BDirectory bDirectory) throws Exception {
if (bDirectory == null) {
this.certs.clear();
} else {
this.certs = new Array((Object[])PemCertInfo.makeCertificates(bDirectory.listFiles()));
}
this.updateTable(true);
}
public int getColumnCount() {
return 6;
}
public String getColumnName(int n) {
switch (n) {
case 0: {
return LEX.getText("CACertsTable.col.source");
}
case 1: {
return LEX.getText("CACertsTable.col.issuer");
}
case 2: {
return LEX.getText("CACertsTable.col.subject");
}
case 3: {
return LEX.getText("CACertsTable.col.start");
}
case 4: {
return LEX.getText("CACertsTable.col.end");
}
case 5: {
return LEX.getText("CACertsTable.col.sig");
}
}
throw new IndexOutOfBoundsException();
}
public int getRowCount() {
return this.certs.size();
}
public PemCertInfo cert(int n) {
return (PemCertInfo)this.certs.get(n);
}
public Object getValueAt(int n, int n2) {
switch (n2) {
case 0: {
return this.cert((int)n).file.getFileName();
}
case 1: {
return this.cert(n).getIssuer();
}
case 2: {
return this.cert(n).getSubject();
}
case 3: {
return this.cert(n).getStart();
}
case 4: {
return this.cert(n).getEnd();
}
case 5: {
return this.cert(n).getSignatureAlgName();
}
}
throw new IndexOutOfBoundsException();
}
}
}
@@ -0,0 +1,699 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.file.BDirectory
* javax.baja.file.BFileSpace
* javax.baja.file.BIFile
* javax.baja.file.FilePath
* javax.baja.file.FileUtil
* javax.baja.file.IFileFilter
* javax.baja.gx.BImage
* javax.baja.gx.Size
* javax.baja.nre.util.Array
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BDialog
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.CommandArtifact
* javax.baja.ui.file.ExtFileFilter
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.table.TableModel
* javax.baja.ui.wizard.BWizard
* javax.baja.ui.wizard.BWizardHeader
* javax.baja.ui.wizard.WizardModel
* javax.baja.util.Lexicon
* javax.baja.workbench.BWbShell
*/
package com.tridium.platform.ui.pki;
import com.tridium.platform.daemon.DaemonFileUtil;
import com.tridium.platform.daemon.file.BDaemonFileSpace;
import com.tridium.platform.daemon.message.FileTransferMessage;
import com.tridium.platform.pki.ClientPrivateKeyInfo;
import com.tridium.platform.pki.PemCertInfo;
import com.tridium.platform.ui.util.BCommandBoundTable;
import com.tridium.platform.ui.util.BCommandEnablePolicy;
import com.tridium.platform.ui.util.BFileChooserPane;
import com.tridium.platform.ui.util.CommandBindings;
import com.tridium.platform.ui.util.CommandUtil;
import com.tridium.platform.ui.util.FavoriteDirectory;
import javax.baja.file.BDirectory;
import javax.baja.file.BFileSpace;
import javax.baja.file.BIFile;
import javax.baja.file.FilePath;
import javax.baja.file.FileUtil;
import javax.baja.file.IFileFilter;
import javax.baja.gx.BImage;
import javax.baja.gx.Size;
import javax.baja.nre.util.Array;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BDialog;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.file.ExtFileFilter;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.table.TableModel;
import javax.baja.ui.wizard.BWizard;
import javax.baja.ui.wizard.BWizardHeader;
import javax.baja.ui.wizard.WizardModel;
import javax.baja.util.Lexicon;
import javax.baja.workbench.BWbShell;
public class BClientKeysTable
extends BCommandBoundTable
implements CommandBindings.Support {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$pki$BClientKeysTable == null ? (class$com$tridium$platform$ui$pki$BClientKeysTable = BClientKeysTable.class$("com.tridium.platform.ui.pki.BClientKeysTable")) : class$com$tridium$platform$ui$pki$BClientKeysTable));
public static final Lexicon LEX = Lexicon.make((String)"platform");
protected FilePath keyDirPath;
protected BDirectory keyDir;
protected FilePath certDirPath;
protected BDirectory certDir;
protected BFileSpace space;
protected boolean readonly = false;
public static final ExtFileFilter KEY_FILTER = new ExtFileFilter("", "p12,pks,pem");
public static final ExtFileFilter CERT_FILTER = new ExtFileFilter("", "pem,crt,cer");
protected static final int COL_KEY_FILE = 0;
protected static final int COL_CERT_FILE = 1;
static /* synthetic */ Class class$com$tridium$platform$ui$pki$BClientKeysTable;
static /* synthetic */ Class class$com$tridium$platform$pki$ClientPrivateKeyInfo;
public Type getType() {
return TYPE;
}
public BClientKeysTable() {
throw new UnsupportedOperationException();
}
public BClientKeysTable(FilePath filePath, FilePath filePath2, BFileSpace bFileSpace, CommandBindings.TableController tableController) throws Exception {
this.setModel(new Model());
this.setController(tableController);
this.keyDirPath = filePath;
this.certDirPath = filePath2;
this.space = bFileSpace;
this.keyDir = this.initDir(filePath);
this.certDir = this.initDir(filePath2);
this.initCommands();
}
public BClientKeysTable(FilePath filePath, FilePath filePath2, BFileSpace bFileSpace) throws Exception {
this.setModel(new Model());
this.keyDirPath = filePath;
this.certDirPath = filePath2;
this.space = bFileSpace;
this.keyDir = this.initDir(filePath);
this.certDir = this.initDir(filePath2);
this.initCommands();
}
public void load() throws Exception {
this.keysModel().load();
}
protected Model keysModel() {
return (Model)this.getModel();
}
protected void initCommands() {
this.getCommandBindings().setSupport(this);
this.addCommand(new ImportCommand(), BCommandEnablePolicy.always);
this.addCommand(new BackupCommand(), BCommandEnablePolicy.singleSelection);
ViewCommand viewCommand = new ViewCommand();
this.addCommand(viewCommand, BCommandEnablePolicy.singleSelection);
this.setDoubleClickCommand(viewCommand);
this.addCommand(new DeleteCommand(), BCommandEnablePolicy.anySelection);
}
protected BDirectory initDir(FilePath filePath) throws Exception {
if (this.space instanceof BDaemonFileSpace) {
BDirectory bDirectory = (BDirectory)this.space.findFile(filePath);
if (bDirectory == null) {
this.initDir(filePath.getParent());
BDaemonFileSpace bDaemonFileSpace = (BDaemonFileSpace)this.space;
DaemonFileUtil.transfer(bDaemonFileSpace.getDaemonSession(), FileTransferMessage.makeMkDir(filePath, bDaemonFileSpace), null);
bDirectory = (BDirectory)this.space.findFile(filePath);
}
return bDirectory;
}
return this.space.makeDir(filePath);
}
protected Object beginFileTransfer() {
if (this.space instanceof BDaemonFileSpace) {
return new FileTransferMessage((BDaemonFileSpace)this.space);
}
return null;
}
protected void install(ClientPrivateKeyInfo clientPrivateKeyInfo, Object object) throws Exception {
FilePath filePath = this.keyDir.getFilePath().merge(clientPrivateKeyInfo.keyFile.getFileName());
FilePath filePath2 = null;
if (clientPrivateKeyInfo.certFile != null && clientPrivateKeyInfo.certFile != clientPrivateKeyInfo.keyFile) {
filePath2 = this.certDir.getFilePath().merge(clientPrivateKeyInfo.getNormalCertFilename());
}
if (this.space instanceof BDaemonFileSpace) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
fileTransferMessage.addFile(clientPrivateKeyInfo.keyFile, filePath);
if (filePath2 != null) {
fileTransferMessage.addFile(clientPrivateKeyInfo.certFile, filePath2);
}
} else {
BIFile bIFile = this.keyDir.getFileSpace().makeFile(filePath);
FileUtil.pipe((BIFile)clientPrivateKeyInfo.keyFile, (BIFile)bIFile);
if (filePath2 != null) {
bIFile = this.certDir.getFileSpace().makeFile(filePath2);
FileUtil.pipe((BIFile)clientPrivateKeyInfo.certFile, (BIFile)bIFile);
}
}
}
protected void delete(ClientPrivateKeyInfo clientPrivateKeyInfo, Object object) throws Exception {
if (this.space instanceof BDaemonFileSpace) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
fileTransferMessage.addDelete(clientPrivateKeyInfo.keyFile.getFilePath());
if (clientPrivateKeyInfo.certFile != null) {
fileTransferMessage.addDelete(clientPrivateKeyInfo.certFile.getFilePath());
}
} else {
clientPrivateKeyInfo.keyFile.delete();
if (clientPrivateKeyInfo.certFile != null) {
clientPrivateKeyInfo.certFile.delete();
}
}
}
protected void commitFileTransfer(Object object) throws Exception {
if (object != null) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
DaemonFileUtil.transfer(fileTransferMessage.getTargetFileSpace().getDaemonSession(), (FileTransferMessage)object, null);
}
}
public void setReadonly(boolean bl) {
this.readonly = bl;
this.setCommandEnabledStates();
}
public boolean isReadonly() {
return this.readonly;
}
public void setBoundCommandEnabled(Command command, boolean bl) {
if (this.readonly && (command instanceof ImportCommand || command instanceof DeleteCommand)) {
command.setEnabled(false);
} else {
command.setEnabled(bl);
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
protected class CertFileStep
extends ImportWizardStep
implements BFileChooserPane.Listener {
private int mode = 0;
private BFileChooserPane chooser;
public CertFileStep(ImportWizardModel importWizardModel) {
super(importWizardModel);
this.chooser = new BFileChooserPane((BIFile)FavoriteDirectory.loadByPath(BClientKeysTable.this.getType().toString(), "clientCertDir", null), (IFileFilter)CERT_FILTER, (IFileFilter)CERT_FILTER, null, null, false, false, null);
this.setContent((BWidget)this.chooser);
this.chooser.addListener(this);
}
public String getStepName() {
return "certFile";
}
public int getMode() {
return this.mode;
}
public void enter() {
this.chooser.notifyFileSelected();
}
public boolean exit(int n) {
if (this.chooser.getSelectedFile() != null) {
FavoriteDirectory.savePath(BClientKeysTable.this.getType().toString(), "clientCertDir", this.chooser.getSelectedFile().getFilePath().getParent());
}
if (n == 4) {
this.wizardModel.getKeyInfo().certFile = this.chooser.getSelectedFile();
}
return true;
}
public void fileSelected(boolean bl) {
if (bl) {
try {
bl = PemCertInfo.getPEMCertificate(this.chooser.getSelectedFile(), new int[0]) != null;
}
catch (Exception exception) {
bl = false;
}
}
this.mode = bl ? 5 : 1;
this.wizardModel.update(this.mode);
}
}
protected class KeyFileStep
extends ImportWizardStep
implements BFileChooserPane.Listener {
private int mode = 0;
private BFileChooserPane chooser;
private ClientPrivateKeyInfo info;
public KeyFileStep(ImportWizardModel importWizardModel) {
super(importWizardModel);
this.chooser = new BFileChooserPane((BIFile)FavoriteDirectory.loadByPath(BClientKeysTable.this.getType().toString(), "clientKeyDir", null), (IFileFilter)KEY_FILTER, (IFileFilter)KEY_FILTER, null, null, false, false, null);
this.setContent((BWidget)this.chooser);
this.chooser.addListener(this);
this.nextStep = new CertFileStep(importWizardModel);
this.nextStep.priorStep = this;
}
public String getStepName() {
return "keyFile";
}
public int getMode() {
return this.mode;
}
public void enter() {
this.chooser.notifyFileSelected();
}
public boolean exit(int n) {
FavoriteDirectory.savePath(BClientKeysTable.this.getType().toString(), "clientKeyDir", this.chooser.getSelectedFile().getFilePath().getParent());
this.wizardModel.setKeyInfo(this.info);
return true;
}
public void fileSelected(boolean bl) {
this.info = null;
if (bl) {
try {
this.info = new ClientPrivateKeyInfo(this.chooser.getSelectedFile());
if (this.info.hasKey) {
this.mode = this.info.certFile == null ? 2 : 4;
this.wizardModel.update(this.mode);
return;
}
}
catch (Exception exception) {
// empty catch block
}
}
this.mode = 0;
this.wizardModel.update(0);
}
}
protected abstract class ImportWizardStep {
protected BEdgePane contentPane;
protected BEdgePane stepPane;
protected ImportWizardStep priorStep = null;
protected ImportWizardStep nextStep = null;
protected ImportWizardStep lastStep = this;
protected ImportWizardStep stepAfterSection = null;
protected ImportWizardModel wizardModel;
public ImportWizardStep(ImportWizardModel importWizardModel) {
this.wizardModel = importWizardModel;
this.contentPane = new BEdgePane(null, null, null, null, null);
this.stepPane = new BEdgePane((BWidget)new BWizardHeader(this.getIcon(), LEX.get("ClientKeysTable.importWizard." + this.getStepName() + ".title", ""), LEX.get("ClientKeysTable.importWizard." + this.getStepName() + ".desc", "")), null, null, null, (BWidget)new BBorderPane((BWidget)this.contentPane, 5.0, 10.0, 4.0, 10.0));
}
public BWidget getWidget() {
return this.stepPane;
}
public final BImage getIcon() {
String string = LEX.get("ClientKeysTable.importWizard." + this.getStepName() + ".stepIcon", null);
return string == null ? null : BImage.make((String)string);
}
public abstract String getStepName();
protected void checkMode() {
}
public void sendDaemonMessages() {
}
protected void setContent(BWidget bWidget) {
this.contentPane.setCenter(bWidget);
bWidget.relayout();
this.contentPane.relayout();
}
public boolean showCancelPrompt() {
return true;
}
public int getMode() {
int n = 0;
ImportWizardStep importWizardStep = this.priorStep;
while (importWizardStep != null && importWizardStep.isSkipped()) {
importWizardStep = importWizardStep.priorStep;
}
if (importWizardStep != null) {
n = 1;
}
importWizardStep = this.nextStep;
while (importWizardStep != null && importWizardStep.isSkipped()) {
importWizardStep = importWizardStep.nextStep;
}
n = importWizardStep == null ? (n |= 4) : (n |= 2);
return n;
}
public void enter() {
}
public boolean checkBack() {
return true;
}
public boolean checkNext() {
return true;
}
public boolean exit(int n) {
return true;
}
public boolean cancel() {
return true;
}
public boolean isSkipped() {
return false;
}
public void setStepAfterSection(ImportWizardStep importWizardStep) {
this.stepAfterSection = importWizardStep;
this.lastStep.nextStep = importWizardStep;
if (importWizardStep != null) {
importWizardStep.priorStep = this.lastStep;
}
}
public void setPriorStep(ImportWizardStep importWizardStep) {
this.priorStep = importWizardStep;
}
}
protected class ImportWizardModel
extends WizardModel {
protected BWidget owner;
protected Context context;
protected BWbShell shell;
protected boolean noChanges = false;
protected boolean canceled;
protected ImportWizardStep currentStep = null;
protected ClientPrivateKeyInfo keyInfo = null;
public ImportWizardModel(BWidget bWidget, Context context) throws Exception {
this.context = context;
this.owner = bWidget;
this.shell = BWbShell.getWbShell((BWidget)bWidget);
this.currentStep = new KeyFileStep(this);
}
public ClientPrivateKeyInfo getKeyInfo() {
return this.keyInfo;
}
public void setKeyInfo(ClientPrivateKeyInfo clientPrivateKeyInfo) {
this.keyInfo = clientPrivateKeyInfo;
}
public Context getContext() {
return this.context;
}
public BWidget getOwner() {
return this.owner;
}
public BWbShell getWbShell() {
return this.shell;
}
public boolean hasNoChanges() {
return this.noChanges;
}
public String getTitle() {
return LEX.getText("ClientKeysTable.importWizard.title");
}
public boolean cancel() {
if ((!this.getCurrentStep().showCancelPrompt() || BDialog.confirm((BWidget)this.getWizard(), (String)LEX.getText("ClientKeysTable.importWizard.cancel.title"), (Object)LEX.getText("ClientKeysTable.importWizard.cancel.message")) == 4) && this.getCurrentStep().cancel()) {
this.keyInfo = null;
return true;
}
return false;
}
public void setWizard(BWizard bWizard) {
super.setWizard(bWizard);
this.owner = bWizard;
}
public boolean hasNoSteps() {
ImportWizardStep importWizardStep = this.currentStep;
while (importWizardStep != null && importWizardStep.isSkipped()) {
importWizardStep = importWizardStep.nextStep;
}
return importWizardStep == null;
}
public void init() {
ImportWizardStep importWizardStep = this.currentStep;
while (importWizardStep != null && importWizardStep.isSkipped()) {
importWizardStep = importWizardStep.nextStep;
}
if (importWizardStep != null) {
this.update(importWizardStep);
importWizardStep.enter();
}
}
public void back() {
try {
if (!this.getCurrentStep().checkBack()) {
return;
}
ImportWizardStep importWizardStep = this.getCurrentStep().priorStep;
if (importWizardStep != null && this.getCurrentStep().exit(1)) {
while (importWizardStep != null && importWizardStep.isSkipped()) {
importWizardStep = importWizardStep.priorStep;
}
if (importWizardStep != null) {
this.update(importWizardStep);
importWizardStep.enter();
}
}
}
catch (Throwable throwable) {
BDialog.error((BWidget)this.getWizard(), (String)LEX.getText("ClientKeysTable.importWizard.error.dlgTitle"), (Object)LEX.getText("ClientKeysTable.importWizard.error.dlgMessage"), (Throwable)throwable);
}
}
public void next() {
if (!this.getCurrentStep().checkNext()) {
return;
}
new Thread(){
public void run() {
try {
ImportWizardStep importWizardStep;
if (ImportWizardModel.this.owner != null) {
ImportWizardModel.this.owner.enterBusy();
}
if ((importWizardStep = ImportWizardModel.this.getCurrentStep().nextStep) != null && ImportWizardModel.this.getCurrentStep().exit(2)) {
while (importWizardStep != null && importWizardStep.isSkipped()) {
importWizardStep = importWizardStep.nextStep;
}
if (importWizardStep != null) {
importWizardStep.enter();
ImportWizardModel.this.update(importWizardStep);
}
}
}
catch (Throwable throwable) {
BDialog.error((BWidget)ImportWizardModel.this.getWizard(), (String)LEX.getText("ClientKeysTable.importWizard.error.dlgTitle"), (Object)LEX.getText("ClientKeysTable.importWizard.error.dlgMessage"), (Throwable)throwable);
}
finally {
if (ImportWizardModel.this.owner != null) {
ImportWizardModel.this.owner.exitBusy();
}
}
}
}.start();
}
public boolean finish() {
return this.getCurrentStep().exit(4);
}
public ImportWizardStep getCurrentStep() {
return this.currentStep;
}
public void update(ImportWizardStep importWizardStep) {
this.currentStep = importWizardStep;
this.update(importWizardStep.getWidget(), importWizardStep.getMode());
}
public Size getPreferredSizeOfSteps() {
return new Size(680.0, 480.0);
}
}
protected class ImportCommand
extends Command {
public ImportCommand() {
super((BWidget)BClientKeysTable.this, LEX, "ClientKeysTable.import");
}
public CommandArtifact doInvoke() {
try {
ImportWizardModel importWizardModel = new ImportWizardModel(this.getOwner(), null);
BWizard.open((BWidget)this.getOwner(), (WizardModel)importWizardModel);
ClientPrivateKeyInfo clientPrivateKeyInfo = importWizardModel.getKeyInfo();
if (clientPrivateKeyInfo != null) {
Object object = BClientKeysTable.this.beginFileTransfer();
BClientKeysTable.this.install(clientPrivateKeyInfo, object);
BClientKeysTable.this.commitFileTransfer(object);
BClientKeysTable.this.keysModel().load();
}
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
return null;
}
}
protected class BackupCommand
extends Command {
public BackupCommand() {
super((BWidget)BClientKeysTable.this, LEX, "ClientKeysTable.backup");
}
public CommandArtifact doInvoke() {
return null;
}
}
protected class ViewCommand
extends Command {
public ViewCommand() {
super((BWidget)BClientKeysTable.this, LEX, "ClientKeysTable.view");
}
public CommandArtifact doInvoke() {
return null;
}
}
protected class DeleteCommand
extends Command {
public DeleteCommand() {
super((BWidget)BClientKeysTable.this, LEX, "ClientKeysTable.delete");
}
public CommandArtifact doInvoke() {
try {
if (4 == BDialog.confirm((BWidget)BClientKeysTable.this, (String)LEX.getText("ClientKeysTable.delete.dlgTitle"), (Object)LEX.getText("ClientKeysTable.delete.dlgMessage"), (int)12)) {
int[] nArray = BClientKeysTable.this.getSelection().getRows();
Object object = BClientKeysTable.this.beginFileTransfer();
for (int i = 0; i < nArray.length; ++i) {
BClientKeysTable.this.delete(BClientKeysTable.this.keysModel().keyInfo(nArray[i]), object);
}
BClientKeysTable.this.commitFileTransfer(object);
BClientKeysTable.this.keysModel().load();
}
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
return null;
}
}
protected class Model
extends TableModel {
private Array keys = new Array(class$com$tridium$platform$pki$ClientPrivateKeyInfo == null ? (class$com$tridium$platform$pki$ClientPrivateKeyInfo = BClientKeysTable.class$("com.tridium.platform.pki.ClientPrivateKeyInfo")) : class$com$tridium$platform$pki$ClientPrivateKeyInfo);
protected Model() {
}
public void load() throws Exception {
if (BClientKeysTable.this.keyDir == null) {
this.keys.clear();
} else {
this.keys = new Array((Object[])ClientPrivateKeyInfo.make(BClientKeysTable.this.keyDir.listFiles(), BClientKeysTable.this.certDir));
}
this.updateTable(true);
}
public int getColumnCount() {
return 2;
}
public String getColumnName(int n) {
switch (n) {
case 0: {
return LEX.getText("ClientKeysTable.col.keyFile");
}
case 1: {
return LEX.getText("ClientKeysTable.col.certFile");
}
}
throw new IndexOutOfBoundsException();
}
public int getRowCount() {
return this.keys.size();
}
public ClientPrivateKeyInfo keyInfo(int n) {
return (ClientPrivateKeyInfo)this.keys.get(n);
}
public Object getValueAt(int n, int n2) {
switch (n2) {
case 0: {
return this.keyInfo((int)n).keyFile.getFileName();
}
case 1: {
return this.keyInfo((int)n).certFile == null ? null : this.keyInfo((int)n).certFile.getFileName();
}
}
throw new IndexOutOfBoundsException();
}
}
}
@@ -0,0 +1,164 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.tridium.ui.theme.Theme
* javax.baja.file.BFileSpace
* javax.baja.gx.BBrush
* javax.baja.gx.BInsets
* javax.baja.naming.BOrd
* javax.baja.sys.BObject
* javax.baja.sys.BValue
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BBorder
* javax.baja.ui.BLabel
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.enums.BHalign
* javax.baja.ui.pane.BBorderPane
* javax.baja.ui.pane.BEdgePane
* javax.baja.ui.pane.BGridPane
* javax.baja.ui.pane.BScrollPane
* javax.baja.ui.pane.BTabbedPane
* javax.baja.ui.table.BTable
* javax.baja.ui.util.BTitlePane
* javax.baja.util.Lexicon
* javax.baja.util.LexiconText
* javax.baja.workbench.view.BWbComponentView
*/
package com.tridium.platform.ui.pki;
import com.tridium.platform.pki.ClientPrivateKeyInfo;
import com.tridium.platform.pki.PemCertInfo;
import com.tridium.platform.ui.pki.BCACertsTable;
import com.tridium.platform.ui.pki.BClientKeysTable;
import com.tridium.platform.ui.pki.BServerCertsTable;
import com.tridium.platform.ui.util.BButtonPane;
import com.tridium.ui.theme.Theme;
import javax.baja.file.BFileSpace;
import javax.baja.gx.BBrush;
import javax.baja.gx.BInsets;
import javax.baja.naming.BOrd;
import javax.baja.sys.BObject;
import javax.baja.sys.BValue;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BBorder;
import javax.baja.ui.BLabel;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.enums.BHalign;
import javax.baja.ui.pane.BBorderPane;
import javax.baja.ui.pane.BEdgePane;
import javax.baja.ui.pane.BGridPane;
import javax.baja.ui.pane.BScrollPane;
import javax.baja.ui.pane.BTabbedPane;
import javax.baja.ui.table.BTable;
import javax.baja.ui.util.BTitlePane;
import javax.baja.util.Lexicon;
import javax.baja.util.LexiconText;
import javax.baja.workbench.view.BWbComponentView;
public class BPKICertificateManager
extends BWbComponentView {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$pki$BPKICertificateManager == null ? (class$com$tridium$platform$ui$pki$BPKICertificateManager = BPKICertificateManager.class$("com.tridium.platform.ui.pki.BPKICertificateManager")) : class$com$tridium$platform$ui$pki$BPKICertificateManager));
protected BLabel caDesription;
protected BEdgePane caCertsPane;
protected BButtonPane caCertsButtons;
protected BLabel serverCertsDesription;
protected BEdgePane serverCertsPane;
protected BButtonPane serverCertsButtons;
protected BLabel clientKeysDesription;
protected BEdgePane clientKeysPane;
protected BButtonPane clientKeysButtons;
protected BTabbedPane tabbedPane = new BTabbedPane();
protected static final Lexicon LEX = Lexicon.make((String)"platform");
static /* synthetic */ Class class$com$tridium$platform$ui$pki$BPKICertificateManager;
public Type getType() {
return TYPE;
}
public BPKICertificateManager() {
this.caCertsButtons = new BButtonPane();
this.clientKeysButtons = new BButtonPane();
this.serverCertsButtons = new BButtonPane();
this.caDesription = new BLabel(LEX.getText("CACertsTable.description"), Theme.widget().getBoldText());
this.caCertsPane = new BEdgePane();
this.caCertsPane.setTop((BWidget)new BBorderPane(this.left((BWidget)this.caDesription)));
this.clientKeysDesription = new BLabel(LEX.getText("ClientKeysTable.description"), Theme.widget().getBoldText());
this.clientKeysPane = new BEdgePane();
this.clientKeysPane.setTop((BWidget)new BBorderPane(this.left((BWidget)this.clientKeysDesription)));
this.serverCertsDesription = new BLabel(LEX.getText("ServerCertsTable.description"), Theme.widget().getBoldText());
this.serverCertsPane = new BEdgePane();
this.serverCertsPane.setTop((BWidget)new BBorderPane(this.left((BWidget)this.serverCertsDesription)));
BBrush bBrush = Theme.scrollPane().getControlBackground();
BScrollPane bScrollPane = new BScrollPane((BWidget)new BBorderPane((BWidget)this.tabbedPane));
bScrollPane.setViewportBackground(bBrush);
this.setContent((BWidget)new BBorderPane((BWidget)bScrollPane, BBorder.inset, BInsets.DEFAULT));
}
protected void doLoadValue(BObject bObject, Context context) throws Exception {
BFileSpace bFileSpace = (BFileSpace)BOrd.make((String)"file:").get(bObject);
BCACertsTable bCACertsTable = new BCACertsTable(PemCertInfo.CA_CERTS_PATH, bFileSpace);
Command[] commandArray = bCACertsTable.getCommands();
this.caCertsButtons.removeAll();
for (int i = 0; i < commandArray.length; ++i) {
this.caCertsButtons.add(commandArray[i]);
}
BTitlePane bTitlePane = BTitlePane.makePane((String)LEX.getText("PKICertificateManager.caCerts"), (BTable)bCACertsTable);
BBorderPane bBorderPane = new BBorderPane((BWidget)this.caCertsButtons);
bBorderPane.setPadding(BInsets.make((double)5.0, (double)0.0, (double)5.0, (double)0.0));
bTitlePane.setBottom((BWidget)bBorderPane);
this.caCertsPane.setCenter((BWidget)new BBorderPane((BWidget)bTitlePane, BInsets.make((double)0.0, (double)7.0, (double)7.0, (double)7.0)));
bCACertsTable.load();
BServerCertsTable bServerCertsTable = new BServerCertsTable(PemCertInfo.SERVER_CERTS_PATH, bFileSpace);
commandArray = bServerCertsTable.getCommands();
this.serverCertsButtons.removeAll();
for (int i = 0; i < commandArray.length; ++i) {
this.serverCertsButtons.add(commandArray[i]);
}
BTitlePane bTitlePane2 = BTitlePane.makePane((String)LEX.getText("PKICertificateManager.serverCerts"), (BTable)bServerCertsTable);
BBorderPane bBorderPane2 = new BBorderPane((BWidget)this.serverCertsButtons);
bBorderPane2.setPadding(BInsets.make((double)5.0, (double)0.0, (double)5.0, (double)0.0));
bTitlePane2.setBottom((BWidget)bBorderPane2);
this.serverCertsPane.setCenter((BWidget)new BBorderPane((BWidget)bTitlePane2, BInsets.make((double)0.0, (double)7.0, (double)7.0, (double)7.0)));
bServerCertsTable.load();
BClientKeysTable bClientKeysTable = new BClientKeysTable(ClientPrivateKeyInfo.CLIENT_KEYS_PATH, ClientPrivateKeyInfo.CLIENT_CERTS_PATH, bFileSpace);
commandArray = bClientKeysTable.getCommands();
this.clientKeysButtons.removeAll();
for (int i = 0; i < commandArray.length; ++i) {
this.clientKeysButtons.add(commandArray[i]);
}
BTitlePane bTitlePane3 = BTitlePane.makePane((String)LEX.getText("PKICertificateManager.clientKeys"), (BTable)bClientKeysTable);
BBorderPane bBorderPane3 = new BBorderPane((BWidget)this.clientKeysButtons);
bBorderPane3.setPadding(BInsets.make((double)5.0, (double)0.0, (double)5.0, (double)0.0));
bTitlePane3.setBottom((BWidget)bBorderPane3);
this.clientKeysPane.setCenter((BWidget)new BBorderPane((BWidget)bTitlePane3, BInsets.make((double)0.0, (double)7.0, (double)7.0, (double)7.0)));
bClientKeysTable.load();
this.tabbedPane.addPane(new BLabel(LexiconText.make((Type)TYPE, (String)"PKICertificateManager.clientKeys").getText(context), Theme.widget().getBoldText()), (BWidget)this.clientKeysPane);
this.tabbedPane.addPane(new BLabel(LexiconText.make((Type)TYPE, (String)"PKICertificateManager.serverCerts").getText(context), Theme.widget().getBoldText()), (BWidget)this.serverCertsPane);
this.tabbedPane.addPane(new BLabel(LexiconText.make((Type)TYPE, (String)"PKICertificateManager.caCerts").getText(context), Theme.widget().getBoldText()), (BWidget)this.caCertsPane);
}
private BWidget left(BWidget bWidget) {
BGridPane bGridPane = new BGridPane(1);
bGridPane.setHalign(BHalign.left);
bGridPane.setColumnAlign(BHalign.left);
bGridPane.add(null, (BValue)bWidget);
return bGridPane;
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,65 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.agent.BIAgent
* javax.baja.naming.BISession
* javax.baja.sys.Context
* javax.baja.sys.Sys
* javax.baja.sys.Type
*/
package com.tridium.platform.ui.pki;
import com.tridium.platform.BSessionNavNode;
import com.tridium.platform.BSessionNavNodeFactory;
import com.tridium.platform.daemon.BDaemonSession;
import com.tridium.platform.daemon.BHostProperties;
import com.tridium.platform.ui.pki.BPKICertificateManager;
import javax.baja.agent.BIAgent;
import javax.baja.naming.BISession;
import javax.baja.sys.Context;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
public class BPKINavNodeFactory
extends BSessionNavNodeFactory
implements BIAgent {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$pki$BPKINavNodeFactory == null ? (class$com$tridium$platform$ui$pki$BPKINavNodeFactory = BPKINavNodeFactory.class$("com.tridium.platform.ui.pki.BPKINavNodeFactory")) : class$com$tridium$platform$ui$pki$BPKINavNodeFactory));
static /* synthetic */ Class class$com$tridium$platform$ui$pki$BPKINavNodeFactory;
public Type getType() {
return TYPE;
}
public boolean equivalent(Object object) {
return false;
}
public String toString(Context context) {
return null;
}
public void connect() {
BDaemonSession bDaemonSession = (BDaemonSession)this.getNavSession();
BSessionNavNode[] bSessionNavNodeArray = new BSessionNavNode[]{new BSessionNavNode((BISession)bDaemonSession, BPKICertificateManager.TYPE)};
boolean bl = false;
BHostProperties bHostProperties = bDaemonSession.getHostProperties();
if (bHostProperties.supportsServlet("wifi")) {
bl = true;
}
if (bHostProperties.supportsServlet("ieee8021x") && !bHostProperties.supportsServlet("crypto")) {
bl = true;
}
this.setNavNodes(bl ? bSessionNavNodeArray : new BSessionNavNode[]{});
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
}
@@ -0,0 +1,377 @@
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* javax.baja.file.BDirectory
* javax.baja.file.BFileSpace
* javax.baja.file.BFileSystem
* javax.baja.file.BIFile
* javax.baja.file.FilePath
* javax.baja.file.FileUtil
* javax.baja.file.IFileFilter
* javax.baja.gx.BImage
* javax.baja.nre.util.Array
* javax.baja.sys.Sys
* javax.baja.sys.Type
* javax.baja.ui.BDialog
* javax.baja.ui.BWidget
* javax.baja.ui.Command
* javax.baja.ui.CommandArtifact
* javax.baja.ui.file.ExtFileFilter
* javax.baja.ui.table.TableModel
* javax.baja.util.Lexicon
*/
package com.tridium.platform.ui.pki;
import com.tridium.platform.daemon.DaemonFileUtil;
import com.tridium.platform.daemon.file.BDaemonFileSpace;
import com.tridium.platform.daemon.message.FileTransferMessage;
import com.tridium.platform.pki.PemCertInfo;
import com.tridium.platform.ui.util.BCommandBoundTable;
import com.tridium.platform.ui.util.BCommandEnablePolicy;
import com.tridium.platform.ui.util.BFileChooserDialog;
import com.tridium.platform.ui.util.BIndentPane;
import com.tridium.platform.ui.util.CommandBindings;
import com.tridium.platform.ui.util.CommandUtil;
import com.tridium.platform.ui.util.FavoriteDirectory;
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.file.FileUtil;
import javax.baja.file.IFileFilter;
import javax.baja.gx.BImage;
import javax.baja.nre.util.Array;
import javax.baja.sys.Sys;
import javax.baja.sys.Type;
import javax.baja.ui.BDialog;
import javax.baja.ui.BWidget;
import javax.baja.ui.Command;
import javax.baja.ui.CommandArtifact;
import javax.baja.ui.file.ExtFileFilter;
import javax.baja.ui.table.TableModel;
import javax.baja.util.Lexicon;
public class BServerCertsTable
extends BCommandBoundTable
implements CommandBindings.Support {
public static final Type TYPE = Sys.loadType((Class)(class$com$tridium$platform$ui$pki$BServerCertsTable == null ? (class$com$tridium$platform$ui$pki$BServerCertsTable = BServerCertsTable.class$("com.tridium.platform.ui.pki.BServerCertsTable")) : class$com$tridium$platform$ui$pki$BServerCertsTable));
public static final Lexicon LEX = Lexicon.make((String)"platform");
public static final ExtFileFilter PEM_FILTER = new ExtFileFilter("", "pem,crt,cer");
protected BDirectory dir;
protected FilePath dirPath;
protected BFileSpace space;
public static final int COL_SOURCE = 0;
public static final int COL_ISSUER = 1;
public static final int COL_SUBJECT = 2;
public static final int COL_START = 3;
public static final int COL_END = 4;
public static final int COL_ALG = 5;
protected boolean readonly = false;
static /* synthetic */ Class class$com$tridium$platform$ui$pki$BServerCertsTable;
static /* synthetic */ Class class$com$tridium$platform$pki$PemCertInfo;
static /* synthetic */ Class class$java$lang$String;
public Type getType() {
return TYPE;
}
public BServerCertsTable() {
throw new UnsupportedOperationException();
}
public BServerCertsTable(FilePath filePath, BFileSpace bFileSpace, CommandBindings.TableController tableController) throws Exception {
super(new ServerCertModel(), tableController);
this.dirPath = filePath;
this.space = bFileSpace;
this.dir = this.initDir(filePath);
this.initCommands();
}
public BServerCertsTable(FilePath filePath, BFileSpace bFileSpace) throws Exception {
super(new ServerCertModel());
this.dirPath = filePath;
this.space = bFileSpace;
this.dir = this.initDir(filePath);
this.initCommands();
}
public void load() throws Exception {
this.serverCertModel().load(this.dir);
}
protected void initCommands() {
this.getCommandBindings().setSupport(this);
this.addCommand(new ImportCommand(), BCommandEnablePolicy.always);
this.addCommand(new ExportCommand(), BCommandEnablePolicy.anySelection);
ViewCommand viewCommand = new ViewCommand();
this.addCommand(viewCommand, BCommandEnablePolicy.singleSelection);
this.setDoubleClickCommand(viewCommand);
this.addCommand(new DeleteCommand(), BCommandEnablePolicy.anySelection);
}
protected ServerCertModel serverCertModel() {
return (ServerCertModel)this.getModel();
}
protected BDirectory initDir(FilePath filePath) throws Exception {
if (this.space instanceof BDaemonFileSpace) {
BDirectory bDirectory = (BDirectory)this.space.findFile(filePath);
if (bDirectory == null) {
this.initDir(filePath.getParent());
BDaemonFileSpace bDaemonFileSpace = (BDaemonFileSpace)this.space;
DaemonFileUtil.transfer(bDaemonFileSpace.getDaemonSession(), FileTransferMessage.makeMkDir(filePath, bDaemonFileSpace), null);
bDirectory = (BDirectory)this.space.findFile(filePath);
}
return bDirectory;
}
return this.space.makeDir(this.dirPath);
}
protected Object beginFileTransfer() {
if (this.space instanceof BDaemonFileSpace) {
return new FileTransferMessage((BDaemonFileSpace)this.space);
}
return null;
}
protected void installCertFile(BIFile bIFile, Object object) throws Exception {
FilePath filePath = this.dir.getFilePath().merge(FileUtil.getBase((String)bIFile.getFileName()) + ".pem");
if (this.space instanceof BDaemonFileSpace) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
fileTransferMessage.addFile(bIFile, filePath);
} else {
BIFile bIFile2 = this.dir.getFileSpace().makeFile(filePath);
FileUtil.pipe((BIFile)bIFile, (BIFile)bIFile2);
}
}
protected void deleteCertFile(BIFile bIFile, Object object) throws Exception {
if (this.space instanceof BDaemonFileSpace) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
fileTransferMessage.addDelete(bIFile.getFilePath());
} else {
bIFile.delete();
}
}
protected void commitFileTransfer(Object object) throws Exception {
if (object != null) {
FileTransferMessage fileTransferMessage = (FileTransferMessage)object;
DaemonFileUtil.transfer(fileTransferMessage.getTargetFileSpace().getDaemonSession(), (FileTransferMessage)object, null);
}
}
public boolean isReadonly() {
return this.readonly;
}
public void setReadonly(boolean bl) {
this.readonly = bl;
this.setCommandEnabledStates();
}
public void setBoundCommandEnabled(Command command, boolean bl) {
if (this.readonly && (command instanceof ImportCommand || command instanceof DeleteCommand)) {
command.setEnabled(false);
} else {
command.setEnabled(bl);
}
}
static /* synthetic */ Class class$(String string) {
try {
return Class.forName(string);
}
catch (ClassNotFoundException classNotFoundException) {
throw new NoClassDefFoundError(classNotFoundException.getMessage());
}
}
protected class ExportCommand
extends Command {
public ExportCommand() {
super((BWidget)BServerCertsTable.this, LEX, "ServerCertsTable.export");
}
public CommandArtifact doInvoke() {
try {
BDirectory bDirectory = FavoriteDirectory.loadByPath(BServerCertsTable.this.getType().toString(), "exportDir", null);
BDirectory bDirectory2 = (BDirectory)BFileChooserDialog.chooseFile(this.getOwner(), null, LEX.getText("ServerCertsTable.export.dlgTitle"), LEX.getText("ServerCertsTable.export.dlgMessage"), (BIFile)bDirectory, IFileFilter.directory, null, null);
if (bDirectory2 != null) {
int[] nArray = BServerCertsTable.this.getSelection().getRows();
for (int i = 0; i < nArray.length; ++i) {
BIFile bIFile = BServerCertsTable.this.serverCertModel().cert((int)nArray[i]).file;
BIFile bIFile2 = BFileSystem.INSTANCE.makeFile(bDirectory2.getFilePath().merge(bIFile.getFileName()));
FileUtil.pipe((BIFile)bIFile, (BIFile)bIFile2);
}
FavoriteDirectory.savePath(BServerCertsTable.this.getType().toString(), "exportDir", bDirectory2.getFilePath().getParent());
}
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
return null;
}
}
protected class DeleteCommand
extends Command {
public DeleteCommand() {
super((BWidget)BServerCertsTable.this, LEX, "ServerCertsTable.delete");
}
public CommandArtifact doInvoke() {
try {
if (4 == BDialog.confirm((BWidget)BServerCertsTable.this, (String)LEX.getText("ServerCertsTable.delete.dlgTitle"), (Object)LEX.getText("ServerCertsTable.delete.dlgMessage"), (int)12)) {
int[] nArray = BServerCertsTable.this.getSelection().getRows();
Object object = BServerCertsTable.this.beginFileTransfer();
for (int i = 0; i < nArray.length; ++i) {
BServerCertsTable.this.deleteCertFile(BServerCertsTable.this.serverCertModel().cert((int)nArray[i]).file, object);
}
BServerCertsTable.this.commitFileTransfer(object);
BServerCertsTable.this.serverCertModel().load(BServerCertsTable.this.dir);
}
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
return null;
}
}
protected class ImportCommand
extends Command {
public ImportCommand() {
super((BWidget)BServerCertsTable.this, LEX, "ServerCertsTable.import");
}
public CommandArtifact doInvoke() {
try {
BDirectory bDirectory = FavoriteDirectory.loadByPath(BServerCertsTable.this.getType().toString(), "serverCertDir", null);
BIFile[] bIFileArray = BFileChooserDialog.chooseFiles(this.getOwner(), BImage.make((String)LEX.getText("ServerCertsTable.import.dlgIcon")), LEX.getText("ServerCertsTable.import.dlgTitle"), LEX.getText("ServerCertsTable.import.dlgMessage"), (BIFile)bDirectory, (IFileFilter)PEM_FILTER, (IFileFilter)PEM_FILTER);
if (bIFileArray == null || bIFileArray.length == 0) {
return null;
}
PemCertInfo[] pemCertInfoArray = PemCertInfo.makeCertificates(bIFileArray);
Object object = BServerCertsTable.this.beginFileTransfer();
Array array = new Array(class$java$lang$String == null ? (class$java$lang$String = BServerCertsTable.class$("java.lang.String")) : class$java$lang$String);
for (int i = 0; i < pemCertInfoArray.length; ++i) {
if (pemCertInfoArray[i].cert == null) {
array.add((Object)pemCertInfoArray[i].file.getFileName());
continue;
}
BServerCertsTable.this.installCertFile(pemCertInfoArray[i].file, object);
}
BServerCertsTable.this.commitFileTransfer(object);
if (array.size() > 0) {
BIndentPane bIndentPane = new BIndentPane();
bIndentPane.add(LEX.getText("ServerCertsTable.import.invalidFile.header"));
bIndentPane.indent();
for (int i = 0; i < array.size(); ++i) {
bIndentPane.add(array.get(i).toString());
}
BDialog.warning((BWidget)this.getOwner(), (String)LEX.getText("ServerCertsTable.import.invalidFile.dlgTitle"), (Object)((Object)bIndentPane));
}
BServerCertsTable.this.serverCertModel().load(BServerCertsTable.this.dir);
if (bIFileArray.length > 0) {
FavoriteDirectory.savePath(BServerCertsTable.this.getType().toString(), "serverCertDir", bIFileArray[0].getFilePath().getParent());
}
}
catch (Exception exception) {
CommandUtil.error(this, exception);
}
return null;
}
}
protected class ViewCommand
extends Command {
public ViewCommand() {
super((BWidget)BServerCertsTable.this, LEX, "ServerCertsTable.view");
}
public CommandArtifact doInvoke() {
return null;
}
}
protected static class ServerCertModel
extends TableModel {
private Array certs = new Array(class$com$tridium$platform$pki$PemCertInfo == null ? (class$com$tridium$platform$pki$PemCertInfo = BServerCertsTable.class$("com.tridium.platform.pki.PemCertInfo")) : class$com$tridium$platform$pki$PemCertInfo);
protected ServerCertModel() {
}
public void load(BDirectory bDirectory) throws Exception {
if (bDirectory == null) {
this.certs.clear();
} else {
this.certs = new Array((Object[])PemCertInfo.makeCertificates(bDirectory.listFiles()));
}
this.updateTable(true);
}
public int getColumnCount() {
return 6;
}
public String getColumnName(int n) {
switch (n) {
case 0: {
return LEX.getText("ServerCertsTable.col.source");
}
case 1: {
return LEX.getText("ServerCertsTable.col.issuer");
}
case 2: {
return LEX.getText("ServerCertsTable.col.subject");
}
case 3: {
return LEX.getText("ServerCertsTable.col.start");
}
case 4: {
return LEX.getText("ServerCertsTable.col.end");
}
case 5: {
return LEX.getText("ServerCertsTable.col.sig");
}
}
throw new IndexOutOfBoundsException();
}
public int getRowCount() {
return this.certs.size();
}
public PemCertInfo cert(int n) {
return (PemCertInfo)this.certs.get(n);
}
public Object getValueAt(int n, int n2) {
switch (n2) {
case 0: {
return this.cert((int)n).file.getFileName();
}
case 1: {
return this.cert(n).getIssuer();
}
case 2: {
return this.cert(n).getSubject();
}
case 3: {
return this.cert(n).getStart();
}
case 4: {
return this.cert(n).getEnd();
}
case 5: {
return this.cert(n).getSignatureAlgName();
}
}
throw new IndexOutOfBoundsException();
}
}
}