@Override public boolean isSystemUser() { return delegate.isSystemUser(); }
@NotNull @Override public Boolean perform() { return getDelegate().isSystemUser(); } });
@Nonnull @Override public Boolean perform() { return getDelegate().isSystemUser(); } });
@NotNull @Override public Boolean perform() { return getDelegate().isSystemUser(); } });
@Override public boolean isSystemUser() { return getDelegate().isSystemUser(); }
@Override public boolean isSystemUser() { return getDelegate().isSystemUser(); }
@Override public boolean isSystemUser() { return getDelegate().isSystemUser(); }
/** * Let the configured {@code AuthorizableAction}s perform additional * tasks associated with the creation of the new user before the * corresponding new node is persisted. * * @param user The new user. * @param password The password. * @throws RepositoryException If an exception occurs. */ void onCreate(@Nonnull User user, @CheckForNull String password) throws RepositoryException { if (!user.isSystemUser()) { for (AuthorizableAction action : actionProvider.getAuthorizableActions(securityProvider)) { action.onCreate(user, password, root, namePathMapper); } } else { log.debug("Omit onCreate action for system users."); } }
/** * Let the configured {@code AuthorizableAction}s perform additional * tasks associated with the creation of the new user before the * corresponding new node is persisted. * * @param user The new user. * @param password The password. * @throws RepositoryException If an exception occurs. */ void onCreate(@NotNull User user, @Nullable String password) throws RepositoryException { if (!user.isSystemUser()) { for (AuthorizableAction action : actionProvider.getAuthorizableActions(securityProvider)) { action.onCreate(user, password, root, namePathMapper); } } else { log.debug("Omit onCreate action for system users."); } }
/** * Let the configured {@code AuthorizableAction}s perform additional * tasks associated with the creation of the new user before the * corresponding new node is persisted. * * @param user The new user. * @param password The password. * @throws RepositoryException If an exception occurs. */ void onCreate(@NotNull User user, @Nullable String password) throws RepositoryException { if (!user.isSystemUser()) { for (AuthorizableAction action : actionProvider.getAuthorizableActions(securityProvider)) { action.onCreate(user, password, root, namePathMapper); } } else { log.debug("Omit onCreate action for system users."); } }
@Override public void importedPath(final PackageId packageId, final String path, final Node node) throws RepositoryException { // fast check for authorizables if (node.isNodeType(NT_REP_AUTHORIZABLE)) { final UserManager userManager = ((JackrabbitSession) node.getSession()).getUserManager(); final Authorizable authz = userManager.getAuthorizableByPath(path); // if an authorizable is not loaded from the path, short circuit. if (authz != null) { final String id = authz.getID(); // check for inclusion based on authorizableId Rule lastMatched = Rule.lastMatch(scopeIds, id); // if id is excluded, or is user and not system user, short circuit if (lastMatched.isExclude() || (!authz.isGroup() && !((User) authz).isSystemUser())) { return; } // report for groups and system users reportViolation(severity, String.format("%s: imported explicit %s. %s", path, authz.isGroup() ? "group" : "system user", recommendation), packageId); } } } }
@Test public void testIsSystemUser() throws Exception { assertTrue(createUser(null).isSystemUser()); }
@Test public void testFindAuthorizable() throws Exception { user = createUser(uid); Iterator<Authorizable> iterator = userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, user.getPrincipal().getName()); assertTrue(iterator.hasNext()); Authorizable authorizable = iterator.next(); assertNotNull(authorizable); assertFalse(authorizable.isGroup()); assertTrue(((User) authorizable).isSystemUser()); assertFalse(iterator.hasNext()); }
public void testGetUserAfterCreation() throws RepositoryException, NotExecutableException { Principal p = getTestPrincipal(); String uid = p.getName(); User user = createUser(uid, "pw"); createdUsers.add(user); assertFalse(user.isSystemUser()); assertFalse(user.isGroup()); assertFalse(user.isAdmin()); Authorizable authorizable = userMgr.getAuthorizable(user.getID()); assertNotNull(authorizable); assertFalse(authorizable.isGroup()); assertFalse(((User) authorizable).isAdmin()); assertFalse(((User) authorizable).isSystemUser()); authorizable = userMgr.getAuthorizable(p); assertNotNull(authorizable); assertFalse(authorizable.isGroup()); assertFalse(((User) authorizable).isAdmin()); assertFalse(((User) authorizable).isSystemUser()); } }
@Test public void testPassword() throws Exception { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sv:node sv:name=\"t\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" + " <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:SystemUser</sv:value></sv:property>" + " <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>e358efa4-89f5-3062-b10d-d7316b65649e</sv:value></sv:property>" + " <sv:property sv:name=\"rep:password\" sv:type=\"String\"><sv:value>{sha1}8efd86fb78a56a5145ed7739dcb00c78581c5375</sv:value></sv:property>" + " <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" + "</sv:node>"; doImport(getTargetPath(), xml); Node target = getTargetNode(); assertFalse(target.hasProperty(UserConstants.REP_PASSWORD)); Authorizable user = getUserManager().getAuthorizable("t"); assertNotNull(user); assertFalse(user.isGroup()); assertTrue(((User)user).isSystemUser()); getImportSession().save(); }
@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 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()); }
@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()); }
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()); }
@Test public void testAccessControlActionExecutionForSystemUser() throws Exception { AccessControlAction a1 = new AccessControlAction(); a1.init(securityProvider, ConfigurationParameters.of(AccessControlAction.USER_PRIVILEGE_NAMES, new String[] {Privilege.JCR_ALL})); setAuthorizableActions(a1); String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sv:node sv:name=\"t\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" + " <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:SystemUser</sv:value></sv:property>" + " <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>e358efa4-89f5-3062-b10d-d7316b65649e</sv:value></sv:property>" + " <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>tSystemPrincipal</sv:value></sv:property>" + "</sv:node>"; doImport(USERPATH, xml); Authorizable a = getUserManager().getAuthorizable("t"); assertNotNull(a); assertFalse(a.isGroup()); assertTrue(((User) a).isSystemUser()); AccessControlManager acMgr = getImportSession().getAccessControlManager(); AccessControlPolicy[] policies = acMgr.getPolicies(a.getPath()); assertNotNull(policies); assertEquals(0, policies.length); }