Package com.ericdaugherty.mail.server.info

Examples of com.ericdaugherty.mail.server.info.User


            //Check the address to see if we can deliver it.
            DeliveryService deliveryService = DeliveryService.getDeliveryService();
            if( deliveryService.acceptAddress( address, clientIp, message.getFromAddress() ) ) {
                // Check to see if it is a local user.  If so, ask to
                // user object for the delivery addresses.
                User localUser = configurationManager.getUser( address );
                if( localUser!= null ) {
                    EmailAddress[] addresses = localUser.getDeliveryAddresses();
                    for( int index = 0; index < addresses.length; index++ ) {
                        message.addToAddress( addresses[index] );
                    }
                }
                // Otherwise, just add the address.
View Full Code Here


    private void deliverLocalMessage( EmailAddress address, SMTPMessage message )
        throws NotFoundException {

        if( log.isDebugEnabled() ) { log.debug( "Delivering Message to local user: " + address.getAddress() ); }

        User user = null;
        //Load the user.  If the user doesn't exist, a not found exception will
        //be thrown and the deliver() message will deal with the notification.
        user = configurationManager.getUser( address );
        if( user == null )
        {
            log.debug( "User not found, checking for default delivery options" );
            //Check to see if a default delivery mailbox exists, and if so, deliver it.
            //Otherwise, just throw the NotFoundException to bounce the email.
            if( configurationManager.isDefaultUserEnabled() ) {
                EmailAddress defaultAddress = configurationManager.getDefaultUser();
                //If this throws a NotFoundException, go ahead and let it bounce.
                user = configurationManager.getUser( defaultAddress );
                if( user == null ) throw new NotFoundException();
                if( log.isDebugEnabled() ) { log.info( "Delivering message addressed to: " + address + " to default user: " + defaultAddress ); }
            }
            else {
                throw new NotFoundException( "User does not exist and no default delivery options found." );
            }
        }

        //The file to write to.
        File messageFile = null;
        //The output stream to write the message to.
        BufferedWriter out = null;

        try {

            //Get the directory and create a new file.
            File userDirectory = user.getUserDirectory();
            messageFile = userDirectory.createTempFile("pop", ".jmsg", userDirectory );

            if( log.isDebugEnabled() ) { log.debug( "Delivering to: " + messageFile.getAbsolutePath() ); }

            //Open the output stream.
View Full Code Here

     * @param address the user's full email address.
     * @return null if the user does not exist.
     */
    public User getUser( EmailAddress address )
    {
        User user = (User) users.get( address.getAddress() );
        if( log.isInfoEnabled() && user == null ) log.info( "Tried to load non-existent user: " +  address.getAddress() );

        return user;
    }
View Full Code Here

     * @return a new User instance.
     */
    private User loadUser( String fullAddress, Properties properties ) throws InvalidAddressException
    {
        EmailAddress address = new EmailAddress( fullAddress );
        User user = new User( address );

        // Load the password
        String password = properties.getProperty( USER_DEF_PREFIX + fullAddress );
        // If the password is not hashed, hash it now.
        if( password.length() != 60 ) {
            password = PasswordManager.encryptPassword( password );
            properties.setProperty( USER_DEF_PREFIX + fullAddress, password );
            if( password == null ) {
                log.error( "Error encrypting plaintext password from user.conf for user " + fullAddress );
                throw new RuntimeException( "Error encrypting password for user: " + fullAddress );
            }
            userConfModified = true;
        }
        user.setPassword( password );

        // Load the 'forward' addresses.
        String forwardAddressesString = properties.getProperty( USER_PROPERTY_PREFIX + fullAddress + USER_FILE_FORWARDS );
        String[] forwardAddresses = new String[0];
        if( forwardAddressesString != null && forwardAddressesString.trim().length() >= 0 )
        {
            forwardAddresses = tokenize( forwardAddressesString );
        }
        ArrayList addressList = new ArrayList( forwardAddresses.length );
        for( int index = 0; index < forwardAddresses.length; index++ ) {
            try {
                addressList.add( new EmailAddress( forwardAddresses[index] ) );
            }
            catch (InvalidAddressException e) {
                log.warn( "Forward address: " + forwardAddresses[index] + " for user " + user.getFullUsername() + " is invalid and will be ignored." );
            }
        }

        EmailAddress[] emailAddresses = new EmailAddress[ addressList.size() ];
        emailAddresses = (EmailAddress[]) addressList.toArray( emailAddresses );

        if( log.isDebugEnabled() ) log.debug( emailAddresses.length + " forward addresses load for user: " + user.getFullUsername() );
        user.setForwardAddresses( emailAddresses );

        return user;
    }
View Full Code Here

TOP

Related Classes of com.ericdaugherty.mail.server.info.User

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.