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