Search in sources :

Example 21 with ImapConnection

use of com.zimbra.cs.mailclient.imap.ImapConnection in project zm-mailbox by Zimbra.

the class TestImapSync method connect.

private void connect() throws IOException {
    imapConnection = new ImapConnection(config);
    imapConnection.connect();
    imapConnection.login(pass);
}
Also used : ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection)

Example 22 with ImapConnection

use of com.zimbra.cs.mailclient.imap.ImapConnection in project zm-mailbox by Zimbra.

the class ReloadLocalConfig method reloadImapDaemonLC.

private void reloadImapDaemonLC(Server server) {
    ImapConnection connection = null;
    try {
        connection = ImapConnection.getZimbraConnection(server, LC.zimbra_ldap_user.value(), AuthProvider.getAdminAuthToken());
    } catch (ServiceException e) {
        ZimbraLog.imap.warn("unable to connect to IMAP server '%s'", server.getServiceHostname(), e);
        return;
    }
    try {
        ZimbraLog.imap.debug("issuing RELOADLC request to imapd server '%s'", server.getServiceHostname());
        connection.reloadLocalConfig();
    } catch (IOException e) {
        ZimbraLog.imap.warn("unable to issue RELOADLC request to IMAP server '%s'", server.getServiceHostname(), e);
    } finally {
        connection.close();
    }
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) IOException(java.io.IOException) ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection)

Example 23 with ImapConnection

use of com.zimbra.cs.mailclient.imap.ImapConnection in project zm-mailbox by Zimbra.

the class ImapTestBase method connectAndSelectInbox.

protected ImapConnection connectAndSelectInbox(String user) throws IOException {
    ImapConnection imapConn = connectAndLogin(user);
    imapConn.select("INBOX");
    return imapConn;
}
Also used : ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection)

Example 24 with ImapConnection

use of com.zimbra.cs.mailclient.imap.ImapConnection in project zm-mailbox by Zimbra.

the class ImapTestBase method getAdminConnection.

protected ImapConnection getAdminConnection() throws Exception {
    AuthenticatorFactory authFactory = new AuthenticatorFactory();
    authFactory.register(ZimbraAuthenticator.MECHANISM, ZimbraClientAuthenticator.class);
    ImapConfig config = new ImapConfig(imapServer.getServiceHostname());
    config.setMechanism(ZimbraAuthenticator.MECHANISM);
    config.setAuthenticatorFactory(authFactory);
    config.setPort(imapPort);
    config.setAuthenticationId(LC.zimbra_ldap_user.value());
    config.getLogger().setLevel(Log.Level.trace);
    ImapConnection conn = new ImapConnection(config);
    conn.connect();
    conn.authenticate(AuthProvider.getAdminAuthToken().getEncoded());
    return conn;
}
Also used : ImapConfig(com.zimbra.cs.mailclient.imap.ImapConfig) AuthenticatorFactory(com.zimbra.cs.mailclient.auth.AuthenticatorFactory) ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection)

Example 25 with ImapConnection

use of com.zimbra.cs.mailclient.imap.ImapConnection in project zm-mailbox by Zimbra.

the class ImapTestBase method connect.

protected ImapConnection connect(String user) throws IOException {
    ImapConfig config = new ImapConfig(imapHostname);
    config.setPort(imapPort);
    config.setAuthenticationId(user);
    config.getLogger().setLevel(Log.Level.trace);
    ImapConnection conn = new ImapConnection(config);
    conn.connect();
    return conn;
}
Also used : ImapConfig(com.zimbra.cs.mailclient.imap.ImapConfig) ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection)

Aggregations

ImapConnection (com.zimbra.cs.mailclient.imap.ImapConnection)27 ImapConfig (com.zimbra.cs.mailclient.imap.ImapConfig)11 IOException (java.io.IOException)7 CommandFailedException (com.zimbra.cs.mailclient.CommandFailedException)5 ServiceException (com.zimbra.common.service.ServiceException)4 Test (org.junit.Test)4 Account (com.zimbra.cs.account.Account)2 AuthenticatorFactory (com.zimbra.cs.mailclient.auth.AuthenticatorFactory)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 Ignore (org.junit.Ignore)2 LocalConfig (com.zimbra.common.localconfig.LocalConfig)1 RemoteServiceException (com.zimbra.common.service.RemoteServiceException)1 ZMimeMessage (com.zimbra.common.zmime.ZMimeMessage)1 AccountServiceException (com.zimbra.cs.account.AccountServiceException)1 CacheEntry (com.zimbra.cs.account.Provisioning.CacheEntry)1 ImapAppender (com.zimbra.cs.datasource.imap.ImapAppender)1 PurgedConversation (com.zimbra.cs.db.DbDataSource.PurgedConversation)1 PurgedMessage (com.zimbra.cs.db.DbDataSource.PurgedMessage)1 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)1