2015-05-18 19:15:11 +02:00
|
|
|
package org.gcube.common.authorization.library;
|
|
|
|
|
2015-06-04 18:50:06 +02: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;
|
|
|
|
|
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 {
|
|
|
|
|
2015-11-24 19:26:46 +01:00
|
|
|
private String clientId;
|
2015-05-29 18:32:49 +02:00
|
|
|
private List<String> roles;
|
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;
|
2015-11-24 19:26:46 +01:00
|
|
|
private List<CalledService> bannedServices = new ArrayList<CalledService>();
|
2015-05-18 19:15:11 +02:00
|
|
|
|
|
|
|
protected AuthorizationEntry(){}
|
|
|
|
|
2015-11-24 19:26:46 +01:00
|
|
|
public AuthorizationEntry(String clientId, List<String> roles, String context) {
|
2015-05-18 19:15:11 +02:00
|
|
|
super();
|
2015-11-24 19:26:46 +01:00
|
|
|
this.clientId = clientId;
|
2015-05-29 18:32:49 +02:00
|
|
|
this.roles = roles;
|
2015-11-24 19:26:46 +01:00
|
|
|
this.context = context;
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|
2015-06-04 18:50:06 +02:00
|
|
|
|
2015-11-27 18:06:23 +01:00
|
|
|
public AuthorizationEntry(String userName, List<String> roles, String context , List<CalledService> bannedServices) {
|
|
|
|
this(userName, roles, context);
|
2015-06-04 18:50:06 +02:00
|
|
|
this.bannedServices = bannedServices;
|
|
|
|
}
|
2015-05-18 19:15:11 +02:00
|
|
|
|
2015-11-24 19:26:46 +01:00
|
|
|
public String getClientId() {
|
|
|
|
return clientId;
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|
|
|
|
|
2015-05-29 18:32:49 +02:00
|
|
|
public List<String> getRoles() {
|
|
|
|
return roles;
|
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;
|
|
|
|
}
|
|
|
|
|
2015-06-04 18:50:06 +02:00
|
|
|
|
2015-11-27 18:06:23 +01:00
|
|
|
|
|
|
|
public void setMap(ServiceMap map) {
|
|
|
|
this.map = map;
|
|
|
|
}
|
|
|
|
|
2015-11-24 19:26:46 +01:00
|
|
|
public List<CalledService> getBannedServices() {
|
2015-06-04 18:50:06 +02:00
|
|
|
return bannedServices;
|
|
|
|
}
|
|
|
|
|
2015-11-24 19:26:46 +01:00
|
|
|
public void setBannedServices(List<CalledService> bannedServices) {
|
2015-06-04 18:50:06 +02:00
|
|
|
this.bannedServices = bannedServices;
|
|
|
|
}
|
2015-05-18 19:15:11 +02:00
|
|
|
|
2015-12-22 19:38:57 +01:00
|
|
|
|
|
|
|
|
2015-05-18 19:15:11 +02:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2015-11-24 19:26:46 +01:00
|
|
|
return "AuthorizationEntry [clientId=" + clientId + ", roles=" + roles
|
2015-12-22 19:38:57 +01:00
|
|
|
+ ", context=" + context + ", map=" + map + ", bannedServices="
|
|
|
|
+ bannedServices + "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
final int prime = 31;
|
|
|
|
int result = 1;
|
|
|
|
result = prime * result
|
|
|
|
+ ((bannedServices == null) ? 0 : bannedServices.hashCode());
|
|
|
|
result = prime * result
|
|
|
|
+ ((clientId == null) ? 0 : clientId.hashCode());
|
|
|
|
result = prime * result + ((context == null) ? 0 : context.hashCode());
|
|
|
|
result = prime * result + ((map == null) ? 0 : map.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;
|
|
|
|
AuthorizationEntry other = (AuthorizationEntry) obj;
|
|
|
|
if (bannedServices == null) {
|
|
|
|
if (other.bannedServices != null)
|
|
|
|
return false;
|
|
|
|
} else if (!bannedServices.equals(other.bannedServices))
|
|
|
|
return false;
|
|
|
|
if (clientId == null) {
|
|
|
|
if (other.clientId != null)
|
|
|
|
return false;
|
|
|
|
} else if (!clientId.equals(other.clientId))
|
|
|
|
return false;
|
|
|
|
if (context == null) {
|
|
|
|
if (other.context != null)
|
|
|
|
return false;
|
|
|
|
} else if (!context.equals(other.context))
|
|
|
|
return false;
|
|
|
|
if (map == null) {
|
|
|
|
if (other.map != null)
|
|
|
|
return false;
|
|
|
|
} else if (!map.equals(other.map))
|
|
|
|
return false;
|
|
|
|
if (roles == null) {
|
|
|
|
if (other.roles != null)
|
|
|
|
return false;
|
|
|
|
} else if (!roles.equals(other.roles))
|
|
|
|
return false;
|
|
|
|
return true;
|
2015-05-18 19:15:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|