Lucio Lelii 2016-01-21 18:37:31 +00:00
parent 3476d4a3d2
commit fe151091b1
8 changed files with 61 additions and 12 deletions

View File

@ -83,5 +83,11 @@ public class AuthorizationEntry {
return false;
return true;
}
@Override
public String toString() {
return "AuthorizationEntry [clientInfo=" + clientInfo + ", context="
+ context + ", map=" + map + ", policies=" + policies + "]";
}
}

View File

@ -7,11 +7,25 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class Policy {
private long id;
protected Policy() {}
public abstract PolicyType getPolicyType();
public abstract String getPolicyAsString();
public abstract ServiceAccess getServiceAccess();
public abstract String getContext();
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}

View File

@ -11,7 +11,7 @@ public class Service2ServicePolicy extends Policy{
private ServiceAccess client;
private String context;
private ServiceAccess serviceAccess;
protected Service2ServicePolicy(){}
public Service2ServicePolicy(String context, ServiceAccess serviceAccess,
@ -20,7 +20,7 @@ public class Service2ServicePolicy extends Policy{
this.serviceAccess = serviceAccess;
this.client = client;
}
@Override
public PolicyType getPolicyType() {
return PolicyType.SERVICE;

View File

@ -25,6 +25,10 @@ public class User2ServicePolicy extends Policy {
return entity;
}
public ServiceAccess getServiceAccess() {
return serviceAccess;
}
@Override
public PolicyType getPolicyType() {
return PolicyType.USER;

View File

@ -13,6 +13,11 @@ import javax.xml.bind.annotation.XmlSeeAlso;
@XmlSeeAlso(value={UserInfo.class, ServiceInfo.class})
public abstract class ClientInfo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
public abstract String getId();
public abstract List<String> getRoles();

View File

@ -1,18 +1,25 @@
package org.gcube.common.authorization.library.provider;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ServiceIdentifier {
public class ServiceIdentifier implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String serviceClass;
private String serviceName;
private String serviceId;
public ServiceIdentifier() {}
protected ServiceIdentifier() {}
public ServiceIdentifier(String serviceClass, String serviceName, String serviceId) {
super();
@ -34,13 +41,17 @@ public class ServiceIdentifier {
}
public String getFullIdentifier(){
return getIdentifier(serviceClass, serviceName, serviceId);
}
public static String getIdentifier(String serviceClass, String serviceName, String serviceId){
return serviceClass+":"+serviceName+":"+serviceId;
}
public static ServiceIdentifier getServiceIdentifierFromId(String serviceId){
String[] split = serviceId.split(":");
if (split.length!=3)
throw new IllegalArgumentException("invalid serviceId provided: "+serviceId);
return new ServiceIdentifier(split[0], split[1] , split[2]);
}
@Override
public int hashCode() {
final int prime = 31;

View File

@ -11,6 +11,10 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class ServiceInfo extends ClientInfo{
/**
*
*/
private static final long serialVersionUID = 1L;
ServiceIdentifier serviceIdentifier;
protected ServiceInfo() {}

View File

@ -12,6 +12,11 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class UserInfo extends ClientInfo {
/**
*
*/
private static final long serialVersionUID = 1L;
private String clientId;
private List<String> roles = Collections.emptyList();