Search in sources :

Example 16 with ImapConnection

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

the class ImapProxy method writeRequest.

private ImapConnection writeRequest(final byte[] payload) throws ImapProxyException {
    ImapConnection conn = connection;
    if (conn == null) {
        throw new ImapProxyException("proxy connection already closed");
    }
    // proxy the request over to the remote server
    OutputStream remote = conn.getOutputStream();
    if (remote == null) {
        dropConnection();
        throw new ImapProxyException("proxy connection already closed");
    }
    try {
        remote.write(payload);
        remote.flush();
    } catch (IOException e) {
        throw new ImapProxyException(e);
    }
    return conn;
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection)

Example 17 with ImapConnection

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

the class TestImapClient method testYahoo.

@Ignore("deprecated")
public void testYahoo() throws Exception {
    ImapConfig config = new ImapConfig();
    config.getLogger().setLevel(Log.Level.trace);
    config.setHost("imap.mail.yahoo.com");
    config.setAuthenticationId("dacztest");
    connection = new ImapConnection(config);
    connection.connect();
    IDInfo id = new IDInfo();
    id.put("guid", "unknown");
    connection.id(id);
    connection.login("test1234");
    char delim = connection.getDelimiter();
    assertEquals(0, delim);
    createTestMailbox("Large", 10000);
}
Also used : ImapConfig(com.zimbra.cs.mailclient.imap.ImapConfig) IDInfo(com.zimbra.cs.mailclient.imap.IDInfo) ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection) Ignore(org.junit.Ignore)

Example 18 with ImapConnection

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

the class TestImapClient method connect.

private void connect(MailConfig.Security security) throws IOException {
    if (config == null) {
        config = getConfig(security);
    }
    System.out.println("---------");
    connection = new ImapConnection(config);
    connection.connect();
}
Also used : ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection)

Example 19 with ImapConnection

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

the class TestImapViaImapDaemon method testZimbraCommandsNonAdminUser.

@Test
public void testZimbraCommandsNonAdminUser() throws Exception {
    Account acct = TestUtil.getAccount(USER);
    AuthenticatorFactory authFactory = new AuthenticatorFactory();
    authFactory.register(ZimbraAuthenticator.MECHANISM, ZimbraClientAuthenticator.class);
    ImapConfig config = new ImapConfig(imapHostname);
    config.setMechanism(ZimbraAuthenticator.MECHANISM);
    config.setAuthenticatorFactory(authFactory);
    config.setPort(imapPort);
    config.setAuthenticationId(acct.getName());
    config.getLogger().setLevel(Log.Level.trace);
    ImapConnection conn = new ImapConnection(config);
    conn.connect();
    conn.authenticate(AuthProvider.getAuthToken(acct).getEncoded());
    try {
        conn.reloadLocalConfig();
        fail("should not be able to run X-ZIMBRA-RELOADLC command with a non-admin auth token");
    } catch (CommandFailedException cfe) {
        assertEquals("must be authenticated as admin with X-ZIMBRA auth mechanism", cfe.getError());
    }
    try {
        conn.flushCache("all");
        fail("should not be able to run X-ZIMBRA-FLUSHCACHE command with a non-admin auth token");
    } catch (CommandFailedException cfe) {
        assertEquals("must be authenticated as admin with X-ZIMBRA auth mechanism", cfe.getError());
    }
}
Also used : Account(com.zimbra.cs.account.Account) ImapConfig(com.zimbra.cs.mailclient.imap.ImapConfig) AuthenticatorFactory(com.zimbra.cs.mailclient.auth.AuthenticatorFactory) ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection) CommandFailedException(com.zimbra.cs.mailclient.CommandFailedException) Test(org.junit.Test)

Example 20 with ImapConnection

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

the class TestImapThrottle method connect.

private ImapConnection connect() throws IOException {
    ImapConfig config = new ImapConfig(HOST);
    config.setPort(PORT);
    config.setAuthenticationId(USER);
    config.getLogger().setLevel(Log.Level.trace);
    ImapConnection connection = new ImapConnection(config);
    connection.connect();
    connection.login(PASS);
    connection.select("INBOX");
    return connection;
}
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