001: package com.technoetic.xplanner.security.auth;
002:
003: import com.technoetic.xplanner.domain.Identifiable;
004:
005: public class Permission implements Identifiable {
006: private int id;
007: private String resourceType;
008: private int resourceId;
009: private int principalId;
010: private String name;
011: private boolean positive = true;
012:
013: public Permission() {
014: }
015:
016: public Permission(String resourceType, int resourceId,
017: int personId, String permissionName) {
018: this .resourceType = resourceType;
019: this .resourceId = resourceId;
020: this .principalId = personId;
021: this .name = permissionName;
022: }
023:
024: public boolean isPositive() {
025: return positive;
026: }
027:
028: public void setPositive(boolean positive) {
029: this .positive = positive;
030: }
031:
032: public int getId() {
033: return id;
034: }
035:
036: public void setId(int id) {
037: this .id = id;
038: }
039:
040: public int getPrincipalId() {
041: return principalId;
042: }
043:
044: public void setPrincipalId(int principalId) {
045: this .principalId = principalId;
046: }
047:
048: public String getName() {
049: return name;
050: }
051:
052: public void setName(String name) {
053: this .name = name;
054: }
055:
056: public String getResourceType() {
057: return resourceType;
058: }
059:
060: public void setResourceType(String resourceType) {
061: this .resourceType = resourceType;
062: }
063:
064: public int getResourceId() {
065: return resourceId;
066: }
067:
068: public void setResourceId(int resourceId) {
069: this .resourceId = resourceId;
070: }
071:
072: public String toString() {
073: return getClass().getName().substring(
074: getClass().getName().lastIndexOf(".") + 1)
075: + "("
076: + "id="
077: + id
078: + ", principalId="
079: + principalId
080: + ", resourceType='"
081: + resourceType
082: + "'"
083: + ", resourceId="
084: + resourceId
085: + ", name='"
086: + name
087: + "'," + (positive ? "positive" : "negative") + " )";
088: }
089:
090: public boolean equals(Object o) {
091: if (this == o)
092: return true;
093: if (o == null || getClass() != o.getClass())
094: return false;
095:
096: final Permission that = (Permission) o;
097:
098: if (id != that.id)
099: return false;
100: if (positive != that.positive)
101: return false;
102: if (principalId != that.principalId)
103: return false;
104: if (resourceId != that.resourceId)
105: return false;
106: if (name != null ? !name.equals(that.name) : that.name != null)
107: return false;
108: if (resourceType != null ? !resourceType
109: .equals(that.resourceType) : that.resourceType != null)
110: return false;
111:
112: return true;
113: }
114:
115: public int hashCode() {
116: int result;
117: result = id;
118: result = 29 * result
119: + (resourceType != null ? resourceType.hashCode() : 0);
120: result = 29 * result + resourceId;
121: result = 29 * result + principalId;
122: result = 29 * result + (name != null ? name.hashCode() : 0);
123: result = 29 * result + (positive ? 1 : 0);
124: return result;
125: }
126: }
|