comparison src/main/java/de/mpiwg/itgroup/annotations/Annotation.java @ 14:629e15b345aa

permissions mostly work. need more server-side checking.
author casties
date Fri, 13 Jul 2012 20:41:02 +0200
parents 90911b2da322
children 58357a4b86de
comparison
equal deleted inserted replaced
13:abe25edf2178 14:629e15b345aa
78 * The user or group that has read permissions. 78 * The user or group that has read permissions.
79 * null means any user. 79 * null means any user.
80 */ 80 */
81 protected Actor readPermission; 81 protected Actor readPermission;
82 82
83
84 /**
85 * Returns if the requested action is allowed on this annotation.
86 *
87 * @param action
88 * @param userId
89 * @return
90 */
91 public boolean isActionAllowed(String action, String userId) {
92 if (action.equals("read")) {
93 Actor reader = getReadPermission();
94 if (reader == null) {
95 return true;
96 } else {
97 return reader.isEquivalentWith(userId);
98 }
99 } else if (action.equals("update")) {
100 // require at least an authenticated user
101 if (userId == null) return false;
102 Actor updater = getUpdatePermission();
103 if (updater == null) {
104 return true;
105 } else {
106 return updater.isEquivalentWith(userId);
107 }
108 } else if (action.equals("delete")) {
109 // require at least an authenticated user
110 if (userId == null) return false;
111 Actor updater = getUpdatePermission();
112 if (updater == null) {
113 return true;
114 } else {
115 return updater.isEquivalentWith(userId);
116 }
117 } else if (action.equals("admin")) {
118 // require at least an authenticated user
119 if (userId == null) return false;
120 Actor admin = getAdminPermission();
121 if (admin == null) {
122 return true;
123 } else {
124 return admin.isEquivalentWith(userId);
125 }
126 }
127 return false;
128 }
129
83 /** 130 /**
84 * @return the uri 131 * @return the uri
85 */ 132 */
86 public String getUri() { 133 public String getUri() {
87 return uri; 134 return uri;