Package org.exist.security

Examples of org.exist.security.AbstractRealm$PrincipalDbByName


            id = group.getId();
        } else {
            id = getNextGroupId();
        }
       
        final AbstractRealm registeredRealm = (AbstractRealm)findRealmForRealmId(group.getRealmId());
        if (registeredRealm.hasGroup(group.getName())) {
            throw new ConfigurationException("The group '"+group.getName()+"' at realm '" + group.getRealmId() + "' already exist.");
        }
       
        final GroupImpl newGroup = new GroupImpl(registeredRealm, id, group.getName(), group.getManagers());
        for(final SchemaType metadataKey : group.getMetadataKeys()) {
            final String metadataValue = group.getMetadataValue(metadataKey);
            newGroup.setMetadataValue(metadataKey, metadataValue);
        }
       
        groupLocks.getWriteLock(newGroup).lock();
        try {
            groupsById.modify(new PrincipalDbModify<Group>(){
                @Override
                public void execute(final Int2ObjectHashMap<Group> principalDb) {
                    principalDb.put(id, newGroup);
                }
            });
           
            registeredRealm.registerGroup(newGroup);

            save();
            newGroup.save();

            return newGroup;
View Full Code Here


            id = account.getId();
        } else {
            id = getNextAccountId();
        }

    final AbstractRealm registeredRealm = (AbstractRealm) findRealmForRealmId(account.getRealmId());
    final AccountImpl newAccount = new AccountImpl(registeredRealm, id, account);
 
        accountLocks.getWriteLock(newAccount).lock();
        try {
            usersById.modify(new PrincipalDbModify<Account>(){
                @Override
                public void execute(final Int2ObjectHashMap<Account> principalDb) {
                    principalDb.put(id, newAccount);
                }
            });
           
            registeredRealm.registerAccount(newAccount);

            //XXX: one transaction?
            save();
            newAccount.save();
View Full Code Here

            id = account.getId();
        } else {
            id = getNextAccountId();
        }

        final AbstractRealm registeredRealm = (AbstractRealm) findRealmForRealmId(account.getRealmId());
        final AccountImpl newAccount = new AccountImpl(broker, registeredRealm, id, account);

        accountLocks.getWriteLock(newAccount).lock();
        try {
            usersById.modify(new PrincipalDbModify<Account>(){
                @Override
                public void execute(final Int2ObjectHashMap<Account> principalDb) {
                    principalDb.put(id, newAccount);
                }
            });
           
            registeredRealm.registerAccount(newAccount);

            //XXX: one transaction?
            save(broker);
            newAccount.save(broker);
View Full Code Here

        if(isAccount || isGroup) {
            uri = uri.removeLastSegment();

            final String realmId = uri.lastSegment().toString();
     
            final AbstractRealm realm = (AbstractRealm)findRealmForRealmId(realmId);
            final Configuration conf = Configurator.parse(document);

            Integer id = -1;
            if(isRemoved) {
                id = conf.getPropertyInteger("id");
            }

            final String name = conf.getProperty("name");

            if(isAccount) {
                if (isRemoved && id > 2 && !hasUser(id)) {
                    final AccountImpl account = new AccountImpl( realm, conf );
                    account.removed = true;
                    addUser(account.getId(), account);
                } else if(name != null) {
                  if (realm.hasAccount(name)) {
                    final Integer oldId = saving.get(document.getURI());
                   
                  final Integer newId = conf.getPropertyInteger("id");
                 
                  //XXX: resolve conflicts on ids!!!
                 
                  if (!newId.equals(oldId)) {
                        final Account current = realm.getAccount(name);
                        accountLocks.getWriteLock(current).lock();
                        try {
                            usersById.modify(new PrincipalDbModify<Account>(){
                                @Override
                                public void execute(final Int2ObjectHashMap<Account> principalDb) {
                                    principalDb.remove(oldId);
                                    principalDb.put(newId, current);
                                }
                            });
                        } finally {
                            accountLocks.getWriteLock(current).unlock();
                        }
                  }
                  } else {
                    final Account account = new AccountImpl( realm, conf );
                    addUser(account.getId(), account);
                    realm.registerAccount(account);
                  }
                } else {
                    //this can't be! log any way
                    LOG.error("Account '"+name+"' pressent at '"+realmId+"' realm, but get event that new one created.");
                }
           
            } else if(isGroup) {
                if (isRemoved && id > 2 && !hasGroup(id)) {
                    final GroupImpl group = new GroupImpl( realm, conf );
                    group.removed = true;
                    addGroup(group.getId(), group);
                } else if (name != null && !realm.hasGroup(name)) {
                    final GroupImpl group = new GroupImpl( realm, conf );
                    addGroup(group.getId(), group);
                    realm.registerGroup(group);
                } else {
                    //this can't be! log any way
                    LOG.error("Group '"+name+"' pressent at '"+realmId+"' realm, but get event that new one created.");
                }
                           
View Full Code Here

TOP

Related Classes of org.exist.security.AbstractRealm$PrincipalDbByName

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.