[DEV] update get tocken
This commit is contained in:
parent
a135ff746d
commit
caa3ccba33
@ -88,7 +88,7 @@ public class WebLauncher {
|
|||||||
WebLauncher.LOGGER.info("Add migration since last version");
|
WebLauncher.LOGGER.info("Add migration since last version");
|
||||||
// NOTHING for now
|
// NOTHING for now
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||||
migrationEngine.migrate(GlobalConfiguration.dbConfig);
|
migrationEngine.migrateErrorThrow(GlobalConfiguration.dbConfig);
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,38 +4,40 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
public record DataGetToken(String login,
|
public record DataGetToken(
|
||||||
String method,
|
String login,
|
||||||
String time,
|
String method,
|
||||||
String password
|
String time,
|
||||||
) {
|
String password) {
|
||||||
|
|
||||||
/*public DataGetToken(String login, String method,
|
/*public DataGetToken(String login, String method,
|
||||||
String time,
|
String time,
|
||||||
String password) {
|
String password) {
|
||||||
this(login, method, time, password);
|
this(login, method, time, password);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public static String sha512(String passwordToHash) { //, String salt){
|
public static String sha512(final String passwordToHash) { //, String salt){
|
||||||
String generatedPassword = null;
|
String generatedPassword = null;
|
||||||
try {
|
try {
|
||||||
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||||
//md.update(salt.getBytes(StandardCharsets.UTF_8));
|
//md.update(salt.getBytes(StandardCharsets.UTF_8));
|
||||||
byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
|
final byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for(int i=0; i< bytes.length ;i++){
|
for (final byte element : bytes) {
|
||||||
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
|
sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
|
||||||
}
|
}
|
||||||
generatedPassword = sb.toString();
|
generatedPassword = sb.toString();
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (final NoSuchAlgorithmException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return generatedPassword;
|
return generatedPassword;
|
||||||
}
|
}
|
||||||
public static DataGetToken generate(String login, String method, String time, String password) {
|
|
||||||
return generateSha(login, method , time , sha512(password));
|
public static DataGetToken generate(final String login, final String method, final String time, final String password) {
|
||||||
|
return generateSha(login, method, time, sha512(password));
|
||||||
}
|
}
|
||||||
public static DataGetToken generateSha(String login, String method, String time, String password) {
|
|
||||||
return new DataGetToken(login, method , time , sha512("login='" + login + "';pass='" + password + "';date='" + time + "'"));
|
public static DataGetToken generateSha(final String login, final String method, final String time, final String password) {
|
||||||
|
return new DataGetToken(login, method, time, sha512("login='" + login + "';pass='" + password + "';date='" + time + "'"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user