Search in sources :

Example 1 with IDInfo

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

the class ImapProxy method createIDInfo.

private IDInfo createIDInfo(ImapHandler handler) {
    IDInfo id = new IDInfo();
    id.put(IDInfo.NAME, "ZCS");
    id.put(IDInfo.VERSION, BuildInfo.VERSION);
    id.put(IDInfo.X_VIA, handler.getNextVia());
    if (handler.getOrigRemoteIp() != null) {
        id.put(IDInfo.X_ORIGINATING_IP, handler.getOrigRemoteIp());
    }
    return id;
}
Also used : IDInfo(com.zimbra.cs.mailclient.imap.IDInfo)

Example 2 with IDInfo

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

the class TestRemoteImapMultiServer method testAuthenticateAsProxyToHomeHost.

@Test
public void testAuthenticateAsProxyToHomeHost() throws IOException, LoginException, AuthProviderException, AuthTokenException {
    connection = connectAsProxy(homeServer);
    IDInfo id = new IDInfo();
    id.put(IDInfo.NAME, "ZCS");
    id.put(IDInfo.VERSION, BuildInfo.VERSION);
    connection.id(id);
    connection.authenticate(AuthProvider.getAuthToken(acc).getEncoded());
    assertTrue("IMAP connection is not authenticated", connection.isAuthenticated());
}
Also used : IDInfo(com.zimbra.cs.mailclient.imap.IDInfo) Test(org.junit.Test)

Example 3 with IDInfo

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

the class ConnectionManager method isImportingSelf.

private static boolean isImportingSelf(DataSource ds, ImapConnection ic) throws IOException, ServiceException {
    if (!ds.isOffline() && ic.hasCapability(ImapCapabilities.ID)) {
        try {
            IDInfo clientId = new IDInfo();
            clientId.put(IDInfo.NAME, IDInfo.DATASOURCE_IMAP_CLIENT_NAME);
            clientId.put(IDInfo.VERSION, BuildInfo.VERSION);
            IDInfo id = ic.id(clientId);
            if ("Zimbra".equalsIgnoreCase(id.get(IDInfo.NAME)) && ds.getAccount() != null) {
                String user = id.get("user");
                String server = id.get("server");
                return user != null && user.equals(ds.getAccount().getName()) && server != null && server.equals(Provisioning.getInstance().getLocalServer().getId());
            }
        } catch (CommandFailedException e) {
            // Skip check if ID command fails
            LOG.warn("ID command failed, assuming not importing self", e);
        }
    }
    return false;
}
Also used : IDInfo(com.zimbra.cs.mailclient.imap.IDInfo) CommandFailedException(com.zimbra.cs.mailclient.CommandFailedException)

Example 4 with IDInfo

use of com.zimbra.cs.mailclient.imap.IDInfo 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 5 with IDInfo

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

the class TestImapClient method testID.

@Test
public void testID() throws Exception {
    IDInfo id = new IDInfo();
    id.put(IDInfo.NAME, "foo");
    assertEquals("foo", id.get(IDInfo.NAME));
    assertEquals("foo", id.get("Name"));
    connect();
    IDInfo id1 = connection.id(id);
    assertNotNull(id1);
    assertEquals("Zimbra", id1.get(IDInfo.NAME));
    IDInfo id2 = connection.id(new IDInfo());
    assertEquals(id1.get(IDInfo.NAME), id2.get(IDInfo.NAME));
    assertEquals(id1.get(IDInfo.VERSION), id2.get(IDInfo.VERSION));
}
Also used : IDInfo(com.zimbra.cs.mailclient.imap.IDInfo) Test(org.junit.Test)

Aggregations

IDInfo (com.zimbra.cs.mailclient.imap.IDInfo)6 Test (org.junit.Test)3 CommandFailedException (com.zimbra.cs.mailclient.CommandFailedException)1 ImapConfig (com.zimbra.cs.mailclient.imap.ImapConfig)1 ImapConnection (com.zimbra.cs.mailclient.imap.ImapConnection)1 Ignore (org.junit.Ignore)1