// start authentication
// TODO: very dirty, must be replaced by Spring Security stuff
ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext( SessionManager
.getRequest().getSession().getServletContext() );
MailboxFactory factory = context.getBean( MailboxFactory.class );
IMailbox mailbox = factory.createMailbox( IMailbox.TYPE_IMAP );
mailbox.init( username, new String( password ) );
log.debug( "Start login..." );
mailbox.login();
log.debug( "Login successful" );