X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=plugins%2Forg.argeo.slc.client.ui.dist%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Fmodel%2FRepoElem.java;h=6d07d1c672725063c1a49aae3ea313576b8d3d0a;hb=adec844f9bcb5c6c45009409476776b3dbdc1d3d;hp=8e48d231f26bc65fb582eb31a8ae6b7192cad07e;hpb=bc869fa855fac4e75bd3dc00def779f72ea7362c;p=gpl%2Fargeo-slc.git diff --git a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/RepoElem.java b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/RepoElem.java index 8e48d231f..6d07d1c67 100644 --- a/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/RepoElem.java +++ b/plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/RepoElem.java @@ -1,5 +1,6 @@ package org.argeo.slc.client.ui.dist.model; +import java.security.AccessControlException; import java.util.HashMap; import java.util.Map; @@ -25,7 +26,7 @@ import org.argeo.util.security.Keyring; * Node or just an URI and a label if user is anonymous */ public class RepoElem extends DistParentElem { - + // private final static Log log = LogFactory.getLog(RepoElem.class); private Repository repository; private Credentials credentials; private RepositoryFactory repositoryFactory; @@ -112,27 +113,25 @@ public class RepoElem extends DistParentElem { // Add a supplementary check to hide workspace that are not // public to anonymous user - // TODO fix this - // if (repoNode == null) { - // Session tmpSession = null; - // try { - // tmpSession = repository.login(); - // Privilege[] priv = new Privilege[1]; - // priv[0] = tmpSession.getAccessControlManager() - // .privilegeFromName(Privilege.JCR_READ); - // Privilege[] tmp = tmpSession.getAccessControlManager() - // .getPrivileges("/"); - // boolean res = tmpSession.getAccessControlManager() - // .hasPrivileges("/", priv); - // if (!res) - // continue buildWksp; - // } catch (RepositoryException e) { - // throw new SlcException( - // "Cannot list workspaces for anonymous user", e); - // } finally { - // JcrUtils.logoutQuietly(tmpSession); - // } - // } + if (repoNode == null) { + Session tmpSession = null; + try { + tmpSession = repository.login(workspaceName); + Boolean res = true; + try { + tmpSession.checkPermission("/", "read"); + } catch (AccessControlException e) { + res = false; + } + if (!res) + continue buildWksp; + } catch (RepositoryException e) { + throw new SlcException( + "Cannot list workspaces for anonymous user", e); + } finally { + JcrUtils.logoutQuietly(tmpSession); + } + } // filter technical workspaces // FIXME: rely on a more robust rule than just wksp name