@Override protected Mailbox auth(POP3Session session, String username, String password) throws Exception { MailboxSession mSession = null; try { mSession = manager.login(session.getUser(), password); manager.startProcessingRequest(mSession); MailboxPath inbox = MailboxPath.inbox(mSession); // check if the mailbox exists, if not create it if (!manager.mailboxExists(inbox, mSession)) { Optional<MailboxId> mailboxId = manager.createMailbox(inbox, mSession); LOGGER.info("Provisioning INBOX. {} created.", mailboxId); } MessageManager mailbox = manager.getMailbox(MailboxPath.inbox(mSession), mSession); return new MailboxAdapter(manager, mailbox, mSession); } catch (BadCredentialsException e) { return null; } catch (MailboxException e) { throw new IOException("Unable to access mailbox for user " + session.getUser(), e); } finally { if (mSession != null) { manager.endProcessingRequest(mSession); } } }
protected void doAuth(AuthenticationAttempt authenticationAttempt, ImapSession session, String tag, ImapCommand command, Responder responder, HumanReadableText failed) { Preconditions.checkArgument(!authenticationAttempt.isDelegation()); try { boolean authFailure = false; if (authenticationAttempt.getAuthenticationId() == null) { authFailure = true; } if (!authFailure) { final MailboxManager mailboxManager = getMailboxManager(); try { final MailboxSession mailboxSession = mailboxManager.login(authenticationAttempt.getAuthenticationId(), authenticationAttempt.getPassword()); session.authenticated(); session.setAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY, mailboxSession); provisionInbox(session, mailboxManager, mailboxSession); okComplete(command, tag, responder); } catch (BadCredentialsException e) { authFailure = true; } } if (authFailure) { manageFailureCount(session, tag, command, responder, failed); } } catch (MailboxException e) { LOGGER.error("Error encountered while login", e); no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING); } }
final MailboxManager mailboxManager = getMailboxManager(); try { final MailboxSession mailboxSession = mailboxManager.login(userid, passwd, session.getLog()); session.authenticated(); session.setAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY, mailboxSession);
@Before public void setup() throws Exception { InMemoryIntegrationResources inMemoryIntegrationResources = new InMemoryIntegrationResources(); mailboxManager = inMemoryIntegrationResources.createMailboxManager(inMemoryIntegrationResources.createGroupMembershipResolver()); user = "user@domain.org"; mailboxSession = mailboxManager.login(user, "pass"); sut = new MailboxUtils(mailboxManager); }
String passArg = parameters; try { MailboxSession mSession = mailboxManager.login(session.getUser(), passArg, session.getLogger());
public ManagerTestResources(IntegrationResources<T> integrationResources) throws Exception { this.integrationResources = integrationResources; groupMembershipResolver = integrationResources.createGroupMembershipResolver(); mailboxManager = integrationResources.createMailboxManager(groupMembershipResolver); maxQuotaManager = integrationResources.retrieveMaxQuotaManager(mailboxManager); quotaRootResolver = integrationResources.retrieveQuotaRootResolver(mailboxManager); quotaManager = integrationResources.retrieveQuotaManager(mailboxManager); integrationResources.init(); session = mailboxManager.login(USER, USER_PASS); inbox = MailboxPath.inbox(session); subFolder = new MailboxPath(inbox, "INBOX.SUB"); maxQuotaManager.setGlobalMaxMessage(QuotaCount.count(1000)); maxQuotaManager.setGlobalMaxStorage(QuotaSize.size(1000000)); }