static String getClusterNodeId(final Session session) { String clusterNodeId = session.getRepository().getDescriptor("jackrabbit.cluster.id"); if (clusterNodeId == null) { clusterNodeId = DEFAULT_CLUSTER_NODE_ID; } return clusterNodeId; }
/** * Return the repository. */ public Repository getRepository() { return getSession().getRepository(); }
/** * Returns <code>true</code> if the repository supports observation. * * @param s a session of the repository. * @return <code>true</code> if the repository supports observation. */ private static boolean isObservationSupported(Session s) { return "true".equalsIgnoreCase(s.getRepository().getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED)); }
/** * Returns <code>true</code> if the repository supports observation. * * @param s a session of the repository. * @return <code>true</code> if the repository supports observation. */ private static boolean isObservationSupported(Session s) { return "true".equalsIgnoreCase(s.getRepository().getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED)); }
/** * Returns <code>true</code> if the repository supports observation. * * @param s a session of the repository. * @return <code>true</code> if the repository supports observation. */ private static boolean isObservationSupported(Session s) { return "true".equalsIgnoreCase(s.getRepository().getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED)); }
public static boolean supportsAccessControl(Session session) { String desc = session.getRepository().getDescriptor(Repository.OPTION_ACCESS_CONTROL_SUPPORTED); return Boolean.valueOf(desc); } }
/** * @param repoSession * @return true if the JCR repository supports versioning. */ private static boolean versioningSupported(Session repoSession) { String desc = repoSession.getRepository().getDescriptor(Repository.OPTION_VERSIONING_SUPPORTED); return Boolean.valueOf(desc); } }
public String getClusterNodeId() { String clusteNodeId = session.getRepository().getDescriptor("jackrabbit.cluster.id"); if (clusteNodeId == null) { clusteNodeId = "default"; } return clusteNodeId; }
/** * @see AccessControlProviderFactory#init(Session) */ public void init(Session securitySession) throws RepositoryException { secWorkspaceName = securitySession.getWorkspace().getName(); if (securitySession instanceof SessionImpl) { defaultWorkspaceName = ((RepositoryImpl) securitySession.getRepository()).getConfig().getDefaultWorkspaceName(); } // else: unable to determine default workspace name }
/** * @see AccessControlProviderFactory#init(Session) */ public void init(Session securitySession) throws RepositoryException { secWorkspaceName = securitySession.getWorkspace().getName(); if (securitySession instanceof SessionImpl) { defaultWorkspaceName = ((RepositoryImpl) securitySession.getRepository()).getConfig().getDefaultWorkspaceName(); } // else: unable to determine default workspace name }
public String getRepositoryVersion() { Repository repository = UserSession.get().getJcrSession().getRepository(); if (repository != null) { return repository.getDescriptor(Repository.REP_VERSION_DESC); } else { return "unknown"; } }
public String getRepositoryVendor() { Repository repository = UserSession.get().getJcrSession().getRepository(); if (repository != null) { return repository.getDescriptor(Repository.REP_VENDOR_DESC); } else { return "unknown"; } } }
/** * wait for async text-extraction tasks to finish */ public static void waitForTextExtractionTasksToFinish(Session session) throws Exception { final RepositoryContext context = JackrabbitRepositoryStub .getRepositoryContext(session.getRepository()); JackrabbitThreadPool jtp = ((JackrabbitThreadPool) context .getExecutor()); while (jtp.getPendingLowPriorityTaskCount() != 0) { TimeUnit.MILLISECONDS.sleep(100); } }
private Session createTestSession() throws RepositoryException { if (testSession == null) { testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID())); } return testSession; }
private Session createTestSession() throws RepositoryException { if (testSession == null) { testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID())); } return testSession; }
@Override public void before() throws Exception { super.before(); User u = userMgr.createUser(uid, "pw"); adminSession.save(); AccessControlUtils.addAccessControlEntry(adminSession, Text.getRelativeParent(getTargetPath(), 1), u.getPrincipal(), new String[] {Privilege.JCR_ALL}, true); AccessControlUtils.addAccessControlEntry(adminSession, null, u.getPrincipal(), new String[] {PrivilegeConstants.JCR_NAMESPACE_MANAGEMENT}, true); adminSession.save(); testSession = adminSession.getRepository().login(new SimpleCredentials(uid, "pw".toCharArray())); }
public void testImpersonateOneSelf() throws RepositoryException { // EXERCISE: walk through this impersonation. does it work? if it does: why? Session testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID())); sessionList.add(testSession); Session impersonated = testSession.impersonate(new SimpleCredentials(testUser.getID(), new char[0])); sessionList.add(impersonated); assertEquals(testUser.getID(), impersonated.getUserID()); }
public void testWritePoliciesAsReadOnlySession() throws RepositoryException { testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testID)); // EXERCISE: Fix the test and explain your fix. // NOTE: that obviously is prone to cause troubles as the policies is retrieved with a different session! AccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, testRoot); testSession.getAccessControlManager().setPolicy(testRoot, acl); }
public void testImpersonateTestUser() throws RepositoryException { Principal principal = null; // EXERCISE: fill in the correct principal such that the test passes. Impersonation impersonation = anotherUser.getImpersonation(); impersonation.grantImpersonation(principal); superuser.save(); Session testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testUser.getID())); sessionList.add(testSession); Session impersonated = testSession.impersonate(new SimpleCredentials(anotherUser.getID(), new char[0])); sessionList.add(impersonated); assertEquals(anotherUser.getID(), impersonated.getUserID()); }
public void testRetrievePoliciesAsReadOnlySession() throws RepositoryException { testSession = superuser.getRepository().login(ExerciseUtility.getTestCredentials(testID)); // EXERCISE: Fix the test and explain your fix. AccessControlPolicyIterator policyIterator = testSession.getAccessControlManager().getApplicablePolicies(testRoot); AccessControlPolicy[] policies = testSession.getAccessControlManager().getPolicies(testRoot); }