KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jguard > core > authorization > permissions > PermissionUtils


1 /*
2 jGuard is a security framework based on top of jaas (java authentication and authorization security).
3 it is written for web applications, to resolve simply, access control problems.
4 version $Name$
5 http://sourceforge.net/projects/jguard/
6
7 Copyright (C) 2004 Charles GAY
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23
24 jGuard project home page:
25 http://sourceforge.net/projects/jguard/
26
27 */

28 package net.sf.jguard.core.authorization.permissions;
29
30 import java.lang.reflect.Constructor JavaDoc;
31 import java.lang.reflect.InvocationTargetException JavaDoc;
32 import java.security.Permission JavaDoc;
33 import java.security.PermissionCollection JavaDoc;
34
35 import java.security.Principal JavaDoc;
36 import java.security.ProtectionDomain JavaDoc;
37 import java.util.ArrayList JavaDoc;
38 import java.util.Enumeration JavaDoc;
39 import java.util.HashMap JavaDoc;
40 import java.util.HashSet JavaDoc;
41 import java.util.Iterator JavaDoc;
42 import java.util.List JavaDoc;
43 import java.util.Map JavaDoc;
44 import java.util.Set JavaDoc;
45 import java.util.logging.Level JavaDoc;
46 import java.util.logging.Logger JavaDoc;
47 import java.util.regex.Matcher JavaDoc;
48 import java.util.regex.Pattern JavaDoc;
49
50 import net.sf.ehcache.Cache;
51 import net.sf.ehcache.CacheException;
52 import net.sf.ehcache.CacheManager;
53 import net.sf.ehcache.Element;
54 import net.sf.jguard.core.principals.RolePrincipal;
55 import net.sf.jguard.core.principals.UserPrincipal;
56
57 import org.apache.commons.jexl.Expression;
58 import org.apache.commons.jexl.ExpressionFactory;
59 import org.apache.commons.jexl.JexlContext;
60 import org.apache.commons.jexl.JexlHelper;
61
62
63
64 /**
65  * java.security.Permission related utility class.
66  * @author <a HREF="mailto:diabolo512@users.sourceforge.net">Charles Gay</a>
67  * @author <a HREF="mailto:vberetti@users.sourceforge.net">Vincent Beretti</a>
68  * @author <a HREF="mailto:tandilero@users.sourceforge.net">Maximiliano Batelli</a>
69  */

