Package org.exist.security

Examples of org.exist.security.SecurityManager


      sendChallenge(request, response);
      return null;
    }
    final Digest digest = new Digest(request.getMethod());
    parseCredentials(digest, credentials);
    final SecurityManager secman = pool.getSecurityManager();
    final AccountImpl user = (AccountImpl)secman.getAccount(digest.username);
    if (user == null) {
      // If user does not exist then send a challenge request again
      if (sendChallenge) {sendChallenge(request, response);}
      return null;
    }
View Full Code Here


      if (sendChallenge) {sendChallenge(request, response);}
      return null;
    }

    // authenticate the credentials
    final SecurityManager secman = pool.getSecurityManager();
    try {
      user = secman.authenticate(username, password);
    } catch (final AuthenticationException e) {
      // if authentication failed then send a challenge request again
      if (sendChallenge) {sendChallenge(request, response);}
      return null;
    }
View Full Code Here

        if (username == null) {
            return null;
        }

        SecurityManager securityManager = brokerPool.getSecurityManager();
        try {
            subject = securityManager.authenticate(username, password);

        } catch (AuthenticationException e) {
            LOG.info(String.format("User %s could not be authenticated. %s", username, e.getMessage()));
        }
        return subject;
View Full Code Here

        super(context, signature);
    }
   
    @Override
    public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
        final SecurityManager sm = context.getBroker().getBrokerPool().getSecurityManager();
        final LDAPRealm ldapRealm = getLdapRealm(sm);
        final String accountName = args[0].itemAt(0).getStringValue();
       
        final Account ldapAccount = sm.getAccount(accountName);
        if(ldapAccount == null)
            throw new XPathException("The Account '" + accountName + "' does not exist!");
       
        try {
            ldapRealm.refreshAccountFromLdap(ldapAccount);
View Full Code Here

    }
   
    @Override
    public boolean updateGroup(final String name, final Vector<String> managers, final Map<String, String> metadata) throws EXistException, PermissionDeniedException {
      
        final SecurityManager manager = factory.getBrokerPool().getSecurityManager();

      if(manager.hasGroup(name)) {
       
            final GroupAider group = new GroupAider(name);
       
            for(final String groupManager : managers) {
                group.addManager(new UserAider(groupManager));
            }

            if(metadata != null) {
                for(final String key : metadata.keySet()) {
                    if(AXSchemaType.valueOfNamespace(key) != null) {
                        group.setMetadataValue(AXSchemaType.valueOfNamespace(key), metadata.get(key));
                    } else if(EXistSchemaType.valueOfNamespace(key) != null) {
                        group.setMetadataValue(EXistSchemaType.valueOfNamespace(key), metadata.get(key));
                    }
                }
            }
           
            try {
                executeWithBroker(new BrokerOperation<Void>() {
                    @Override
                    public Void withBroker(final DBBroker broker) throws EXistException, URISyntaxException, PermissionDeniedException {
                        manager.updateGroup(group);
                        return null;
                    }
                });
                return true;
            } catch (final URISyntaxException use) {
View Full Code Here

    public void addAccountToGroup(final String accountName, final String groupName) throws EXistException, PermissionDeniedException {
         try {
            executeWithBroker(new BrokerOperation<Void>() {
                @Override
                public Void withBroker(final DBBroker broker) throws EXistException, PermissionDeniedException {
                    final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
                    final Account account = sm.getAccount(accountName);
                    account.addGroup(groupName);
                    sm.updateAccount(account);
                   
                    return null;
                }
            });
        } catch (final URISyntaxException use) {
View Full Code Here

    public void addGroupManager(final String manager, final String groupName) throws EXistException, PermissionDeniedException {
        try {
            executeWithBroker(new BrokerOperation<Void>() {
                @Override
                public Void withBroker(final DBBroker broker) throws EXistException, PermissionDeniedException {
                    final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
                   
                    final Account account = sm.getAccount(manager);
                    final Group group = sm.getGroup(groupName);
                    group.addManager(account);
                    sm.updateGroup(group);
                   
                    return null;
                }
            });
        } catch (final URISyntaxException use) {
View Full Code Here

    public void removeGroupManager(final String groupName, final String manager) throws EXistException, PermissionDeniedException {
        try {
            executeWithBroker(new BrokerOperation<Void>() {
                @Override
                public Void withBroker(final DBBroker broker) throws EXistException, PermissionDeniedException {
                    final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
                    final Group group = sm.getGroup(groupName);
                    final Account account = sm.getAccount(manager);
                   
                    group.removeManager(account);
                    sm.updateGroup(group);
                   
                    return null;
                }
            });
        } catch (final URISyntaxException use) {
View Full Code Here

    public void removeGroupMember(final String group, final String member) throws EXistException, PermissionDeniedException {
        try {
            executeWithBroker(new BrokerOperation<Void>() {
                @Override
                public Void withBroker(final DBBroker broker) throws EXistException, PermissionDeniedException {
                    final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
                   
                    final Account account = sm.getAccount(member);
                    account.remGroup(group);
                    sm.updateAccount(account);
                   
                    return null;
                }
            });
        } catch (final URISyntaxException use) {
View Full Code Here

     * This is called via RemoteUserManagementService.addUserGroup(Account)
     */
    public boolean updateAccount(String name, Vector<String> groups) throws EXistException,
    PermissionDeniedException {

      final SecurityManager manager = factory.getBrokerPool().getSecurityManager();
        DBBroker broker = null;

        try {
          broker = factory.getBrokerPool().get(user);
         
          Account u;

          if (!manager.hasAccount(name)) {
            u = new UserAider(name);
          } else {
            u = manager.getAccount(name);
          }

          for (final String g : groups) {
            if (!u.hasGroup(g)) {
              u.addGroup(g);
            }
          }

          return manager.updateAccount(u);
         
        } catch (final Exception ex) {
          LOG.debug("addUserGroup encountered error", ex);
          return false;
        } finally {
View Full Code Here

TOP

Related Classes of org.exist.security.SecurityManager

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.