X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=server%2Fruntime%2Forg.argeo.server.jackrabbit%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjackrabbit%2FJackrabbitAuthorizations.java;h=e880b6700fcbfb85c405be766c5d9561c22f5236;hb=2409f1f71765e8ae15dddd39482323db771108d7;hp=2347e8c7b37d644f479e85c31411473a9300d993;hpb=18c8ea2376fe85245d50a98ea7c0a95a51b17370;p=lgpl%2Fargeo-commons.git diff --git a/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitAuthorizations.java b/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitAuthorizations.java index 2347e8c7b..e880b6700 100644 --- a/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitAuthorizations.java +++ b/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitAuthorizations.java @@ -1,7 +1,22 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.argeo.jackrabbit; import java.security.Principal; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import javax.jcr.RepositoryException; @@ -20,26 +35,29 @@ public class JackrabbitAuthorizations extends JcrAuthorizations { private final static Log log = LogFactory .getLog(JackrabbitAuthorizations.class); - private List groupPrefixes = new ArrayList(); + private List groupPrefixes = Arrays + .asList(new String[] { "ROLE_" });// new ArrayList(); @Override protected Principal getOrCreatePrincipal(Session session, String principalName) throws RepositoryException { UserManager um = ((JackrabbitSession) session).getUserManager(); - Authorizable authorizable = um.getAuthorizable(principalName); - if (authorizable == null) { - groupPrefixes: for (String groupPrefix : groupPrefixes) { - if (principalName.startsWith(groupPrefix)) { - authorizable = um.createGroup(principalName); - log.info("Created group " + principalName); - break groupPrefixes; + synchronized (um) { + Authorizable authorizable = um.getAuthorizable(principalName); + if (authorizable == null) { + groupPrefixes: for (String groupPrefix : groupPrefixes) { + if (principalName.startsWith(groupPrefix)) { + authorizable = um.createGroup(principalName); + log.info("Created group " + principalName); + break groupPrefixes; + } } + if (authorizable == null) + throw new ArgeoException("Authorizable " + principalName + + " not found"); } - if (authorizable == null) - throw new ArgeoException("Authorizable " + principalName - + " not found"); + return authorizable.getPrincipal(); } - return authorizable.getPrincipal(); } public void setGroupPrefixes(List groupsToCreate) {