94 lines
2.1 KiB
Java
94 lines
2.1 KiB
Java
package org.gcube.common.authorization.library.policies;
|
|
|
|
import javax.xml.bind.annotation.XmlAccessType;
|
|
import javax.xml.bind.annotation.XmlAccessorType;
|
|
import javax.xml.bind.annotation.XmlRootElement;
|
|
|
|
@XmlRootElement
|
|
@XmlAccessorType(XmlAccessType.FIELD)
|
|
public class ServicePolicy extends Policy{
|
|
|
|
private String clientID;
|
|
private String environment;
|
|
private ServiceAccess serviceAccess;
|
|
|
|
protected ServicePolicy(){}
|
|
|
|
public ServicePolicy(String environment, ServiceAccess serviceAccess,
|
|
String clientID) {
|
|
this.environment = environment;
|
|
this.serviceAccess = serviceAccess;
|
|
this.clientID = clientID;
|
|
}
|
|
|
|
@Override
|
|
public PolicyType getPolicyType() {
|
|
return PolicyType.SERVICE;
|
|
}
|
|
|
|
@Override
|
|
public String getPolicyAsString() {
|
|
return serviceAccess.getAsString();
|
|
}
|
|
|
|
public String getClientID() {
|
|
return clientID;
|
|
}
|
|
|
|
public String getEnvironment() {
|
|
return environment;
|
|
}
|
|
|
|
public ServiceAccess getServiceAccess() {
|
|
return serviceAccess;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
final int prime = 31;
|
|
int result = 1;
|
|
result = prime * result
|
|
+ ((clientID == null) ? 0 : clientID.hashCode());
|
|
result = prime * result
|
|
+ ((environment == null) ? 0 : environment.hashCode());
|
|
result = prime * result
|
|
+ ((serviceAccess == null) ? 0 : serviceAccess.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;
|
|
ServicePolicy other = (ServicePolicy) obj;
|
|
if (clientID == null) {
|
|
if (other.clientID != null)
|
|
return false;
|
|
} else if (!clientID.equals(other.clientID))
|
|
return false;
|
|
if (environment == null) {
|
|
if (other.environment != null)
|
|
return false;
|
|
} else if (!environment.equals(other.environment))
|
|
return false;
|
|
if (serviceAccess == null) {
|
|
if (other.serviceAccess != null)
|
|
return false;
|
|
} else if (!serviceAccess.equals(other.serviceAccess))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "ServicePolicy [clientID=" + clientID + ", environment="
|
|
+ environment + ", serviceAccess=" + serviceAccess + "]";
|
|
}
|
|
|
|
|
|
}
|