309 lines
12 KiB
Java
309 lines
12 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* javax.baja.nre.util.Array
|
|
*/
|
|
package com.tridium.util;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.StringTokenizer;
|
|
import javax.baja.file.BAbstractFile;
|
|
import javax.baja.file.BFileSystem;
|
|
import javax.baja.file.BIFile;
|
|
import javax.baja.file.BScopedFileSpace;
|
|
import javax.baja.file.FilePath;
|
|
import javax.baja.naming.UnresolvedException;
|
|
import javax.baja.nre.util.Array;
|
|
import javax.baja.security.BPermissions;
|
|
import javax.baja.sys.Context;
|
|
import javax.baja.sys.Sys;
|
|
import javax.baja.sys.Type;
|
|
import javax.baja.user.BUser;
|
|
import javax.baja.util.LexiconText;
|
|
import javax.baja.util.PatternFilter;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public final class BRestrictedFileSpace
|
|
extends BScopedFileSpace {
|
|
public static final Type TYPE;
|
|
public static final BRestrictedFileSpace INSTANCE;
|
|
private static final FilePath STATION_HOME_SCOPE;
|
|
private static String SYS_HOME_CANONICAL_PATH;
|
|
private static String STATION_HOME_CANONICAL_PATH;
|
|
private static int SYS_HOME_CANONICAL_PATH_LENGTH;
|
|
private static int STATION_HOME_CANONICAL_PATH_LENGTH;
|
|
private static PatternFilter[] FILE_NAME_BLACKLIST;
|
|
private static Array FILE_PATH_BLACKLIST;
|
|
static /* synthetic */ Class class$com$tridium$util$BRestrictedFileSpace;
|
|
static /* synthetic */ Class class$java$lang$String;
|
|
|
|
public final Type getType() {
|
|
return TYPE;
|
|
}
|
|
|
|
public final boolean inScope(FilePath filePath) {
|
|
return super.inScope(filePath);
|
|
}
|
|
|
|
public final boolean isBlacklisted(BIFile bIFile) {
|
|
if (bIFile == null) {
|
|
return false;
|
|
}
|
|
return this.isBlacklistedFilePath(bIFile.getFilePath());
|
|
}
|
|
|
|
private final boolean isBlacklistedFilePath(FilePath filePath) {
|
|
Object object;
|
|
Object object2;
|
|
Object object3;
|
|
String string = null;
|
|
File file = null;
|
|
try {
|
|
file = BFileSystem.INSTANCE.pathToLocalFile(filePath).getCanonicalFile();
|
|
string = file.getName();
|
|
}
|
|
catch (Exception exception) {
|
|
return true;
|
|
}
|
|
if (string != null) {
|
|
object3 = string.toLowerCase();
|
|
if (((String)object3).startsWith("config") && ((String)object3).endsWith(".bog") || ((String)object3).equals("config.bog.lock") || ((String)object3).equals("config.bog.working")) {
|
|
return true;
|
|
}
|
|
if (((String)object3).endsWith(".properties")) {
|
|
object2 = BFileSystem.INSTANCE.getStationHome();
|
|
if (object2 == null) {
|
|
return true;
|
|
}
|
|
object = filePath;
|
|
boolean bl = false;
|
|
while (object != null) {
|
|
BIFile bIFile = null;
|
|
try {
|
|
bIFile = BFileSystem.INSTANCE.resolveFile((FilePath)object);
|
|
}
|
|
catch (Exception exception) {
|
|
bIFile = null;
|
|
}
|
|
if (bIFile != null) {
|
|
if (((BAbstractFile)object2).equals(bIFile)) {
|
|
bl = true;
|
|
break;
|
|
}
|
|
object = bIFile.getFilePath().getParent();
|
|
continue;
|
|
}
|
|
object = ((FilePath)object).getParent();
|
|
}
|
|
if (!bl) {
|
|
return true;
|
|
}
|
|
}
|
|
if (FILE_NAME_BLACKLIST != null) {
|
|
int n = 0;
|
|
while (n < FILE_NAME_BLACKLIST.length) {
|
|
if (FILE_NAME_BLACKLIST[n].accept(string)) {
|
|
return true;
|
|
}
|
|
++n;
|
|
}
|
|
}
|
|
}
|
|
if (FILE_PATH_BLACKLIST != null) {
|
|
object3 = filePath;
|
|
try {
|
|
object2 = file.getCanonicalPath();
|
|
if (filePath.isStationHomeAbsolute()) {
|
|
if (STATION_HOME_CANONICAL_PATH_LENGTH == -1) {
|
|
STATION_HOME_CANONICAL_PATH = Sys.getStationHome().getCanonicalPath();
|
|
STATION_HOME_CANONICAL_PATH_LENGTH = STATION_HOME_CANONICAL_PATH.length() + 1;
|
|
}
|
|
if (!((String)object2).equalsIgnoreCase(STATION_HOME_CANONICAL_PATH)) {
|
|
object3 = new FilePath(filePath.getScheme(), "^" + ((String)object2).substring(STATION_HOME_CANONICAL_PATH_LENGTH).replace(File.separatorChar, '/'));
|
|
}
|
|
} else if (filePath.isSysHomeAbsolute()) {
|
|
if (SYS_HOME_CANONICAL_PATH_LENGTH == -1) {
|
|
SYS_HOME_CANONICAL_PATH = Sys.getBajaHome().getCanonicalPath();
|
|
SYS_HOME_CANONICAL_PATH_LENGTH = SYS_HOME_CANONICAL_PATH.length() + 1;
|
|
}
|
|
if (!((String)object2).equalsIgnoreCase(SYS_HOME_CANONICAL_PATH)) {
|
|
object3 = new FilePath(filePath.getScheme(), "!" + ((String)object2).substring(SYS_HOME_CANONICAL_PATH_LENGTH).replace(File.separatorChar, '/'));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception exception) {
|
|
return true;
|
|
}
|
|
object2 = null;
|
|
while (object3 != null) {
|
|
object = ((FilePath)object3).getBody().toLowerCase();
|
|
if (FILE_PATH_BLACKLIST.contains(object)) {
|
|
return true;
|
|
}
|
|
if (((String)object).equals("!stations") && object2 != null && !((String)object2).equalsIgnoreCase(Sys.getStation().getStationName())) {
|
|
return true;
|
|
}
|
|
object2 = ((FilePath)object3).getName();
|
|
object3 = ((FilePath)object3).getParent();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* Unable to fully structure code
|
|
*/
|
|
public final boolean isBlacklistedForUser(BUser var1_1, BIFile var2_2) {
|
|
var3_3 = var2_2.getFilePath();
|
|
var4_4 = null;
|
|
var5_5 = null;
|
|
try {
|
|
var5_5 = BFileSystem.INSTANCE.pathToLocalFile(var3_3).getCanonicalFile();
|
|
var4_4 = var5_5.getName();
|
|
}
|
|
catch (Exception var6_6) {
|
|
return true;
|
|
}
|
|
if (var4_4 != null && (var6_7 = var4_4.toLowerCase()).endsWith(".dist") && !(var7_9 = var1_1.getPermissionsFor(var2_2)).hasAdminRead()) {
|
|
return true;
|
|
}
|
|
try {
|
|
if (var3_3.isStationHomeAbsolute()) {
|
|
var6_7 = var5_5.getCanonicalPath();
|
|
if (BRestrictedFileSpace.STATION_HOME_CANONICAL_PATH_LENGTH < 0) {
|
|
BRestrictedFileSpace.STATION_HOME_CANONICAL_PATH = Sys.getStationHome().getCanonicalPath();
|
|
BRestrictedFileSpace.STATION_HOME_CANONICAL_PATH_LENGTH = BRestrictedFileSpace.STATION_HOME_CANONICAL_PATH.length() + 1;
|
|
}
|
|
if (!var6_7.equalsIgnoreCase(BRestrictedFileSpace.STATION_HOME_CANONICAL_PATH)) {
|
|
var3_3 = new FilePath(var3_3.getScheme(), "^" + var6_7.substring(BRestrictedFileSpace.STATION_HOME_CANONICAL_PATH_LENGTH).replace(File.separatorChar, '/'));
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
if (true) ** GOTO lbl31
|
|
}
|
|
catch (Exception var6_8) {
|
|
return true;
|
|
}
|
|
do {
|
|
if ((var6_7 = var3_3.getBody().toLowerCase()).equals("^provisioningniagara")) {
|
|
var7_9 = var1_1.getPermissionsFor(var2_2);
|
|
if (var7_9.hasAdminRead()) break;
|
|
return true;
|
|
}
|
|
var3_3 = var3_3.getParent();
|
|
lbl31:
|
|
// 2 sources
|
|
|
|
} while (var3_3 != null);
|
|
return false;
|
|
}
|
|
|
|
public final BPermissions getPermissionsFor(FilePath filePath, Context context) {
|
|
if (this.inScope(filePath)) {
|
|
return super.getPermissionsFor(filePath, context);
|
|
}
|
|
return BPermissions.none;
|
|
}
|
|
|
|
protected final FilePath scopedPathToAbsPath(FilePath filePath) {
|
|
switch (filePath.getAbsoluteMode()) {
|
|
case 0: {
|
|
return STATION_HOME_SCOPE.merge(filePath);
|
|
}
|
|
case 2: {
|
|
return STATION_HOME_SCOPE.merge(new FilePath(filePath.getScheme(), filePath.getBody().substring(1)));
|
|
}
|
|
case 3:
|
|
case 4: {
|
|
if (!this.inScope(filePath)) break;
|
|
return filePath;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public final BIFile makeFile(FilePath filePath, Context context) throws IOException {
|
|
if (this.isBlacklistedFilePath(filePath)) {
|
|
throw new UnresolvedException("File path is out of scope: " + filePath.getBody());
|
|
}
|
|
return super.makeFile(filePath, context);
|
|
}
|
|
|
|
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 BRestrictedFileSpace() {
|
|
super(new FilePath("!"), "remoteFileSpace", LexiconText.make("baja", "nav.stationHome"));
|
|
}
|
|
|
|
static {
|
|
Class clazz = class$com$tridium$util$BRestrictedFileSpace;
|
|
if (clazz == null) {
|
|
clazz = class$com$tridium$util$BRestrictedFileSpace = BRestrictedFileSpace.class("[Lcom.tridium.util.BRestrictedFileSpace;", false);
|
|
}
|
|
TYPE = Sys.loadType(clazz);
|
|
INSTANCE = new BRestrictedFileSpace();
|
|
STATION_HOME_SCOPE = new FilePath("^");
|
|
SYS_HOME_CANONICAL_PATH = null;
|
|
STATION_HOME_CANONICAL_PATH = null;
|
|
SYS_HOME_CANONICAL_PATH_LENGTH = -1;
|
|
STATION_HOME_CANONICAL_PATH_LENGTH = -1;
|
|
FILE_NAME_BLACKLIST = null;
|
|
FILE_PATH_BLACKLIST = null;
|
|
String string = System.getProperty("niagara.remoteBlacklist.fileNamePatterns", null);
|
|
if (string != null) {
|
|
try {
|
|
FILE_NAME_BLACKLIST = PatternFilter.parseList(string, ";");
|
|
}
|
|
catch (Exception exception) {
|
|
System.out.println("Could not parse file name patterns for remote blacklist.");
|
|
exception.printStackTrace();
|
|
}
|
|
}
|
|
String string2 = System.getProperty("niagara.remoteBlacklist.filePaths", null);
|
|
Class clazz2 = class$java$lang$String;
|
|
if (clazz2 == null) {
|
|
clazz2 = class$java$lang$String = BRestrictedFileSpace.class("[Ljava.lang.String;", false);
|
|
}
|
|
FILE_PATH_BLACKLIST = new Array(clazz2);
|
|
FILE_PATH_BLACKLIST.add((Object)"!backups");
|
|
FILE_PATH_BLACKLIST.add((Object)"!bin");
|
|
FILE_PATH_BLACKLIST.add((Object)"!daemon");
|
|
FILE_PATH_BLACKLIST.add((Object)"!files");
|
|
FILE_PATH_BLACKLIST.add((Object)"!jre");
|
|
FILE_PATH_BLACKLIST.add((Object)"!modules");
|
|
FILE_PATH_BLACKLIST.add((Object)"!registry");
|
|
FILE_PATH_BLACKLIST.add((Object)"!security");
|
|
FILE_PATH_BLACKLIST.add((Object)"!users");
|
|
FILE_PATH_BLACKLIST.add((Object)"!workbench");
|
|
if (string2 != null) {
|
|
StringTokenizer stringTokenizer = new StringTokenizer(string2, ";");
|
|
while (stringTokenizer.hasMoreTokens()) {
|
|
try {
|
|
FILE_PATH_BLACKLIST.add((Object)stringTokenizer.nextToken().toLowerCase());
|
|
}
|
|
catch (Exception exception) {
|
|
System.out.println("Could not parse file paths for remote blacklist.");
|
|
exception.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|