common-authorization/src/main/java/org/gcube/common/authorization/library/provider/ClientInfo.java

90 lines
2.0 KiB
Java

package org.gcube.common.authorization.library.provider;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.gcube.common.authorization.library.policies.Policy;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ClientInfo {
private String clientId;
private List<String> roles = Collections.emptyList();
private List<Policy> policies;
protected ClientInfo(){}
public ClientInfo(String clientId, List<String> roles, List<Policy> policies) {
super();
this.clientId = clientId;
this.roles = roles;
this.policies = policies;
}
public String getClientId() {
return clientId;
}
public List<Policy> getPolicies() {
return policies;
}
/*
public boolean isTokenBannedForService(BannedService service){
return (bannedServices.contains(service));
}*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((clientId == null) ? 0 : clientId.hashCode());
result = prime * result
+ ((policies == null) ? 0 : policies.hashCode());
result = prime * result + ((roles == null) ? 0 : roles.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ClientInfo other = (ClientInfo) obj;
if (clientId == null) {
if (other.clientId != null)
return false;
} else if (!clientId.equals(other.clientId))
return false;
if (policies == null) {
if (other.policies != null)
return false;
} else if (!policies.equals(other.policies))
return false;
if (roles == null) {
if (other.roles != null)
return false;
} else if (!roles.equals(other.roles))
return false;
return true;
}
@Override
public String toString() {
return "ClientInfo [clientId=" + clientId + ", roles=" + roles
+ ", policies=" + policies + "]";
}
}