link start!
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import javax.baja.security.AuthenticationException;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.user.BUserService;
|
||||
|
||||
public class AuthenticateUtil {
|
||||
public static BUser authenticateUsernameAndPassword(String string, String string2, BUserService bUserService, Context context) throws AuthenticationException {
|
||||
BUser bUser = bUserService.getUser(string);
|
||||
if (bUser != null && bUserService.canLogin(bUser)) {
|
||||
if (bUser.getPassword().validate(string2)) {
|
||||
bUser.authenticateOk(bUserService);
|
||||
bUserService.auditLoginAttempt(true, bUser, context);
|
||||
return bUser;
|
||||
}
|
||||
bUser.authenticateFailed(bUserService);
|
||||
bUserService.auditLoginAttempt(false, bUser, context);
|
||||
}
|
||||
throw new AuthenticationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.sys.BSingleton;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BAuthAgent
|
||||
extends BSingleton
|
||||
implements BIAgent {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$javax$baja$user$BAuthAgent;
|
||||
|
||||
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$user$BAuthAgent;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BAuthAgent = BAuthAgent.class("[Ljavax.baja.user.BAuthAgent;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import javax.baja.security.DigestFactory;
|
||||
import javax.baja.sys.BInterface;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
|
||||
public interface BIDefaultAuthAgent
|
||||
extends BInterface {
|
||||
public static final Type TYPE;
|
||||
|
||||
public BUser authenticateBasic(String var1, String var2, Context var3);
|
||||
|
||||
public BUser authenticateDigest(String var1, DigestFactory var2, byte[] var3, Context var4);
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$javax$baja$user$BIDefaultAuthAgent;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$javax$baja$user$BIDefaultAuthAgent = 1.class("[Ljavax.baja.user.BIDefaultAuthAgent;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BStruct;
|
||||
import javax.baja.sys.LocalizableException;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BPasswordStrength
|
||||
extends BStruct {
|
||||
public static final Property minimumLength = BPasswordStrength.newProperty(0, 10, BFacets.make("min", 0));
|
||||
public static final Property minimumLowerCase = BPasswordStrength.newProperty(0, 1, BFacets.make("min", 0));
|
||||
public static final Property minimumUpperCase = BPasswordStrength.newProperty(0, 1, BFacets.make("min", 0));
|
||||
public static final Property minimumDigits = BPasswordStrength.newProperty(0, 1, BFacets.make("min", 0));
|
||||
public static final Property minimumSpecial = BPasswordStrength.newProperty(0, 0, BFacets.make("min", 0));
|
||||
public static final Type TYPE;
|
||||
private static Lexicon lex;
|
||||
public static final BPasswordStrength DEFAULT;
|
||||
public static final BPasswordStrength STRONG;
|
||||
public static final BPasswordStrength OFF;
|
||||
static /* synthetic */ Class class$javax$baja$user$BPasswordStrength;
|
||||
|
||||
public int getMinimumLength() {
|
||||
return this.getInt(minimumLength);
|
||||
}
|
||||
|
||||
public void setMinimumLength(int n) {
|
||||
this.setInt(minimumLength, n, null);
|
||||
}
|
||||
|
||||
public int getMinimumLowerCase() {
|
||||
return this.getInt(minimumLowerCase);
|
||||
}
|
||||
|
||||
public void setMinimumLowerCase(int n) {
|
||||
this.setInt(minimumLowerCase, n, null);
|
||||
}
|
||||
|
||||
public int getMinimumUpperCase() {
|
||||
return this.getInt(minimumUpperCase);
|
||||
}
|
||||
|
||||
public void setMinimumUpperCase(int n) {
|
||||
this.setInt(minimumUpperCase, n, null);
|
||||
}
|
||||
|
||||
public int getMinimumDigits() {
|
||||
return this.getInt(minimumDigits);
|
||||
}
|
||||
|
||||
public void setMinimumDigits(int n) {
|
||||
this.setInt(minimumDigits, n, null);
|
||||
}
|
||||
|
||||
public int getMinimumSpecial() {
|
||||
return this.getInt(minimumSpecial);
|
||||
}
|
||||
|
||||
public void setMinimumSpecial(int n) {
|
||||
this.setInt(minimumSpecial, n, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void isPasswordValid(String string) throws Exception {
|
||||
int n = 0;
|
||||
int n2 = 0;
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
int n5 = string.length();
|
||||
int n6 = 0;
|
||||
while (n6 < n5) {
|
||||
char c = string.charAt(n6);
|
||||
if (Character.isLetter(c)) {
|
||||
if (Character.isUpperCase(c)) {
|
||||
++n2;
|
||||
} else {
|
||||
++n;
|
||||
}
|
||||
} else if (Character.isDigit(c)) {
|
||||
++n3;
|
||||
} else {
|
||||
++n4;
|
||||
}
|
||||
++n6;
|
||||
}
|
||||
if (n5 < this.getMinimumLength() || n3 < this.getMinimumDigits() || n < this.getMinimumLowerCase() || n2 < this.getMinimumUpperCase() || n4 < this.getMinimumSpecial()) {
|
||||
StringBuffer stringBuffer = new StringBuffer(lex.getText("user.password.notStrong"));
|
||||
if (this.getMinimumLength() > 0) {
|
||||
stringBuffer.append("\n- ").append(lex.getText("user.password.notLongEnough", new Object[]{new Integer(this.getMinimumLength())}));
|
||||
}
|
||||
if (this.getMinimumDigits() > 0) {
|
||||
stringBuffer.append("\n- ").append(lex.getText("user.password.notEnoughDigits", new Object[]{new Integer(this.getMinimumDigits())}));
|
||||
}
|
||||
if (this.getMinimumLowerCase() > 0) {
|
||||
stringBuffer.append("\n- ").append(lex.getText("user.password.notEnoughLowerCase", new Object[]{new Integer(this.getMinimumLowerCase())}));
|
||||
}
|
||||
if (this.getMinimumUpperCase() > 0) {
|
||||
stringBuffer.append("\n- ").append(lex.getText("user.password.notEnoughUpperCase", new Object[]{new Integer(this.getMinimumUpperCase())}));
|
||||
}
|
||||
if (this.getMinimumSpecial() > 0) {
|
||||
stringBuffer.append("\n- ").append(lex.getText("user.password.notEnoughSpecial", new Object[]{new Integer(this.getMinimumSpecial())}));
|
||||
}
|
||||
throw new LocalizableException("baja", lex.getText(stringBuffer.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
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 BPasswordStrength() {
|
||||
}
|
||||
|
||||
public BPasswordStrength(int n, int n2, int n3, int n4, int n5) {
|
||||
this.setMinimumLength(n);
|
||||
this.setMinimumLowerCase(n2);
|
||||
this.setMinimumUpperCase(n3);
|
||||
this.setMinimumDigits(n4);
|
||||
this.setMinimumSpecial(n5);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$user$BPasswordStrength;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BPasswordStrength = BPasswordStrength.class("[Ljavax.baja.user.BPasswordStrength;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
lex = Lexicon.make("baja");
|
||||
DEFAULT = new BPasswordStrength();
|
||||
STRONG = new BPasswordStrength(8, 0, 0, 1, 0);
|
||||
OFF = new BPasswordStrength(0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,620 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import com.tridium.sys.schema.ComponentSlotMap;
|
||||
import com.tridium.user.BUserPasswordConfiguration;
|
||||
import javax.baja.category.BCategoryMask;
|
||||
import javax.baja.license.LicenseException;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nav.BNavFileNode;
|
||||
import javax.baja.nav.NavFileDecoder;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPassword;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.security.BPermissionsMap;
|
||||
import javax.baja.security.PermissionException;
|
||||
import javax.baja.space.BComponentSpace;
|
||||
import javax.baja.status.BIStatus;
|
||||
import javax.baja.status.BStatus;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BInteger;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BasicContext;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Flags;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUserService;
|
||||
import javax.baja.user.PermissionsManager;
|
||||
import javax.baja.util.Queue;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BUser
|
||||
extends BComponent
|
||||
implements BIStatus,
|
||||
Context {
|
||||
public static final Property fullName = BUser.newProperty(0, "", null);
|
||||
public static final Property enabled = BUser.newProperty(0, true, null);
|
||||
public static final Property expiration = BUser.newProperty(0, BAbsTime.NULL, BFacets.make("fieldEditor", "wbutil:ExpirationFE"));
|
||||
public static final Property lockOut = BUser.newProperty(1, false, null);
|
||||
public static final Property permissions = BUser.newProperty(0, BPermissionsMap.DEFAULT, null);
|
||||
public static final Property language = BUser.newProperty(0, "", BFacets.make("fieldWidth", BInteger.make(6)));
|
||||
public static final Property email = BUser.newProperty(256, "", null);
|
||||
public static final Property password = BUser.newProperty(256, BPassword.DEFAULT, BFacets.make("fieldEditor", "wbutil:UserPasswordFE"));
|
||||
public static final Property facets = BUser.newProperty(256, BFacets.NULL, BFacets.make("fieldEditor", "wbutil:UserFacetsFE"));
|
||||
public static final Property navFile = BUser.newProperty(0, BOrd.NULL, null);
|
||||
public static final Property prototypeName = BUser.newProperty(0, "", BFacets.make("fieldEditor", BString.make("workbench:UserPrototypeFE")));
|
||||
public static final Property networkUser = BUser.newProperty(0, false, BFacets.make("fieldEditor", "wbutil:NetworkUserFE"));
|
||||
public static final Property version = BUser.newProperty(5, "", null);
|
||||
public static final Property prototypeVersion = BUser.newProperty(5, "", null);
|
||||
public static final Property cellPhoneNumber = BUser.newProperty(256, "", null);
|
||||
public static final Action clearLockOut = BUser.newAction(0, null);
|
||||
public static final Action setModified = BUser.newAction(0, null);
|
||||
public static final Type TYPE;
|
||||
private static final BIcon icon;
|
||||
static final Log log;
|
||||
static final BOrd DEFAULT_HOME_PAGE;
|
||||
public static final Context pwConverted;
|
||||
private static volatile boolean checkLicense;
|
||||
private static boolean guestLicensed;
|
||||
Queue authFailTimes = new Queue();
|
||||
static /* synthetic */ Class class$javax$baja$user$BUser;
|
||||
|
||||
public String getFullName() {
|
||||
return this.getString(fullName);
|
||||
}
|
||||
|
||||
public void setFullName(String string) {
|
||||
this.setString(fullName, string, null);
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return this.getBoolean(enabled);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean bl) {
|
||||
this.setBoolean(enabled, bl, null);
|
||||
}
|
||||
|
||||
public BAbsTime getExpiration() {
|
||||
return (BAbsTime)this.get(expiration);
|
||||
}
|
||||
|
||||
public void setExpiration(BAbsTime bAbsTime) {
|
||||
this.set(expiration, (BValue)bAbsTime, null);
|
||||
}
|
||||
|
||||
public boolean getLockOut() {
|
||||
return this.getBoolean(lockOut);
|
||||
}
|
||||
|
||||
public void setLockOut(boolean bl) {
|
||||
this.setBoolean(lockOut, bl, null);
|
||||
}
|
||||
|
||||
public BPermissionsMap getPermissions() {
|
||||
return (BPermissionsMap)this.get(permissions);
|
||||
}
|
||||
|
||||
public void setPermissions(BPermissionsMap bPermissionsMap) {
|
||||
this.set(permissions, (BValue)bPermissionsMap, null);
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return this.getString(language);
|
||||
}
|
||||
|
||||
public void setLanguage(String string) {
|
||||
this.setString(language, string, null);
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.getString(email);
|
||||
}
|
||||
|
||||
public void setEmail(String string) {
|
||||
this.setString(email, string, null);
|
||||
}
|
||||
|
||||
public BPassword getPassword() {
|
||||
return (BPassword)this.get(password);
|
||||
}
|
||||
|
||||
public void setPassword(BPassword bPassword) {
|
||||
this.set(password, (BValue)bPassword, null);
|
||||
}
|
||||
|
||||
public BFacets getFacets() {
|
||||
return (BFacets)this.get(facets);
|
||||
}
|
||||
|
||||
public void setFacets(BFacets bFacets) {
|
||||
this.set(facets, (BValue)bFacets, null);
|
||||
}
|
||||
|
||||
public BOrd getNavFile() {
|
||||
return (BOrd)this.get(navFile);
|
||||
}
|
||||
|
||||
public void setNavFile(BOrd bOrd) {
|
||||
this.set(navFile, (BValue)bOrd, null);
|
||||
}
|
||||
|
||||
public String getPrototypeName() {
|
||||
return this.getString(prototypeName);
|
||||
}
|
||||
|
||||
public void setPrototypeName(String string) {
|
||||
this.setString(prototypeName, string, null);
|
||||
}
|
||||
|
||||
public boolean getNetworkUser() {
|
||||
return this.getBoolean(networkUser);
|
||||
}
|
||||
|
||||
public void setNetworkUser(boolean bl) {
|
||||
this.setBoolean(networkUser, bl, null);
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.getString(version);
|
||||
}
|
||||
|
||||
public void setVersion(String string) {
|
||||
this.setString(version, string, null);
|
||||
}
|
||||
|
||||
public String getPrototypeVersion() {
|
||||
return this.getString(prototypeVersion);
|
||||
}
|
||||
|
||||
public void setPrototypeVersion(String string) {
|
||||
this.setString(prototypeVersion, string, null);
|
||||
}
|
||||
|
||||
public String getCellPhoneNumber() {
|
||||
return this.getString(cellPhoneNumber);
|
||||
}
|
||||
|
||||
public void setCellPhoneNumber(String string) {
|
||||
this.setString(cellPhoneNumber, string, null);
|
||||
}
|
||||
|
||||
public void clearLockOut() {
|
||||
this.invoke(clearLockOut, null, null);
|
||||
}
|
||||
|
||||
public void setModified() {
|
||||
this.invoke(setModified, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static BUser makeAdmin() {
|
||||
BUser bUser = new BUser();
|
||||
bUser.setFlags(permissions, bUser.getFlags(permissions) | 1);
|
||||
bUser.setFlags(expiration, bUser.getFlags(expiration) | 1);
|
||||
bUser.checkAdmin();
|
||||
return bUser;
|
||||
}
|
||||
|
||||
static BUser makeGuest() {
|
||||
BUser bUser = new BUser();
|
||||
bUser.setEnabled(false);
|
||||
bUser.checkGuest();
|
||||
return bUser;
|
||||
}
|
||||
|
||||
private final void checkAdmin() {
|
||||
if (!this.getExpiration().isNull()) {
|
||||
this.setExpiration(BAbsTime.NULL);
|
||||
}
|
||||
if (!this.getPermissions().isSuperUser()) {
|
||||
this.setPermissions(BPermissionsMap.SUPER_USER);
|
||||
}
|
||||
}
|
||||
|
||||
private final void checkGuest() {
|
||||
Object object;
|
||||
if (!this.isRunning()) {
|
||||
return;
|
||||
}
|
||||
if (checkLicense) {
|
||||
try {
|
||||
object = Sys.getLicenseManager().getFeature("tridium", "station");
|
||||
guestLicensed = object.getb("guestEnabled", false);
|
||||
}
|
||||
catch (LicenseException licenseException) {
|
||||
guestLicensed = false;
|
||||
}
|
||||
checkLicense = false;
|
||||
if (!guestLicensed && log.isTraceOn()) {
|
||||
log.trace("Guest user account not licensed. Guest user is disabled.");
|
||||
}
|
||||
}
|
||||
if (guestLicensed) {
|
||||
object = this.getParent();
|
||||
Property property = this.getPropertyInParent();
|
||||
if (object != null && property != null) {
|
||||
int n = ((BComplex)object).getFlags(property);
|
||||
if ((n & 4) != 0) {
|
||||
n &= 0xFFFFFFFB;
|
||||
}
|
||||
if ((n & 1) != 0) {
|
||||
n &= 0xFFFFFFFE;
|
||||
}
|
||||
((BComplex)object).setFlags(property, n);
|
||||
Flags.setAllReadonly(this, false, null);
|
||||
}
|
||||
} else {
|
||||
if (this.getEnabled()) {
|
||||
this.setEnabled(false);
|
||||
}
|
||||
object = this.getParent();
|
||||
Property property = this.getPropertyInParent();
|
||||
if (object != null && property != null) {
|
||||
int n = ((BComplex)object).getFlags(property);
|
||||
if ((n & 4) == 0) {
|
||||
n |= 4;
|
||||
}
|
||||
if ((n & 1) == 0) {
|
||||
n |= 1;
|
||||
}
|
||||
((BComplex)object).setFlags(property, n);
|
||||
Flags.setAllReadonly(this, true, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
String string = this.getName();
|
||||
if (string == null) {
|
||||
return "";
|
||||
}
|
||||
return SlotPath.unescape(string);
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return BUser.isExpired(this.getExpiration());
|
||||
}
|
||||
|
||||
public static boolean isExpired(BAbsTime bAbsTime) {
|
||||
if (bAbsTime.isNull()) {
|
||||
return false;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (bAbsTime.getMillis() < Clock.millis()) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public BOrd getHomePage() {
|
||||
try {
|
||||
BOrd bOrd = this.getNavFile();
|
||||
if (!bOrd.isNull()) {
|
||||
BNavFileNode bNavFileNode = NavFileDecoder.load(bOrd).getRootNode();
|
||||
return bNavFileNode.getOrdInSession();
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return DEFAULT_HOME_PAGE;
|
||||
}
|
||||
|
||||
public final Context getBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final BUser getUser() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public final BObject getFacet(String string) {
|
||||
return this.getFacets().get(string);
|
||||
}
|
||||
|
||||
public BStatus getStatus() {
|
||||
int n = 0;
|
||||
if (!this.getEnabled()) {
|
||||
n |= 1;
|
||||
}
|
||||
if (this.isExpired()) {
|
||||
n |= 2;
|
||||
}
|
||||
if (this.getLockOut()) {
|
||||
n |= 8;
|
||||
}
|
||||
return BStatus.make(n);
|
||||
}
|
||||
|
||||
public void authenticateOk(BUserService bUserService) {
|
||||
this.authFailTimes.clear();
|
||||
}
|
||||
|
||||
public void authenticateFailed(BUserService bUserService) {
|
||||
if (!bUserService.getLockOutEnabled()) {
|
||||
return;
|
||||
}
|
||||
BAbsTime bAbsTime = BAbsTime.now();
|
||||
this.authFailTimes.enqueue(bAbsTime);
|
||||
BAbsTime bAbsTime2 = bAbsTime.subtract(bUserService.getLockOutWindow());
|
||||
while (((BAbsTime)this.authFailTimes.peek()).isBefore(bAbsTime2)) {
|
||||
this.authFailTimes.dequeue();
|
||||
}
|
||||
if (this.authFailTimes.size() >= bUserService.getMaxBadLoginsBeforeLockOut()) {
|
||||
this.setLockOut(true);
|
||||
this.authenticateOk(bUserService);
|
||||
Clock.schedule((BComponent)this, bUserService.getLockOutPeriod(), clearLockOut, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void doClearLockOut() {
|
||||
this.setLockOut(false);
|
||||
}
|
||||
|
||||
private final BPermissionsMap getPermissionsMap(BIProtected bIProtected) {
|
||||
if (this.getParent() instanceof BUserService) {
|
||||
BUserService bUserService = (BUserService)this.getParent();
|
||||
PermissionsManager[] permissionsManagerArray = bUserService.getPermissionsManagers();
|
||||
int n = 0;
|
||||
while (n < permissionsManagerArray.length) {
|
||||
BPermissionsMap bPermissionsMap = permissionsManagerArray[n].getPermissionsMap(this, bIProtected);
|
||||
if (bPermissionsMap != null) {
|
||||
return bPermissionsMap;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
return this.getPermissions();
|
||||
}
|
||||
|
||||
public BPermissions getPermissions(Context context) {
|
||||
BPermissions bPermissions = super.getPermissions(context);
|
||||
BUser bUser = null;
|
||||
if (context != null) {
|
||||
bUser = context.getUser();
|
||||
}
|
||||
if (bUser == null) {
|
||||
return bPermissions;
|
||||
}
|
||||
if (bUser != this) {
|
||||
if (!bPermissions.hasAdminRead()) {
|
||||
return BPermissions.none;
|
||||
}
|
||||
if (!bPermissions.hasAdminWrite()) {
|
||||
bPermissions = BPermissions.make(bPermissions.getMask() & 0xFFFFFFFD);
|
||||
} else if (this.getPermissions().isSuperUser() && !bUser.getPermissions().isSuperUser()) {
|
||||
bPermissions = BPermissions.make(bPermissions.getMask() & 0xFFFFFFDF);
|
||||
bPermissions = BPermissions.make(bPermissions.getMask() & 0xFFFFFFFD);
|
||||
}
|
||||
}
|
||||
return bPermissions;
|
||||
}
|
||||
|
||||
public BPermissions getPermissionsFor(BIProtected bIProtected) {
|
||||
BComplex bComplex;
|
||||
BCategoryMask bCategoryMask;
|
||||
BPermissions bPermissions;
|
||||
BPermissions bPermissions2;
|
||||
BCategoryMask bCategoryMask2 = bIProtected.getAppliedCategoryMask();
|
||||
if (bIProtected instanceof BComponent && !((BComponent)bIProtected).isMounted() && bCategoryMask2.isNull()) {
|
||||
return BPermissions.all;
|
||||
}
|
||||
BPermissionsMap bPermissionsMap = this.getPermissions();
|
||||
if (!bPermissionsMap.isSuperUser()) {
|
||||
bPermissionsMap = this.getPermissionsMap(bIProtected);
|
||||
}
|
||||
if (!(bPermissions2 = bPermissionsMap.getPermissions(bCategoryMask2)).hasOperatorRead() && (bIProtected instanceof BComponent || bIProtected instanceof BComponentSpace) && (bPermissions = bPermissionsMap.getPermissions(bCategoryMask = ((ComponentSlotMap)(bComplex = bIProtected instanceof BComponent ? (BComponent)bIProtected : ((BComponentSpace)bIProtected).getRootComponent()).fw(1)).getDeepOrCategoryMask())).getMask() != 0) {
|
||||
bPermissions2 = BPermissions.operatorRead;
|
||||
}
|
||||
if (bIProtected instanceof BComplex && (bComplex = ((BComplex)((Object)bIProtected)).getParent()) instanceof BUser) {
|
||||
bIProtected = (BIProtected)((Object)bComplex);
|
||||
}
|
||||
if (bIProtected instanceof BUser && bIProtected != this && !bPermissionsMap.isSuperUser() && ((BUser)bIProtected).getPermissions().isSuperUser()) {
|
||||
bPermissions2 = BPermissions.make(bPermissions2.getMask() & 0xFFFFFFDF);
|
||||
bPermissions2 = BPermissions.make(bPermissions2.getMask() & 0xFFFFFFFD);
|
||||
}
|
||||
return bPermissions2;
|
||||
}
|
||||
|
||||
public void check(BIProtected bIProtected, BPermissions bPermissions) throws PermissionException {
|
||||
BPermissions bPermissions2 = this.getPermissionsFor(bIProtected);
|
||||
if (!bPermissions2.has(bPermissions)) {
|
||||
throw new PermissionException(bPermissions2 + " < " + bPermissions);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkRead(BComponent bComponent, Slot slot) {
|
||||
if (Flags.isOperator(bComponent, slot)) {
|
||||
this.check(bComponent, BPermissions.operatorRead);
|
||||
} else {
|
||||
this.check(bComponent, BPermissions.adminRead);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkWrite(BComponent bComponent, Slot slot) {
|
||||
if (bComponent instanceof BUser && slot.equals(permissions) && ((BUser)bComponent).getPermissions().isSuperUser() && !this.getPermissions().isSuperUser()) {
|
||||
throw new PermissionException("SuperUser required");
|
||||
}
|
||||
if (Flags.isOperator(bComponent, slot)) {
|
||||
this.check(bComponent, BPermissions.operatorWrite);
|
||||
} else {
|
||||
this.check(bComponent, BPermissions.adminWrite);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkInvoke(BComponent bComponent, Slot slot) {
|
||||
if (Flags.isOperator(bComponent, slot)) {
|
||||
this.check(bComponent, BPermissions.operatorInvoke);
|
||||
} else {
|
||||
this.check(bComponent, BPermissions.adminInvoke);
|
||||
}
|
||||
}
|
||||
|
||||
public final Object fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
switch (n) {
|
||||
case 11: {
|
||||
this.fwStarted();
|
||||
break;
|
||||
}
|
||||
case 13: {
|
||||
this.fwDescendantsStarted();
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
BComponentSpace bComponentSpace = this.getComponentSpace();
|
||||
if (bComponentSpace != null && !bComponentSpace.fireDirectCallbacks()) break;
|
||||
this.fwChanged((Property)object, (Context)object2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
|
||||
private final void fwStarted() {
|
||||
BComplex bComplex = this.getParent();
|
||||
if (bComplex instanceof BUserService) {
|
||||
if (this.getName().equals("admin")) {
|
||||
this.checkAdmin();
|
||||
} else if (this.getName().equals("guest")) {
|
||||
this.checkGuest();
|
||||
}
|
||||
if (this.getLockOut()) {
|
||||
Clock.schedule((BComponent)this, ((BUserService)bComplex).getLockOutPeriod(), clearLockOut, null);
|
||||
}
|
||||
} else if (this.getLockOut()) {
|
||||
this.setLockOut(false);
|
||||
}
|
||||
if (this.getVersion().length() == 0) {
|
||||
this.updateVersion();
|
||||
}
|
||||
}
|
||||
|
||||
private final void fwChanged(Property property, Context context) {
|
||||
BComplex bComplex = this.getParent();
|
||||
if (bComplex instanceof BUserService) {
|
||||
if (this.getName().equals("admin")) {
|
||||
this.checkAdmin();
|
||||
} else if (this.getName().equals("guest")) {
|
||||
this.checkGuest();
|
||||
}
|
||||
if (property.equals(password) && context != pwConverted) {
|
||||
this.convertToPbkdf2Password();
|
||||
}
|
||||
}
|
||||
if (this.isRunning() && property.equals(prototypeName)) {
|
||||
this.setPrototypeVersion("");
|
||||
}
|
||||
}
|
||||
|
||||
private final BUserPasswordConfiguration getPasswordConfig() {
|
||||
return (BUserPasswordConfiguration)this.getMixIn(BUserPasswordConfiguration.TYPE);
|
||||
}
|
||||
|
||||
private final void updatePasswordHistory() {
|
||||
BUserPasswordConfiguration bUserPasswordConfiguration;
|
||||
if (((BUserService)this.getParent()).canUsePasswordFeatures(this) && (bUserPasswordConfiguration = this.getPasswordConfig()) != null) {
|
||||
bUserPasswordConfiguration.passwordModified();
|
||||
}
|
||||
}
|
||||
|
||||
boolean convertToPbkdf2Password() {
|
||||
BPassword bPassword = this.getPassword();
|
||||
if (bPassword.getPasswordEncoder().isReversible()) {
|
||||
this.updatePasswordHistory();
|
||||
BPassword bPassword2 = BPassword.make(bPassword.getValue(), "pbkdf2hmacsha256/text");
|
||||
this.set("password", (BValue)bPassword2, pwConverted);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final void fwDescendantsStarted() {
|
||||
}
|
||||
|
||||
public String toString(Context context) {
|
||||
return this.getUsername();
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void doSetModified() {
|
||||
BComponent bComponent = (BComponent)this.getParent();
|
||||
if (bComponent instanceof BUserService) {
|
||||
((BUserService)bComponent).setModified(this);
|
||||
} else {
|
||||
this.updateVersion();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateVersion() {
|
||||
String string = "";
|
||||
if (Sys.getStation() != null) {
|
||||
string = Sys.getStation().getStationName();
|
||||
}
|
||||
this.setVersion(string + ':' + System.currentTimeMillis());
|
||||
}
|
||||
|
||||
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$user$BUser;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BUser = BUser.class("[Ljavax.baja.user.BUser;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
icon = BIcon.std("user.png");
|
||||
log = Log.getLog("sys.service");
|
||||
DEFAULT_HOME_PAGE = BOrd.make("station:|slot:/");
|
||||
pwConverted = new BasicContext(){
|
||||
|
||||
public final boolean equals(Object object) {
|
||||
boolean bl = false;
|
||||
if (this == object) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return "Context.pwConverted";
|
||||
}
|
||||
};
|
||||
checkLicense = true;
|
||||
guestLicensed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import javax.baja.sys.BStruct;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BUserEvent
|
||||
extends BStruct {
|
||||
public static final int UNKNOWN = -1;
|
||||
public static final int ADDED = 0;
|
||||
public static final int REMOVED = 1;
|
||||
public static final int MODIFIED = 2;
|
||||
public static final int RENAMED = 3;
|
||||
public static final Property id = BUserEvent.newProperty(0, -1, null);
|
||||
public static final Property userName = BUserEvent.newProperty(0, "", null);
|
||||
public static final Property oldName = BUserEvent.newProperty(0, "", null);
|
||||
public static final Type TYPE;
|
||||
private BUser user;
|
||||
static /* synthetic */ Class class$javax$baja$user$BUserEvent;
|
||||
|
||||
public int getId() {
|
||||
return this.getInt(id);
|
||||
}
|
||||
|
||||
public void setId(int n) {
|
||||
this.setInt(id, n, null);
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.getString(userName);
|
||||
}
|
||||
|
||||
public void setUserName(String string) {
|
||||
this.setString(userName, string, null);
|
||||
}
|
||||
|
||||
public String getOldName() {
|
||||
return this.getString(oldName);
|
||||
}
|
||||
|
||||
public void setOldName(String string) {
|
||||
this.setString(oldName, string, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static BUserEvent makeAdded(BUser bUser) {
|
||||
return new BUserEvent(0, bUser);
|
||||
}
|
||||
|
||||
public static BUserEvent makeRemoved(BUser bUser, String string) {
|
||||
return new BUserEvent(1, bUser, string);
|
||||
}
|
||||
|
||||
public static BUserEvent makeModified(BUser bUser) {
|
||||
return new BUserEvent(2, bUser);
|
||||
}
|
||||
|
||||
public static BUserEvent makeRenamed(BUser bUser, String string) {
|
||||
BUserEvent bUserEvent = new BUserEvent(3, bUser);
|
||||
bUserEvent.setOldName(string);
|
||||
return bUserEvent;
|
||||
}
|
||||
|
||||
public BUser getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
public String toString(Context context) {
|
||||
return BUserEvent.idToString(this.getId()) + ": " + this.getUserName();
|
||||
}
|
||||
|
||||
public static String idToString(int n) {
|
||||
switch (n) {
|
||||
case 0: {
|
||||
return "Added";
|
||||
}
|
||||
case 1: {
|
||||
return "Removed";
|
||||
}
|
||||
case 2: {
|
||||
return "Modified";
|
||||
}
|
||||
case 3: {
|
||||
return "Renamed";
|
||||
}
|
||||
}
|
||||
return "Unknown(" + n + ')';
|
||||
}
|
||||
|
||||
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 BUserEvent() {
|
||||
}
|
||||
|
||||
public BUserEvent(int n, BUser bUser) {
|
||||
this(n, bUser, bUser.getName());
|
||||
}
|
||||
|
||||
public BUserEvent(int n, BUser bUser, String string) {
|
||||
this.setId(n);
|
||||
this.setUserName(string);
|
||||
this.user = bUser;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$user$BUserEvent;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BUserEvent = BUserEvent.class("[Ljavax.baja.user.BUserEvent;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.Array
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Topic;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.user.BUserEvent;
|
||||
import javax.baja.user.UserMonitor;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BUserPrototypes
|
||||
extends BComponent {
|
||||
public static final Property defaultPrototype = BUserPrototypes.newProperty(0, BUserPrototypes.makeDefaultPrototype(), null);
|
||||
public static final Topic userEvent = BUserPrototypes.newTopic(0, null);
|
||||
public static final Type TYPE;
|
||||
private static final BIcon icon;
|
||||
private UserMonitor monitor;
|
||||
static /* synthetic */ Class class$javax$baja$user$BUserPrototypes;
|
||||
static /* synthetic */ Class class$java$lang$String;
|
||||
static /* synthetic */ Class class$javax$baja$user$BUser;
|
||||
|
||||
public BUser getDefaultPrototype() {
|
||||
return (BUser)this.get(defaultPrototype);
|
||||
}
|
||||
|
||||
public void setDefaultPrototype(BUser bUser) {
|
||||
this.set(defaultPrototype, (BValue)bUser, null);
|
||||
}
|
||||
|
||||
public void fireUserEvent(BUserEvent bUserEvent) {
|
||||
this.fire(userEvent, bUserEvent, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static BUser makeDefaultPrototype() {
|
||||
BUser bUser = new BUser();
|
||||
Property[] propertyArray = new Property[]{BUser.permissions, BUser.navFile};
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
bUser.setFlags(propertyArray[n], 0x10000000 | bUser.getFlags(propertyArray[n]));
|
||||
++n;
|
||||
}
|
||||
return bUser;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public String[] getPrototypeNames() {
|
||||
v0 = BUserPrototypes.class$java$lang$String;
|
||||
if (v0 == null) {
|
||||
v0 = BUserPrototypes.class$java$lang$String = BUserPrototypes.class("[Ljava.lang.String;", false);
|
||||
}
|
||||
var1_1 = new Array(v0);
|
||||
var2_2 = this.getProperties();
|
||||
if (true) ** GOTO lbl11
|
||||
do {
|
||||
if (var2_2.property() != BUserPrototypes.defaultPrototype) {
|
||||
var1_1.add((Object)var2_2.property().getName());
|
||||
}
|
||||
lbl11:
|
||||
// 4 sources
|
||||
|
||||
if ((v1 = BUserPrototypes.class$javax$baja$user$BUser) != null) continue;
|
||||
v1 = BUserPrototypes.class("[Ljavax.baja.user.BUser;", false);
|
||||
} while (var2_2.next(v1));
|
||||
return (String[])var1_1.trim();
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public Object fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
if (this.monitor != null) {
|
||||
this.monitor.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
return super.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
|
||||
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.monitor = new UserMonitor(this);
|
||||
}
|
||||
|
||||
public BUserPrototypes() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$user$BUserPrototypes;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BUserPrototypes = BUserPrototypes.class("[Ljavax.baja.user.BUserPrototypes;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
icon = BIcon.std("profile.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,490 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.nre.auth.SecurityUtil
|
||||
* javax.baja.nre.util.Array
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import com.tridium.nre.auth.SecurityUtil;
|
||||
import com.tridium.sys.station.Station;
|
||||
import com.tridium.user.BUserPasswordConfiguration;
|
||||
import com.tridium.user.BUserServicePasswordConfiguration;
|
||||
import javax.baja.agent.AgentFilter;
|
||||
import javax.baja.agent.AgentInfo;
|
||||
import javax.baja.agent.AgentList;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.security.AuditEvent;
|
||||
import javax.baja.security.Auditor;
|
||||
import javax.baja.security.AuthenticationException;
|
||||
import javax.baja.security.BHttpFoxCredentials;
|
||||
import javax.baja.security.BPassword;
|
||||
import javax.baja.security.BPasswordHistory;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIService;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BRelTime;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Flags;
|
||||
import javax.baja.sys.LocalizableException;
|
||||
import javax.baja.sys.LocalizableRuntimeException;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Topic;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BAuthAgent;
|
||||
import javax.baja.user.BIDefaultAuthAgent;
|
||||
import javax.baja.user.BPasswordStrength;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.user.BUserEvent;
|
||||
import javax.baja.user.BUserPrototypes;
|
||||
import javax.baja.user.PermissionsManager;
|
||||
import javax.baja.user.UserMonitor;
|
||||
import javax.baja.util.Version;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BUserService
|
||||
extends BComponent
|
||||
implements BIService {
|
||||
public static final Property requireStrongPasswords = BUserService.newProperty(5, true, null);
|
||||
public static final Property passwordStrength = BUserService.newProperty(0, BPasswordStrength.DEFAULT, null);
|
||||
public static final Property lockOutEnabled = BUserService.newProperty(0, true, null);
|
||||
public static final Property lockOutPeriod = BUserService.newProperty(0, BRelTime.make(10000L), null);
|
||||
public static final Property maxBadLoginsBeforeLockOut = BUserService.newProperty(0, 5, BFacets.make(BFacets.make("min", 1), BFacets.make("max", 10)));
|
||||
public static final Property lockOutWindow = BUserService.newProperty(0, BRelTime.makeSeconds(30), BFacets.make(BFacets.make("min", BRelTime.makeSeconds(1)), BFacets.make("max", BRelTime.makeHours(24))));
|
||||
public static final Property admin = BUserService.newProperty(0, BUser.makeAdmin(), null);
|
||||
public static final Property guest = BUserService.newProperty(0, BUser.makeGuest(), null);
|
||||
public static final Property userPrototypes = BUserService.newProperty(0, new BUserPrototypes(), null);
|
||||
public static final Topic userEvent = BUserService.newTopic(0, null);
|
||||
public static final Type TYPE;
|
||||
private static Type[] serviceTypes;
|
||||
private static final BIcon icon;
|
||||
private static final Version PASSWORD_STRENGTH_VERSION;
|
||||
public static HttpCredentialsHandler httpHandler;
|
||||
static final Log log;
|
||||
private UserMonitor monitor;
|
||||
private PermissionsManager[] permissionsManagers;
|
||||
static /* synthetic */ Class class$javax$baja$user$BUserService;
|
||||
static /* synthetic */ Class class$com$tridium$user$BUserPasswordConfiguration;
|
||||
static /* synthetic */ Class class$com$tridium$user$BUserServicePasswordConfiguration;
|
||||
static /* synthetic */ Class class$javax$baja$user$BUser;
|
||||
|
||||
public boolean getRequireStrongPasswords() {
|
||||
return this.getBoolean(requireStrongPasswords);
|
||||
}
|
||||
|
||||
public void setRequireStrongPasswords(boolean bl) {
|
||||
this.setBoolean(requireStrongPasswords, bl, null);
|
||||
}
|
||||
|
||||
public BPasswordStrength getPasswordStrength() {
|
||||
return (BPasswordStrength)this.get(passwordStrength);
|
||||
}
|
||||
|
||||
public void setPasswordStrength(BPasswordStrength bPasswordStrength) {
|
||||
this.set(passwordStrength, (BValue)bPasswordStrength, null);
|
||||
}
|
||||
|
||||
public boolean getLockOutEnabled() {
|
||||
return this.getBoolean(lockOutEnabled);
|
||||
}
|
||||
|
||||
public void setLockOutEnabled(boolean bl) {
|
||||
this.setBoolean(lockOutEnabled, bl, null);
|
||||
}
|
||||
|
||||
public BRelTime getLockOutPeriod() {
|
||||
return (BRelTime)this.get(lockOutPeriod);
|
||||
}
|
||||
|
||||
public void setLockOutPeriod(BRelTime bRelTime) {
|
||||
this.set(lockOutPeriod, (BValue)bRelTime, null);
|
||||
}
|
||||
|
||||
public int getMaxBadLoginsBeforeLockOut() {
|
||||
return this.getInt(maxBadLoginsBeforeLockOut);
|
||||
}
|
||||
|
||||
public void setMaxBadLoginsBeforeLockOut(int n) {
|
||||
this.setInt(maxBadLoginsBeforeLockOut, n, null);
|
||||
}
|
||||
|
||||
public BRelTime getLockOutWindow() {
|
||||
return (BRelTime)this.get(lockOutWindow);
|
||||
}
|
||||
|
||||
public void setLockOutWindow(BRelTime bRelTime) {
|
||||
this.set(lockOutWindow, (BValue)bRelTime, null);
|
||||
}
|
||||
|
||||
public BUser getAdmin() {
|
||||
return (BUser)this.get(admin);
|
||||
}
|
||||
|
||||
public void setAdmin(BUser bUser) {
|
||||
this.set(admin, (BValue)bUser, null);
|
||||
}
|
||||
|
||||
public BUser getGuest() {
|
||||
return (BUser)this.get(guest);
|
||||
}
|
||||
|
||||
public void setGuest(BUser bUser) {
|
||||
this.set(guest, (BValue)bUser, null);
|
||||
}
|
||||
|
||||
public BUserPrototypes getUserPrototypes() {
|
||||
return (BUserPrototypes)this.get(userPrototypes);
|
||||
}
|
||||
|
||||
public void setUserPrototypes(BUserPrototypes bUserPrototypes) {
|
||||
this.set(userPrototypes, (BValue)bUserPrototypes, null);
|
||||
}
|
||||
|
||||
public void fireUserEvent(BUserEvent bUserEvent) {
|
||||
this.fire(userEvent, bUserEvent, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static BUserService getService() {
|
||||
return (BUserService)Sys.getService(TYPE);
|
||||
}
|
||||
|
||||
public Type[] getServiceTypes() {
|
||||
return serviceTypes;
|
||||
}
|
||||
|
||||
public void serviceStarted() throws Exception {
|
||||
this.checkUsersForPbkdf2PasswordConversion();
|
||||
if (!Flags.isUserDefined4(this, requireStrongPasswords)) {
|
||||
if (!this.getRequireStrongPasswords()) {
|
||||
this.setPasswordStrength((BPasswordStrength)BPasswordStrength.OFF.newCopy(true));
|
||||
}
|
||||
this.setFlags(requireStrongPasswords, this.getFlags(requireStrongPasswords) | Integer.MIN_VALUE);
|
||||
}
|
||||
this.getComponentSpace().enableMixIn(BUserPasswordConfiguration.TYPE);
|
||||
this.getComponentSpace().enableMixIn(BUserServicePasswordConfiguration.TYPE);
|
||||
}
|
||||
|
||||
public void serviceStopped() throws Exception {
|
||||
this.getComponentSpace().disableMixIn(BUserPasswordConfiguration.TYPE);
|
||||
this.getComponentSpace().disableMixIn(BUserServicePasswordConfiguration.TYPE);
|
||||
}
|
||||
|
||||
public boolean isDistributable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getDisplayName(Slot slot, Context context) {
|
||||
if (slot.equals(admin)) {
|
||||
return "admin";
|
||||
}
|
||||
if (slot.equals(guest)) {
|
||||
return "guest";
|
||||
}
|
||||
return super.getDisplayName(slot, context);
|
||||
}
|
||||
|
||||
public BUser getGuestUser() {
|
||||
return this.getGuest();
|
||||
}
|
||||
|
||||
public BUser getUser(String string) {
|
||||
BUser bUser = (BUser)this.get(SlotPath.escape(string));
|
||||
if (bUser == null) {
|
||||
return null;
|
||||
}
|
||||
if (!SecurityUtil.equals((String)bUser.getUsername(), (String)string)) {
|
||||
return null;
|
||||
}
|
||||
return bUser;
|
||||
}
|
||||
|
||||
public final BUser authenticateBasic(String string, String string2) throws AuthenticationException {
|
||||
return this.authenticateBasic(string, string2, null);
|
||||
}
|
||||
|
||||
public BUser authenticateBasic(String string, String string2, Context context) throws AuthenticationException {
|
||||
BIDefaultAuthAgent bIDefaultAuthAgent = (BIDefaultAuthAgent)((Object)this.getAuthAgent(BIDefaultAuthAgent.TYPE));
|
||||
if (bIDefaultAuthAgent != null) {
|
||||
return bIDefaultAuthAgent.authenticateBasic(string, string2, context);
|
||||
}
|
||||
throw new AuthenticationException();
|
||||
}
|
||||
|
||||
public boolean canLogin(BUser bUser) {
|
||||
if (!bUser.getEnabled()) {
|
||||
return false;
|
||||
}
|
||||
if (bUser.getLockOut()) {
|
||||
return false;
|
||||
}
|
||||
if (bUser.isExpired()) {
|
||||
return false;
|
||||
}
|
||||
if (bUser.getName().equals("BACnet")) {
|
||||
return false;
|
||||
}
|
||||
if (this.canUsePasswordFeatures(bUser)) {
|
||||
BAbsTime bAbsTime;
|
||||
BUserPasswordConfiguration[] bUserPasswordConfigurationArray;
|
||||
Class clazz = class$com$tridium$user$BUserPasswordConfiguration;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$user$BUserPasswordConfiguration = BUserService.class("[Lcom.tridium.user.BUserPasswordConfiguration;", false);
|
||||
}
|
||||
if ((bUserPasswordConfigurationArray = (BUserPasswordConfiguration[])bUser.getChildren(clazz)).length > 0 && !(bAbsTime = bUserPasswordConfigurationArray[0].getExpiration()).isNull() && bAbsTime.isBefore(BAbsTime.now())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void checkStrongPassword(String string) throws Exception {
|
||||
BUserService bUserService = null;
|
||||
try {
|
||||
bUserService = (BUserService)Sys.getService(TYPE);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
bUserService = null;
|
||||
}
|
||||
if (bUserService != null) {
|
||||
bUserService.checkPassword(string);
|
||||
return;
|
||||
}
|
||||
log.warning("The static call to checkStrongPassword has been deprecated!\nUpdate to use the user service instance method checkPassword!");
|
||||
BUserService.checkLegacyPassword(string);
|
||||
}
|
||||
|
||||
public void checkPassword(String string) throws Exception {
|
||||
Version version = (Version)this.fw(404, "baja", null, null, null);
|
||||
if (version.compareTo(PASSWORD_STRENGTH_VERSION) >= 0) {
|
||||
this.getPasswordStrength().isPasswordValid(string);
|
||||
} else {
|
||||
if (!this.getRequireStrongPasswords()) {
|
||||
return;
|
||||
}
|
||||
BUserService.checkLegacyPassword(string);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDuplicatePassword(String string, BUser bUser) throws Exception {
|
||||
if (this.canUsePasswordFeatures(bUser)) {
|
||||
BUserPasswordConfiguration bUserPasswordConfiguration = this.getUserPasswordConfig(bUser);
|
||||
BUserServicePasswordConfiguration bUserServicePasswordConfiguration = this.getPasswordConfig();
|
||||
if (bUserPasswordConfiguration != null) {
|
||||
BPasswordHistory bPasswordHistory = bUserPasswordConfiguration.getPasswordHistory();
|
||||
int n = bUserServicePasswordConfiguration != null ? bUserServicePasswordConfiguration.getPasswordHistoryLength() : bPasswordHistory.getSize();
|
||||
if (bPasswordHistory.contains(bUser.getName(), BPassword.make(string, "plain/text"), n)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final void checkLegacyPassword(String string) throws Exception {
|
||||
if (string.length() < 8) {
|
||||
throw new LocalizableException("baja", "user.strongPassword.tooShort");
|
||||
}
|
||||
boolean bl = true;
|
||||
int n = 0;
|
||||
while (n < string.length()) {
|
||||
if (!Character.isLetter(string.charAt(n))) {
|
||||
bl = false;
|
||||
break;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
if (bl) {
|
||||
throw new LocalizableException("baja", "user.strongPassword.allAlpha");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canUsePasswordFeatures(BUser bUser) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public BUserPasswordConfiguration getUserPasswordConfig(BUser bUser) {
|
||||
Object[] objectArray;
|
||||
Class clazz = class$com$tridium$user$BUserPasswordConfiguration;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$user$BUserPasswordConfiguration = BUserService.class("[Lcom.tridium.user.BUserPasswordConfiguration;", false);
|
||||
}
|
||||
if ((objectArray = bUser.getChildren(clazz)).length > 0) {
|
||||
return (BUserPasswordConfiguration)objectArray[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BUserServicePasswordConfiguration getPasswordConfig() {
|
||||
Object[] objectArray;
|
||||
Class clazz = class$com$tridium$user$BUserServicePasswordConfiguration;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$user$BUserServicePasswordConfiguration = BUserService.class("[Lcom.tridium.user.BUserServicePasswordConfiguration;", false);
|
||||
}
|
||||
if ((objectArray = this.getChildren(clazz)).length > 0) {
|
||||
return (BUserServicePasswordConfiguration)objectArray[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void auditLoginAttempt(boolean bl, BUser bUser, Context context) {
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Auditor auditor = Sys.getAuditor();
|
||||
if (auditor != null) {
|
||||
BFacets bFacets = context.getFacets();
|
||||
auditor.audit(new AuditEvent(bl ? "Login" : "Login Failure", bFacets.gets("target", ""), bFacets.gets("slotName", ""), bFacets.gets("oldValue", ""), bl ? "" : Integer.toString(bUser.authFailTimes.size()), bUser.getUsername()));
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkAdd(String string, BValue bValue, int n, BFacets bFacets, Context context) {
|
||||
if (bValue instanceof BUser && ((BUser)bValue).getPermissions().isSuperUser() && context != null && context.getUser() != null && !context.getUser().getPermissions().isSuperUser()) {
|
||||
throw new LocalizableRuntimeException("wbutil", "superUser.canNotCreateSuperuser");
|
||||
}
|
||||
super.checkAdd(string, bValue, n, bFacets, context);
|
||||
}
|
||||
|
||||
public void checkRename(Property property, String string, Context context) {
|
||||
BValue bValue = this.get(property);
|
||||
if (bValue instanceof BUser && ((BUser)bValue).getPermissions().isSuperUser() && context != null && context.getUser() != null && !context.getUser().getPermissions().isSuperUser()) {
|
||||
throw new LocalizableRuntimeException("wbutil", "superUser.canNotRenameSuperuser");
|
||||
}
|
||||
super.checkRename(property, string, context);
|
||||
}
|
||||
|
||||
public synchronized void addPermissionsManager(PermissionsManager permissionsManager) {
|
||||
if (this.permissionsManagers.length == 0) {
|
||||
this.permissionsManagers = new PermissionsManager[]{permissionsManager};
|
||||
} else {
|
||||
Array array = new Array((Object[])this.permissionsManagers);
|
||||
array.add((Object)permissionsManager);
|
||||
this.permissionsManagers = (PermissionsManager[])array.trim();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void removePermissionsManager(PermissionsManager permissionsManager) {
|
||||
Array array = new Array((Object[])this.permissionsManagers);
|
||||
array.remove((Object)permissionsManager);
|
||||
this.permissionsManagers = (PermissionsManager[])array.trim();
|
||||
}
|
||||
|
||||
public synchronized PermissionsManager[] getPermissionsManagers() {
|
||||
return this.permissionsManagers;
|
||||
}
|
||||
|
||||
public void setModified(BUser bUser) {
|
||||
this.monitor.setModified(bUser);
|
||||
}
|
||||
|
||||
public Object fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
if (this.monitor != null) {
|
||||
this.monitor.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
return super.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
|
||||
public final BAuthAgent getAuthAgent(Type type) {
|
||||
BAuthAgent bAuthAgent = null;
|
||||
AgentList agentList = Sys.getRegistry().getSpecificAgents(this.getType().getTypeInfo());
|
||||
if (agentList == null || agentList.size() == 0) {
|
||||
log.error(this.getType().toString() + " does not have an associated AuthAgent.");
|
||||
return null;
|
||||
}
|
||||
if ((agentList = agentList.filter(AgentFilter.is(type))) == null || agentList.size() == 0) {
|
||||
log.error(this.getType().toString() + " does not have an associated AuthAgent.");
|
||||
return null;
|
||||
}
|
||||
AgentInfo agentInfo = agentList.get(0);
|
||||
bAuthAgent = (BAuthAgent)agentInfo.getInstance();
|
||||
return bAuthAgent;
|
||||
}
|
||||
|
||||
private final void checkUsersForPbkdf2PasswordConversion() {
|
||||
boolean bl = false;
|
||||
log.trace("checking passwords for pbkdf2 format in user service");
|
||||
Class clazz = class$javax$baja$user$BUser;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BUser = BUserService.class("[Ljavax.baja.user.BUser;", false);
|
||||
}
|
||||
BUser[] bUserArray = (BUser[])this.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bUserArray.length) {
|
||||
if (bUserArray[n].convertToPbkdf2Password()) {
|
||||
bl = true;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
if (bl) {
|
||||
try {
|
||||
Station.saveAsync(null);
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
log.trace("check for pbkdf2 password conversion in user service completed");
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
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.monitor = new UserMonitor(this);
|
||||
this.permissionsManagers = new PermissionsManager[0];
|
||||
}
|
||||
|
||||
public BUserService() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$user$BUserService;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BUserService = BUserService.class("[Ljavax.baja.user.BUserService;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
serviceTypes = new Type[]{TYPE};
|
||||
icon = BIcon.std("user.png");
|
||||
PASSWORD_STRENGTH_VERSION = new Version("3.7.30");
|
||||
httpHandler = new HttpCredentialsHandler();
|
||||
log = Log.getLog("sys.service");
|
||||
}
|
||||
|
||||
public static class HttpCredentialsHandler {
|
||||
public BUser processCredentials(BHttpFoxCredentials bHttpFoxCredentials, String string) {
|
||||
throw new UnsupportedOperationException("Method not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissionsMap;
|
||||
import javax.baja.user.BUser;
|
||||
|
||||
public interface PermissionsManager {
|
||||
public BPermissionsMap getPermissionsMap(BUser var1, BIProtected var2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.user;
|
||||
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BComponentEvent;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Subscriber;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.user.BUserEvent;
|
||||
import javax.baja.user.BUserService;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class UserMonitor {
|
||||
private BComponent comp;
|
||||
private UserSubscriber subscriber;
|
||||
static /* synthetic */ Class class$javax$baja$user$BUser;
|
||||
|
||||
final void fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
switch (n) {
|
||||
case 13: {
|
||||
this.fwDecendantsStarted();
|
||||
break;
|
||||
}
|
||||
case 14: {
|
||||
this.fwDecendantsStopped();
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
this.fwAdded((Property)object, (Context)object2);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
this.fwRemoved((Property)object, (BValue)object2, (Context)object3);
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
this.fwRenamed((Property)object, (String)object2, (Context)object3);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
this.fwChanged((Property)object, (Context)object2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final void setModified(BUser bUser) {
|
||||
bUser.updateVersion();
|
||||
this.fireUserEvent(new BUserEvent(2, bUser));
|
||||
}
|
||||
|
||||
private final void fwDecendantsStarted() {
|
||||
this.subscribeToAllUsers();
|
||||
}
|
||||
|
||||
private final void fwDecendantsStopped() {
|
||||
this.subscriber.unsubscribeAll();
|
||||
}
|
||||
|
||||
private final void fwAdded(Property property, Context context) {
|
||||
if (!this.comp.isRunning()) {
|
||||
return;
|
||||
}
|
||||
if (property.getType().is(BUser.TYPE)) {
|
||||
BUser bUser = (BUser)this.comp.get(property);
|
||||
if (bUser.getParent() instanceof BUserService) {
|
||||
bUser.convertToPbkdf2Password();
|
||||
}
|
||||
this.subscriber.subscribe(bUser, 10);
|
||||
this.cleanupSubscriptions();
|
||||
this.fireUserEvent(BUserEvent.makeAdded(bUser));
|
||||
}
|
||||
}
|
||||
|
||||
private final void fwRemoved(Property property, BValue bValue, Context context) {
|
||||
if (!this.comp.isRunning()) {
|
||||
return;
|
||||
}
|
||||
if (property.getType().is(BUser.TYPE)) {
|
||||
BUser bUser = (BUser)bValue;
|
||||
this.subscriber.unsubscribe(bUser);
|
||||
this.cleanupSubscriptions();
|
||||
this.fireUserEvent(BUserEvent.makeRemoved(bUser, property.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
private final void fwRenamed(Property property, String string, Context context) {
|
||||
if (!this.comp.isRunning()) {
|
||||
return;
|
||||
}
|
||||
if (property.getType().is(BUser.TYPE)) {
|
||||
BUser bUser = (BUser)this.comp.get(property);
|
||||
this.cleanupSubscriptions();
|
||||
this.fireUserEvent(BUserEvent.makeRenamed(bUser, string));
|
||||
}
|
||||
}
|
||||
|
||||
private final void fwChanged(Property property, Context context) {
|
||||
if (!this.comp.isRunning()) {
|
||||
return;
|
||||
}
|
||||
if (property.getType().is(BUser.TYPE)) {
|
||||
BUser bUser = (BUser)this.comp.get(property);
|
||||
if (bUser.getParent() instanceof BUserService) {
|
||||
bUser.convertToPbkdf2Password();
|
||||
}
|
||||
this.subscriber.subscribe(bUser, 10);
|
||||
this.cleanupSubscriptions();
|
||||
this.fireUserEvent(BUserEvent.makeModified(bUser));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
private final void subscribeToAllUsers() {
|
||||
this.subscriber.unsubscribeAll();
|
||||
var1_1 = this.comp.getProperties();
|
||||
if (true) ** GOTO lbl7
|
||||
do {
|
||||
var2_2 = (BUser)var1_1.get();
|
||||
this.subscriber.subscribe(var2_2, 10);
|
||||
lbl7:
|
||||
// 2 sources
|
||||
|
||||
if ((v0 = UserMonitor.class$javax$baja$user$BUser) != null) continue;
|
||||
v0 = UserMonitor.class("[Ljavax.baja.user.BUser;", false);
|
||||
} while (var1_1.next(v0));
|
||||
}
|
||||
|
||||
private final void cleanupSubscriptions() {
|
||||
BComponent[] bComponentArray = this.subscriber.getSubscriptions();
|
||||
int n = 0;
|
||||
while (n < bComponentArray.length) {
|
||||
if (!bComponentArray[n].isMounted()) {
|
||||
this.subscriber.unsubscribe(bComponentArray[n]);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
private final void fireUserEvent(BUserEvent bUserEvent) {
|
||||
this.comp.fire(this.comp.getTopic("userEvent"), bUserEvent);
|
||||
}
|
||||
|
||||
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.subscriber = new UserSubscriber();
|
||||
}
|
||||
|
||||
UserMonitor(BComponent bComponent) {
|
||||
this.this();
|
||||
if (bComponent.getTopic("userEvent") == null) {
|
||||
throw new BajaRuntimeException("Component must implement userEvent Topic!");
|
||||
}
|
||||
this.comp = bComponent;
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class UserSubscriber
|
||||
extends Subscriber {
|
||||
public void event(BComponentEvent bComponentEvent) {
|
||||
int n = bComponentEvent.getId();
|
||||
BUser bUser = this.getUser(bComponentEvent);
|
||||
if (bUser == null) {
|
||||
return;
|
||||
}
|
||||
switch (n) {
|
||||
case 0:
|
||||
case 1: {
|
||||
if (bComponentEvent.getSlot() == BUser.version) break;
|
||||
}
|
||||
case 2:
|
||||
case 3:
|
||||
case 6: {
|
||||
BUserEvent bUserEvent = new BUserEvent(2, bUser);
|
||||
bUser.updateVersion();
|
||||
UserMonitor.this.fireUserEvent(bUserEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final BUser getUser(BComponentEvent bComponentEvent) {
|
||||
BComponent bComponent = bComponentEvent.getSourceComponent();
|
||||
if (bComponent instanceof BUser) {
|
||||
return (BUser)bComponent;
|
||||
}
|
||||
BComplex bComplex = bComponent.getParent();
|
||||
while (bComplex != null && !(bComplex instanceof BUser)) {
|
||||
bComplex = bComplex.getParent();
|
||||
}
|
||||
return (BUser)bComplex;
|
||||
}
|
||||
|
||||
private UserSubscriber() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user