/** * Returns the names of all workspaces of this repository with respect of the * access rights of this session. * * @return the names of all accessible workspaces * @throws RepositoryException if an error occurs */ public String[] getAccessibleWorkspaceNames() throws RepositoryException { // check state of this instance sanityCheck(); // filter workspaces according to access rights List<String> names = new ArrayList<String>(); WorkspaceManager manager = context.getRepositoryContext().getWorkspaceManager(); for (String name : manager.getWorkspaceNames()) { try { if (context.getAccessManager().canAccess(name)) { names.add(name); } } catch (NoSuchWorkspaceException e) { log.warn("Workspace disappeared unexpectedly: " + name, e); } } return names.toArray(new String[names.size()]); }
/** * Returns the names of all workspaces of this repository with respect of the * access rights of this session. * * @return the names of all accessible workspaces * @throws RepositoryException if an error occurs */ public String[] getAccessibleWorkspaceNames() throws RepositoryException { // check state of this instance sanityCheck(); // filter workspaces according to access rights List<String> names = new ArrayList<String>(); WorkspaceManager manager = context.getRepositoryContext().getWorkspaceManager(); for (String name : manager.getWorkspaceNames()) { try { if (context.getAccessManager().canAccess(name)) { names.add(name); } } catch (NoSuchWorkspaceException e) { log.warn("Workspace disappeared unexpectedly: " + name, e); } } return names.toArray(new String[names.size()]); }
public void testCanAccessDeniedWorkspace() throws RepositoryException, NotExecutableException { Session s = getHelper().getReadOnlySession(); try { Set<String> allAccessibles = new HashSet<String>(Arrays.asList(superuser.getWorkspace().getAccessibleWorkspaceNames())); Set<String> sWorkspaceNames = new HashSet<String>(Arrays.asList(s.getWorkspace().getAccessibleWorkspaceNames())); if (!allAccessibles.removeAll(sWorkspaceNames) || allAccessibles.isEmpty()) { throw new NotExecutableException("No workspace name found that exists but is not accessible for ReadOnly session."); } String notAccessibleName = allAccessibles.iterator().next(); assertFalse(getAccessManager(s).canAccess(notAccessibleName)); } finally { s.logout(); } }
public void testCanAccessAllAvailable() throws RepositoryException, NotExecutableException { Session s = getHelper().getReadOnlySession(); try { String[] wspNames = s.getWorkspace().getAccessibleWorkspaceNames(); for (String wspName : wspNames) { assertTrue(getAccessManager(s).canAccess(wspName)); } } finally { s.logout(); } }
public void testCanAccessNotExistingWorkspace() throws RepositoryException, NotExecutableException { Session s = getHelper().getReadOnlySession(); try { List<String> all = Arrays.asList(s.getWorkspace().getAccessibleWorkspaceNames()); String testName = "anyWorkspace"; int i = 0; while (all.contains(testName)) { testName = "anyWorkspace" + i; i++; } assertFalse(getAccessManager(s).canAccess(testName)); } catch (NoSuchWorkspaceException e) { // fine as well. } finally { s.logout(); } }
public void testCanAccess() throws RepositoryException, NotExecutableException { Session s = getHelper().getReadOnlySession(); try { String wspName = s.getWorkspace().getName(); assertTrue(getAccessManager(s).canAccess(wspName)); } finally { s.logout(); } }
if (!context.getAccessManager().canAccess(srcWorkspace)) { throw new AccessDeniedException("not authorized to access " + srcWorkspace);
if (!context.getAccessManager().canAccess(srcWorkspace)) { throw new AccessDeniedException("not authorized to access " + srcWorkspace);
if (!context.getAccessManager().canAccess(srcWorkspace)) { throw new AccessDeniedException("not authorized to access " + srcWorkspace);
if (!session.getAccessManager().canAccess(srcWorkspaceName)) { String msg = "not authorized to access " + srcWorkspaceName; log.error(msg);
if (!context.getAccessManager().canAccess(srcWorkspace)) { throw new AccessDeniedException("not authorized to access " + srcWorkspace);
if (!session.getAccessManager().canAccess(srcWorkspaceName)) { String msg = "not authorized to access " + srcWorkspaceName; log.error(msg);