link start!
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.SlotCursor;
|
||||
import javax.baja.sys.Topic;
|
||||
|
||||
public final class AccessSlotCursor
|
||||
implements SlotCursor {
|
||||
SlotCursor c;
|
||||
Context context;
|
||||
|
||||
public static final AccessSlotCursor make(SlotCursor slotCursor, Context context) {
|
||||
return new AccessSlotCursor(slotCursor, context);
|
||||
}
|
||||
|
||||
public final Context getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
public final boolean next() {
|
||||
while (this.c.next()) {
|
||||
if (!this.has()) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean nextObject() {
|
||||
while (this.c.nextObject()) {
|
||||
if (!this.has()) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean nextComponent() {
|
||||
while (this.c.nextComponent()) {
|
||||
if (!this.has()) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean next(Class clazz) {
|
||||
while (this.c.next(clazz)) {
|
||||
if (!this.has()) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final BObject target() {
|
||||
return this.c.target();
|
||||
}
|
||||
|
||||
public final Slot slot() {
|
||||
return this.c.slot();
|
||||
}
|
||||
|
||||
public final Property property() {
|
||||
return this.c.property();
|
||||
}
|
||||
|
||||
public final int getTypeAccess() {
|
||||
return this.c.getTypeAccess();
|
||||
}
|
||||
|
||||
public final BObject get() {
|
||||
return this.c.get();
|
||||
}
|
||||
|
||||
public final boolean getBoolean() {
|
||||
return this.c.getBoolean();
|
||||
}
|
||||
|
||||
public final int getInt() {
|
||||
return this.c.getInt();
|
||||
}
|
||||
|
||||
public final long getLong() {
|
||||
return this.c.getLong();
|
||||
}
|
||||
|
||||
public final float getFloat() {
|
||||
return this.c.getFloat();
|
||||
}
|
||||
|
||||
public final double getDouble() {
|
||||
return this.c.getDouble();
|
||||
}
|
||||
|
||||
public final String getString() {
|
||||
return this.c.getString();
|
||||
}
|
||||
|
||||
public final Action action() {
|
||||
return this.c.action();
|
||||
}
|
||||
|
||||
public final Topic topic() {
|
||||
return this.c.topic();
|
||||
}
|
||||
|
||||
private final boolean has() {
|
||||
boolean bl;
|
||||
Slot slot;
|
||||
BComplex bComplex = (BComplex)this.c.target();
|
||||
int n = bComplex.getFlags(slot = this.c.slot());
|
||||
if ((n & 4) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (this.context == null) {
|
||||
return true;
|
||||
}
|
||||
if (slot.isProperty() && this.c.getTypeAccess() == 7 && this.c.get().isComponent()) {
|
||||
BComponent bComponent = this.c.get().asComponent();
|
||||
return this.permissionsFor(bComponent).has(BPermissions.operatorRead);
|
||||
}
|
||||
BComponent bComponent = bComplex.isComponent() ? bComplex.asComponent() : bComplex.asComplex().getParentComponent();
|
||||
BPermissions bPermissions = this.permissionsFor(bComponent);
|
||||
boolean bl2 = false;
|
||||
if ((n & 0x100) != 0) {
|
||||
bl2 = bl = true;
|
||||
}
|
||||
if (slot.isAction()) {
|
||||
if (bl) {
|
||||
return bPermissions.has(4);
|
||||
}
|
||||
return bPermissions.has(64);
|
||||
}
|
||||
if (bl) {
|
||||
return bPermissions.has(1);
|
||||
}
|
||||
return bPermissions.has(16);
|
||||
}
|
||||
|
||||
private final BPermissions permissionsFor(BComponent bComponent) {
|
||||
if (bComponent == null || this.context == null) {
|
||||
return BPermissions.all;
|
||||
}
|
||||
return bComponent.getPermissions(this.context);
|
||||
}
|
||||
|
||||
private AccessSlotCursor(SlotCursor slotCursor, Context context) {
|
||||
this.c = slotCursor;
|
||||
this.context = context;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.Clock;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AuditEvent {
|
||||
public static final String CHANGED = "Changed";
|
||||
public static final String ADDED = "Added";
|
||||
public static final String REMOVED = "Removed";
|
||||
public static final String RENAMED = "Renamed";
|
||||
public static final String REORDERED = "Reordered";
|
||||
public static final String FLAGS_CHANGED = "Flags Changed";
|
||||
public static final String FACETS_CHANGED = "Facets Changed";
|
||||
public static final String RECATEGORIZED = "Recategorized";
|
||||
public static final String INVOKED = "Invoked";
|
||||
public static final String LOGIN = "Login";
|
||||
public static final String LOGOUT = "Logout";
|
||||
public static final String LOGIN_FAILURE = "Login Failure";
|
||||
private DateFormat format;
|
||||
private String operation;
|
||||
private String target;
|
||||
private String slotName;
|
||||
private String oldValue;
|
||||
private String value;
|
||||
private String userName;
|
||||
private BAbsTime timestamp;
|
||||
|
||||
public String getOperation() {
|
||||
return this.operation;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public String getSlotName() {
|
||||
return this.slotName;
|
||||
}
|
||||
|
||||
public String getOldValue() {
|
||||
return this.oldValue;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.userName;
|
||||
}
|
||||
|
||||
public BAbsTime getTimestamp() {
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append('[').append(this.format.format(new Date(this.timestamp.getMillis()))).append("][").append(this.userName).append("][").append(this.target).append("] ").append(this.toSummaryString());
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public String toSummaryString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
if (this.operation.equals(CHANGED)) {
|
||||
stringBuffer.append(this.slotName).append(": ").append(this.oldValue).append(" -> ").append(this.value);
|
||||
} else if (this.operation.equals(ADDED)) {
|
||||
stringBuffer.append(this.slotName).append(": added");
|
||||
} else if (this.operation.equals(REMOVED)) {
|
||||
stringBuffer.append(this.slotName).append(": removed");
|
||||
} else if (this.operation.equals(RENAMED)) {
|
||||
stringBuffer.append(this.slotName).append(": renamed " + this.value);
|
||||
} else if (this.operation.equals(REORDERED)) {
|
||||
stringBuffer.append("reordered");
|
||||
} else if (this.operation.equals(FLAGS_CHANGED)) {
|
||||
stringBuffer.append(this.slotName).append(": flags ").append(this.oldValue).append(" -> ").append(this.value);
|
||||
} else if (this.operation.equals(RECATEGORIZED)) {
|
||||
stringBuffer.append("recategorized ").append(this.oldValue).append(" -> ").append(this.value);
|
||||
} else if (this.operation.equals(INVOKED)) {
|
||||
stringBuffer.append(this.slotName).append('(');
|
||||
if (this.value != null) {
|
||||
stringBuffer.append(this.value);
|
||||
}
|
||||
stringBuffer.append(')');
|
||||
} else if (this.operation.equals(LOGIN)) {
|
||||
stringBuffer.append("login");
|
||||
} else if (this.operation.equals(LOGOUT)) {
|
||||
stringBuffer.append("logout");
|
||||
} else if (this.operation.equals(LOGIN_FAILURE)) {
|
||||
stringBuffer.append("login failure ").append(this.value);
|
||||
} else {
|
||||
stringBuffer.append(this.operation);
|
||||
if (this.slotName != null) {
|
||||
stringBuffer.append(";slotName=" + this.slotName);
|
||||
}
|
||||
if (this.oldValue != null) {
|
||||
stringBuffer.append(";oldValue=" + this.oldValue);
|
||||
}
|
||||
if (this.value != null) {
|
||||
stringBuffer.append(";value=" + this.value);
|
||||
}
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.format = new SimpleDateFormat("HH:mm:ss dd-MMM-yy");
|
||||
}
|
||||
|
||||
public AuditEvent(String string, String string2, String string3, String string4, String string5, String string6) {
|
||||
this.this();
|
||||
this.operation = string;
|
||||
this.target = string2;
|
||||
this.slotName = string3;
|
||||
this.oldValue = string4;
|
||||
this.value = string5;
|
||||
this.userName = string6;
|
||||
this.timestamp = Clock.time();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import javax.baja.security.AuditEvent;
|
||||
|
||||
public interface Auditor {
|
||||
public void audit(AuditEvent var1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import javax.baja.security.AuthenticationRealm;
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Localizable;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
public class AuthenticationException
|
||||
extends BajaRuntimeException
|
||||
implements Localizable {
|
||||
private AuthenticationRealm authenticationRealm;
|
||||
|
||||
public String toString(Context context) {
|
||||
return Lexicon.make("baja", context).getText("AuthenticationException");
|
||||
}
|
||||
|
||||
public AuthenticationRealm getAuthenticationRealm() {
|
||||
return this.authenticationRealm;
|
||||
}
|
||||
|
||||
public AuthenticationException(String string, Throwable throwable, AuthenticationRealm authenticationRealm) {
|
||||
super(string, throwable);
|
||||
this.authenticationRealm = authenticationRealm;
|
||||
}
|
||||
|
||||
public AuthenticationException(AuthenticationRealm authenticationRealm) {
|
||||
this.authenticationRealm = authenticationRealm;
|
||||
}
|
||||
|
||||
public AuthenticationException(AuthenticationRealm authenticationRealm, Throwable throwable) {
|
||||
super(throwable);
|
||||
this.authenticationRealm = authenticationRealm;
|
||||
}
|
||||
|
||||
public AuthenticationException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public AuthenticationException() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import javax.baja.security.BICredentials;
|
||||
|
||||
public interface AuthenticationRealm {
|
||||
public String getAuthenticationRealmName();
|
||||
|
||||
public String getAuthenticationScheme();
|
||||
|
||||
public BICredentials makeCredentials();
|
||||
|
||||
public BICredentials getCredentials();
|
||||
|
||||
public void setCredentials(BICredentials var1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.agent.AgentFilter;
|
||||
import javax.baja.agent.AgentList;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.registry.TypeInfo;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BAbstractPasswordEncoder
|
||||
extends BObject
|
||||
implements BIAgent {
|
||||
public static final Type TYPE;
|
||||
private static Log log;
|
||||
private static HashMap encodingTypes;
|
||||
static /* synthetic */ Class class$javax$baja$security$BAbstractPasswordEncoder;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public abstract void encode(String var1) throws Exception;
|
||||
|
||||
public abstract void parse(String var1) throws Exception;
|
||||
|
||||
public abstract String getValue() throws Exception;
|
||||
|
||||
public abstract String getEncodingType();
|
||||
|
||||
public abstract boolean isReversible();
|
||||
|
||||
public abstract boolean validate(String var1) throws Exception;
|
||||
|
||||
public abstract String getEncodedValue();
|
||||
|
||||
public String getPortableEncoding() throws Exception {
|
||||
throw new UnsupportedOperationException("Encoding [" + this.getEncodingType() + "] does not support portable encoding.");
|
||||
}
|
||||
|
||||
protected static BAbstractPasswordEncoder make(String string) throws Exception {
|
||||
string = BAbstractPasswordEncoder.stripBrackets(string);
|
||||
String string2 = (String)encodingTypes.get(string);
|
||||
Object var2_2 = null;
|
||||
if (string2 == null) {
|
||||
throw new IllegalArgumentException("unrecognized encoding type: " + string);
|
||||
}
|
||||
Class<?> clazz = Class.forName(string2);
|
||||
Constructor<?> constructor = clazz.getConstructor(null);
|
||||
var2_2 = constructor.newInstance(null);
|
||||
return var2_2;
|
||||
}
|
||||
|
||||
private static final String stripBrackets(String string) {
|
||||
if (string.startsWith("[")) {
|
||||
return string.substring(1, string.length() - 1);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
private static final HashMap createEncodingMap() {
|
||||
HashMap<String, String> hashMap = new HashMap<String, String>();
|
||||
Class clazz = class$javax$baja$security$BAbstractPasswordEncoder;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BAbstractPasswordEncoder = BAbstractPasswordEncoder.class("[Ljavax.baja.security.BAbstractPasswordEncoder;", false);
|
||||
}
|
||||
Lexicon lexicon = Lexicon.make(clazz);
|
||||
TypeInfo typeInfo = null;
|
||||
AgentList agentList = Sys.getRegistry().getAgents(Sys.getRegistry().getType("baja:Password"));
|
||||
agentList = agentList.filter(AgentFilter.is(TYPE));
|
||||
int n = 0;
|
||||
while (n < agentList.size()) {
|
||||
try {
|
||||
typeInfo = agentList.get(n).getAgentType();
|
||||
Class<?> clazz2 = Class.forName(typeInfo.getTypeClassName());
|
||||
String string = (String)clazz2.getField("ENCODING_TYPE").get(null);
|
||||
hashMap.put(string, typeInfo.getTypeClassName());
|
||||
}
|
||||
catch (NoSuchFieldException noSuchFieldException) {
|
||||
log.error(lexicon.getText("password.encoder.noTypeField", new Object[]{typeInfo.getTypeName()}));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
log.error(lexicon.getText("password.encoder.genericFailure", new Object[]{typeInfo.getTypeName(), exception}));
|
||||
}
|
||||
++n;
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BAbstractPasswordEncoder;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BAbstractPasswordEncoder = BAbstractPasswordEncoder.class("[Ljavax.baja.security.BAbstractPasswordEncoder;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
log = Log.getLog("baja");
|
||||
encodingTypes = BAbstractPasswordEncoder.createEncodingMap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.nre.security.Aes256PasswordManager
|
||||
* com.tridium.nre.security.KeyRing
|
||||
* javax.baja.nre.util.ByteArrayUtil
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import com.tridium.nre.security.Aes256PasswordManager;
|
||||
import com.tridium.nre.security.KeyRing;
|
||||
import com.tridium.sys.Nre;
|
||||
import java.security.SecureRandom;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.nre.util.ByteArrayUtil;
|
||||
import javax.baja.security.BAbstractPasswordEncoder;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BAes256PasswordEncoder
|
||||
extends BAbstractPasswordEncoder
|
||||
implements BIAgent {
|
||||
public static final Type TYPE;
|
||||
public static final String ENCODING_TYPE = "aes256/text";
|
||||
private String cipher;
|
||||
private String iv;
|
||||
static /* synthetic */ Class class$javax$baja$security$BAes256PasswordEncoder;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final void encode(String string) throws Exception {
|
||||
byte[] byArray = new byte[16];
|
||||
new SecureRandom().nextBytes(byArray);
|
||||
this.iv = ByteArrayUtil.toHexString((byte[])byArray);
|
||||
this.cipher = ByteArrayUtil.toHexString((byte[])Aes256PasswordManager.getManager((KeyRing)Nre.getSecurityInfoProvider().getKeyRing()).encrypt(string, this.iv));
|
||||
}
|
||||
|
||||
public final void parse(String string) throws Exception {
|
||||
int n = string.indexOf(":");
|
||||
if (n == -1) {
|
||||
this.encode(string);
|
||||
} else {
|
||||
this.iv = string.substring(0, n);
|
||||
this.cipher = string.substring(n + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public final String getValue() throws Exception {
|
||||
return Aes256PasswordManager.getManager((KeyRing)Nre.getSecurityInfoProvider().getKeyRing()).decrypt(this.cipher, this.iv);
|
||||
}
|
||||
|
||||
public final String getEncodingType() {
|
||||
return ENCODING_TYPE;
|
||||
}
|
||||
|
||||
public final boolean isReversible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final boolean validate(String string) throws Exception {
|
||||
try {
|
||||
return string.equals(this.getValue());
|
||||
}
|
||||
catch (SecurityException securityException) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final String getEncodedValue() {
|
||||
return this.iv + ':' + this.cipher;
|
||||
}
|
||||
|
||||
public final String getPortableEncoding() throws Exception {
|
||||
try {
|
||||
return this.getValue();
|
||||
}
|
||||
catch (SecurityException securityException) {
|
||||
return this.getEncodedValue();
|
||||
}
|
||||
}
|
||||
|
||||
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 final /* synthetic */ void this() {
|
||||
this.cipher = null;
|
||||
this.iv = null;
|
||||
}
|
||||
|
||||
public BAes256PasswordEncoder() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BAes256PasswordEncoder;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BAes256PasswordEncoder = BAes256PasswordEncoder.class("[Ljavax.baja.security.BAes256PasswordEncoder;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.baja.security.BICredentials;
|
||||
import javax.baja.security.BIUserCredentials;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BStruct;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BHttpFoxCredentials
|
||||
extends BStruct
|
||||
implements BIUserCredentials {
|
||||
public static final Property username = BHttpFoxCredentials.newProperty(0, BString.DEFAULT, null);
|
||||
public static final Property sessionId = BHttpFoxCredentials.newProperty(0, BString.DEFAULT, null);
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$javax$baja$security$BHttpFoxCredentials;
|
||||
|
||||
public String getUsername() {
|
||||
return this.getString(username);
|
||||
}
|
||||
|
||||
public void setUsername(String string) {
|
||||
this.setString(username, string, null);
|
||||
}
|
||||
|
||||
public String getSessionId() {
|
||||
return this.getString(sessionId);
|
||||
}
|
||||
|
||||
public void setSessionId(String string) {
|
||||
this.setString(sessionId, string, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BICredentials decodeCredentials(byte[] byArray) throws IOException {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byArray);
|
||||
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
|
||||
BHttpFoxCredentials bHttpFoxCredentials = (BHttpFoxCredentials)this.newCopy();
|
||||
bHttpFoxCredentials.set(username, (BValue)BString.DEFAULT.decode(dataInputStream));
|
||||
bHttpFoxCredentials.set(sessionId, (BValue)BString.DEFAULT.decode(dataInputStream));
|
||||
return bHttpFoxCredentials;
|
||||
}
|
||||
|
||||
public byte[] encodeCredentials() throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
|
||||
BString.make(this.getUsername()).encode(dataOutputStream);
|
||||
BString.make(this.getSessionId()).encode(dataOutputStream);
|
||||
dataOutputStream.flush();
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
}
|
||||
|
||||
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 BHttpFoxCredentials() {
|
||||
}
|
||||
|
||||
public BHttpFoxCredentials(String string, String string2) {
|
||||
this.setUsername(string);
|
||||
this.setSessionId(string2);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BHttpFoxCredentials;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BHttpFoxCredentials = BHttpFoxCredentials.class("[Ljavax.baja.security.BHttpFoxCredentials;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.baja.sys.BInterface;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BICredentials
|
||||
extends BInterface {
|
||||
public static final Type TYPE;
|
||||
|
||||
public byte[] encodeCredentials() throws IOException;
|
||||
|
||||
public BICredentials decodeCredentials(byte[] var1) throws IOException;
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$javax$baja$security$BICredentials;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$javax$baja$security$BICredentials = 1.class("[Ljavax.baja.security.BICredentials;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import javax.baja.category.BICategorizable;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIProtected
|
||||
extends BICategorizable {
|
||||
public static final Type TYPE;
|
||||
|
||||
public BPermissions getPermissions(Context var1);
|
||||
|
||||
public boolean canRead(OrdTarget var1);
|
||||
|
||||
public boolean canWrite(OrdTarget var1);
|
||||
|
||||
public boolean canInvoke(OrdTarget var1);
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$javax$baja$security$BIProtected;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$javax$baja$security$BIProtected = 1.class("[Ljavax.baja.security.BIProtected;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import javax.baja.security.BICredentials;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIUserCredentials
|
||||
extends BICredentials {
|
||||
public static final Type TYPE;
|
||||
|
||||
public String getUsername();
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$javax$baja$security$BIUserCredentials;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$javax$baja$security$BIUserCredentials = 1.class("[Ljavax.baja.security.BIUserCredentials;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.nre.util.LegacyStorageUtil
|
||||
* javax.baja.nre.util.Base64
|
||||
* javax.baja.nre.util.TextUtil
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import com.tridium.nre.util.LegacyStorageUtil;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
import javax.baja.io.BIContextEncodable;
|
||||
import javax.baja.io.BITypeEncodable;
|
||||
import javax.baja.nre.util.Base64;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.security.BAbstractPasswordEncoder;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIComparable;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BPassword
|
||||
extends BSimple
|
||||
implements BIComparable,
|
||||
BIContextEncodable,
|
||||
BITypeEncodable {
|
||||
public static final BPassword DEFAULT = new BPassword("");
|
||||
public static final Type TYPE;
|
||||
private BAbstractPasswordEncoder encoder;
|
||||
static /* synthetic */ Class class$javax$baja$security$BPassword;
|
||||
|
||||
public static final BPassword make(String string) {
|
||||
if (string == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new BPassword(string);
|
||||
}
|
||||
|
||||
public static final BPassword make(char[] cArray) {
|
||||
if (cArray == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
String string = new String(cArray);
|
||||
return BPassword.make(string);
|
||||
}
|
||||
|
||||
public static final BPassword make(String string, String string2) {
|
||||
if (string == null || string2 == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new BPassword(string, string2);
|
||||
}
|
||||
|
||||
public static final BPassword make(char[] cArray, String string) {
|
||||
if (cArray == null || string == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
String string2 = new String(cArray);
|
||||
return BPassword.make(string2, string);
|
||||
}
|
||||
|
||||
public static final BPassword make(BAbstractPasswordEncoder bAbstractPasswordEncoder) {
|
||||
return new BPassword(bAbstractPasswordEncoder);
|
||||
}
|
||||
|
||||
private final String stripEncodingType(String string) {
|
||||
int n = string.indexOf("encoded[");
|
||||
int n2 = string.indexOf("]=");
|
||||
if (n == 0 && n2 > 0) {
|
||||
return string.substring(n2 + 2);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
private final String extractEncodingType(String string) {
|
||||
if (string.startsWith("encoded[")) {
|
||||
String[] stringArray = TextUtil.split((String)string.substring(8), (char)']');
|
||||
if (stringArray.length == 0) {
|
||||
throw new BajaRuntimeException("unrecognized encoding type");
|
||||
}
|
||||
return stringArray[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final String getString() {
|
||||
return this.getValue();
|
||||
}
|
||||
|
||||
public final String getValue() throws SecurityException {
|
||||
try {
|
||||
if (this.encoder.isReversible()) {
|
||||
return this.encoder.getValue();
|
||||
}
|
||||
byte[] byArray = new byte[16];
|
||||
new SecureRandom().nextBytes(byArray);
|
||||
return Base64.encode((byte[])byArray);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
return this.encoder.getEncodedValue().hashCode();
|
||||
}
|
||||
|
||||
public final boolean equals(Object object) {
|
||||
if (object instanceof BPassword) {
|
||||
return this.encoder.getEncodedValue().equals(((BPassword)object).encoder.getEncodedValue());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final int compareTo(Object object) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final boolean validate(String string) {
|
||||
try {
|
||||
return this.encoder.validate(string);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
}
|
||||
|
||||
public final String toString(Context context) {
|
||||
return "--password--";
|
||||
}
|
||||
|
||||
public final void encode(DataOutput dataOutput) throws IOException {
|
||||
dataOutput.writeUTF(this.encodeToString());
|
||||
}
|
||||
|
||||
public final void encode(DataOutput dataOutput, Context context) throws IOException {
|
||||
dataOutput.writeUTF(this.encodeToString(context));
|
||||
}
|
||||
|
||||
public final BObject decode(DataInput dataInput) throws IOException {
|
||||
String string = dataInput.readUTF();
|
||||
if (string.equals("")) {
|
||||
return DEFAULT;
|
||||
}
|
||||
return this.decodeFromString(string);
|
||||
}
|
||||
|
||||
public final BObject decode(DataInput dataInput, Context context) throws IOException {
|
||||
String string = dataInput.readUTF();
|
||||
if (string.equals("")) {
|
||||
return DEFAULT;
|
||||
}
|
||||
return this.decodeFromString(string, context);
|
||||
}
|
||||
|
||||
public final String encodeToString() throws IOException {
|
||||
try {
|
||||
return LegacyStorageUtil.encode((String)this.getPasswordEncoder().getPortableEncoding());
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
|
||||
public final String encodeToString(Context context) throws IOException {
|
||||
BString bString = null;
|
||||
BFacets bFacets = null;
|
||||
if (context != null) {
|
||||
bFacets = context.getFacets();
|
||||
}
|
||||
if (bFacets != null) {
|
||||
bString = (BString)bFacets.getFacet("encodingMode");
|
||||
}
|
||||
if (!this.getPasswordEncoder().isReversible() || bString != null && bString.equals(BString.make("encrypt"))) {
|
||||
return LegacyStorageUtil.encode((String)("encoded[" + this.encoder.getEncodingType() + "]=" + this.encoder.getEncodedValue()));
|
||||
}
|
||||
return this.encodeToString();
|
||||
}
|
||||
|
||||
public final BObject decodeFromString(String string) throws IOException {
|
||||
return this.decodeFromString(string, null);
|
||||
}
|
||||
|
||||
public final BObject decodeFromString(String string, Context context) throws IOException {
|
||||
if (string.equals("")) {
|
||||
return DEFAULT;
|
||||
}
|
||||
return BPassword.make(LegacyStorageUtil.decode((String)string));
|
||||
}
|
||||
|
||||
public final String getEncodingType() {
|
||||
return this.encoder.getEncodingType();
|
||||
}
|
||||
|
||||
public final BAbstractPasswordEncoder getPasswordEncoder() {
|
||||
return this.encoder;
|
||||
}
|
||||
|
||||
public final 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 BPassword(String string) {
|
||||
boolean bl = true;
|
||||
String string2 = this.extractEncodingType(string);
|
||||
if (string2 == null) {
|
||||
bl = false;
|
||||
string2 = "aes256/text";
|
||||
}
|
||||
try {
|
||||
this.encoder = BAbstractPasswordEncoder.make(string2);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new IllegalArgumentException("unrecognized encoding type: " + string2);
|
||||
}
|
||||
try {
|
||||
if (bl) {
|
||||
this.encoder.parse(this.stripEncodingType(string));
|
||||
} else {
|
||||
this.encoder.encode(string);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
}
|
||||
|
||||
private BPassword(String string, String string2) {
|
||||
try {
|
||||
this.encoder = BAbstractPasswordEncoder.make(string2);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new IllegalArgumentException("unrecognized encoding type: " + string2);
|
||||
}
|
||||
try {
|
||||
this.encoder.encode(string);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
}
|
||||
|
||||
private BPassword(BAbstractPasswordEncoder bAbstractPasswordEncoder) {
|
||||
this.encoder = bAbstractPasswordEncoder;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BPassword;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BPassword = BPassword.class("[Ljavax.baja.security.BPassword;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.Base64
|
||||
* javax.baja.nre.util.TextUtil
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.security.MessageDigest;
|
||||
import javax.baja.io.BIContextEncodable;
|
||||
import javax.baja.nre.util.Base64;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.security.BPassword;
|
||||
import javax.baja.security.BPbkdf2HmacSha256PasswordEncoder;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BPasswordHistory
|
||||
extends BSimple
|
||||
implements BIContextEncodable {
|
||||
public static final BPasswordHistory DEFAULT = new BPasswordHistory();
|
||||
public static final Type TYPE;
|
||||
private BPassword[] passwords;
|
||||
private String salt;
|
||||
private int iterationCount;
|
||||
static /* synthetic */ Class class$javax$baja$security$BPasswordHistory;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final BPasswordHistory add(String string, BPassword bPassword) {
|
||||
return this.add(string, bPassword, this.passwords.length + 1);
|
||||
}
|
||||
|
||||
public final BPasswordHistory add(String string, BPassword bPassword, int n) {
|
||||
if (!bPassword.getPasswordEncoder().isReversible()) {
|
||||
throw new BajaRuntimeException("Cannot add " + bPassword.getEncodingType() + " encoded passwords to BPasswordHistory.");
|
||||
}
|
||||
if (n < 0) {
|
||||
throw new InvalidParameterException("History size must be zero or greater.");
|
||||
}
|
||||
if (n == 0) {
|
||||
return DEFAULT;
|
||||
}
|
||||
BPassword bPassword2 = this.getConvertedPassword(bPassword);
|
||||
if (this.contains(string, bPassword, bPassword2, n)) {
|
||||
throw new BajaRuntimeException("Duplicate password.");
|
||||
}
|
||||
BPasswordHistory bPasswordHistory = new BPasswordHistory();
|
||||
bPasswordHistory.passwords = new BPassword[Math.min(n, this.passwords.length + 1)];
|
||||
bPasswordHistory.passwords[0] = bPassword2;
|
||||
if (this.passwords.length > 0) {
|
||||
System.arraycopy(this.passwords, 0, bPasswordHistory.passwords, 1, Math.min(n - 1, this.passwords.length));
|
||||
}
|
||||
bPasswordHistory.initSaltAndIterationCount();
|
||||
return bPasswordHistory;
|
||||
}
|
||||
|
||||
private final String getOldPasswordHash(String string, BPassword bPassword) {
|
||||
String string2;
|
||||
try {
|
||||
string2 = bPassword.getPasswordEncoder().getValue();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
try {
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
|
||||
messageDigest.update(string2.getBytes());
|
||||
messageDigest.update((TextUtil.bytesToHexString((byte[])messageDigest.digest()) + 'H' + string).getBytes());
|
||||
return TextUtil.bytesToHexString((byte[])messageDigest.digest());
|
||||
}
|
||||
catch (Exception exception) {
|
||||
return String.valueOf(string2.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean contains(String string, BPassword bPassword) {
|
||||
return this.contains(string, bPassword, this.passwords.length);
|
||||
}
|
||||
|
||||
public final boolean contains(String string, BPassword bPassword, int n) {
|
||||
return this.contains(string, bPassword, null, n);
|
||||
}
|
||||
|
||||
public final boolean contains(String string, BPassword bPassword, BPassword bPassword2, int n) {
|
||||
if (bPassword.getPasswordEncoder().isReversible()) {
|
||||
String string2 = null;
|
||||
if (bPassword2 != null) {
|
||||
string2 = bPassword2.getPasswordEncoder().getEncodedValue();
|
||||
}
|
||||
int n2 = 0;
|
||||
while (n2 < Math.min(this.passwords.length, n)) {
|
||||
block11: {
|
||||
if (this.passwords[n2].getPasswordEncoder().isReversible()) {
|
||||
try {
|
||||
if (this.passwords[n2].getPasswordEncoder().getValue().equals(this.getOldPasswordHash(string, bPassword))) {
|
||||
return true;
|
||||
}
|
||||
break block11;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
}
|
||||
if (this.passwords[n2].getEncodingType().equals("pbkdf2hmacsha256/text")) {
|
||||
if (string2 == null) {
|
||||
string2 = this.getConvertedPassword(bPassword).getPasswordEncoder().getEncodedValue();
|
||||
}
|
||||
if (this.passwords[n2].getPasswordEncoder().getEncodedValue().equals(string2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final int getSize() {
|
||||
return this.passwords.length;
|
||||
}
|
||||
|
||||
public final void encode(DataOutput dataOutput) throws IOException {
|
||||
this.encode(dataOutput, null);
|
||||
}
|
||||
|
||||
public final void encode(DataOutput dataOutput, Context context) throws IOException {
|
||||
dataOutput.writeInt(this.passwords.length);
|
||||
int n = 0;
|
||||
while (n < this.passwords.length) {
|
||||
dataOutput.writeUTF(this.passwords[n].encodeToString(context));
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public final BObject decode(DataInput dataInput) throws IOException {
|
||||
return this.decode(dataInput, null);
|
||||
}
|
||||
|
||||
public final BObject decode(DataInput dataInput, Context context) throws IOException {
|
||||
BPasswordHistory bPasswordHistory = new BPasswordHistory();
|
||||
bPasswordHistory.passwords = new BPassword[dataInput.readInt()];
|
||||
int n = 0;
|
||||
while (n < bPasswordHistory.passwords.length) {
|
||||
bPasswordHistory.passwords[n] = (BPassword)BPassword.DEFAULT.decodeFromString(dataInput.readUTF());
|
||||
++n;
|
||||
}
|
||||
bPasswordHistory.initSaltAndIterationCount();
|
||||
return bPasswordHistory;
|
||||
}
|
||||
|
||||
public final String encodeToString() throws IOException {
|
||||
return this.encodeToString(null);
|
||||
}
|
||||
|
||||
public final String encodeToString(Context context) throws IOException {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
if (this.passwords.length > 0) {
|
||||
int n = 0;
|
||||
while (n < this.passwords.length) {
|
||||
stringBuffer.append(this.passwords[n].encodeToString(context)).append("|");
|
||||
++n;
|
||||
}
|
||||
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
||||
}
|
||||
return Base64.encode((String)stringBuffer.toString());
|
||||
}
|
||||
|
||||
public final BObject decodeFromString(String string) throws IOException {
|
||||
return this.decodeFromString(string, null);
|
||||
}
|
||||
|
||||
public final BObject decodeFromString(String string, Context context) throws IOException {
|
||||
BPasswordHistory bPasswordHistory = new BPasswordHistory();
|
||||
String[] stringArray = TextUtil.split((String)Base64.decodeToString((String)string), (char)'|');
|
||||
bPasswordHistory.passwords = new BPassword[stringArray.length];
|
||||
int n = 0;
|
||||
while (n < stringArray.length) {
|
||||
try {
|
||||
bPasswordHistory.passwords[n] = (BPassword)BPassword.DEFAULT.decodeFromString(stringArray[n]);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
bPasswordHistory.passwords[n] = BPassword.make(stringArray[n]);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
bPasswordHistory.initSaltAndIterationCount();
|
||||
return bPasswordHistory;
|
||||
}
|
||||
|
||||
public final boolean equals(Object object) {
|
||||
if (!(object instanceof BPasswordHistory)) {
|
||||
return false;
|
||||
}
|
||||
BPasswordHistory bPasswordHistory = (BPasswordHistory)object;
|
||||
if (bPasswordHistory.passwords.length != this.passwords.length) {
|
||||
return false;
|
||||
}
|
||||
if (bPasswordHistory.passwords.length != this.passwords.length) {
|
||||
return false;
|
||||
}
|
||||
int n = 0;
|
||||
while (n < bPasswordHistory.passwords.length) {
|
||||
if (!bPasswordHistory.passwords[n].equals(this.passwords[n])) {
|
||||
return false;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private final void initSaltAndIterationCount() {
|
||||
if (this.salt == null) {
|
||||
int n = 0;
|
||||
while (n < this.passwords.length) {
|
||||
if (this.passwords[n].getEncodingType().equals("pbkdf2hmacsha256/text")) {
|
||||
String string = this.passwords[n].getPasswordEncoder().getEncodedValue();
|
||||
int n2 = string.indexOf(":");
|
||||
int n3 = string.indexOf(":", n2 + 1);
|
||||
this.salt = string.substring(0, n2);
|
||||
this.iterationCount = Integer.parseInt(string.substring(n2 + 1, n3));
|
||||
return;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final BPassword getConvertedPassword(BPassword bPassword) {
|
||||
try {
|
||||
if (this.salt != null && this.iterationCount != 0) {
|
||||
BPbkdf2HmacSha256PasswordEncoder bPbkdf2HmacSha256PasswordEncoder = new BPbkdf2HmacSha256PasswordEncoder();
|
||||
bPbkdf2HmacSha256PasswordEncoder.encode(bPassword.getPasswordEncoder().getValue(), this.salt, this.iterationCount);
|
||||
return BPassword.make(bPbkdf2HmacSha256PasswordEncoder);
|
||||
}
|
||||
return BPassword.make(bPassword.getPasswordEncoder().getValue(), "pbkdf2hmacsha256/text");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
}
|
||||
|
||||
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 final /* synthetic */ void this() {
|
||||
this.salt = null;
|
||||
this.iterationCount = 0;
|
||||
}
|
||||
|
||||
public BPasswordHistory() {
|
||||
this.this();
|
||||
this.passwords = new BPassword[0];
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BPasswordHistory;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BPasswordHistory = BPasswordHistory.class("[Ljavax.baja.security.BPasswordHistory;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.nre.auth.Pbkdf2HmacSha256
|
||||
* com.tridium.nre.auth.SecurityUtil
|
||||
* javax.baja.nre.util.ByteArrayUtil
|
||||
* javax.baja.nre.util.TextUtil
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import com.tridium.nre.auth.Pbkdf2HmacSha256;
|
||||
import com.tridium.nre.auth.SecurityUtil;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.nre.util.ByteArrayUtil;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.security.BAbstractPasswordEncoder;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BPbkdf2HmacSha256PasswordEncoder
|
||||
extends BAbstractPasswordEncoder
|
||||
implements BIAgent {
|
||||
public static final Type TYPE;
|
||||
public static final String ENCODING_TYPE = "pbkdf2hmacsha256/text";
|
||||
private static final int DK_LEN = 32;
|
||||
private static final int ITERATION_COUNT = 4096;
|
||||
private String salt;
|
||||
private String key;
|
||||
private int iterationCount;
|
||||
static /* synthetic */ Class class$javax$baja$security$BPbkdf2HmacSha256PasswordEncoder;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final void encode(String string) throws Exception {
|
||||
byte[] byArray = new byte[16];
|
||||
new SecureRandom().nextBytes(byArray);
|
||||
this.salt = ByteArrayUtil.toHexString((byte[])byArray);
|
||||
this.iterationCount = 4096;
|
||||
byte[] byArray2 = Pbkdf2HmacSha256.deriveKey((byte[])byArray, (long)this.iterationCount, (String)string, (int)32);
|
||||
this.key = TextUtil.bytesToHexString((byte[])byArray2);
|
||||
}
|
||||
|
||||
public final void encode(String string, String string2, int n) throws Exception {
|
||||
this.salt = string2;
|
||||
this.iterationCount = n;
|
||||
byte[] byArray = ByteArrayUtil.hexStringToBytes((String)string2);
|
||||
byte[] byArray2 = Pbkdf2HmacSha256.deriveKey((byte[])byArray, (long)n, (String)string, (int)32);
|
||||
this.key = TextUtil.bytesToHexString((byte[])byArray2);
|
||||
}
|
||||
|
||||
public final void parse(String string) throws IllegalArgumentException {
|
||||
try {
|
||||
int n = string.indexOf(":");
|
||||
int n2 = string.indexOf(":", n + 1);
|
||||
this.salt = string.substring(0, n);
|
||||
this.iterationCount = Integer.parseInt(string.substring(n + 1, n2));
|
||||
this.key = string.substring(n2 + 1);
|
||||
}
|
||||
catch (NumberFormatException numberFormatException) {
|
||||
throw new IllegalArgumentException("error parsing key");
|
||||
}
|
||||
}
|
||||
|
||||
public final String getValue() {
|
||||
String string = this.salt + ':' + this.iterationCount + ':' + this.key;
|
||||
return string;
|
||||
}
|
||||
|
||||
public final String getEncodingType() {
|
||||
return ENCODING_TYPE;
|
||||
}
|
||||
|
||||
public final boolean isReversible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean validate(String string) {
|
||||
try {
|
||||
byte[] byArray = Pbkdf2HmacSha256.deriveKey((byte[])ByteArrayUtil.hexStringToBytes((String)this.salt), (long)this.iterationCount, (String)string, (int)32);
|
||||
String string2 = TextUtil.bytesToHexString((byte[])byArray);
|
||||
return SecurityUtil.equals((String)string2, (String)this.key);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final String getEncodedValue() {
|
||||
return this.getValue();
|
||||
}
|
||||
|
||||
public final String getSalt() {
|
||||
return this.salt;
|
||||
}
|
||||
|
||||
public final int getIterationCount() {
|
||||
return this.iterationCount;
|
||||
}
|
||||
|
||||
public static final BPbkdf2HmacSha256PasswordEncoder makeFake(String string) {
|
||||
byte[] byArray = new byte[32];
|
||||
new SecureRandom().nextBytes(byArray);
|
||||
BPbkdf2HmacSha256PasswordEncoder bPbkdf2HmacSha256PasswordEncoder = new BPbkdf2HmacSha256PasswordEncoder();
|
||||
bPbkdf2HmacSha256PasswordEncoder.key = TextUtil.bytesToHexString((byte[])byArray);
|
||||
try {
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("Sha-256");
|
||||
byte[] byArray2 = messageDigest.digest(string.getBytes());
|
||||
bPbkdf2HmacSha256PasswordEncoder.salt = TextUtil.bytesToHexString((byte[])byArray2);
|
||||
bPbkdf2HmacSha256PasswordEncoder.iterationCount = 4096;
|
||||
return bPbkdf2HmacSha256PasswordEncoder;
|
||||
}
|
||||
catch (NoSuchAlgorithmException noSuchAlgorithmException) {
|
||||
throw new UnsupportedOperationException(noSuchAlgorithmException.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BPbkdf2HmacSha256PasswordEncoder;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BPbkdf2HmacSha256PasswordEncoder = BPbkdf2HmacSha256PasswordEncoder.class("[Ljavax.baja.security.BPbkdf2HmacSha256PasswordEncoder;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.IntHashMap
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.nre.util.IntHashMap;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.IllegalNameException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BPermissions
|
||||
extends BSimple {
|
||||
static IntHashMap cache = new IntHashMap();
|
||||
public static final int OPERATOR_READ = 1;
|
||||
public static final int OPERATOR_WRITE = 2;
|
||||
public static final int OPERATOR_INVOKE = 4;
|
||||
public static final int ADMIN_READ = 16;
|
||||
public static final int ADMIN_WRITE = 32;
|
||||
public static final int ADMIN_INVOKE = 64;
|
||||
public static final BPermissions operatorRead = BPermissions.make(1);
|
||||
public static final BPermissions operatorWrite = BPermissions.make(2);
|
||||
public static final BPermissions operatorInvoke = BPermissions.make(4);
|
||||
public static final BPermissions adminRead = BPermissions.make(16);
|
||||
public static final BPermissions adminWrite = BPermissions.make(32);
|
||||
public static final BPermissions adminInvoke = BPermissions.make(64);
|
||||
public static final BPermissions all = BPermissions.make(119);
|
||||
public static final BPermissions none;
|
||||
public static final BPermissions DEFAULT;
|
||||
public static final Type TYPE;
|
||||
private int mask;
|
||||
private String string;
|
||||
static /* synthetic */ Class class$javax$baja$security$BPermissions;
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public static final BPermissions make(int n) {
|
||||
if ((n & 2) != 0) {
|
||||
n |= 1;
|
||||
}
|
||||
if ((n & 0x10) != 0) {
|
||||
n |= 1;
|
||||
}
|
||||
if ((n & 0x20) != 0) {
|
||||
n |= 0x13;
|
||||
}
|
||||
if ((n & 0x40) != 0) {
|
||||
n |= 4;
|
||||
}
|
||||
IntHashMap intHashMap = cache;
|
||||
synchronized (intHashMap) {
|
||||
BPermissions bPermissions = (BPermissions)cache.get(n);
|
||||
if (bPermissions == null) {
|
||||
bPermissions = new BPermissions(n);
|
||||
cache.put(n, (Object)bPermissions);
|
||||
}
|
||||
return bPermissions;
|
||||
}
|
||||
}
|
||||
|
||||
public final BPermissions or(BPermissions bPermissions) {
|
||||
return BPermissions.make(this.mask | bPermissions.mask);
|
||||
}
|
||||
|
||||
public final BPermissions and(BPermissions bPermissions) {
|
||||
return BPermissions.make(this.mask & bPermissions.mask);
|
||||
}
|
||||
|
||||
public static final BPermissions make(String string) throws IOException {
|
||||
return (BPermissions)DEFAULT.decodeFromString(string);
|
||||
}
|
||||
|
||||
public final int getMask() {
|
||||
return this.mask;
|
||||
}
|
||||
|
||||
public final boolean has(int n) {
|
||||
boolean bl = false;
|
||||
if ((this.mask & n) == n) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean has(BPermissions bPermissions) {
|
||||
boolean bl = false;
|
||||
if ((this.mask & bPermissions.mask) == bPermissions.mask) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean hasOperatorRead() {
|
||||
boolean bl = false;
|
||||
if ((this.mask & 1) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean hasOperatorWrite() {
|
||||
boolean bl = false;
|
||||
if ((this.mask & 2) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean hasOperatorInvoke() {
|
||||
boolean bl = false;
|
||||
if ((this.mask & 4) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean hasAdminRead() {
|
||||
boolean bl = false;
|
||||
if ((this.mask & 0x10) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean hasAdminWrite() {
|
||||
boolean bl = false;
|
||||
if ((this.mask & 0x20) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean hasAdminInvoke() {
|
||||
boolean bl = false;
|
||||
if ((this.mask & 0x40) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
return System.identityHashCode(this);
|
||||
}
|
||||
|
||||
public final boolean equals(Object object) {
|
||||
boolean bl = false;
|
||||
if (object == this) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final String toString(Context context) {
|
||||
return this.encodeToString();
|
||||
}
|
||||
|
||||
public final void encode(DataOutput dataOutput) throws IOException {
|
||||
dataOutput.writeUTF(this.encodeToString());
|
||||
}
|
||||
|
||||
public final BObject decode(DataInput dataInput) throws IOException {
|
||||
return this.decodeFromString(dataInput.readUTF());
|
||||
}
|
||||
|
||||
public final String encodeToString() {
|
||||
if (this.string == null) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
if (this.hasOperatorRead()) {
|
||||
stringBuffer.append('r');
|
||||
}
|
||||
if (this.hasOperatorWrite()) {
|
||||
stringBuffer.append('w');
|
||||
}
|
||||
if (this.hasOperatorInvoke()) {
|
||||
stringBuffer.append('i');
|
||||
}
|
||||
if (this.hasAdminRead()) {
|
||||
stringBuffer.append('R');
|
||||
}
|
||||
if (this.hasAdminWrite()) {
|
||||
stringBuffer.append('W');
|
||||
}
|
||||
if (this.hasAdminInvoke()) {
|
||||
stringBuffer.append('I');
|
||||
}
|
||||
this.string = stringBuffer.toString();
|
||||
}
|
||||
return this.string;
|
||||
}
|
||||
|
||||
public final BObject decodeFromString(String string) throws IOException {
|
||||
try {
|
||||
int n = 0;
|
||||
int n2 = 0;
|
||||
while (n2 < string.length()) {
|
||||
switch (string.charAt(n2)) {
|
||||
case 'i': {
|
||||
n |= 4;
|
||||
break;
|
||||
}
|
||||
case 'r': {
|
||||
n |= 1;
|
||||
break;
|
||||
}
|
||||
case 'w': {
|
||||
n |= 2;
|
||||
break;
|
||||
}
|
||||
case 'I': {
|
||||
n |= 0x40;
|
||||
break;
|
||||
}
|
||||
case 'R': {
|
||||
n |= 0x10;
|
||||
break;
|
||||
}
|
||||
case 'W': {
|
||||
n |= 0x20;
|
||||
break;
|
||||
}
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
return BPermissions.make(n);
|
||||
}
|
||||
catch (IllegalNameException illegalNameException) {
|
||||
throw illegalNameException;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new IOException("Invalid BPermissions: " + string);
|
||||
}
|
||||
}
|
||||
|
||||
public final 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 BPermissions(int n) {
|
||||
this.mask = n;
|
||||
}
|
||||
|
||||
static {
|
||||
DEFAULT = none = BPermissions.make(0);
|
||||
Class clazz = class$javax$baja$security$BPermissions;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BPermissions = BPermissions.class("[Ljavax.baja.security.BPermissions;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.TextUtil
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.category.BCategory;
|
||||
import javax.baja.category.BCategoryMask;
|
||||
import javax.baja.category.BCategoryMode;
|
||||
import javax.baja.category.BCategoryService;
|
||||
import javax.baja.nre.util.TextUtil;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.NotRunningException;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BPermissionsMap
|
||||
extends BSimple {
|
||||
public static final BPermissionsMap SUPER_USER = new BPermissionsMap(new BPermissions[0], "super");
|
||||
public static final BPermissionsMap DEFAULT = new BPermissionsMap(new BPermissions[0], "");
|
||||
public static final Type TYPE;
|
||||
private BPermissions[] permissions;
|
||||
private int size;
|
||||
private String string;
|
||||
private int hashCode;
|
||||
static /* synthetic */ Class class$javax$baja$security$BPermissionsMap;
|
||||
|
||||
public static final BPermissionsMap make(BPermissions[] bPermissionsArray) {
|
||||
if (bPermissionsArray.length <= 1) {
|
||||
return DEFAULT;
|
||||
}
|
||||
bPermissionsArray = (BPermissions[])bPermissionsArray.clone();
|
||||
return (BPermissionsMap)new BPermissionsMap(bPermissionsArray, null).intern();
|
||||
}
|
||||
|
||||
public final BPermissionsMap or(BPermissionsMap bPermissionsMap) {
|
||||
if (this.isSuperUser() || bPermissionsMap.isSuperUser()) {
|
||||
return SUPER_USER;
|
||||
}
|
||||
BPermissions[] bPermissionsArray = new BPermissions[Math.max(this.permissions.length, bPermissionsMap.permissions.length)];
|
||||
int n = 0;
|
||||
while (n < bPermissionsArray.length) {
|
||||
BPermissions bPermissions;
|
||||
BPermissions bPermissions2 = n < this.permissions.length ? this.permissions[n] : BPermissions.none;
|
||||
BPermissions bPermissions3 = bPermissions = n < bPermissionsMap.permissions.length ? bPermissionsMap.permissions[n] : BPermissions.none;
|
||||
if (bPermissions2 == null) {
|
||||
bPermissions2 = BPermissions.none;
|
||||
}
|
||||
if (bPermissions == null) {
|
||||
bPermissions = BPermissions.none;
|
||||
}
|
||||
bPermissionsArray[n] = bPermissions2.or(bPermissions);
|
||||
++n;
|
||||
}
|
||||
return BPermissionsMap.make(bPermissionsArray);
|
||||
}
|
||||
|
||||
public final BPermissionsMap and(BPermissionsMap bPermissionsMap) {
|
||||
if (this.isSuperUser() && bPermissionsMap.isSuperUser()) {
|
||||
return SUPER_USER;
|
||||
}
|
||||
BPermissions[] bPermissionsArray = new BPermissions[Math.max(this.permissions.length, bPermissionsMap.permissions.length)];
|
||||
int n = 0;
|
||||
while (n < bPermissionsArray.length) {
|
||||
BPermissions bPermissions;
|
||||
BPermissions bPermissions2 = n < this.permissions.length ? this.permissions[n] : BPermissions.none;
|
||||
BPermissions bPermissions3 = bPermissions = n < bPermissionsMap.permissions.length ? bPermissionsMap.permissions[n] : BPermissions.none;
|
||||
if (this.isSuperUser()) {
|
||||
bPermissions2 = BPermissions.all;
|
||||
}
|
||||
if (bPermissionsMap.isSuperUser()) {
|
||||
bPermissions = BPermissions.all;
|
||||
}
|
||||
if (bPermissions2 == null) {
|
||||
bPermissions2 = BPermissions.none;
|
||||
}
|
||||
if (bPermissions == null) {
|
||||
bPermissions = BPermissions.none;
|
||||
}
|
||||
bPermissionsArray[n] = bPermissions2.and(bPermissions);
|
||||
++n;
|
||||
}
|
||||
return BPermissionsMap.make(bPermissionsArray);
|
||||
}
|
||||
|
||||
public final boolean isSuperUser() {
|
||||
boolean bl = false;
|
||||
if (this == SUPER_USER) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final int size() {
|
||||
if (this.size < 0) {
|
||||
int n = this.permissions.length - 1;
|
||||
while (n > 0) {
|
||||
BPermissions bPermissions = this.permissions[n];
|
||||
if (bPermissions != null && bPermissions.getMask() != 0) break;
|
||||
--n;
|
||||
}
|
||||
this.size = n + 1;
|
||||
}
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public final BPermissions getPermissions(int n) {
|
||||
if (n < 1) {
|
||||
throw new IllegalArgumentException("Category index < 1");
|
||||
}
|
||||
if (this == SUPER_USER) {
|
||||
return BPermissions.all;
|
||||
}
|
||||
if (n >= this.permissions.length) {
|
||||
return BPermissions.none;
|
||||
}
|
||||
BPermissions bPermissions = this.permissions[n];
|
||||
if (bPermissions == null) {
|
||||
return BPermissions.none;
|
||||
}
|
||||
return bPermissions;
|
||||
}
|
||||
|
||||
public final BPermissions getPermissions(BCategoryMask bCategoryMask) {
|
||||
if (this == SUPER_USER) {
|
||||
return BPermissions.all;
|
||||
}
|
||||
BCategoryService bCategoryService = null;
|
||||
try {
|
||||
bCategoryService = (BCategoryService)Sys.getService(BCategoryService.TYPE);
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
}
|
||||
catch (NotRunningException notRunningException) {}
|
||||
int n = 0;
|
||||
int n2 = -1;
|
||||
boolean bl = false;
|
||||
boolean bl2 = false;
|
||||
int n3 = this.permissions.length;
|
||||
int n4 = 1;
|
||||
while (n4 < n3) {
|
||||
if (bCategoryMask.get(n4)) {
|
||||
BValue bValue;
|
||||
BCategoryMode bCategoryMode = null;
|
||||
if (bCategoryService != null) {
|
||||
bValue = null;
|
||||
try {
|
||||
bValue = bCategoryService.getCategory(n4);
|
||||
}
|
||||
catch (NotRunningException notRunningException) {}
|
||||
if (bValue != null) {
|
||||
bCategoryMode = ((BCategory)bValue).getMode();
|
||||
}
|
||||
}
|
||||
bValue = this.permissions[n4];
|
||||
if (bCategoryMode == null || bCategoryMode == BCategoryMode.union) {
|
||||
if (bValue != null) {
|
||||
bl2 = true;
|
||||
n |= ((BPermissions)bValue).getMask();
|
||||
}
|
||||
} else {
|
||||
if (bValue == null) {
|
||||
return BPermissions.none;
|
||||
}
|
||||
bl = true;
|
||||
n2 &= ((BPermissions)bValue).getMask();
|
||||
}
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
if (bl) {
|
||||
if (bl2) {
|
||||
return BPermissions.make(n & n2);
|
||||
}
|
||||
return BPermissions.make(n2);
|
||||
}
|
||||
return BPermissions.make(n);
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
try {
|
||||
if (this.hashCode == -1) {
|
||||
this.hashCode = this.encodeToString().hashCode();
|
||||
}
|
||||
return this.hashCode;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
return System.identityHashCode(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean equals(Object object) {
|
||||
if (object instanceof BPermissionsMap) {
|
||||
BPermissionsMap bPermissionsMap = (BPermissionsMap)object;
|
||||
if (this.isSuperUser()) {
|
||||
return bPermissionsMap.isSuperUser();
|
||||
}
|
||||
if (bPermissionsMap.isSuperUser()) {
|
||||
return this.isSuperUser();
|
||||
}
|
||||
int n = Math.max(this.permissions.length, bPermissionsMap.permissions.length);
|
||||
int n2 = 1;
|
||||
while (n2 < n) {
|
||||
if (!this.getPermissions(n2).equals(bPermissionsMap.getPermissions(n2))) {
|
||||
return false;
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final void encode(DataOutput dataOutput) throws IOException {
|
||||
dataOutput.writeUTF(this.encodeToString());
|
||||
}
|
||||
|
||||
public final BObject decode(DataInput dataInput) throws IOException {
|
||||
return this.decodeFromString(dataInput.readUTF());
|
||||
}
|
||||
|
||||
public final String encodeToString() {
|
||||
if (this.string == null) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
int n = 1;
|
||||
while (n < this.permissions.length) {
|
||||
BPermissions bPermissions = this.permissions[n];
|
||||
if (bPermissions != null && bPermissions.getMask() != 0) {
|
||||
if (stringBuffer.length() > 0) {
|
||||
stringBuffer.append(';');
|
||||
}
|
||||
stringBuffer.append(n).append('=').append(bPermissions.encodeToString());
|
||||
}
|
||||
++n;
|
||||
}
|
||||
this.string = stringBuffer.toString();
|
||||
}
|
||||
return this.string;
|
||||
}
|
||||
|
||||
public final BObject decodeFromString(String string) throws IOException {
|
||||
if (string.equals("super")) {
|
||||
return SUPER_USER;
|
||||
}
|
||||
if (string.equals("")) {
|
||||
return DEFAULT;
|
||||
}
|
||||
BPermissions[] bPermissionsArray = new BPermissions[8];
|
||||
String[] stringArray = TextUtil.split((String)string, (char)';');
|
||||
int n = 0;
|
||||
while (n < stringArray.length) {
|
||||
String string2 = stringArray[n];
|
||||
int n2 = string2.indexOf(61);
|
||||
int n3 = Integer.parseInt(string2.substring(0, n2));
|
||||
BPermissions bPermissions = BPermissions.make(string2.substring(n2 + 1));
|
||||
if (n3 >= bPermissionsArray.length) {
|
||||
BPermissions[] bPermissionsArray2 = new BPermissions[Math.max(n3 + 4, bPermissionsArray.length * 2)];
|
||||
System.arraycopy(bPermissionsArray, 0, bPermissionsArray2, 0, bPermissionsArray.length);
|
||||
bPermissionsArray = bPermissionsArray2;
|
||||
}
|
||||
bPermissionsArray[n3] = bPermissions;
|
||||
++n;
|
||||
}
|
||||
return (BPermissionsMap)new BPermissionsMap(bPermissionsArray, string).intern();
|
||||
}
|
||||
|
||||
public final 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 final /* synthetic */ void this() {
|
||||
this.size = -1;
|
||||
this.hashCode = -1;
|
||||
}
|
||||
|
||||
private BPermissionsMap(BPermissions[] bPermissionsArray, String string) {
|
||||
this.this();
|
||||
this.permissions = bPermissionsArray;
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BPermissionsMap;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BPermissionsMap = BPermissionsMap.class("[Ljavax.baja.security.BPermissionsMap;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.nre.auth.SecurityUtil
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import com.tridium.nre.auth.SecurityUtil;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.security.BAbstractPasswordEncoder;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BPlainPasswordEncoder
|
||||
extends BAbstractPasswordEncoder
|
||||
implements BIAgent {
|
||||
public static final Type TYPE;
|
||||
public static final String ENCODING_TYPE = "plain/text";
|
||||
private String value;
|
||||
static /* synthetic */ Class class$javax$baja$security$BPlainPasswordEncoder;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final void encode(String string) {
|
||||
this.value = string;
|
||||
}
|
||||
|
||||
public final void parse(String string) throws IllegalArgumentException {
|
||||
this.value = string;
|
||||
}
|
||||
|
||||
public final String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public final String getEncodingType() {
|
||||
return ENCODING_TYPE;
|
||||
}
|
||||
|
||||
public final boolean isReversible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final boolean validate(String string) {
|
||||
return SecurityUtil.equals((String)string, (String)this.value);
|
||||
}
|
||||
|
||||
public final String getEncodedValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public final String getPortableEncoding() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
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 final /* synthetic */ void this() {
|
||||
this.value = null;
|
||||
}
|
||||
|
||||
public BPlainPasswordEncoder() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BPlainPasswordEncoder;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BPlainPasswordEncoder = BPlainPasswordEncoder.class("[Ljavax.baja.security.BPlainPasswordEncoder;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.baja.security.BICredentials;
|
||||
import javax.baja.security.BIUserCredentials;
|
||||
import javax.baja.security.BPassword;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BStruct;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BUsernameAndPassword
|
||||
extends BStruct
|
||||
implements BIUserCredentials {
|
||||
public static final Property username = BUsernameAndPassword.newProperty(0, BString.DEFAULT, null);
|
||||
public static final Property password = BUsernameAndPassword.newProperty(0, BPassword.DEFAULT, null);
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$javax$baja$security$BUsernameAndPassword;
|
||||
|
||||
public String getUsername() {
|
||||
return this.getString(username);
|
||||
}
|
||||
|
||||
public void setUsername(String string) {
|
||||
this.setString(username, string, null);
|
||||
}
|
||||
|
||||
public BPassword getPassword() {
|
||||
return (BPassword)this.get(password);
|
||||
}
|
||||
|
||||
public void setPassword(BPassword bPassword) {
|
||||
this.set(password, (BValue)bPassword, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public byte[] encodeCredentials() throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
|
||||
BString.make(this.getUsername()).encode(dataOutputStream);
|
||||
this.getPassword().encode(dataOutputStream, Context.encrypt);
|
||||
dataOutputStream.flush();
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
}
|
||||
|
||||
public BICredentials decodeCredentials(byte[] byArray) throws IOException {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byArray);
|
||||
DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
|
||||
BUsernameAndPassword bUsernameAndPassword = (BUsernameAndPassword)this.newCopy();
|
||||
bUsernameAndPassword.set(username, (BValue)BString.DEFAULT.decode(dataInputStream));
|
||||
bUsernameAndPassword.set(password, (BValue)BPassword.DEFAULT.decode(dataInputStream));
|
||||
return bUsernameAndPassword;
|
||||
}
|
||||
|
||||
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 BUsernameAndPassword(String string, BPassword bPassword) {
|
||||
this.setUsername(string);
|
||||
this.setPassword(bPassword);
|
||||
}
|
||||
|
||||
public BUsernameAndPassword(String string, String string2) {
|
||||
this(string, BPassword.make(string2));
|
||||
}
|
||||
|
||||
public BUsernameAndPassword() {
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$BUsernameAndPassword;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$BUsernameAndPassword = BUsernameAndPassword.class("[Ljavax.baja.security.BUsernameAndPassword;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
public interface DigestFactory {
|
||||
public byte[] makeDigest(String var1, String var2);
|
||||
|
||||
public byte[] getNonce();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security;
|
||||
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
|
||||
public class PermissionException
|
||||
extends BajaRuntimeException {
|
||||
public PermissionException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public PermissionException() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security.crypto;
|
||||
|
||||
import javax.baja.sys.BFrozenEnum;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BSslTlsEnum
|
||||
extends BFrozenEnum {
|
||||
public static final int SSLV_3 = 1;
|
||||
public static final int TLSV_1 = 2;
|
||||
public static final int SSLV_3ANDTLSV_1 = 4;
|
||||
public static final BSslTlsEnum sslv3 = new BSslTlsEnum(1);
|
||||
public static final BSslTlsEnum tlsv1 = new BSslTlsEnum(2);
|
||||
public static final BSslTlsEnum sslv3andtlsv1 = new BSslTlsEnum(4);
|
||||
public static final Type TYPE;
|
||||
public static final BSslTlsEnum DEFAULT;
|
||||
static /* synthetic */ Class class$javax$baja$security$crypto$BSslTlsEnum;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static final BSslTlsEnum make(int n) {
|
||||
return (BSslTlsEnum)sslv3.getRange().get(n, false);
|
||||
}
|
||||
|
||||
public static final BSslTlsEnum make(String string) {
|
||||
return (BSslTlsEnum)sslv3.getRange().get(string);
|
||||
}
|
||||
|
||||
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 BSslTlsEnum(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$crypto$BSslTlsEnum;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$crypto$BSslTlsEnum = BSslTlsEnum.class("[Ljavax.baja.security.crypto.BSslTlsEnum;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
DEFAULT = sslv3andtlsv1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security.crypto;
|
||||
|
||||
import javax.baja.sys.BFrozenEnum;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BTlsEnum
|
||||
extends BFrozenEnum {
|
||||
public static final int TLSV_1 = 0;
|
||||
public static final int TLSV_1_1 = 1;
|
||||
public static final int TLSV_1_2 = 2;
|
||||
public static final BTlsEnum tlsv1 = new BTlsEnum(0);
|
||||
public static final BTlsEnum tlsv1_1 = new BTlsEnum(1);
|
||||
public static final BTlsEnum tlsv1_2 = new BTlsEnum(2);
|
||||
public static final Type TYPE;
|
||||
public static final BTlsEnum DEFAULT;
|
||||
public static final int DEFAULT_ORDINAL;
|
||||
static /* synthetic */ Class class$javax$baja$security$crypto$BTlsEnum;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static final BTlsEnum make(int n) {
|
||||
return (BTlsEnum)tlsv1.getRange().get(n, false);
|
||||
}
|
||||
|
||||
public static final BTlsEnum make(String string) {
|
||||
return (BTlsEnum)tlsv1.getRange().get(string);
|
||||
}
|
||||
|
||||
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 BTlsEnum(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$security$crypto$BTlsEnum;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$security$crypto$BTlsEnum = BTlsEnum.class("[Ljavax.baja.security.crypto.BTlsEnum;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
DEFAULT = tlsv1;
|
||||
DEFAULT_ORDINAL = DEFAULT.getOrdinal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security.crypto;
|
||||
|
||||
import com.tridium.sys.Nre;
|
||||
import java.lang.reflect.Method;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.security.crypto.ICryptoManager;
|
||||
import javax.baja.security.crypto.ICryptoManagerEx;
|
||||
import javax.baja.sys.NotRunningException;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public class CertManagerFactory {
|
||||
private static Log log = Log.getLog("crypto");
|
||||
private static ICryptoManagerEx instance = null;
|
||||
private static Object mutex = new Object();
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
* Converted monitor instructions to comments
|
||||
* Lifted jumps to return sites
|
||||
*/
|
||||
public static boolean isCertManagerActive() {
|
||||
try {
|
||||
CertManagerFactory.getInstanceEx();
|
||||
Object object = mutex;
|
||||
// MONITORENTER : object
|
||||
if (instance != null) {
|
||||
// MONITOREXIT : object
|
||||
return true;
|
||||
}
|
||||
// MONITOREXIT : object
|
||||
return false;
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ICryptoManager getInstance() throws Exception {
|
||||
return CertManagerFactory.getInstanceEx();
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public static ICryptoManagerEx getInstanceEx() throws Exception {
|
||||
Object object = mutex;
|
||||
synchronized (object) {
|
||||
block9: {
|
||||
block10: {
|
||||
if (instance != null) break block9;
|
||||
if (Nre.stationHome == null) break block10;
|
||||
if (Sys.getStation() == null) {
|
||||
throw new NotRunningException("station hasn't finished loading services, can't retrieve ICryptoManagerEx instance");
|
||||
}
|
||||
if (Sys.getStation().isRunning() && (instance = (ICryptoManagerEx)((Object)Sys.getService(Sys.getType("platCrypto:CertManagerService")))) == null) {
|
||||
throw new ServiceNotFoundException("unable to find CertManagerService");
|
||||
}
|
||||
break block9;
|
||||
}
|
||||
if (Nre.bootEnv.isRemote()) {
|
||||
Type type = Sys.getType("platCrypto:WbAppletCertManager");
|
||||
instance = CertManagerFactory.make(type.getTypeClass());
|
||||
if (instance == null) {
|
||||
throw new ServiceNotFoundException("unable to find WbAppletCertManager instance");
|
||||
}
|
||||
} else {
|
||||
Type type = Sys.getType("platCrypto:WbCertManager");
|
||||
instance = CertManagerFactory.make(type.getTypeClass());
|
||||
if (instance == null) {
|
||||
throw new ServiceNotFoundException("unable to find WbCertManager instance");
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private static final ICryptoManagerEx make(Class clazz) {
|
||||
try {
|
||||
Method method = clazz.getMethod("make", null);
|
||||
ICryptoManagerEx iCryptoManagerEx = (ICryptoManagerEx)method.invoke((Object)clazz, null);
|
||||
return iCryptoManagerEx;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
if (log.isTraceOn()) {
|
||||
log.error("unable to call make on " + clazz.getName(), exception);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security.crypto;
|
||||
|
||||
import javax.baja.io.net.IClientSocketFactory;
|
||||
import javax.baja.io.net.IServerSocketFactory;
|
||||
import javax.baja.security.crypto.BSslTlsEnum;
|
||||
import javax.baja.security.crypto.IKeyStore;
|
||||
|
||||
public interface ICryptoManager {
|
||||
public IKeyStore getTrustStore() throws Exception;
|
||||
|
||||
public IKeyStore getKeyStore() throws Exception;
|
||||
|
||||
public IServerSocketFactory getServerSocketFactory(BSslTlsEnum var1, boolean var2, String var3) throws Exception;
|
||||
|
||||
public IClientSocketFactory getClientSocketFactory(BSslTlsEnum var1) throws Exception;
|
||||
|
||||
public String getClientSocketFactoryClass(BSslTlsEnum var1) throws Exception;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security.crypto;
|
||||
|
||||
import javax.baja.io.net.IClientSocketFactory;
|
||||
import javax.baja.io.net.IServerSocketFactory;
|
||||
import javax.baja.security.crypto.ICryptoManager;
|
||||
|
||||
public interface ICryptoManagerEx
|
||||
extends ICryptoManager {
|
||||
public IServerSocketFactory getServerSocketFactory(String var1, boolean var2, String var3) throws Exception;
|
||||
|
||||
public IClientSocketFactory getClientSocketFactory(String var1) throws Exception;
|
||||
|
||||
public String getClientSocketFactoryClass(String var1) throws Exception;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security.crypto;
|
||||
|
||||
import java.security.Key;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public interface IKeyStore {
|
||||
public Enumeration aliases() throws Exception;
|
||||
|
||||
public boolean containsAlias(String var1) throws Exception;
|
||||
|
||||
public void deleteEntry(String var1) throws Exception;
|
||||
|
||||
public X509Certificate getCertificate(String var1) throws Exception;
|
||||
|
||||
public String getCertificateAlias(X509Certificate var1) throws Exception;
|
||||
|
||||
public X509Certificate[] getCertificateChain(String var1) throws Exception;
|
||||
|
||||
public Date getCreationDate(String var1) throws Exception;
|
||||
|
||||
public Key getKey(String var1, char[] var2) throws Exception;
|
||||
|
||||
public boolean isCertificateEntry(String var1) throws Exception;
|
||||
|
||||
public boolean isKeyEntry(String var1) throws Exception;
|
||||
|
||||
public void setCertificateEntry(String var1, X509Certificate var2) throws Exception;
|
||||
|
||||
public void setKeyEntry(String var1, byte[] var2, X509Certificate[] var3) throws Exception;
|
||||
|
||||
public void setKeyEntry(String var1, Key var2, char[] var3, X509Certificate[] var4) throws Exception;
|
||||
|
||||
public int size() throws Exception;
|
||||
|
||||
public void save() throws Exception;
|
||||
|
||||
public Enumeration getCertificates() throws Exception;
|
||||
|
||||
public String findCertificate(X509Certificate var1) throws Exception;
|
||||
|
||||
public void deleteEntries(String[] var1) throws Exception;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security.crypto.se;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import javax.baja.security.crypto.BTlsEnum;
|
||||
import javax.baja.security.crypto.CertManagerFactory;
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BajaSSLSocketFactory
|
||||
extends SSLSocketFactory {
|
||||
private SSLSocketFactory factory;
|
||||
|
||||
public static SocketFactory getDefault() {
|
||||
try {
|
||||
return new BajaSSLSocketFactory();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return SSLSocketFactory.getDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public Socket createSocket(Socket socket, String string, int n, boolean bl) throws IOException {
|
||||
return this.factory.createSocket(socket, string, n, bl);
|
||||
}
|
||||
|
||||
public Socket createSocket(String string, int n) throws IOException, UnknownHostException {
|
||||
return this.factory.createSocket(string, n);
|
||||
}
|
||||
|
||||
public Socket createSocket(InetAddress inetAddress, int n) throws IOException {
|
||||
return this.factory.createSocket(inetAddress, n);
|
||||
}
|
||||
|
||||
public Socket createSocket(String string, int n, InetAddress inetAddress, int n2) throws IOException, UnknownHostException {
|
||||
return this.factory.createSocket(string, n, inetAddress, n2);
|
||||
}
|
||||
|
||||
public Socket createSocket(InetAddress inetAddress, int n, InetAddress inetAddress2, int n2) throws IOException {
|
||||
return this.factory.createSocket(inetAddress, n, inetAddress2, n2);
|
||||
}
|
||||
|
||||
public String[] getDefaultCipherSuites() {
|
||||
return this.factory.getDefaultCipherSuites();
|
||||
}
|
||||
|
||||
public String[] getSupportedCipherSuites() {
|
||||
return this.factory.getSupportedCipherSuites();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.factory.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
return this.factory.equals(object);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.factory.toString();
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.factory = null;
|
||||
}
|
||||
|
||||
public BajaSSLSocketFactory() throws Exception {
|
||||
this.this();
|
||||
this.factory = (SSLSocketFactory)((Object)CertManagerFactory.getInstanceEx().getClientSocketFactory(BTlsEnum.DEFAULT.getTag()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.security.kerberos;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import javax.baja.security.AuthenticationException;
|
||||
import javax.baja.security.BICredentials;
|
||||
import javax.baja.security.BIUserCredentials;
|
||||
import javax.baja.sys.BStruct;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import org.ietf.jgss.GSSCredential;
|
||||
import org.ietf.jgss.GSSException;
|
||||
|
||||
public class BKerberosCredentials
|
||||
extends BStruct
|
||||
implements BIUserCredentials {
|
||||
public static final Type TYPE = Sys.loadType(class$javax$baja$security$kerberos$BKerberosCredentials == null ? (class$javax$baja$security$kerberos$BKerberosCredentials = BKerberosCredentials.class$("javax.baja.security.kerberos.BKerberosCredentials")) : class$javax$baja$security$kerberos$BKerberosCredentials);
|
||||
GSSCredential credentials;
|
||||
private String username = null;
|
||||
static /* synthetic */ Class class$javax$baja$security$kerberos$BKerberosCredentials;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BKerberosCredentials() {
|
||||
this.credentials = null;
|
||||
}
|
||||
|
||||
public BKerberosCredentials(GSSCredential gSSCredential) {
|
||||
this.credentials = gSSCredential;
|
||||
}
|
||||
|
||||
public GSSCredential getCredential() {
|
||||
return this.credentials;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
if (this.credentials == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.username == null) {
|
||||
try {
|
||||
String string = this.credentials.getName().toString();
|
||||
int n = string.indexOf("@");
|
||||
if (n > -1) {
|
||||
string = string.substring(0, n);
|
||||
}
|
||||
this.username = string;
|
||||
}
|
||||
catch (GSSException gSSException) {
|
||||
throw new AuthenticationException("Could not extract username from credentials");
|
||||
}
|
||||
}
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getRealm() {
|
||||
if (this.credentials == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String string = this.credentials.getName().toString();
|
||||
int n = string.indexOf("@");
|
||||
if (n > -1) {
|
||||
return string.substring(n + 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (GSSException gSSException) {
|
||||
throw new AuthenticationException("Could not extract realm name from credentials");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
if (this.credentials == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return this.credentials.getRemainingLifetime() == 0;
|
||||
}
|
||||
catch (GSSException gSSException) {
|
||||
throw new AuthenticationException("Could not extract remaining lifetime from credentials");
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyTicket() {
|
||||
try {
|
||||
this.credentials.dispose();
|
||||
}
|
||||
catch (GSSException gSSException) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
|
||||
public BICredentials decodeCredentials(byte[] byArray) throws IOException {
|
||||
BKerberosCredentials bKerberosCredentials = (BKerberosCredentials)this.newCopy();
|
||||
try {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byArray);
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
|
||||
bKerberosCredentials.credentials = (GSSCredential)objectInputStream.readObject();
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
classNotFoundException.printStackTrace();
|
||||
}
|
||||
return bKerberosCredentials;
|
||||
}
|
||||
|
||||
public byte[] encodeCredentials() throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
|
||||
objectOutputStream.writeObject(this.credentials);
|
||||
objectOutputStream.flush();
|
||||
byte[] byArray = byteArrayOutputStream.toByteArray();
|
||||
byteArrayOutputStream.close();
|
||||
return byArray;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String string) {
|
||||
try {
|
||||
return Class.forName(string);
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user