Package org.exist.security

Examples of org.exist.security.Account


    private void miEditUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miEditUserActionPerformed
       
        final String selectedUsername = getSelectedUsername();
        try {
            final Account account = userManagementService.getAccount(selectedUsername);
            showEditUserDialog(account);
        } catch(final XMLDBException xmldbe) {
            JOptionPane.showMessageDialog(this, "Could not edit user '" + selectedUsername + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_miEditUserActionPerformed
View Full Code Here


        miRemoveUser.setEnabled(canDelete);
       
        if(evt.getClickCount() == 2 && canModify) {
           
            try {
                final Account account = userManagementService.getAccount(selectedUsername);
                showEditUserDialog(account);
            } catch(final XMLDBException xmldbe) {
                JOptionPane.showMessageDialog(this, "Could not edit user '" + selectedUsername + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
            }
        }
View Full Code Here

       
        DBBroker broker = null;
        try {
            broker = pool.get(user);

        Account u;
        if(!manager.hasAccount(name)) {
            if(!manager.hasAdminPrivileges(user)) {
                throw new RemoteException("not allowed to create user");
            }
         
            u = new UserAider(name);
            ((UserAider)u).setPasswordDigest(password);
        } else {
            u = manager.getAccount(name);
            if(!(u.getName().equals(user.getName()) || manager.hasAdminPrivileges(user))) {
                throw new RemoteException("you are not allowed to change this user");
            }
            ((AccountImpl)u).setPassword(password);
                    }
       
            for(final String groupName : groups.getElements()) {
                if (!u.hasGroup(groupName)) {

                    if(!manager.hasAdminPrivileges(user)) {
                        throw new RemoteException("User is not allowed to add groups");
                    }

                    if(!manager.hasGroup(groupName)){
                        manager.addGroup(groupName);
                    }
                    u.addGroup(groupName);
                }
            }
           
            manager.addAccount(u);
           
View Full Code Here

       
        DBBroker broker = null;
        try {
            broker = pool.get(session.getUser());

          final Account u = pool.getSecurityManager().getAccount(user);
          if (u == null)
              {throw new RemoteException("user " + user + " does not exist");}
          final UserDesc desc = new UserDesc();
          desc.setName(u.getName());
  /*
          Vector groups = new Vector();
          for (Iterator i = u.getGroups(); i.hasNext(); )
              groups.addElement(i.next());
          desc.setGroups(new Strings((String[])groups.toArray(new String[groups.size()])));
   */
          desc.setGroups(new Strings(u.getGroups()));
          return desc;
        } catch (final EXistException e) {
            throw new RemoteException(e.getMessage());
        } finally {
            pool.release(broker);
View Full Code Here

           
            final org.exist.security.SecurityManager manager = pool.getSecurityManager();
            if (!(userName.equals(user.getName()) || manager.hasAdminPrivileges(user)))
                {throw new PermissionDeniedException("User " + user.getName() + " is not allowed " +
                        "to lock the resource for user " + userName);}
            final Account lockOwner = doc.getUserLock();
            if(lockOwner != null && (!lockOwner.equals(user)) && (!manager.hasAdminPrivileges(user)))
                {throw new PermissionDeniedException("Resource is already locked by user " +
                        lockOwner.getName());}
            final Account lo = manager.getAccount(userName);
            doc.setUserLock(lo);
// TODO check XML/Binary resource
//            broker.storeDocument(transaction, doc);
            broker.storeXMLResource(transaction, doc);
            transact.commit(transaction);
View Full Code Here

                {throw new EXistException("Resource "
                        + path + " not found");}
            if (!doc.getPermissions().validate(user, Permission.WRITE))
                {throw new PermissionDeniedException("User is not allowed to lock resource " + path);}
            final org.exist.security.SecurityManager manager = pool.getSecurityManager();
            final Account lockOwner = doc.getUserLock();
            if(lockOwner != null && (!lockOwner.equals(user)) && (!manager.hasAdminPrivileges(user)))
                {throw new PermissionDeniedException("Resource is already locked by user " +
                        lockOwner.getName());}
            transaction = transact.beginTransaction();
            doc.setUserLock(null);
// TODO check XML/Binary resource
//            broker.storeDocument(transaction, doc);
            broker.storeXMLResource(transaction, doc);
View Full Code Here

            if (doc == null)
                {throw new EXistException("Resource "
                        + path + " not found");}
            if(!doc.getPermissions().validate(user, Permission.READ))
                {throw new PermissionDeniedException("Insufficient privileges to read resource");}
            final Account u = doc.getUserLock();
            return u == null ? "" : u.getName();
        } catch (final Exception ex) {
            throw new RemoteException(ex.getMessage());
        } finally {
            if(doc != null)
                {doc.getUpdateLock().release(Lock.READ_LOCK);}
View Full Code Here

  }
  /**
   * Return the Principal associated with the given user name.
   */
  protected Principal getPrincipal(String username) {
    Account user = null;
   
    try {
      user = service.getAccount(username);
    } catch (XMLDBException e) {
    }
   
    if (user == null) {
      user = defaultUser;
    }
   
    // Accumulate the list of roles for this user
    ArrayList<String> list = new ArrayList<String>();
    String[] groups = user.getGroups();
    for (int i = 0; i < groups.length; i++) {
      list.add(groups[i]);
    }
    return (Principal) new DefaultXmldbPrinciple(this, username, user.getPassword(), list);
  }
View Full Code Here

      defaultUser = service.getAccount(SecurityManager.GUEST_USER);
     
      /* initialize security */
      boolean admin = true;
      if(admin){
        Account adminUser = service.getAccount(SecurityManager.DBA_USER);
        if(adminUser.getPassword() == null){
          adminUser.setPassword("admin");
          log("Update Admin User on inital start");
        }
      }
     
    } catch (ClassNotFoundException e) {
View Full Code Here

     
    String id = responseAttributes.get("id");
   
    String accountName = id + "@facebook.com";

    Account found = OAuthRealm._.getAccount(accountName);
   
    if (found == null) {
      Map<SchemaType, String> metadata = new HashMap<SchemaType, String>();
      metadata.put(FBSchemaType.ID, responseAttributes.get("id"));
      metadata.put(AXSchemaType.FIRSTNAME, responseAttributes.get("first_name"));
      metadata.put(AXSchemaType.LASTNAME, responseAttributes.get("last_name"));
      metadata.put(AXSchemaType.FULLNAME, responseAttributes.get("name"));
      metadata.put(AXSchemaType.TIMEZONE, responseAttributes.get("timezone"));
     
      found = OAuthRealm._.createAccountInDatabase(accountName, metadata);
    }
   
    Account principal = new SubjectAccreditedImpl((AbstractAccount) found, accessToken);
   
        HttpSession session = request.getSession(true);

    Subject subject = new Subject();
View Full Code Here

TOP

Related Classes of org.exist.security.Account

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.