Index: topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityCaching.java diff -u topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityCaching.java:1.1 topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityCaching.java:1.2 --- topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityCaching.java:1.1 Fri Sep 29 15:50:07 2006 +++ topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityCaching.java Thu Oct 5 07:49:44 2006 @@ -38,11 +38,11 @@ } public TopiaSecurityCaching() { - this(0); + this(1); } public void put(Object value, Object ... keys) { - if(keys.length != niveau + 2) { + if(keys.length != niveau) { throw new ArrayIndexOutOfBoundsException(); } @@ -53,14 +53,28 @@ if (next == null) { next = new ReferenceMap(SOFT, SOFT); current.put(key, next); - current = next; } + current = next; } current.put(keys[keys.length - 1], value); } + public void clear(Object ... keys) { + ReferenceMap current = map; + for (int i = 0; i < keys.length -1 ; i++) { + Object key = keys[i]; + ReferenceMap next = (ReferenceMap) current.get(key); + if (next == null) { + next = new ReferenceMap(SOFT, SOFT); + current.put(key, next); + } + current = next; + } + current.clear(); + } + public Object get(Object ... keys) { - if(keys.length != niveau + 2) { + if(keys.length != niveau) { throw new ArrayIndexOutOfBoundsException(); } Index: topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityUtil.java diff -u topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityUtil.java:1.1 topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityUtil.java:1.2 --- topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityUtil.java:1.1 Mon Sep 25 13:24:40 2006 +++ topia-security/src/java/org/codelutin/topia/security/util/TopiaSecurityUtil.java Thu Oct 5 07:49:44 2006 @@ -24,9 +24,9 @@ * Created: 15 févr. 2006 * * @author Arnaud Thimel -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * -* Mise a jour: $Date: 2006/09/25 13:24:40 $ +* Mise a jour: $Date: 2006/10/05 07:49:44 $ * par : $Author: ruchaud $ */ @@ -76,6 +76,8 @@ public static final String TOPIA_SECURITY_PERSISTENCE_CLASSES = "org.codelutin.topia.security.entities.user.TopiaUserImpl,org.codelutin.topia.security.entities.authorization.TopiaEntityAuthorizationImpl,org.codelutin.topia.security.entities.user.TopiaGroupImpl,org.codelutin.topia.security.entities.authorization.TopiaLinkAuthorizationImpl,org.codelutin.topia.security.entities.authorization.TopiaAssociationAuthorizationImpl,org.codelutin.topia.security.entities.authorization.TopiaAuthorizationImpl"; + public static long NUMBER_CHECK = 0; + /** * Applique un algorithme de hashage sur la chaine de caratère passée en * paramètre @@ -223,19 +225,21 @@ * @throws TopiaSecurityException */ public static void checkPermission(String topiaId, int actions) throws TopiaException { + NUMBER_CHECK ++; Subject subj = Subject.getSubject(AccessController.getContext()); - if (subj == null) { - throw new TopiaException("Use doAs() and login first"); - } - try { - TopiaEntityAuthorization authorization = new TopiaEntityAuthorizationImpl( - topiaId, actions, subj.getPrincipals()); - AccessController.checkPermission(new TopiaPermission(authorization)); - } catch (AccessControlException e) { - throw new TopiaException("access denied to object \"" + topiaId + "\" for \"" + subj + "\"", e); - } - if (log.isTraceEnabled()) { - log.trace("Permission granted for entity : " + topiaId); + if (subj == null && log.isWarnEnabled()) { + log.warn("Use doAs() and login first"); + } else { + try { + TopiaEntityAuthorization authorization = new TopiaEntityAuthorizationImpl( + topiaId, actions, subj.getPrincipals()); + AccessController.checkPermission(new TopiaPermission(authorization)); + } catch (AccessControlException e) { + throw new TopiaException("access denied to object \"" + topiaId + "\" for \"" + subj + "\"", e); + } + if (log.isTraceEnabled()) { + log.trace("Permission granted for entity : " + topiaId); + } } }