+
+ @Override
+ protected WorkspaceAccessManager createDefaultWorkspaceAccessManager() {
+ WorkspaceAccessManager wam = super
+ .createDefaultWorkspaceAccessManager();
+ return new ArgeoWorkspaceAccessManagerImpl(wam);
+ }
+
+ private class ArgeoWorkspaceAccessManagerImpl implements SecurityConstants,
+ WorkspaceAccessManager {
+ private final WorkspaceAccessManager wam;
+ private String defaultWorkspace;
+
+ public ArgeoWorkspaceAccessManagerImpl(WorkspaceAccessManager wam) {
+ super();
+ this.wam = wam;
+ }
+
+ public void init(Session systemSession) throws RepositoryException {
+ wam.init(systemSession);
+ defaultWorkspace = ((RepositoryImpl) getRepository()).getConfig()
+ .getDefaultWorkspaceName();
+ }
+
+ public void close() throws RepositoryException {
+ }
+
+ public boolean grants(Set<Principal> principals, String workspaceName)
+ throws RepositoryException {
+ // everybody has access to all workspaces
+ // TODO: implements finer access to workspaces
+ return true;
+
+ // anonymous has access to the default workspace (required for
+ // remoting which does a default login when initializing the
+ // repository)
+ // Boolean anonymous = false;
+ // for (Principal principal : principals)
+ // if (principal instanceof AnonymousPrincipal)
+ // anonymous = true;
+ //
+ // if (anonymous && workspaceName.equals(defaultWorkspace))
+ // return true;
+ // else
+ // return wam.grants(principals, workspaceName);
+ }
+ }
+