2015-05-18 19:15:11 +02:00
|
|
|
package org.gcube.common.authorization.library;
|
|
|
|
|
2016-02-15 12:38:51 +01:00
|
|
|
import java.util.ArrayList;
|
2015-05-29 18:32:49 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2015-05-18 19:15:11 +02:00
|
|
|
import javax.xml.bind.annotation.XmlAccessType;
|
|
|
|
import javax.xml.bind.annotation.XmlAccessorType;
|
2016-07-14 17:47:51 +02:00
|
|
|
import javax.xml.bind.annotation.XmlElement;
|
2015-12-22 19:38:57 +01:00
|
|
|
import javax.xml.bind.annotation.XmlElementRef;
|
|
|
|
import javax.xml.bind.annotation.XmlElementRefs;
|
2015-05-18 19:15:11 +02:00
|
|
|
import javax.xml.bind.annotation.XmlRootElement;
|
|
|
|
|
2016-01-19 18:49:25 +01:00
|
|
|
import org.gcube.common.authorization.library.policies.Policy;
|
2016-01-26 18:45:22 +01:00
|
|
|
import org.gcube.common.authorization.library.policies.Service2ServicePolicy;
|
|
|
|
import org.gcube.common.authorization.library.policies.User2ServicePolicy;
|
2016-01-19 18:49:25 +01:00
|
|
|
import org.gcube.common.authorization.library.provider.ClientInfo;
|
2016-07-22 14:27:15 +02:00
|
|
|
import org.gcube.common.authorization.library.provider.ContainerInfo;
|
2016-07-14 17:47:51 +02:00
|
|
|
import org.gcube.common.authorization.library.provider.ExternalServiceInfo;
|
2016-01-26 18:45:22 +01:00
|
|
|
import org.gcube.common.authorization.library.provider.ServiceInfo;
|
|
|
|
import org.gcube.common.authorization.library.provider.UserInfo;
|
2015-11-27 18:06:23 +01:00
|
|
|
import org.gcube.common.scope.api.ServiceMap;
|
2015-12-22 19:38:57 +01:00
|
|
|
import org.gcube.common.scope.impl.DefaultServiceMap;
|
2015-11-27 18:06:23 +01:00
|
|
|
|
2015-05-18 19:15:11 +02:00
|
|
|
@XmlRootElement
|
|
|
|
@XmlAccessorType(XmlAccessType.FIELD)
|
|
|
|
public class AuthorizationEntry {
|
|
|
|
|
2016-01-26 18:45:22 +01:00
|
|
|
@XmlElementRefs({
|
|
|
|
@XmlElementRef(type = UserInfo.class),
|
|
|
|
@XmlElementRef(type = ServiceInfo.class),
|
2016-07-22 14:27:15 +02:00
|
|
|
@XmlElementRef(type = ExternalServiceInfo.class),
|
|
|
|
@XmlElementRef(type = ContainerInfo.class)
|
2016-01-26 18:45:22 +01:00
|
|
|
})
|
2016-01-19 18:49:25 +01:00
|
|
|
ClientInfo clientInfo;
|
2016-07-14 17:47:51 +02:00
|
|
|
|
2015-11-24 19:26:46 +01:00
|
|
|
private String context;
|
2020-11-17 15:37:12 +01:00
|
|
|
|
|
|
|
@XmlElementRef(type = DefaultServiceMap.class)
|
2015-11-27 18:06:23 +01:00
|
|
|
private ServiceMap map;
|
2020-11-17 15:37:12 +01:00
|
|
|
|
2016-01-26 18:45:22 +01:00
|
|
|
@XmlElementRefs({
|
|
|
|
@XmlElementRef(type = Service2ServicePolicy.class),
|
|
|
|
@XmlElementRef(type = User2ServicePolicy.class),
|
|
|
|
})
|
2016-02-15 12:38:51 +01:00
|
|
|
private List<Policy> policies = new ArrayList<Policy>();
|
2015-05-18 19:15:11 +02:00
|
|
|
|
2016-07-14 17:47:51 +02:00
|
|
|
|
|
|
|
@XmlElement
|
|
|
|
private String qualifier;
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-18 19:15:11 +02:00
|
|
|
protected AuthorizationEntry(){}
|
|
|
|
|
2016-07-14 17:47:51 +02:00
|
|
|
public AuthorizationEntry(ClientInfo clientInfo, String context, List<Policy> policies, String qualifier) {
|
2015-05-18 19:15:11 +02:00
|
|
|
super();
|
2016-01-19 18:49:25 +01:00
|
|
|
this.clientInfo = clientInfo;
|
2015-11-24 19:26:46 +01:00
|
|
|
this.context = context;
|
2016-01-19 18:49:25 +01:00
|
|
|
this.policies = policies;
|
2016-07-14 17:47:51 +02:00
|
|
|
this.qualifier = qualifier;
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|
|
|
|
|
2016-01-19 18:49:25 +01:00
|
|
|
public ClientInfo getClientInfo() {
|
|
|
|
return clientInfo;
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-24 19:26:46 +01:00
|
|
|
public String getContext() {
|
|
|
|
return context;
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|
2015-11-27 18:06:23 +01:00
|
|
|
|
|
|
|
public ServiceMap getMap() {
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2016-07-14 17:47:51 +02:00
|
|
|
public String getQualifier() {
|
|
|
|
return qualifier;
|
|
|
|
}
|
|
|
|
|
2015-11-27 18:06:23 +01:00
|
|
|
public void setMap(ServiceMap map) {
|
|
|
|
this.map = map;
|
|
|
|
}
|
|
|
|
|
2016-01-19 18:49:25 +01:00
|
|
|
public List<Policy> getPolicies() {
|
|
|
|
return policies;
|
2015-12-22 19:38:57 +01:00
|
|
|
}
|
|
|
|
|
2016-07-14 17:47:51 +02:00
|
|
|
|
|
|
|
|
2015-12-22 19:38:57 +01:00
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
final int prime = 31;
|
|
|
|
int result = 1;
|
|
|
|
result = prime * result
|
2016-01-19 18:49:25 +01:00
|
|
|
+ ((clientInfo == null) ? 0 : clientInfo.hashCode());
|
2015-12-22 19:38:57 +01:00
|
|
|
result = prime * result + ((context == null) ? 0 : context.hashCode());
|
2016-07-14 17:47:51 +02:00
|
|
|
result = prime * result
|
|
|
|
+ ((qualifier == null) ? 0 : qualifier.hashCode());
|
2015-12-22 19:38:57 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj)
|
|
|
|
return true;
|
|
|
|
if (obj == null)
|
|
|
|
return false;
|
|
|
|
if (getClass() != obj.getClass())
|
|
|
|
return false;
|
|
|
|
AuthorizationEntry other = (AuthorizationEntry) obj;
|
2016-01-19 18:49:25 +01:00
|
|
|
if (clientInfo == null) {
|
|
|
|
if (other.clientInfo != null)
|
2015-12-22 19:38:57 +01:00
|
|
|
return false;
|
2016-01-19 18:49:25 +01:00
|
|
|
} else if (!clientInfo.equals(other.clientInfo))
|
2015-12-22 19:38:57 +01:00
|
|
|
return false;
|
|
|
|
if (context == null) {
|
|
|
|
if (other.context != null)
|
|
|
|
return false;
|
|
|
|
} else if (!context.equals(other.context))
|
|
|
|
return false;
|
2016-07-14 17:47:51 +02:00
|
|
|
if (qualifier == null) {
|
|
|
|
if (other.qualifier != null)
|
|
|
|
return false;
|
|
|
|
} else if (!qualifier.equals(other.qualifier))
|
|
|
|
return false;
|
2015-12-22 19:38:57 +01:00
|
|
|
return true;
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|
2016-01-21 19:37:31 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return "AuthorizationEntry [clientInfo=" + clientInfo + ", context="
|
2016-07-14 17:47:51 +02:00
|
|
|
+ context + ", map=" + map + ", qualifier=" + qualifier
|
|
|
|
+ ", policies=" + policies + "]";
|
2016-01-21 19:37:31 +01:00
|
|
|
}
|
2016-07-14 17:47:51 +02:00
|
|
|
|
2016-01-21 19:37:31 +01:00
|
|
|
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|