mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 12:45:57 +01:00
Removed redundant code, fixed some warnings, other minor fixes
This commit is contained in:
parent
82bf0f45ca
commit
09067ddbd1
@ -157,10 +157,7 @@ public class API {
|
||||
return false;
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com", playerName);
|
||||
if (!instance.database.saveAuth(auth)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return instance.database.saveAuth(auth);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
return false;
|
||||
}
|
||||
|
@ -744,9 +744,10 @@ public class FlatFile implements DataSource {
|
||||
for (String l : lines) {
|
||||
bw.write(l + "\n");
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
@ -761,7 +762,6 @@ public class FlatFile implements DataSource {
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import fr.xephi.authme.security.pbkdf2.PBKDF2Engine;
|
||||
import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -25,7 +26,7 @@ public class CryptPBKDF2 implements EncryptionMethod {
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
|
||||
PBKDF2Engine engine = new PBKDF2Engine(params);
|
||||
|
||||
return result + String.valueOf(engine.deriveKey(password, 64));
|
||||
return result + Arrays.toString(engine.deriveKey(password, 64));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ public interface PBKDF2 {
|
||||
*
|
||||
* @return internal byte array
|
||||
*/
|
||||
public abstract byte[] deriveKey(String inputPassword);
|
||||
byte[] deriveKey(String inputPassword);
|
||||
|
||||
/**
|
||||
* Convert String-based input to internal byte array, then invoke PBKDF2.
|
||||
@ -51,7 +51,7 @@ public interface PBKDF2 {
|
||||
*
|
||||
* @return internal byte array
|
||||
*/
|
||||
public abstract byte[] deriveKey(String inputPassword, int dkLen);
|
||||
byte[] deriveKey(String inputPassword, int dkLen);
|
||||
|
||||
/**
|
||||
* Convert String-based input to internal byte arrays, then invoke PBKDF2
|
||||
@ -63,28 +63,28 @@ public interface PBKDF2 {
|
||||
* @return <code>true</code> password match; <code>false</code> incorrect
|
||||
* password
|
||||
*/
|
||||
public abstract boolean verifyKey(String inputPassword);
|
||||
boolean verifyKey(String inputPassword);
|
||||
|
||||
/**
|
||||
* Allow reading of configured parameters.
|
||||
*
|
||||
* @return Currently set parameters.
|
||||
*/
|
||||
public abstract PBKDF2Parameters getParameters();
|
||||
PBKDF2Parameters getParameters();
|
||||
|
||||
/**
|
||||
* Allow setting of configured parameters.
|
||||
*
|
||||
* @param parameters
|
||||
*/
|
||||
public abstract void setParameters(PBKDF2Parameters parameters);
|
||||
void setParameters(PBKDF2Parameters parameters);
|
||||
|
||||
/**
|
||||
* Get currently set Pseudo Random Function.
|
||||
*
|
||||
* @return Currently set Pseudo Random Function
|
||||
*/
|
||||
public abstract PRF getPseudoRandomFunction();
|
||||
PRF getPseudoRandomFunction();
|
||||
|
||||
/**
|
||||
* Set the Pseudo Random Function to use. Note that deriveKeys/getPRF does
|
||||
@ -93,5 +93,5 @@ public interface PBKDF2 {
|
||||
*
|
||||
* @param prf Pseudo Random Function to set.
|
||||
*/
|
||||
public abstract void setPseudoRandomFunction(PRF prf);
|
||||
void setPseudoRandomFunction(PRF prf);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public interface PBKDF2Formatter {
|
||||
*
|
||||
* @return String representation
|
||||
*/
|
||||
public abstract String toString(PBKDF2Parameters p);
|
||||
String toString(PBKDF2Parameters p);
|
||||
|
||||
/**
|
||||
* Convert String to parameters. Depending on actual implementation, it may
|
||||
@ -52,5 +52,5 @@ public interface PBKDF2Formatter {
|
||||
* @return <code>false</code> syntax OK, <code>true</code> some syntax
|
||||
* issue.
|
||||
*/
|
||||
public abstract boolean fromString(PBKDF2Parameters p, String s);
|
||||
boolean fromString(PBKDF2Parameters p, String s);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class PBKDF2HexFormatter implements PBKDF2Formatter {
|
||||
}
|
||||
|
||||
String[] p123 = s.split(":");
|
||||
if (p123 == null || p123.length != 3) {
|
||||
if (p123.length != 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public interface PRF {
|
||||
* @param P The password supplied as array of bytes. It is the caller's
|
||||
* task to convert String passwords to bytes as appropriate.
|
||||
*/
|
||||
public void init(byte[] P);
|
||||
void init(byte[] P);
|
||||
|
||||
/**
|
||||
* Pseudo Random Function
|
||||
@ -49,12 +49,12 @@ public interface PRF {
|
||||
*
|
||||
* @return Random bytes of hLen length.
|
||||
*/
|
||||
public byte[] doFinal(byte[] M);
|
||||
byte[] doFinal(byte[] M);
|
||||
|
||||
/**
|
||||
* Query block size of underlying algorithm/mechanism.
|
||||
*
|
||||
* @return block size
|
||||
*/
|
||||
public int getHLen();
|
||||
int getHLen();
|
||||
}
|
||||
|
@ -268,6 +268,7 @@ public final class Utils {
|
||||
if (target.isDirectory()) {
|
||||
purgeDirectory(target);
|
||||
}
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
target.delete();
|
||||
}
|
||||
}
|
||||
|
@ -25,15 +25,12 @@ import static org.mockito.Mockito.when;
|
||||
*/
|
||||
public class UtilsTest {
|
||||
|
||||
private AuthMe authMeMock;
|
||||
private PermissionsManager permissionsManagerMock;
|
||||
|
||||
@Before
|
||||
public void setUpMocks() {
|
||||
AuthMeMockUtil.mockAuthMeInstance();
|
||||
authMeMock = AuthMe.getInstance();
|
||||
AuthMe authMeMock = AuthMe.getInstance();
|
||||
|
||||
permissionsManagerMock = mock(PermissionsManager.class);
|
||||
PermissionsManager permissionsManagerMock = mock(PermissionsManager.class);
|
||||
when(authMeMock.getPermissionsManager()).thenReturn(permissionsManagerMock);
|
||||
|
||||
Server serverMock = mock(Server.class);
|
||||
|
Loading…
Reference in New Issue
Block a user