@Override public boolean isDisabled() throws RepositoryException { return delegate.isDisabled(); }
@NotNull @Override public Boolean perform() throws RepositoryException { return getDelegate().isDisabled(); } });
@NotNull @Override public Boolean perform() throws RepositoryException { return getDelegate().isDisabled(); } });
@Nonnull @Override public Boolean perform() throws RepositoryException { return getDelegate().isDisabled(); } });
@Override public boolean isDisabled() throws RepositoryException { return getDelegate().isDisabled(); }
@Override public boolean isDisabled() throws RepositoryException { return getDelegate().isDisabled(); }
@Override public boolean isDisabled() throws RepositoryException { return getDelegate().isDisabled(); }
@Nullable private User getUser(@NotNull Tree tokenTree) throws RepositoryException { String userPath = Text.getRelativeParent(tokenTree.getPath(), 2); Authorizable authorizable = userManager.getAuthorizableByPath(userPath); if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) { return (User) authorizable; } else { return null; } }
@Nullable private User getUser(@NotNull Tree tokenTree) throws RepositoryException { String userPath = Text.getRelativeParent(tokenTree.getPath(), 2); Authorizable authorizable = userManager.getAuthorizableByPath(userPath); if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) { return (User) authorizable; } else { return null; } }
@CheckForNull private User getUser(@Nonnull Tree tokenTree) throws RepositoryException { String userPath = Text.getRelativeParent(tokenTree.getPath(), 2); Authorizable authorizable = userManager.getAuthorizableByPath(userPath); if (authorizable != null && !authorizable.isGroup() && !((User) authorizable).isDisabled()) { return (User) authorizable; } else { return null; } }
@Test public void testDisable() throws Exception { user = createUser(uid); user.disable("gone"); superuser.save(); assertTrue(user.isDisabled()); assertEquals("gone", user.getDisabledReason()); user.disable(null); assertFalse(user.isDisabled()); } }
@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 testEnabledByDefault() throws Exception { // by default a user isn't disabled assertFalse(user.isDisabled()); assertNull(user.getDisabledReason()); }
@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(); }
private static String getUserId(NodeImpl tokenNode, UserManager userManager) throws RepositoryException { if (tokenNode != null) { final NodeImpl userNode = (NodeImpl) tokenNode.getParent().getParent(); final String principalName = userNode.getProperty(UserImpl.P_PRINCIPAL_NAME).getString(); if (userNode.isNodeType(UserImpl.NT_REP_USER)) { Authorizable a = userManager.getAuthorizable(new ItemBasedPrincipal() { public String getPath() throws RepositoryException { return userNode.getPath(); } public String getName() { return principalName; } }); if (a != null && !a.isGroup() && !((User)a).isDisabled()) { return a.getID(); } } else { throw new RepositoryException("Failed to calculate userId from token credentials"); } } return null; }
static String getUserId(NodeImpl tokenNode, UserManager userManager) throws RepositoryException { if (tokenNode != null) { final NodeImpl userNode = (NodeImpl) tokenNode.getParent().getParent(); final String principalName = userNode.getProperty(UserImpl.P_PRINCIPAL_NAME).getString(); if (userNode.isNodeType(UserImpl.NT_REP_USER)) { Authorizable a = userManager.getAuthorizable(new ItemBasedPrincipal() { public String getPath() throws RepositoryException { return userNode.getPath(); } public String getName() { return principalName; } }); if (a != null && !a.isGroup() && !((User)a).isDisabled()) { return a.getID(); } } else { throw new RepositoryException("Failed to calculate userId from token credentials"); } } return null; }
private static String getUserId(NodeImpl tokenNode, UserManager userManager) throws RepositoryException { if (tokenNode != null) { final NodeImpl userNode = (NodeImpl) tokenNode.getParent().getParent(); final String principalName = userNode.getProperty(UserImpl.P_PRINCIPAL_NAME).getString(); if (userNode.isNodeType(UserImpl.NT_REP_USER)) { Authorizable a = userManager.getAuthorizable(new ItemBasedPrincipal() { public String getPath() throws RepositoryException { return userNode.getPath(); } public String getName() { return principalName; } }); if (a != null && !a.isGroup() && !((User)a).isDisabled()) { return a.getID(); } } else { throw new RepositoryException("Failed to calculate userId from token credentials"); } } return null; }
static String getUserId(NodeImpl tokenNode, UserManager userManager) throws RepositoryException { if (tokenNode != null) { final NodeImpl userNode = (NodeImpl) tokenNode.getParent().getParent(); final String principalName = userNode.getProperty(UserImpl.P_PRINCIPAL_NAME).getString(); if (userNode.isNodeType(UserImpl.NT_REP_USER)) { Authorizable a = userManager.getAuthorizable(new ItemBasedPrincipal() { public String getPath() throws RepositoryException { return userNode.getPath(); } public String getName() { return principalName; } }); if (a != null && !a.isGroup() && !((User)a).isDisabled()) { return a.getID(); } } else { throw new RepositoryException("Failed to calculate userId from token credentials"); } } return null; }
@Test public void testUser() throws Exception { User u = mgr.createUser("u", "u"); u.disable("disabled"); assertTrue(u.isDisabled()); assertFalse(root.hasPendingChanges()); u.disable(null); assertFalse(u.isDisabled()); assertFalse(root.hasPendingChanges()); u.changePassword("t"); assertFalse(root.hasPendingChanges()); u.changePassword("tt", "t"); assertFalse(root.hasPendingChanges()); }
@Test public void testSyncDoesNotEnableUsers() throws Exception { // configure to remove missing users, check that sync does not mess with disabled status syncConfig.user().setDisableMissing(false); // test sync with 'keepmissing' = false syncCtx.setKeepMissing(false); ExternalUser user = idp.listUsers().next(); assertNotNull(user); SyncResult result = syncCtx.sync(user); assertEquals(SyncResult.Status.ADD, result.getStatus()); Authorizable authorizable = userManager.getAuthorizable(user.getId()); assertTrue(authorizable instanceof User); User u = (User) authorizable; // disable user u.disable("disabled locally"); root.commit(); // sync syncCtx.setForceUserSync(true); result = syncCtx.sync(user.getId()); assertEquals(SyncResult.Status.UPDATE, result.getStatus()); authorizable = userManager.getAuthorizable(user.getId()); assertNotNull(authorizable); assertTrue(authorizable instanceof User); assertTrue(((User)authorizable).isDisabled()); }