@Override public void performVoid() throws RepositoryException { getDelegate().disable(reason); } });
@Override public void performVoid() throws RepositoryException { getDelegate().disable(reason); } });
@Override public void performVoid() throws RepositoryException { getDelegate().disable(reason); } });
@Override public void disable(String msg) throws RepositoryException { try { getDelegate().disable(msg); } finally { getMgr().autosave(); } }
@Override public void disable(String msg) throws RepositoryException { try { getDelegate().disable(msg); } finally { getMgr().autosave(); } }
@Override public void disable(String msg) throws RepositoryException { try { getDelegate().disable(msg); } finally { getMgr().autosave(); } }
@Test public void testDisable() throws NotExecutableException, RepositoryException { try { admin.disable("-> out"); superuser.save(); fail("The admin cannot be disabled"); } catch (RepositoryException e) { // success } }
@Override protected void setUp() throws Exception { super.setUp(); userManager = ((JackrabbitSession) superuser).getUserManager(); testUser = ExerciseUtility.createTestUser(userManager); testUser.disable("no longer active"); testGroup = ExerciseUtility.createTestGroup(userManager); superuser.save(); }
@Test public void testEnableUser() throws Exception { user.disable("readonly user is disabled!"); superuser.save(); // enable user again user.disable(null); superuser.save(); assertFalse(user.isDisabled()); assertNull(user.getDisabledReason()); // -> login must succeed again getHelper().getRepository().login(new SimpleCredentials(user.getID(), "pw".toCharArray())).logout(); }
@Test public void testLoginDisabledUser() throws Exception { user.disable("readonly user is disabled!"); superuser.save(); // -> login must fail try { Session ss = getHelper().getRepository().login(new SimpleCredentials(user.getID(), "pw".toCharArray())); ss.logout(); fail("A disabled user must not be allowed to login any more"); } catch (LoginException e) { // success } }
@Test public void testDisable() throws Exception { String reason = "readonly user is disabled!"; user.disable(reason); superuser.save(); assertTrue(user.isDisabled()); assertEquals(reason, user.getDisabledReason()); }
@Test public void testDisableUser() throws Exception { createUser(userId); // after granting user-mgt privilege changing the pw must succeed. modify("/", PrivilegeConstants.REP_USER_MANAGEMENT, true); UserManager testUserMgr = getUserManager(testSession); User user = (User) testUserMgr.getAuthorizable(userId); user.disable("disabled!"); testSession.save(); }
@Test public void testAccessPrincipalOfDisabledUser() throws Exception { user.disable("readonly user is disabled!"); superuser.save(); Principal principal = user.getPrincipal(); assertTrue(((JackrabbitSession) superuser).getPrincipalManager().hasPrincipal(principal.getName())); assertEquals(principal, ((JackrabbitSession) superuser).getPrincipalManager().getPrincipal(principal.getName())); }
@Test public void testDisableUserCnt() throws Exception { User user = getTestUser(); user.disable("disabled"); assertEquals(1, cntAction.onDisabledCnt); assertEquals(0, cntAction.onGrantImpCnt); assertEquals(0, cntAction.onRevokeImpCnt); user.disable(null); assertEquals(2, cntAction.onDisabledCnt); assertEquals(0, cntAction.onGrantImpCnt); assertEquals(0, cntAction.onRevokeImpCnt); }
@Test public void testDisableUserWithoutPermission() throws Exception { createUser(userId); UserManager testUserMgr = getUserManager(testSession); User user = (User) testUserMgr.getAuthorizable(userId); try { user.disable("disabled!"); testSession.save(); fail(); } catch (AccessDeniedException e) { // success } }
@Test public void testGetTokenInfoFromDisabledUser() throws Exception { TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap()); getTestUser().disable("disabled"); assertNull(tokenProvider.getTokenInfo(info.getToken())); }
@Test public void testDisableUserWithoutPermission2() throws Exception { createUser(userId); modify("/", PrivilegeConstants.REP_WRITE, true); UserManager testUserMgr = getUserManager(testSession); User user = (User) testUserMgr.getAuthorizable(userId); try { user.disable("disabled!"); testSession.save(); fail(); } catch (AccessDeniedException e) { // success } }
@Test public void testAccessDisabledUser() throws Exception { user.disable("readonly user is disabled!"); superuser.save(); // user must still be retrievable from user manager assertNotNull(getUserManager(superuser).getAuthorizable(user.getID())); // ... and from principal manager as well assertTrue(((JackrabbitSession) superuser).getPrincipalManager().hasPrincipal(user.getPrincipal().getName())); }
@Override protected void setUp() throws Exception { super.setUp(); userManager = ((JackrabbitSession) superuser).getUserManager(); testUser = ExerciseUtility.createTestUser(userManager); testUser.disable("no longer active"); testGroup = ExerciseUtility.createTestGroup(userManager); testGroup.addMember(testUser); testGroup.setProperty("Name", superuser.getValueFactory().createValue("Test Group")); superuser.save(); }