Package org.apache.james

Examples of org.apache.james.AccessControlException


    public boolean hasDeleteRights(String username)
        throws AccessControlException {
        boolean[] usersRights = (boolean[]) acl.get(username);
        if (usersRights == null  || (usersRights[LOOKUP] == false)) {
            throw new AccessControlException(DENY_ACCESS);
        }
        return usersRights[DELETE];
    }
View Full Code Here


    public boolean hasAdminRights(String username)
        throws AccessControlException {
        boolean[] usersRights = (boolean[]) acl.get(username);
        if (usersRights == null  || (usersRights[LOOKUP] == false)) {
            throw new AccessControlException(DENY_ACCESS);
        }
        return usersRights[ADMIN];
    }
View Full Code Here

                throw new MailboxException( "Mailbox has been deleted", MailboxException.LOCAL_BUT_DELETED );
            }
            else if ( openMailboxes.contains( absoluteName ) ) {
                mailbox = openMailboxes.getMailbox( absoluteName );
                if ( ! mailbox.hasLookupRights( user ) ) {
                    throw new AccessControlException( "No lookup rights." );
                }
                openMailboxes.addReference( absoluteName );
                return mailbox;
            }
            else {
                String owner = record.getUser();
                String key = getPath( absoluteName );
                ObjectInputStream in = null;
                try {
                    in = new ObjectInputStream( new FileInputStream( key + File.separator + FileMailbox.MAILBOX_FILE_NAME ) );
                    mailbox = (FileMailbox) in.readObject();
                    setupLogger( mailbox );
                    mailbox.configure( conf );
                    mailbox.contextualize( context );
                    mailbox.compose( compMgr );
                    mailbox.reinitialize();
                }
                catch ( Exception e ) {
                    e.printStackTrace();
                    throw new RuntimeException( "Exception caught while reading FileMailbox: " + e );
                }
                finally {
                    if ( in != null ) {
                        try {
                            in.close();
                        }
                        catch ( Exception ignored ) {
                        }
                    }
                    notifyAll();
                }
                if ( !mailbox.hasLookupRights( user ) ) {
                    throw new AccessControlException( "No lookup rights." );
                }
                openMailboxes.addMailbox( absoluteName, mailbox );
                return mailbox;
            }
        }
