git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/authorization-common-library@122438 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3476d4a3d2
commit
fe151091b1
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -25,6 +25,10 @@ public class User2ServicePolicy extends Policy {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public ServiceAccess getServiceAccess() {
|
||||
return serviceAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyType getPolicyType() {
|
||||
return PolicyType.USER;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue