Package org.exist.security

Examples of org.exist.security.Subject


                    credentials = null;
                }

    // get the user from the session if possible
    final HttpSession session = request.getSession(false);
    Subject user = null;
    if (session != null) {
      user = (Subject) session.getAttribute(XQueryContext.HTTP_SESSIONVAR_XMLDB_USER);
      if (user != null && (username == null || user.getName().equals(username))) {
        return user;
      }
    }

    if (user != null) {
View Full Code Here


    }
   
    @Override
    public java.lang.String connect(java.lang.String userId, java.lang.String password) throws java.rmi.RemoteException {
      try {
        final Subject u = pool.getSecurityManager().authenticate(userId, password);

            LOG.debug("user " + userId + " connected");
           
            return SessionManager.getInstance().createSession(u);
    } catch (final Exception e) {
View Full Code Here

        DBBroker broker = null;
        final Session session = getSession(sessionId);
        Collection collection = null;
        Collection destination = null;
        try {
            final Subject user = session.getUser();
            broker = pool.get(user);
            // get source document
            collection = broker.openCollection(collectionPath, move ? Lock.WRITE_LOCK : Lock.READ_LOCK);
            if (collection == null) {
                transact.abort(transaction);
View Full Code Here

        if (password.length() == 0) {
            password = null;
        }
       
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
       
        final org.exist.security.SecurityManager manager = pool.getSecurityManager();
        if(name.equals(org.exist.security.SecurityManager.GUEST_USER) && (!manager.hasAdminPrivileges(user))) {
            throw new RemoteException("guest user cannot be modified");
        }
       
        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);
                    }
       
View Full Code Here

        }
    }
   
    @Override
    public void removeUser(java.lang.String sessionId, java.lang.String name) throws java.rmi.RemoteException {
        final Subject user = getSession(sessionId).getUser();
        final org.exist.security.SecurityManager manager = pool
                .getSecurityManager();
        if (!manager.hasAdminPrivileges(user))
            {throw new RemoteException(
                    "you are not allowed to remove users");}
View Full Code Here

      }
    }
    public void lockResource(java.lang.String sessionId, XmldbURI path, java.lang.String userName) throws java.rmi.RemoteException {
        DBBroker broker = null;
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
        DocumentImpl doc = null;
        final TransactionManager transact = pool.getTransactionManager();
        final Txn transaction = transact.beginTransaction();
        try {
            broker = pool.get(user);
// TODO check XML/Binary resource
//            doc = (DocumentImpl) broker.openDocument(path, Lock.WRITE_LOCK);
            doc = broker.getXMLResource(path, Lock.WRITE_LOCK);
            if (doc == null) {
                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();
            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());}
View Full Code Here

      }
    }
    public void unlockResource(java.lang.String sessionId, XmldbURI path) throws java.rmi.RemoteException {
        DBBroker broker = null;
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
        DocumentImpl doc = null;
        final TransactionManager transact = pool.getTransactionManager();
        Txn transaction = null;
        try {
            broker = pool.get(user);
View Full Code Here

      }
    }
    public java.lang.String hasUserLock(java.lang.String sessionId, XmldbURI path) throws java.rmi.RemoteException {
        DBBroker broker = null;
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
        DocumentImpl doc = null;
        try {
            broker = pool.get(user);
// TODO check XML/Binary resource
//            doc = (DocumentImpl) broker.openDocument(path, Lock.READ_LOCK);
View Full Code Here

      }
    }
    public org.exist.soap.Permissions getPermissions(java.lang.String sessionId, XmldbURI resource) throws java.rmi.RemoteException {
        DBBroker broker = null;
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
        try {
            broker = pool.get(user);
            Collection collection = null;
            try {
              collection = broker.openCollection(resource, Lock.READ_LOCK);
View Full Code Here

      }
    }
    public org.exist.soap.EntityPermissionsList listCollectionPermissions(java.lang.String sessionId, XmldbURI name) throws java.rmi.RemoteException {
        DBBroker broker = null;
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
        Collection collection = null;
        try {
            broker = pool.get(user);
            collection = broker.openCollection(name, Lock.READ_LOCK);
            if (collection == null)
View Full Code Here

TOP

Related Classes of org.exist.security.Subject

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.