All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.personify.iam.model.authentication.Permission Maven / Gradle / Ivy

There is a newer version: 1.5.2.RELEASE
Show newest version
package be.personify.iam.model.authentication;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import be.personify.iam.model.util.Persisted;
import be.personify.util.Action;
import be.personify.util.StringUtils;
import be.personify.util.generator.MetaInfo;

@Entity
@MetaInfo( name="Permission", group="authentication", frontendGroup = "Authorization", 
	description="A permission", iconClass = "check-square", number=4, showInMenu = true)
@Table(name="permission", indexes = {
		//@Index(name = "idx_permission_uniq", columnList = "action,resource,namespace", unique=true)
})
public class Permission extends Persisted implements Serializable {
	
	private static final long serialVersionUID = 7658061731882667107L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@MetaInfo(name="The id of the object", description="The id of the object", showInSearchResultGrid = false)
	private long id;
	
	@MetaInfo(name="the nameSpace", description="the nameSpace linked to this permission ( personify/ipersonic/... )")
	private String nameSpace;
	
	@MetaInfo(name="the resource", description="the resource linked to this permission")
	private String resource;
	
	@Enumerated(EnumType.STRING)
	@Column(name="_action")
	@MetaInfo(name="the action", description="the action linked to this permission : \n" + 
			"-  ALL,\n" + 
			"-	DO_NOTHING,\n" + 
			"-	UNCERTAIN,\n" + 
			"-	SEARCH,\n" + 
			"-	READ,\n" + 
			"-	CREATE, \n" + 
			"-	DELETE, \n" + 
			"-	UPDATE,\n" + 
			"-	ARCHIVE,\n" + 
			"-	UNARCHIVE; ")
	private Action action;
	
	
	
	
	public String getName() {
		return nameSpace + StringUtils.COLON + resource + StringUtils.SPACE + action;
	}
	

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Action getAction() {
		return action;
	}

	public void setAction(Action action) {
		this.action = action;
	}

	public String getResource() {
		return resource;
	}

	public void setResource(String resource) {
		this.resource = resource;
	}
	
	

	public String getNameSpace() {
		return nameSpace;
	}


	public void setNameSpace(String nameSpace) {
		this.nameSpace = nameSpace;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((action == null) ? 0 : action.hashCode());
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result + ((nameSpace == null) ? 0 : nameSpace.hashCode());
		result = prime * result + ((resource == null) ? 0 : resource.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Permission other = (Permission) obj;
		if (action != other.action)
			return false;
		if (id != other.id)
			return false;
		if (nameSpace == null) {
			if (other.nameSpace != null)
				return false;
		} else if (!nameSpace.equals(other.nameSpace))
			return false;
		if (resource == null) {
			if (other.resource != null)
				return false;
		} else if (!resource.equals(other.resource))
			return false;
		return true;
	}


	
	

	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy