Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Custom Exchange services

Vladislav Bauer edited this page Apr 6, 2015 · 2 revisions

Customization

It is possible to customize some parts of Exchange services (ExchangeServiceBase, AutodiscoverService and ExchangeService). You need to extend custom class to do it.

Override hostname verifier for SSL connections

An example below shows how to switch off hostname verification:

public class CustomExchangeService extends ExchangeService {

  @Override
  protected Registry<ConnectionSocketFactory> createConnectionSocketFactoryRegistry() {
    try {
      return RegistryBuilder.<ConnectionSocketFactory>create()
          .register(EWSConstants.HTTP_SCHEME, new PlainConnectionSocketFactory())
          .register(EWSConstants.HTTPS_SCHEME, EwsSSLProtocolSocketFactory.build(
              null, NoopHostnameVerifier.INSTANCE
          ))
          .build();
    } catch (GeneralSecurityException e) {
      throw new RuntimeException(
          "Could not initialize ConnectionSocketFactory instances for HttpClientConnectionManager", e
      );
    }
  }

}