239 lines
7.5 KiB
Java
239 lines
7.5 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.tridium.net.HttpUtil
|
|
* javax.baja.naming.BHost
|
|
* javax.baja.naming.BIpHost
|
|
* javax.baja.naming.BStationSessionScheme
|
|
* javax.baja.naming.OrdQuery
|
|
* javax.baja.naming.OrdQueryList
|
|
* javax.baja.naming.OrdTarget
|
|
* javax.baja.naming.SyntaxException
|
|
* javax.baja.naming.UnresolvedException
|
|
* javax.baja.nre.util.TextUtil
|
|
* javax.baja.security.AuthenticationException
|
|
* javax.baja.sys.BComponent
|
|
* javax.baja.sys.BObject
|
|
* javax.baja.sys.Sys
|
|
* javax.baja.sys.Type
|
|
*/
|
|
package com.tridium.fox.sys;
|
|
|
|
import com.tridium.fox.sys.BFoxSession;
|
|
import com.tridium.fox.sys.LocalizableServerException;
|
|
import com.tridium.net.HttpUtil;
|
|
import javax.baja.naming.BHost;
|
|
import javax.baja.naming.BIpHost;
|
|
import javax.baja.naming.BStationSessionScheme;
|
|
import javax.baja.naming.OrdQuery;
|
|
import javax.baja.naming.OrdQueryList;
|
|
import javax.baja.naming.OrdTarget;
|
|
import javax.baja.naming.SyntaxException;
|
|
import javax.baja.naming.UnresolvedException;
|
|
import javax.baja.nre.util.TextUtil;
|
|
import javax.baja.security.AuthenticationException;
|
|
import javax.baja.sys.BComponent;
|
|
import javax.baja.sys.BObject;
|
|
import javax.baja.sys.Sys;
|
|
import javax.baja.sys.Type;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class BFoxsScheme
|
|
extends BStationSessionScheme {
|
|
public static final int DEFAULT_PORT = 4911;
|
|
public static final String SCHEME_NAME = "foxs";
|
|
public static final BFoxsScheme INSTANCE = new BFoxsScheme();
|
|
public static final Type TYPE;
|
|
static /* synthetic */ Class class$com$tridium$fox$sys$BFoxsScheme;
|
|
|
|
public OrdQuery parse(String string) {
|
|
return new FoxQuery(string);
|
|
}
|
|
|
|
public OrdTarget resolve(OrdTarget ordTarget, OrdQuery ordQuery) throws SyntaxException, UnresolvedException {
|
|
String string;
|
|
BHost bHost;
|
|
BHost bHost2 = null;
|
|
BObject bObject = ordTarget.get();
|
|
bHost2 = bObject instanceof BHost ? (BHost)bObject : ((BComponent)bObject).getHost();
|
|
FoxQuery foxQuery = (FoxQuery)ordQuery;
|
|
int n = foxQuery.port;
|
|
String[] stringArray = foxQuery.tunnelAuthorities;
|
|
BFoxSession bFoxSession = BFoxSession.make(null, bHost2, n, true, stringArray);
|
|
if (Sys.isStationStarted() && stringArray != null && stringArray.length > 0 && (bHost = BHost.getHost((String)(string = BFoxsScheme.parseHost(stringArray[stringArray.length - 1])))) == null) {
|
|
bHost = new BIpHost(string);
|
|
BHost.mount((BHost)bHost);
|
|
}
|
|
try {
|
|
bFoxSession.connect();
|
|
return new OrdTarget(ordTarget, (BObject)bFoxSession);
|
|
}
|
|
catch (LocalizableServerException localizableServerException) {
|
|
if (localizableServerException.getLexiconModule().equals("fox") && localizableServerException.getLexiconKey().equals("error.NoPermissionForStation")) {
|
|
bFoxSession.disconnect();
|
|
}
|
|
throw localizableServerException;
|
|
}
|
|
catch (AuthenticationException authenticationException) {
|
|
throw authenticationException;
|
|
}
|
|
catch (Throwable throwable) {
|
|
throw new UnresolvedException(ordQuery.toString(), throwable);
|
|
}
|
|
}
|
|
|
|
public int getDefaultPort() {
|
|
return 4911;
|
|
}
|
|
|
|
static String parseHost(String string) {
|
|
return HttpUtil.parseHost((String)string);
|
|
}
|
|
|
|
static int parsePort(String string) {
|
|
return HttpUtil.parsePort((String)string, (int)4911);
|
|
}
|
|
|
|
static String[] validateAuthorities(String[] stringArray) {
|
|
if (stringArray == null) {
|
|
return null;
|
|
}
|
|
int n = stringArray.length;
|
|
if (n < 1) {
|
|
return null;
|
|
}
|
|
String[] stringArray2 = new String[n];
|
|
int n2 = 0;
|
|
int n3 = 0;
|
|
while (n3 < n) {
|
|
if (stringArray[n3] != null && !stringArray[n3].equals("")) {
|
|
stringArray2[n2] = stringArray[n3];
|
|
++n2;
|
|
}
|
|
++n3;
|
|
}
|
|
String[] stringArray3 = new String[n2];
|
|
System.arraycopy(stringArray2, 0, stringArray3, 0, n2);
|
|
return stringArray3;
|
|
}
|
|
|
|
public Type getType() {
|
|
return TYPE;
|
|
}
|
|
|
|
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 BFoxsScheme() {
|
|
super(SCHEME_NAME);
|
|
}
|
|
|
|
static {
|
|
Class clazz = class$com$tridium$fox$sys$BFoxsScheme;
|
|
if (clazz == null) {
|
|
clazz = class$com$tridium$fox$sys$BFoxsScheme = BFoxsScheme.class("[Lcom.tridium.fox.sys.BFoxsScheme;", false);
|
|
}
|
|
TYPE = Sys.loadType((Class)clazz);
|
|
}
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public static class FoxQuery
|
|
implements OrdQuery {
|
|
int port;
|
|
String[] tunnelAuthorities;
|
|
|
|
public boolean isHost() {
|
|
return false;
|
|
}
|
|
|
|
public boolean isSession() {
|
|
return true;
|
|
}
|
|
|
|
public void normalize(OrdQueryList ordQueryList, int n) {
|
|
ordQueryList.shiftToHost(n);
|
|
}
|
|
|
|
public String getScheme() {
|
|
return BFoxsScheme.SCHEME_NAME;
|
|
}
|
|
|
|
public String getBody() {
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
if (this.port != 4911) {
|
|
stringBuffer.append(String.valueOf(this.port));
|
|
}
|
|
if (this.tunnelAuthorities != null) {
|
|
int n = 0;
|
|
while (n < this.tunnelAuthorities.length) {
|
|
if (this.tunnelAuthorities[n] != null && !this.tunnelAuthorities[n].equals("")) {
|
|
stringBuffer.append("/").append(this.tunnelAuthorities[n]);
|
|
}
|
|
++n;
|
|
}
|
|
}
|
|
return stringBuffer.toString();
|
|
}
|
|
|
|
public String toString() {
|
|
return "foxs:" + this.getBody();
|
|
}
|
|
|
|
public int getPort() {
|
|
return this.port;
|
|
}
|
|
|
|
public String[] getTunnelAuthorities() {
|
|
return this.tunnelAuthorities;
|
|
}
|
|
|
|
private final /* synthetic */ void this() {
|
|
this.tunnelAuthorities = null;
|
|
}
|
|
|
|
FoxQuery(String string) {
|
|
this.this();
|
|
string = string.trim();
|
|
if (string.length() == 0) {
|
|
this.port = 4911;
|
|
} else {
|
|
int n = string.indexOf(47);
|
|
if (n >= 0) {
|
|
this.port = n == 0 ? 4911 : Integer.parseInt(string.substring(0, n));
|
|
string = string.substring(n);
|
|
this.tunnelAuthorities = BFoxsScheme.validateAuthorities(TextUtil.splitAndTrim((String)string, (char)'/'));
|
|
} else {
|
|
this.port = Integer.parseInt(string);
|
|
}
|
|
}
|
|
}
|
|
|
|
FoxQuery(int n) {
|
|
this.this();
|
|
this.port = n;
|
|
}
|
|
|
|
FoxQuery(int n, String[] stringArray) {
|
|
this.this();
|
|
this.port = n;
|
|
this.tunnelAuthorities = BFoxsScheme.validateAuthorities(stringArray);
|
|
}
|
|
}
|
|
}
|
|
|