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;
|
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-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-01-19 18:49:25 +01:00
|
|
|
ClientInfo clientInfo;
|
2015-11-24 19:26:46 +01:00
|
|
|
private String context;
|
2015-12-22 19:38:57 +01:00
|
|
|
@XmlElementRefs({@XmlElementRef(type=DefaultServiceMap.class)})
|
2015-11-27 18:06:23 +01:00
|
|
|
private ServiceMap map;
|
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
|
|
|
|
|
|
|
protected AuthorizationEntry(){}
|
|
|
|
|
2016-01-19 18:49:25 +01:00
|
|
|
public AuthorizationEntry(ClientInfo clientInfo, String context, List<Policy> policies) {
|
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;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
@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());
|
|
|
|
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;
|
|
|
|
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="
|
|
|
|
+ context + ", map=" + map + ", policies=" + policies + "]";
|
|
|
|
}
|
|
|
|
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|