private void checkAuthorizableNodeExists(String nodeName, Node folder) throws AuthorizableExistsException, RepositoryException { if (folder.hasNode(nodeName) && ((NodeImpl) folder.getNode(nodeName)).isNodeType(NT_REP_AUTHORIZABLE)) { throw new AuthorizableExistsException("Unable to create Group/User: Collision with existing authorizable."); } }
public void testCreateUser() throws NotExecutableException { try { Principal p = getTestPrincipal(); User u = uMgr.createUser(p.getName(), buildPassword(p)); save(uSession); fail("A non-UserAdmin should not be allowed to create a new User."); // clean-up: let superuser remove the user created by fault. userMgr.getAuthorizable(u.getID()).remove(); } catch (AuthorizableExistsException e) { // should never get here. fail(e.getMessage()); } catch (RepositoryException e) { // success } }
public void testCreateUserWithItermediatePath() throws NotExecutableException { try { Principal p = getTestPrincipal(); User u = uMgr.createUser(p.getName(), buildPassword(p), p, "/any/intermediate/path"); save(uSession); fail("A non-UserAdmin should not be allowed to create a new User."); // clean-up: let superuser remove the user created by fault. userMgr.getAuthorizable(u.getID()).remove(); } catch (AuthorizableExistsException e) { // should never get here. fail(e.getMessage()); } catch (RepositoryException e) { // success } }
private void checkValidId(@Nullable String id) throws RepositoryException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Invalid ID " + id); } if (getAuthorizable(id) != null) { throw new AuthorizableExistsException("Authorizable with ID " + id + " already exists"); } }
void checkValidPrincipal(@Nullable Principal principal, boolean isGroup) throws RepositoryException { if (principal == null || Strings.isNullOrEmpty(principal.getName())) { throw new IllegalArgumentException("Principal may not be null and must have a valid name."); } if (!isGroup && EveryonePrincipal.NAME.equals(principal.getName())) { throw new IllegalArgumentException("'everyone' is a reserved group principal name."); } if (getAuthorizable(principal) != null) { throw new AuthorizableExistsException("Authorizable with principal " + principal.getName() + " already exists."); } }
void checkValidPrincipal(@Nullable Principal principal, boolean isGroup) throws RepositoryException { if (principal == null || Strings.isNullOrEmpty(principal.getName())) { throw new IllegalArgumentException("Principal may not be null and must have a valid name."); } if (!isGroup && EveryonePrincipal.NAME.equals(principal.getName())) { throw new IllegalArgumentException("'everyone' is a reserved group principal name."); } if (getAuthorizable(principal) != null) { throw new AuthorizableExistsException("Authorizable with principal " + principal.getName() + " already exists."); } }
private void checkValidId(@Nullable String id) throws RepositoryException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Invalid ID " + id); } if (getAuthorizable(id) != null) { throw new AuthorizableExistsException("Authorizable with ID " + id + " already exists"); } }
private void checkAuthorizableNodeExists(String nodeName, Node folder) throws AuthorizableExistsException, RepositoryException { if (folder.hasNode(nodeName) && ((NodeImpl) folder.getNode(nodeName)).isNodeType(NT_REP_AUTHORIZABLE)) { throw new AuthorizableExistsException("Unable to create Group/User: Collision with existing authorizable."); } }
private void checkValidId(@CheckForNull String id) throws RepositoryException { if (id == null || id.isEmpty()) { throw new IllegalArgumentException("Invalid ID " + id); } if (getAuthorizable(id) != null) { throw new AuthorizableExistsException("Authorizable with ID " + id + " already exists"); } }
void checkValidPrincipal(@CheckForNull Principal principal, boolean isGroup) throws RepositoryException { if (principal == null || Strings.isNullOrEmpty(principal.getName())) { throw new IllegalArgumentException("Principal may not be null and must have a valid name."); } if (!isGroup && EveryonePrincipal.NAME.equals(principal.getName())) { throw new IllegalArgumentException("'everyone' is a reserved group principal name."); } if (getAuthorizable(principal) != null) { throw new AuthorizableExistsException("Authorizable with principal " + principal.getName() + " already exists."); } }
/** * Checks if the specified <code>id</code> is a non-empty string and not yet * in use for another user or group. * * @param id The id of the user or group to be created. * @throws IllegalArgumentException If the specified id is null or empty string. * @throws AuthorizableExistsException If the id is already in use. * @throws RepositoryException If another error occurs. */ private void checkValidID(String id) throws IllegalArgumentException, AuthorizableExistsException, RepositoryException { if (id == null || id.length() == 0) { throw new IllegalArgumentException("Cannot create authorizable: ID can neither be null nor empty String."); } if (internalGetAuthorizable(id) != null) { throw new AuthorizableExistsException("User or Group for '" + id + "' already exists"); } }
/** * Checks if the specified <code>id</code> is a non-empty string and not yet * in use for another user or group. * * @param id The id of the user or group to be created. * @throws IllegalArgumentException If the specified id is null or empty string. * @throws AuthorizableExistsException If the id is already in use. * @throws RepositoryException If another error occurs. */ private void checkValidID(String id) throws IllegalArgumentException, AuthorizableExistsException, RepositoryException { if (id == null || id.length() == 0) { throw new IllegalArgumentException("Cannot create authorizable: ID can neither be null nor empty String."); } if (internalGetAuthorizable(id) != null) { throw new AuthorizableExistsException("User or Group for '" + id + "' already exists"); } }
/** * * @param node The new user/group node. * @param principal A valid non-null principal. * @throws AuthorizableExistsException If there is already another user/group * with the same principal name. * @throws RepositoryException If another error occurs. */ void setPrincipal(NodeImpl node, Principal principal) throws AuthorizableExistsException, RepositoryException { checkValidPrincipal(principal, node.isNodeType(NT_REP_GROUP)); /* Check if there is *another* authorizable with the same principal. The additional validation (nodes not be same) is required in order to circumvent problems with re-importing existing authorizable in which case the original user/group node is being recreated but the search used to look for an colliding authorizable still finds the persisted node. */ Authorizable existing = getAuthorizable(principal); if (existing != null && !((AuthorizableImpl) existing).getNode().isSame(node)) { throw new AuthorizableExistsException("Authorizable for '" + principal.getName() + "' already exists: "); } if (!node.isNew() || node.hasProperty(P_PRINCIPAL_NAME)) { throw new RepositoryException("rep:principalName can only be set once on a new node."); } setProperty(node, P_PRINCIPAL_NAME, getValue(principal.getName()), true); }
/** * * @param node The new user/group node. * @param principal A valid non-null principal. * @throws AuthorizableExistsException If there is already another user/group * with the same principal name. * @throws RepositoryException If another error occurs. */ void setPrincipal(NodeImpl node, Principal principal) throws AuthorizableExistsException, RepositoryException { checkValidPrincipal(principal, node.isNodeType(NT_REP_GROUP)); /* Check if there is *another* authorizable with the same principal. The additional validation (nodes not be same) is required in order to circumvent problems with re-importing existing authorizable in which case the original user/group node is being recreated but the search used to look for an colliding authorizable still finds the persisted node. */ Authorizable existing = getAuthorizable(principal); if (existing != null && !((AuthorizableImpl) existing).getNode().isSame(node)) { throw new AuthorizableExistsException("Authorizable for '" + principal.getName() + "' already exists: "); } if (!node.isNew() || node.hasProperty(P_PRINCIPAL_NAME)) { throw new RepositoryException("rep:principalName can only be set once on a new node."); } setProperty(node, P_PRINCIPAL_NAME, getValue(principal.getName()), true); }
parent.setProperty(REP_AUTHORIZABLE_ID, id); } else { throw new AuthorizableExistsException(id);
parent.setProperty(REP_AUTHORIZABLE_ID, id); } else { throw new AuthorizableExistsException(id);
parent.setProperty(REP_AUTHORIZABLE_ID, id); } else { throw new AuthorizableExistsException(id);