1 package de.webman.acl.resolver; 2 3 import java.util.Hashtable ; 4 import com.teamkonzept.lib.TKException; 5 import com.teamkonzept.lib.TKVector; 6 import de.webman.acl.EventFactory; 7 import de.webman.acl.Login; 8 import de.webman.acl.Policy; 9 import de.webman.acl.PolicyFactory; 10 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 11 12 20 public class SequentialResolver 21 extends ResolverBase 22 implements Checker 23 { 24 25 27 29 34 protected SequentialResolver (Login login) 35 { 36 super(login); 37 } 38 39 40 42 59 public final void resolve (Hashtable collection, 60 Integer context, 61 Integer type, 62 Integer reference) 63 throws TKException 64 { 65 try 66 { 67 resolveParents(collection, context, type, reference); 69 70 processEvents(collection, 73 resolveEvents(context, 74 null, 75 null, 76 Boolean.TRUE), 77 true); 78 79 processEvents(collection, 81 resolveEvents(context, 82 null, 83 null, 84 Boolean.FALSE), 85 false); 86 87 if (type != null && reference != null) 88 { 89 if (Policy.isGeneric(type)) 91 { 92 ResolverFactory.getInstance() 94 .getResolver(this) 95 .resolve(collection, 96 context, 97 type, 98 reference); 99 } 100 else 101 { 102 processEvents(collection, 104 resolveEvents(context, 105 type, 106 reference, 107 Boolean.TRUE), 108 true); 109 110 processEvents(collection, 112 resolveEvents(context, 113 type, 114 reference, 115 Boolean.FALSE), 116 false); 117 } 118 } 119 } 120 catch (Exception x) 121 { 122 throw WebmanExceptionHandler.getException(x); 123 } 124 } 125 126 127 129 146 public final boolean check (Integer event, 147 Integer context, 148 Integer type, 149 Integer reference) 150 throws TKException 151 { 152 boolean check = false; 153 154 try 155 { 156 Boolean value = checkingCacheRead(event, 158 context, 159 type, 160 reference); 161 162 if (value != null) 163 { 164 check = value.booleanValue(); 166 } 167 else 168 { 169 TKVector proxies = PolicyFactory.getInstance() 171 .getPolicyProxies(event, 172 getLogin().getID(), 173 context, 174 type, 175 reference, 176 true); 177 178 if (proxies != null && 179 proxies.size() > 0) 180 { 181 check = PolicyFactory.getInstance() 183 .getPolicy((Integer ) proxies.lastElement()) 184 .isAllowed(); 185 } 186 else 187 { 188 check = checkParents(event, context, type, reference); 190 } 191 192 checkingCacheWrite(event, 194 context, 195 type, 196 reference, 197 check 198 ? Boolean.TRUE 199 : Boolean.FALSE); 200 } 201 } 202 catch (Exception x) 203 { 204 throw WebmanExceptionHandler.getException(x); 205 } 206 207 return check; 208 } 209 210 211 213 224 private final TKVector resolveEvents (Integer context, 225 Integer type, 226 Integer reference, 227 Boolean access) 228 throws TKException 229 { 230 TKVector proxies = null; 231 232 try 233 { 234 proxies = resolutionCacheRead(context, 235 type, 236 reference, 237 access); 238 239 if (proxies == null) 240 { 241 proxies = EventFactory.getInstance() 242 .getEventProxies(getLogin().getID(), 243 context, 244 type, 245 reference, 246 access.booleanValue()); 247 248 resolutionCacheWrite(context, 249 type, 250 reference, 251 access, 252 proxies); 253 } 254 } 255 catch (Exception x) 256 { 257 throw WebmanExceptionHandler.getException(x); 258 } 259 260 return proxies; 261 } 262 263 } 264 | Popular Tags |