70 public class PermissionUtils {
71
72     private static final Logger JavaDoc logger = Logger.getLogger(PermissionUtils.class.getName());
73
74     private static CacheManager manager;
75     private static Cache unresolvedPermToNeededExpressions;
76     private static Cache unresolvedPermAndValuesToResolvedPerm;
77     private static boolean cachesEnabled;
78     private static Pattern JavaDoc JEXL_PATTERN = Pattern.compile("(\\$\\{[^\\}]+\\})");
79
80     /**
81      * instantiate a java.security.Permission subclass.
82      * @param className class name
83      * @param name permission name
84      * @param actions actions name splitted by comma ','
85      * @return a java.security.Permission subclass, or a java.security.BasicPermission subclass
86      * (which inherit java.security.Permission)
87      * @throws ClassNotFoundException
88      */

89     public static Permission JavaDoc getPermission(String JavaDoc className, String JavaDoc name,String JavaDoc actions) throws ClassNotFoundException JavaDoc{
90         // TODO VBE : check if className is instanceof BasicPermission to speed up the method
91
// if (permission instanceof BasicPermission) {
92
// Class[] classes = {String.class, String.class};
93
// String[] initArgs = new String[2];
94
// initArgs[0] = resolvedName;
95
// initArgs[1] = resolvedActions;
96
// Permission resolvedPermission = (Permission) permission.getClass().getConstructor(classes).newInstance(initArgs);
97
//
98
// resolvedPc.add(resolvedPermission);
99
// }
100
Class JavaDoc clazz = null;
101         try {
102             clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
103         } catch (ClassNotFoundException JavaDoc e1) {
104             logger.log(Level.SEVERE," class "+className+" is not found please check your classPath \n and the permission set in the Datasource \n(either database or JGuardPrincipalsPermissions.xml file) ",e1);
105             throw e1;
106         }
107          Class JavaDoc[] permArgsBasicPermClass = {String JavaDoc.class,String JavaDoc.class};
108          Class JavaDoc[] permArgsPermClass = {String JavaDoc.class};
109          Object JavaDoc[] objBasicArray = {name,actions};
110          Object JavaDoc[] objArray = {name};
111          Permission JavaDoc newPerm = null;
112          Constructor JavaDoc[] constructors = clazz.getConstructors();
113          boolean constructorWithActions = false;
114          for(int i = 0;i<constructors.length;i++){
115              Constructor JavaDoc tempConstructor = constructors[i];
116              Class JavaDoc[] classes = tempConstructor.getParameterTypes();
117              if(classes.length==2 && classes[0].equals(String JavaDoc.class)&& classes[1].equals(String JavaDoc.class)){
118                  constructorWithActions = true;
119                  break;
120              }
121          }
122         try {
123             if(constructorWithActions == true){
124              newPerm = (Permission JavaDoc) clazz.getConstructor(permArgsBasicPermClass).newInstance(objBasicArray);
125             }else{
126
127             //Permission subclass which has got a constructor with name argument
128
newPerm = (Permission JavaDoc) clazz.getConstructor(permArgsPermClass).newInstance(objArray);
129             }
130         } catch (IllegalArgumentException JavaDoc e) {
131             logger.log(Level.SEVERE," illegal argument ",e);
132         } catch (SecurityException JavaDoc e) {
133             logger.log(Level.SEVERE,"className="+className);
134             logger.log(Level.SEVERE,"name="+name);
135             logger.log(Level.SEVERE,"actions="+actions);
136             logger.log(Level.SEVERE," you don't have right to instantiate a permission ",e);
137         } catch (InstantiationException JavaDoc e) {
138             logger.log(Level.SEVERE,"className="+className);
139             logger.log(Level.SEVERE,"name="+name);
140             logger.log(Level.SEVERE,"actions="+actions);
141             logger.log(Level.SEVERE," you cannot instantiate a permission ",e);
142         } catch (IllegalAccessException JavaDoc e) {
143             logger.log(Level.SEVERE,"className="+className);
144             logger.log(Level.SEVERE,"name="+name);
145             logger.log(Level.SEVERE,"actions="+actions);
146         } catch (InvocationTargetException JavaDoc e) {
147             logger.log(Level.SEVERE,"className="+className);
148             logger.log(Level.SEVERE,"name="+name);
149             logger.log(Level.SEVERE,"actions="+actions);
150         } catch (NoSuchMethodException JavaDoc e) {
151             logger.log(Level.SEVERE,"method not found =",e);
152         }
153         return newPerm;
154     }
155
156     /**
157      * Evaluate jexlExpression using UserPrincipal as context.<br>
158      * and return <strong>true</strong> if expression is valid,
159      * <strong>false</strong> otherwise.
160      * @param jexlExpression
161      * @param userPrincipal
162      * @return boolean
163      */

164     private static boolean evaluateDefinition(String JavaDoc jexlExpression, UserPrincipal userPrincipal) {
165         if(jexlExpression == null)
166             return false;
167         if("true".equalsIgnoreCase(jexlExpression))
168             return true;
169         if("false".equalsIgnoreCase(jexlExpression))
170             return false;
171         if(jexlExpression != null && userPrincipal == null) {
172             logger.warning("evaluateDefinition() no UserPrincipal defined, can not use regex definition");
173         }
174         
175         jexlExpression = jexlExpression.substring(2, jexlExpression.length()-1);
176         JexlContext jexlContext = JexlHelper.createContext();
177         jexlContext.getVars().put("subject.roles", userPrincipal.getRoles());
178         jexlContext.getVars().put("subject.publicCredentials", userPrincipal.getPublicCredentials());
179         jexlContext.getVars().put("subject.privateCredentials", userPrincipal.getPrivateCredentials());
180
181         Object JavaDoc resolvedExpression = null;
182         try {
183             Expression expression = ExpressionFactory.createExpression(jexlExpression);
184             resolvedExpression = expression.evaluate(jexlContext);
185         } catch (Exception JavaDoc e) {
186             logger.warning("Failed to evaluate : " + jexlExpression);
187         }
188
189         if (resolvedExpression == null || !(resolvedExpression instanceof Boolean JavaDoc)){
190             logger.warning("Subject does not have the required credentials to resolve the role activation : "+ jexlExpression);
191             return false;
192         } else {
193             Boolean JavaDoc val = (Boolean JavaDoc)resolvedExpression;
194             return val.booleanValue();
195         }
196     }
197
198     /**
199      * Evaluate principal definition attr and active attr.<br>
200      * To resolve definition attr, this method uses a particular Principal (UserPrincipal)
201      * set to the user during authentication. If this principal is not present and the definition attr != null, the
202      * definition attr is not evaluated and the function returns false.
203      * definition attr take precedence against active attr, so
204      * if definition evaluate to false but active is true, then evaluatePrincipal return false
205      * @param ppal
206      * @param userPrincipal
207      * @return boolean
208      */

209     public static boolean evaluatePrincipal(RolePrincipal ppal, UserPrincipal userPrincipal) {
210         if(!evaluateDefinition(ppal.getDefinition(), userPrincipal)) {
211             if (logger.isLoggable(Level.FINEST)) {
212                 logger.finest("evaluatePrincipal() - user's principal definition attr evaluates to false="+ ppal.getLocalName());
213             }
214             return false;
215         } else if(!ppal.isActive()) {
216             if (logger.isLoggable(Level.FINEST)) {
217                 logger.finest("evaluatePrincipal() - user's principal active attr is false="+ ppal.getLocalName());
218             }
219             return false;
220         } else
221             return true;
222
223     }
224     
225     /**
226      * Resolve permission collection containing regular expressions.<br>
227      * To resolve the permissions, this method uses a particular Principal (UserPrincipal)
228      * set to the user during authentication. If this principal is not present, the
229      * permission collection given in parameters is returned with no modifications. If
230      * the UserPrincipal is present but does not contain the required data to resolved the regex,
231      * the permission is removed from the permission collection.
232      * @param protectionDomain
233      * @param pc
234      * @return
235      */

236     public static PermissionCollection JavaDoc evaluatePermissionCollection(ProtectionDomain JavaDoc protectionDomain, PermissionCollection JavaDoc pc){
237         // resolve regular expressions in permissions
238
Principal JavaDoc[] ppals = protectionDomain.getPrincipals();
239         boolean hasJexlPrincipal = false;
240         int i = 0;
241         
242         //we are looking for UserPrincipal to resolve regexp with JEXL
243
while (!hasJexlPrincipal && i < ppals.length){
244             hasJexlPrincipal = ppals[i] instanceof UserPrincipal;
245             i++;
246         }
247         if (!hasJexlPrincipal){
248             logger.warning("no UserPrincipal defined, can not use regex permissions");
249             return pc;
250         }else {
251             PermissionCollection JavaDoc resolvedPc = new JGPositivePermissionCollection();
252
253             UserPrincipal subjectPrincipal = (UserPrincipal)ppals[i-1];
254             JexlContext jc = JexlHelper.createContext();
255             Map JavaDoc vars= jc.getVars();
256             vars.put("subject.roles",subjectPrincipal.getRoles());
257             vars.put("subject.publicCredentials",subjectPrincipal.getPublicCredentials());
258             vars.put("subject.privateCredentials",subjectPrincipal.getPrivateCredentials());
259             
260             //TODO CGA add time-based permissions with DurationDecorator class
261

262             Enumeration JavaDoc permissionsEnum = pc.elements();
263
264             Map JavaDoc subjectResolvedExpressions = new HashMap JavaDoc();
265             // stores every already resolved expressions inside this method i.e. for a subject principal
266
while (permissionsEnum.hasMoreElements()){
267                 Permission JavaDoc permission = (Permission JavaDoc)permissionsEnum.nextElement();
268                 logger.finest("Resolving permission = " + permission);
269                 PermissionCollection JavaDoc pcFromPermission = resolvePermission(permission, subjectResolvedExpressions, jc);
270                 Enumeration JavaDoc enumPermissions = pcFromPermission.elements();
271                 while(enumPermissions.hasMoreElements()){
272                     Permission JavaDoc p = (Permission JavaDoc) enumPermissions.nextElement();
273                     resolvedPc.add(p);
274                 }
275             }
276
277             return resolvedPc;
278         }
279     }
280
281     private static HashSet JavaDoc createKey(Permission JavaDoc unresolvedPermission, Map JavaDoc values){
282
283         HashSet JavaDoc key = new HashSet JavaDoc();
284         key.add(unresolvedPermission);
285         key.add(values);
286
287         return key;
288     }
289
290     /**
291      * return all the permissions which match the regexp expression present in the
292      * permission passed as a parameter.
293      * @param permission
294      * @param subjectResolvedExpressions
295      * @param jexlContext
296      * @return
297      */

298     private static PermissionCollection JavaDoc resolvePermission (Permission JavaDoc permission, Map JavaDoc subjectResolvedExpressions, JexlContext jexlContext){
299
300         PermissionCollection JavaDoc resolvedPermissions = new JGPositivePermissionCollection();
301
302         // try to get the resolved permissions from the cache
303
if (cachesEnabled){
304             try {
305                 // check in cache if unresolved permission -> needed expressions exists
306
Element expressionsCacheEntry = unresolvedPermToNeededExpressions.get(permission);
307                 if (expressionsCacheEntry != null){
308
309                     Set JavaDoc neededExpressions =(Set JavaDoc) expressionsCacheEntry.getValue();
310
311                     if (neededExpressions.isEmpty()){
312                         // no need to resolve this permission
313
resolvedPermissions.add(permission);
314                         logger.finest("get permission from cache with no resolution needed");
315                         return resolvedPermissions;
316                     }
317
318                     Iterator JavaDoc itExpressions = neededExpressions.iterator();
319                     Map JavaDoc permissionResolvedExpressions = new HashMap JavaDoc();
320                     boolean hasNull = false;
321                     while (itExpressions.hasNext()){
322                         String JavaDoc jexlExpression = (String JavaDoc) itExpressions.next();
323                         Object JavaDoc resolvedExpression = null;
324
325                         if (subjectResolvedExpressions.containsKey(jexlExpression)){
326                             resolvedExpression = subjectResolvedExpressions.get(jexlExpression);
327                             permissionResolvedExpressions.put(jexlExpression, resolvedExpression);
328                         }else {
329                             try {
330                                 Expression expression = ExpressionFactory.createExpression(jexlExpression);
331                                 resolvedExpression = expression.evaluate(jexlContext);
332                                 subjectResolvedExpressions.put(jexlExpression, resolvedExpression);
333                                 permissionResolvedExpressions.put(jexlExpression, resolvedExpression);
334                             } catch (Exception JavaDoc e) {
335                                 logger.warning("Failed to evaluate : " + jexlExpression);
336                             }
337                         }
338
339                         if (resolvedExpression == null || (resolvedExpression instanceof List JavaDoc && ((List JavaDoc)resolvedExpression).isEmpty())){
340                             hasNull = true;
341                             break;
342                         }
343
344                     }
345
346                     if (hasNull){
347                         logger.warning("Subject does not have the required credentials to resolve the permission : "+ permission);
348                         //skip this unresolvable permission
349
resolvedPermissions.add(permission);
350                         return resolvedPermissions;
351                     }
352
353                     // check in cache if (needed values + unresolvedPermission) -> resolved permission exists
354
HashSet JavaDoc key = createKey(permission, permissionResolvedExpressions);
355                     Element permissionCacheEntry = unresolvedPermAndValuesToResolvedPerm.get(key);
356
357                     if (permissionCacheEntry != null){
358                         PermissionCollection JavaDoc permissionsFromCache = (PermissionCollection JavaDoc) permissionCacheEntry.getValue();
359                         logger.finest("get resolved permission from cache");
360                         Enumeration JavaDoc enumeration = permissionsFromCache.elements();
361                         while(enumeration.hasMoreElements()){
362                             Permission JavaDoc permissionFromCache = (Permission JavaDoc) enumeration.nextElement();
363                             resolvedPermissions.add(permissionFromCache);
364                         }
365                         return resolvedPermissions;
366                     }
367                 }
368             } catch (CacheException e) {
369                 logger.log(Level.WARNING, "Failed using caches : " + e.getMessage());
370             }
371         }
372
373         // if permission is not yet resolved continue
374
// resolution will be fast because jexlExpression -> value
375
// has already been resolved and stored in resolvedValues
376

377         // resolution is combinative so one unresolved permission
378
// may imply n resolved permissions
379
List JavaDoc unresolvedPermissions = new ArrayList JavaDoc();
380         unresolvedPermissions.add(permission);
381         Map JavaDoc resolvedExpressionsByPermission = new HashMap JavaDoc();
382
383         while (!unresolvedPermissions.isEmpty()) {
384
385             Permission JavaDoc unresolvedPermission = (Permission JavaDoc) unresolvedPermissions.remove(0);
386
387             String JavaDoc name = unresolvedPermission.getName();
388             Set JavaDoc partiallyResolvedNames = resolvePartiallyExpression(name, JEXL_PATTERN, jexlContext, resolvedExpressionsByPermission, subjectResolvedExpressions);
389             if(partiallyResolvedNames == null){
390                 // unresolvable permission
391
return new JGPositivePermissionCollection();
392             }
393
394             boolean matchesInName = (partiallyResolvedNames.size() != 1 || !partiallyResolvedNames.contains(name));
395             if (matchesInName) {
396                 Iterator JavaDoc itNames = partiallyResolvedNames.iterator();
397                 while (itNames.hasNext()) {
398                     String JavaDoc resolvedName = (String JavaDoc) itNames.next();
399                     Permission JavaDoc partiallyResolvedPermission;
400                     try {
401                         partiallyResolvedPermission = PermissionUtils.getPermission(permission.getClass().getName(), resolvedName, unresolvedPermission.getActions());
402                     } catch (ClassNotFoundException JavaDoc e) {
403                         logger.warning(e.getMessage());
404                         continue;
405                     }
406                     unresolvedPermissions.add(partiallyResolvedPermission);
407                 }
408                 continue;
409             }
410
411             String JavaDoc actions = unresolvedPermission.getActions();
412             String JavaDoc[] actionsArray = actions.split(",");
413             String JavaDoc action = actionsArray[0];
414             Set JavaDoc partiallyResolvedActions = resolvePartiallyExpression(action, JEXL_PATTERN, jexlContext, resolvedExpressionsByPermission, subjectResolvedExpressions);
415             if(partiallyResolvedActions == null){
416                 // unresolvable permission
417
return new JGPositivePermissionCollection();
418             }
419
420             boolean matchesInActions = (partiallyResolvedActions.size() != 1 || !partiallyResolvedActions.contains(action));
421             if (matchesInActions) {
422                 Iterator JavaDoc itActions = partiallyResolvedActions.iterator();
423                 while (itActions.hasNext()) {
424                     String JavaDoc resolvedAction = (String JavaDoc) itActions.next();
425                     Permission JavaDoc partiallyResolvedPermission;
426                     try {
427                         partiallyResolvedPermission = PermissionUtils.getPermission(permission.getClass().getName(), unresolvedPermission.getName(), resolvedAction);
428                     } catch (ClassNotFoundException JavaDoc e) {
429                         logger.warning(e.getMessage());
430                         continue;
431                     }
432                     unresolvedPermissions.add(partiallyResolvedPermission);
433                 }
434                 continue;
435             }
436
437             // if this code is reached, there is no match in name and actions
438
// the permission is resolved
439
resolvedPermissions.add(unresolvedPermission);
440         }
441
442         if (cachesEnabled){
443             try {
444                 // store permissions needed expressions in cache
445
List JavaDoc unresolvedKeys = unresolvedPermToNeededExpressions.getKeys();
446                 if (!unresolvedKeys.contains(permission)){
447
448                     HashSet JavaDoc permissionNeededExpressions = new HashSet JavaDoc(resolvedExpressionsByPermission.keySet());
449                     unresolvedPermToNeededExpressions.put(new Element(permission, permissionNeededExpressions));
450                 }
451             } catch (CacheException e) {
452                 logger.log(Level.WARNING, "Failed using caches : " + e.getMessage());
453             }
454
455             // store mapping (values + unresolved permission ) -> resolved permission in cache
456
Element cacheEntry = new Element(createKey(permission, resolvedExpressionsByPermission), resolvedPermissions);
457             unresolvedPermAndValuesToResolvedPerm.put(cacheEntry);
458             logger.finest("add resolved permissions to cache");
459         }
460
461         return resolvedPermissions;
462     }
463
464
465     /**
466      * /**
467      * resolves first occurence of jexl expression. The other expressions remain unresolved
468      * @param expression
469      * @param pattern
470      * @param jexlContext
471      * @param resolvedExpressionsByPermission
472      * @param subjectResolvedExpressions
473      * @return
474      */

475     private static Set JavaDoc resolvePartiallyExpression (String JavaDoc expression, Pattern JavaDoc pattern, JexlContext jexlContext, Map JavaDoc resolvedExpressionsByPermission, Map JavaDoc subjectResolvedExpressions){
476
477         boolean hasMatches = false;
478         boolean hasNull = false;
479
480         Set JavaDoc resolvedExpressionsSet = new HashSet JavaDoc();
481
482         Matcher JavaDoc matcher = pattern.matcher(expression);
483         if (matcher.find()) {
484             hasMatches = true;
485             String JavaDoc matchedExpression = matcher.group();
486
487             String JavaDoc jexlExpression = matchedExpression.substring (2, matchedExpression.length()-1);
488             Object JavaDoc resolvedExpression = null;
489
490             if (subjectResolvedExpressions.containsKey(jexlExpression)) {
491                 resolvedExpression = (Set JavaDoc) subjectResolvedExpressions.get(jexlExpression);
492             } else {
493                 try {
494                     Expression expr = ExpressionFactory.createExpression(jexlExpression);
495                     resolvedExpression = expr.evaluate(jexlContext);
496                     subjectResolvedExpressions.put(jexlExpression, resolvedExpression);
497
498                 } catch (Exception JavaDoc e) {
499                     logger.warning("Failed to resolve expression : " + jexlExpression);
500                 }
501             }
502
503             if ( !(resolvedExpressionsByPermission.containsKey(jexlExpression))){
504                 resolvedExpressionsByPermission.put(jexlExpression, resolvedExpression);
505             }
506
507             if(resolvedExpression == null){
508                 // expression can not be resolved
509
hasNull = true;
510             }else if(resolvedExpression instanceof Set JavaDoc) {
511                 Iterator JavaDoc it = ((Set JavaDoc)resolvedExpression).iterator();
512                 while(it.hasNext()){
513                     StringBuffer JavaDoc builder = new StringBuffer JavaDoc(expression);
514                     builder.replace(matcher.start(),matcher.end(),(String JavaDoc)it.next());
515                     resolvedExpressionsSet.add(builder.toString());
516                 }
517             }else if(resolvedExpression instanceof String JavaDoc){
518                 StringBuffer JavaDoc builder = new StringBuffer JavaDoc(expression);
519                 builder.replace(matcher.start(),matcher.end(),(String JavaDoc)resolvedExpression);
520                 resolvedExpressionsSet.add(builder.toString());
521             }
522         }
523
524         if (!hasMatches){
525             // no jexl expression in part, return original part
526
resolvedExpressionsSet.add(expression);
527         }
528         if (hasNull){
529             // can not be resolved
530
return null;
531         }
532
533         return resolvedExpressionsSet;
534     }
535
536     public static void createCaches() throws CacheException{
537         // gets ehcache.xml as a resource in the classpath
538
if(unresolvedPermToNeededExpressions == null ||
539                 unresolvedPermAndValuesToResolvedPerm == null ){
540             logger.info("Creating caches for permissions evaluations");
541             manager = CacheManager.create();
542             unresolvedPermToNeededExpressions = manager.getCache("unresolvedPermToNeededExpressions");
543             unresolvedPermAndValuesToResolvedPerm = manager.getCache("unresolvedPermAndValuesToResolvedPerm");
544
545             if(unresolvedPermToNeededExpressions == null || unresolvedPermAndValuesToResolvedPerm == null){
546                 logger.warning("Failed to create caches for permissions evaluations, use non-caching evaluation");
547                 setCachesEnabled(false);
548             }
549         }
550     }
551
552     public static boolean isCachesEnabled() {
553         return cachesEnabled;
554     }
555
556     public static void setCachesEnabled(boolean cachesEnabled) {
557         PermissionUtils.cachesEnabled = cachesEnabled;
558     }
559 }
Popular Tags