@Override public boolean isAllowed(User user) { return user.isAdmin(); } }
@NotNull @Override public Boolean perform() { return getDelegate().isAdmin(); } });
@NotNull @Override public Boolean perform() { return getDelegate().isAdmin(); } });
public void getDisplayData(GlobalData gd, User user) { if(user.isAdmin()) { return new AdminDisplayData(gd); } else { return new UserDisplayData(gd); } } public void showData(DisplayData data) { String json = data.toJson(); // display json however you want }
static boolean canHavePasswordExpired(@NotNull User user, @NotNull ConfigurationParameters config) { return !user.isAdmin() || config.getConfigValue(UserAuthentication.PARAM_PASSWORD_EXPIRY_FOR_ADMIN, false); } }
private boolean isAdmin(SessionContext sessionContext, String user) { try { Authorizable a = sessionContext.getUserManager().getAuthorizable( user); if (a != null && !a.isGroup()) { return ((User) a).isAdmin(); } } catch (RepositoryException e) { // ? } return false; } }
private boolean isAdmin(SessionContext sessionContext, String user) { try { Authorizable a = sessionContext.getUserManager().getAuthorizable( user); if (a != null && !a.isGroup()) { return ((User) a).isAdmin(); } } catch (RepositoryException e) { // ? } return false; } }
@Override public void remove() throws RepositoryException { // don't allow for removal of the administrator even if the executing // session has all permissions. if (!isGroup() && ((User) this).isAdmin()) { throw new RepositoryException("The administrator cannot be removed."); } userManager.onRemove(this); getTree().remove(); }
@Override public void remove() throws RepositoryException { // don't allow for removal of the administrator even if the executing // session has all permissions. if (!isGroup() && ((User) this).isAdmin()) { throw new RepositoryException("The administrator cannot be removed."); } userManager.onRemove(this); getTree().remove(); }
@Test public void testIsAdmin() throws NotExecutableException, RepositoryException { assertFalse(user.isAdmin()); }
@Test public void testIsAdmin() throws NotExecutableException, RepositoryException { assertTrue(admin.isAdmin()); }
public void testSuperuserIsAdmin() throws NotExecutableException, RepositoryException { User user = getTestUser(superuser); assertTrue(user.isAdmin()); }
@Override public void remove() throws RepositoryException { // don't allow for removal of the administrator even if the executing // session has all permissions. if (!isGroup() && ((User) this).isAdmin()) { throw new RepositoryException("The administrator cannot be removed."); } userManager.onRemove(this); getTree().remove(); }
public void testReadOnlyIsntAdmin() throws NotExecutableException, RepositoryException { Session s = getHelper().getReadOnlySession(); try { User user = getTestUser(s); assertFalse(user.isAdmin()); } finally { s.logout(); } }
@Test public void testCreateUser() throws RepositoryException, NotExecutableException { user = createUser(uid); assertNotNull(user.getID()); assertTrue(user.isSystemUser()); assertFalse(user.isAdmin()); assertFalse(user.isGroup()); }
@Test public void testAdminUser() throws Exception { Authorizable a = userMgr.getAuthorizable(UserUtil.getAdminId(config)); assertFalse(a.isGroup()); User admin = (User) a; assertTrue(admin.isAdmin()); assertTrue(admin.getPrincipal() instanceof AdminPrincipal); assertTrue(admin.getPrincipal() instanceof TreeBasedPrincipal); assertEquals(admin.getID(), admin.getPrincipal().getName()); }
@Test public void testAnonymous() throws Exception { Authorizable a = userMgr.getAuthorizable(UserUtil.getAnonymousId(config)); assertFalse(a.isGroup()); User anonymous = (User) a; assertFalse(anonymous.isAdmin()); assertFalse(anonymous.getPrincipal() instanceof AdminPrincipal); assertTrue(anonymous.getPrincipal() instanceof TreeBasedPrincipal); assertEquals(anonymous.getID(), anonymous.getPrincipal().getName()); }
@Test public void testGetUserByPrincipal() throws Exception { user = createUser(uid); Authorizable authorizable = userMgr.getAuthorizable(user.getPrincipal()); assertNotNull(authorizable); assertFalse(authorizable.isGroup()); assertFalse(((User) authorizable).isAdmin()); assertTrue(((User) authorizable).isSystemUser()); }
@Test public void testGetUserByID() throws RepositoryException, NotExecutableException { user = createUser(uid); Authorizable authorizable = userMgr.getAuthorizable(user.getID()); assertNotNull(authorizable); assertFalse(authorizable.isGroup()); assertFalse(((User) authorizable).isAdmin()); assertTrue(((User) authorizable).isSystemUser()); }
public void testGetUserByPath() throws Exception { user = createUser(uid); Authorizable authorizable = userMgr.getAuthorizableByPath(user.getPath()); assertNotNull(authorizable); assertFalse(authorizable.isGroup()); assertFalse(((User) authorizable).isAdmin()); assertTrue(((User) authorizable).isSystemUser()); assertEquals(user.getPath(), authorizable.getPath()); }