The salt and token are now calculated at each new access starting from the password saved in the database, based on the type of access

This commit is contained in:
CappielloAntonio 2022-02-05 23:33:08 +01:00
parent cc9afb8057
commit d408b82503
4 changed files with 38 additions and 38 deletions

View file

@ -7,7 +7,6 @@ import java.util.UUID;
public class SubsonicPreferences {
private String serverUrl;
private String username;
private String password;
private String clientName = "Play";
private SubsonicAuthentication authentication;
@ -19,10 +18,6 @@ public class SubsonicPreferences {
return username;
}
public String getPassword() {
return password;
}
public String getClientName() {
return clientName;
}
@ -39,26 +34,31 @@ public class SubsonicPreferences {
this.username = username;
}
public void setPassword(String password) {
this.password = password;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public void setAuthentication(String password, String token, String salt) {
if (password != null) this.authentication = new SubsonicAuthentication(password);
if (token != null && salt != null)
public void setAuthentication(String password, String token, String salt, boolean isLowSecurity) {
if (password != null) {
this.authentication = new SubsonicAuthentication(password, isLowSecurity);
}
if (token != null && salt != null) {
this.authentication = new SubsonicAuthentication(token, salt);
}
}
public static class SubsonicAuthentication {
private String password;
private String salt;
private String token;
public SubsonicAuthentication(String password) {
update(password);
public SubsonicAuthentication(String password, boolean isLowSecurity) {
if (isLowSecurity) {
this.password = password;
} else {
update(password);
}
}
public SubsonicAuthentication(String token, String salt) {
@ -66,6 +66,10 @@ public class SubsonicPreferences {
this.salt = salt;
}
public String getPassword() {
return password;
}
public String getSalt() {
return salt;
}