mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-01 23:13:36 +00:00
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:
@@ -115,14 +115,15 @@ public class Subsonic {
|
||||
public Map<String, String> getParams() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("u", preferences.getUsername());
|
||||
params.put("s", preferences.getAuthentication().getSalt());
|
||||
params.put("t", preferences.getAuthentication().getToken());
|
||||
|
||||
if (preferences.getAuthentication().getPassword() != null) params.put("p", preferences.getAuthentication().getPassword());
|
||||
if (preferences.getAuthentication().getSalt() != null) params.put("s", preferences.getAuthentication().getSalt());
|
||||
if (preferences.getAuthentication().getToken() != null) params.put("t", preferences.getAuthentication().getToken());
|
||||
|
||||
params.put("v", getApiVersion().getVersionString());
|
||||
params.put("c", preferences.getClientName());
|
||||
params.put("f", "xml");
|
||||
|
||||
if (preferences.getPassword() != null && !preferences.getPassword().trim().equals("")) params.put("p", preferences.getPassword());
|
||||
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user