Package org.exist.security.internal.aider

Examples of org.exist.security.internal.aider.UserAider


                    uid = (Integer)tab.get("uid");
                } catch (final java.lang.NumberFormatException e) {
                   
                }
         
                u[i] = new UserAider(uid, (String) tab.get("realmId"), (String) tab.get("name"));
                final Object[] groups = (Object[]) tab.get("groups");
                for (int j = 0; j < groups.length; j++) {
                    u[i].addGroup((String) groups[j]);
                }
               
View Full Code Here


    }
    }

  @Override
  public void addUser(User user) throws XMLDBException {
    final Account account = new UserAider(user.getName());
    addAccount(account);
  }
View Full Code Here

    addAccount(account);
  }

  @Override
  public void updateUser(User user) throws XMLDBException {
    final Account account = new UserAider(user.getName());
    account.setPassword(user.getPassword());
    //TODO: groups
    updateAccount(account);
  }
View Full Code Here

   
  }

  @Override
  public void lockResource(Resource res, User u) throws XMLDBException {
    final Account account = new UserAider(u.getName());
    lockResource(res, account);
  }
View Full Code Here

                   
                    if(securityManager.hasAccount(username)) {
                        throw new XPathException("The user account with username " + username + " already exists.");
                    }

                    final Account user = new UserAider(username);
                    user.setPassword(password);

                    if(getSignature().getArgumentCount() >= 5) {
                        //set metadata values if present
                        user.setMetadataValue(AXSchemaType.FULLNAME, args[getSignature().getArgumentCount() - 2].toString());
                        user.setMetadataValue(EXistSchemaType.DESCRIPTION, args[getSignature().getArgumentCount() - 1].toString());
                    }

                    final String[] subGroups;
                    if(getSignature().getArgumentCount() == 3 || getSignature().getArgumentCount() == 5) {
                        //create the personal group
                        final Group group = new GroupAider(username);
                        group.setMetadataValue(EXistSchemaType.DESCRIPTION, "Personal group for " + username);
                        group.addManager(currentUser);
                        securityManager.addGroup(group);

                        //add the personal group as the primary group
                        user.addGroup(username);

                        subGroups = getGroups(args[2]);
                    } else {
                        //add the primary group as the primary group
                        user.addGroup(args[2].getStringValue());

                        subGroups = getGroups(args[3]);
                    }

                    for(int i = 0; i <  subGroups.length; i++) {
                        user.addGroup(subGroups[i]);
                    }

                    //create the account
                    securityManager.addAccount(user);
View Full Code Here

                    //elevate to system privs
          broker.setSubject(getSecurityManager().getSystemSubject());

//                    account = getSecurityManager().addAccount(instantiateAccount(this, username));
          account = (AbstractAccount) getSecurityManager().addAccount(new UserAider(ID, username));
        } catch (Exception e) {
          throw new AuthenticationException(
              AuthenticationException.UNNOWN_EXCEPTION,
              e.getMessage(), e);
        } finally {
View Full Code Here

    final String user = args[0].getStringValue();
    final String pass = args[1].getStringValue();

    logger.info("Attempting to create user " + user);

    final UserAider userObj = new UserAider(user);
    userObj.setPassword(pass);

    // changed by wolf: the first group is always the primary group, so we
    // don't need
    // an additional argument
    final Sequence groups = args[2];
    final int len = groups.getItemCount();
    for (int x = 0; x < len; x++) {
                    userObj.addGroup(groups.itemAt(x).getStringValue());
                }
   
    Collection collection = null;
    try {
      collection = new LocalCollection(
View Full Code Here

                logger.error("User " + userName + " not found");
                throw new XPathException(this, "User " + userName + " not found");
      }

            final Group oldPrimaryGroup = oldUser.getDefaultGroup();
            final UserAider user;
            if(oldPrimaryGroup != null) {
                //dont forget to set the primary group
                user = new UserAider(oldUser.getName(), oldPrimaryGroup);
            } else {
                user = new UserAider(oldUser.getName());
            }
     
            //copy the umask
            user.setUserMask(oldUser.getUserMask());
           
            //copy the metadata
            for(final SchemaType key : oldUser.getMetadataKeys()) {
                user.setMetadataValue(key, oldUser.getMetadataValue(key));
            }
           
            //copy the status
            user.setEnabled(oldUser.isEnabled());
           
            //change the password?
            if(!args[1].isEmpty()) {
                // set password
                user.setPassword(args[1].getStringValue());
      } else {
                //use the old password
                user.setEncodedPassword(oldUser.getPassword());
                user.setPasswordDigest(oldUser.getDigestPassword());
      }
     
            //change the groups?
            if(!args[2].isEmpty()) {
                // set groups
                for(final SequenceIterator i = args[2].iterate(); i.hasNext(); ) {
                    user.addGroup(i.nextItem().getStringValue());
                }
      } else {
                user.setGroups(oldUser.getGroups());
            }

      ums.updateAccount(user);
  } catch(final XMLDBException xe) {
      logger.error("Failed to update user " + userName, xe);
View Full Code Here

        }
    }

    @Override
    public void addUser(User user) throws XMLDBException {
        final Account account = new UserAider(user.getName());
        addAccount(account);
    }
View Full Code Here

        addAccount(account);
    }

    @Override
    public void updateUser(User user) throws XMLDBException {
        final Account account = new UserAider(user.getName());
        account.setPassword(user.getPassword());
        //TODO: groups
        updateAccount(account);
    }
View Full Code Here

TOP

Related Classes of org.exist.security.internal.aider.UserAider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.