[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");
|
||||
// NOTHING for now
|
||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||
migrationEngine.migrate(GlobalConfiguration.dbConfig);
|
||||
migrationEngine.migrateErrorThrow(GlobalConfiguration.dbConfig);
|
||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,11 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public record DataGetToken(String login,
|
||||
public record DataGetToken(
|
||||
String login,
|
||||
String method,
|
||||
String time,
|
||||
String password
|
||||
) {
|
||||
String password) {
|
||||
|
||||
/*public DataGetToken(String login, String method,
|
||||
String time,
|
||||
@ -16,26 +16,28 @@ public record DataGetToken(String login,
|
||||
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;
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||
//md.update(salt.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i=0; i< bytes.length ;i++){
|
||||
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
|
||||
final byte[] bytes = md.digest(passwordToHash.getBytes(StandardCharsets.UTF_8));
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (final byte element : bytes) {
|
||||
sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
generatedPassword = sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch (final NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return generatedPassword;
|
||||
}
|
||||
public static DataGetToken generate(String login, String method, String time, String 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) {
|
||||
|
||||
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