65 lines
1.4 KiB
Java
65 lines
1.4 KiB
Java
package org.gcube.common.authorization.utils.secret;
|
|
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public class ClienIDSecret extends Secret {
|
|
|
|
protected String clientID;
|
|
|
|
public ClienIDSecret(String clientID, String token) {
|
|
super(30, token);
|
|
this.clientID = clientID;
|
|
}
|
|
|
|
@Override
|
|
public void set() throws Exception {
|
|
// TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(CLIENT_ID, CLIENT_SECRET, contextToAuthorise, null);
|
|
// System.out.println(tr.getAccessToken());
|
|
}
|
|
|
|
@Override
|
|
public String getContext() throws Exception {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public String getUsername() throws Exception {
|
|
return clientID;
|
|
}
|
|
|
|
@Override
|
|
public Map<String, String> getHTTPAuthorizationHeaders() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
final int prime = 31;
|
|
int result = super.hashCode();
|
|
result = prime * result + Objects.hash(clientID);
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj)
|
|
return true;
|
|
if (!super.equals(obj))
|
|
return false;
|
|
if (getClass() != obj.getClass())
|
|
return false;
|
|
ClienIDSecret other = (ClienIDSecret) obj;
|
|
return Objects.equals(clientID, other.clientID);
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(Secret obj) {
|
|
int res = super.compareTo(obj);
|
|
return res == 0 ? clientID.compareTo(clientID) : res;
|
|
}
|
|
}
|