2010-06-05 23:33:30 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010
|
|
|
|
*
|
|
|
|
* Robert von Burg
|
|
|
|
* eitch@eitchnet.ch
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
package ch.eitchnet.privilege.model;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2011-07-26 00:00:41 +02:00
|
|
|
import ch.eitchnet.privilege.handler.PrivilegeHandler;
|
|
|
|
import ch.eitchnet.privilege.model.internal.Privilege;
|
|
|
|
import ch.eitchnet.privilege.model.internal.Role;
|
|
|
|
import ch.eitchnet.privilege.policy.PrivilegePolicy;
|
|
|
|
|
2010-06-05 23:33:30 +02:00
|
|
|
/**
|
2011-07-26 00:00:41 +02:00
|
|
|
* To keep certain details of the {@link Privilege} itself hidden from remote clients and make sure instances are only
|
|
|
|
* edited by users with the correct privilege, this representational version is allowed to be viewed by remote clients
|
|
|
|
* and simply wraps all public data from the {@link Privilege}
|
2010-06-05 23:33:30 +02:00
|
|
|
*
|
2011-07-26 00:00:41 +02:00
|
|
|
* @author rvonburg
|
2010-06-05 23:33:30 +02:00
|
|
|
*/
|
|
|
|
public class PrivilegeRep implements Serializable {
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
private String policy;
|
|
|
|
private boolean allAllowed;
|
|
|
|
private Set<String> denyList;
|
|
|
|
private Set<String> allowList;
|
|
|
|
|
|
|
|
/**
|
2011-07-26 00:00:41 +02:00
|
|
|
* Default constructor
|
|
|
|
*
|
2010-06-05 23:33:30 +02:00
|
|
|
* @param name
|
2011-07-26 00:00:41 +02:00
|
|
|
* the name of this privilege, which is unique to all privileges known in the {@link PrivilegeHandler}
|
2010-06-05 23:33:30 +02:00
|
|
|
* @param policy
|
2011-07-26 00:00:41 +02:00
|
|
|
* the {@link PrivilegePolicy} configured to evaluate if the privilege is granted
|
2010-06-05 23:33:30 +02:00
|
|
|
* @param allAllowed
|
2011-07-26 00:00:41 +02:00
|
|
|
* a boolean defining if a {@link Role} with this {@link Privilege} has unrestricted access to a
|
|
|
|
* {@link Restrictable}
|
2010-06-05 23:33:30 +02:00
|
|
|
* @param denyList
|
2011-07-26 00:00:41 +02:00
|
|
|
* a list of deny rules for this {@link Privilege}
|
2010-06-05 23:33:30 +02:00
|
|
|
* @param allowList
|
2011-07-26 00:00:41 +02:00
|
|
|
* a list of allow rules for this {@link Privilege}
|
2010-06-05 23:33:30 +02:00
|
|
|
*/
|
|
|
|
public PrivilegeRep(String name, String policy, boolean allAllowed, Set<String> denyList, Set<String> allowList) {
|
|
|
|
this.name = name;
|
|
|
|
this.policy = policy;
|
|
|
|
this.allAllowed = allAllowed;
|
2010-09-18 22:00:20 +02:00
|
|
|
this.denyList = denyList;
|
|
|
|
this.allowList = allowList;
|
2010-06-05 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the name
|
|
|
|
*/
|
|
|
|
public String getName() {
|
2010-09-19 20:57:23 +02:00
|
|
|
return this.name;
|
2010-06-05 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param name
|
|
|
|
* the name to set
|
|
|
|
*/
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the policy
|
|
|
|
*/
|
|
|
|
public String getPolicy() {
|
2010-09-19 20:57:23 +02:00
|
|
|
return this.policy;
|
2010-06-05 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param policy
|
|
|
|
* the policy to set
|
|
|
|
*/
|
|
|
|
public void setPolicy(String policy) {
|
|
|
|
this.policy = policy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the allAllowed
|
|
|
|
*/
|
|
|
|
public boolean isAllAllowed() {
|
2010-09-19 20:57:23 +02:00
|
|
|
return this.allAllowed;
|
2010-06-05 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param allAllowed
|
|
|
|
* the allAllowed to set
|
|
|
|
*/
|
|
|
|
public void setAllAllowed(boolean allAllowed) {
|
|
|
|
this.allAllowed = allAllowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the denyList
|
|
|
|
*/
|
|
|
|
public Set<String> getDenyList() {
|
2010-09-19 20:57:23 +02:00
|
|
|
return this.denyList;
|
2010-06-05 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param denyList
|
|
|
|
* the denyList to set
|
|
|
|
*/
|
|
|
|
public void setDenyList(Set<String> denyList) {
|
|
|
|
this.denyList = denyList;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the allowList
|
|
|
|
*/
|
|
|
|
public Set<String> getAllowList() {
|
2010-09-19 20:57:23 +02:00
|
|
|
return this.allowList;
|
2010-06-05 23:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param allowList
|
|
|
|
* the allowList to set
|
|
|
|
*/
|
|
|
|
public void setAllowList(Set<String> allowList) {
|
|
|
|
this.allowList = allowList;
|
|
|
|
}
|
|
|
|
}
|