155 lines
5.4 KiB
Java
155 lines
5.4 KiB
Java
/*
|
|
* 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);
|
|
}
|
|
}
|
|
|