View Full Code Here

            }
            else if ( openMailboxes.contains( absoluteName ) ) {
                response = new String();
                mailbox = openMailboxes.getMailbox( absoluteName );
                if ( !mailbox.hasLookupRights( username ) ) {
                    throw new AccessControlException( "No lookup rights." );
                }
                while ( it.hasNext() ) {
                    String dataItem = (String) it.next();
                    if ( dataItem.equalsIgnoreCase( "MESSAGES" ) ) {
                        response += "MESSAGES " + mailbox.getExists();
                    }
                    else if ( dataItem.equalsIgnoreCase( "RECENT" ) ) {
                        response += "RECENT " + mailbox.getRecent();
                    }
                    else if ( dataItem.equalsIgnoreCase( "UIDNEXT" ) ) {
                        response += "UIDNEXT " + mailbox.getNextUID();
                    }
                    else if ( dataItem.equalsIgnoreCase( "UIDVALIDITY" ) ) {
                        response += "UIDVALIDITY " + mailbox.getUIDValidity();
                    }
                    else if ( dataItem.equalsIgnoreCase( "UNSEEN" ) ) {
                        response += "UNSEEN " + mailbox.getUnseen( username );
                    }
                    if ( it.hasNext() ) {
                        response += " ";
                    }
                }
                return response;
            }
            else {
                if ( !record.hasLookupRights( username ) ) {
                    throw new AccessControlException( "No lookup rights." );
                }
                response = new String();
                while ( it.hasNext() ) {
                    String dataItem = (String) it.next();
                    if ( dataItem.equalsIgnoreCase( "MESSAGES" ) ) {
View Full Code Here

            if (record.isDeleted()) {
                throw new MailboxException("Mailbox has been deleted", MailboxException.LOCAL_BUT_DELETED);
            } else if (openMailboxes.containsKey(absoluteName)) {
                mailbox = (ACLMailbox) openMailboxes.get(absoluteName);
                if (!mailbox.hasLookupRights(user)) {
                    throw new AccessControlException("No lookup rights.");
                } else {
                    Integer c = (Integer)mailboxCounts.get(absoluteName);
                    int count = c.intValue() + 1;
                    mailboxCounts.put(absoluteName, (new Integer(count)));
                    getLogger().info("Request no " + count + " for " + absoluteName);
                    return mailbox;
                }
            } else {
                String owner = record.getUser();
                String key = getPath(absoluteName, owner);
                ObjectInputStream in = null;
                try {
                    in        = new ObjectInputStream( new FileInputStream(key + File.separator + FileMailbox.MAILBOX_FILE_NAME) );
                    mailbox = (FileMailbox) in.readObject();
        setupLogger(mailbox);
                    mailbox.configure(conf);
                    mailbox.contextualize(context);
                    mailbox.compose(compMgr);
                    mailbox.reinitialize();
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new
                        RuntimeException("Exception caught while reading FileMailbox: " + e);
                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (Exception ignored) {
                        }
                    }
                    notifyAll();
                }
                if (!mailbox.hasLookupRights(user)) {
                    throw new AccessControlException("No lookup rights.");
                }
                openMailboxes.put(absoluteName, mailbox);
                mailboxCounts.put(absoluteName, new Integer(1));
                return mailbox;
            }
View Full Code Here

                throw new MailboxException("Mailbox has been deleted", MailboxException.LOCAL_BUT_DELETED);
            } else if (openMailboxes.containsKey(absoluteName)) {
                response = new String();
                mailbox = (ACLMailbox) openMailboxes.get(absoluteName);
                if (!mailbox.hasLookupRights(username)) {
                    throw new AccessControlException("No lookup rights.");
                }
                while(it.hasNext()) {
                    String dataItem = (String) it.next();
                    if (dataItem.equalsIgnoreCase("MESSAGES")) {
                        response += "MESSAGES " + mailbox.getExists();
                    } else if (dataItem.equalsIgnoreCase("RECENT")) {
                        response += "RECENT " + mailbox.getRecent();
                    } else if (dataItem.equalsIgnoreCase("UIDNEXT")) {
                        response += "UIDNEXT " + mailbox.getNextUID();
                    } else if (dataItem.equalsIgnoreCase("UIDVALIDITY")) {
                        response += "UIDVALIDITY " + mailbox.getUIDValidity();
                    } else if (dataItem.equalsIgnoreCase("UNSEEN")) {
                        response += "UNSEEN " + mailbox.getUnseen(username);
                    }
                    if (it.hasNext()) { response += " ";}
                }
                return response;
            } else {
                if (!record.hasLookupRights(username)) {
                    throw new AccessControlException("No lookup rights.");
                }
                response = new String();
                while(it.hasNext()) {
                    String dataItem = (String) it.next();
                    if (dataItem.equalsIgnoreCase("MESSAGES")) {
View Full Code Here

        throws AccessControlException, AuthorizationException {

        boolean[] settersRights = (boolean[]) acl.get(setter);
        if (settersRights == null
            || (settersRights[LOOKUP] == false)) {
            throw new AccessControlException(DENY_ACCESS);
        } else if (settersRights[ADMIN] == false) {
            throw new AuthorizationException(DENY_AUTH + setter);
        }
        boolean[] existingRights = (boolean[]) acl.get(identifier);
        char[] mods = modification.toCharArray();
View Full Code Here

    public String getRights(String getter, String identity)
        throws AccessControlException, AuthorizationException {
        boolean[] gettersRights = (boolean[])  acl.get(getter);
        if (gettersRights == null
            || (gettersRights[LOOKUP] == false)) {
            throw new AccessControlException(DENY_ACCESS);
        } else if (!getter.equals(identity) && gettersRights[ADMIN] == false) {
            throw new AuthorizationException(DENY_AUTH + getter);
        }
        boolean[] rights = (boolean[]) acl.get(identity);
        if (rights == null) {
View Full Code Here

    public String getAllRights(String getter)
        throws AccessControlException, AuthorizationException {
        boolean[] gettersRights = (boolean[]) acl.get(getter);
        if (gettersRights == null
            || (gettersRights[LOOKUP] == false)) {
            throw new AccessControlException(DENY_ACCESS);
        } else if ( gettersRights[ADMIN] == false) {
            throw new AuthorizationException(DENY_AUTH + getter);
        }
        Iterator namesIt = acl.keySet().iterator();
        StringBuffer response = new StringBuffer(20*acl.size());
 
View Full Code Here

    public String getRequiredRights(String getter, String identity)
        throws AccessControlException, AuthorizationException {
        boolean[] gettersRights = (boolean[]) acl.get(getter);
        if (gettersRights == null
            || (gettersRights[LOOKUP] == false)) {
            throw new AccessControlException(DENY_ACCESS);
        } else if (!getter.equals(identity) && gettersRights[ADMIN] == false) {
            throw new AuthorizationException(DENY_AUTH + getter);
        }

        return "\"\"";
View Full Code Here

TOP

Related Classes of org.apache.james.AccessControlException

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.