+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 000000000..79ee123c2
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_mockito_mockito_all_1_9_5.xml b/.idea/libraries/Maven__org_mockito_mockito_all_1_9_5.xml
new file mode 100644
index 000000000..7797878d7
--- /dev/null
+++ b/.idea/libraries/Maven__org_mockito_mockito_all_1_9_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index d1297649f..d13de0674 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,6 +3,7 @@
+
diff --git a/ews-java-api.iml b/ews-java-api.iml
index e555cc0d3..7b784e779 100644
--- a/ews-java-api.iml
+++ b/ews-java-api.iml
@@ -1,6 +1,6 @@
-
+
diff --git a/pom.xml b/pom.xml
index 45990c479..8ffad0588 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
com.microsoft.ews-java-apiews-java-api
- 2.0-SNAPSHOT
+ 2.0-eveoh22Exchange Web Services Java APIExchange Web Services (EWS) Java API
@@ -99,14 +99,16 @@
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
- ossrh
- https://oss.sonatype.org/service/local/staging/deploy/maven2
+ eveoh
+ Eveoh Releases
+ https://maven.eveoh.nl/content/repositories/releases/
+
+ eveoh
+ Eveoh Snapshots
+ https://maven.eveoh.nl/content/repositories/snapshots/
+
@@ -158,17 +160,6 @@
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.5
- true
-
-
- true
-
- org.apache.maven.pluginsmaven-compiler-plugin
@@ -179,23 +170,6 @@
${javaLanguage.version}
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.10.1
-
- true
- ${javadoc.doclint.param}
-
-
-
- attach-javadocs
-
- jar
-
-
-
- org.apache.maven.pluginsmaven-source-plugin
diff --git a/src/main/java/microsoft/exchange/webservices/data/AutodiscoverService.java b/src/main/java/microsoft/exchange/webservices/data/AutodiscoverService.java
index f97c958ec..4219b88bd 100644
--- a/src/main/java/microsoft/exchange/webservices/data/AutodiscoverService.java
+++ b/src/main/java/microsoft/exchange/webservices/data/AutodiscoverService.java
@@ -23,35 +23,31 @@
package microsoft.exchange.webservices.data;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import javax.xml.stream.XMLStreamException;
-import java.io.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
/**
* Represents a binding to the Exchange Autodiscover Service.
*/
-public final class AutodiscoverService extends ExchangeServiceBase implements
- IAutodiscoverRedirectionUrl, IFunctionDelegate {
-
- private static final Log log = LogFactory.getLog(AutodiscoverService.class);
+public final class AutodiscoverService extends ExchangeServiceBase {
- // region Private members
/**
* The domain.
*/
private String domain;
- /**
- * The is external.
- */
- private Boolean isExternal = true;
-
/**
* The url.
*/
@@ -74,120 +70,66 @@ public final class AutodiscoverService extends ExchangeServiceBase implements
private String dnsServerAddress;
/**
- * The enable scp lookup.
- */
- private boolean enableScpLookup = true;
-
- // Autodiscover legacy path
- /**
- * The Constant AutodiscoverLegacyPath.
+ * Autodiscover legacy path
*/
private static final String AutodiscoverLegacyPath =
"/autodiscover/autodiscover.xml";
- // Autodiscover legacy HTTPS Url
/**
- * The Constant AutodiscoverLegacyHttpsUrl.
+ * Autodiscover legacy HTTPS Url
*/
private static final String AutodiscoverLegacyHttpsUrl = "https://%s" +
AutodiscoverLegacyPath;
- // Autodiscover legacy HTTP Url
+
/**
- * The Constant AutodiscoverLegacyHttpUrl.
+ * Autodiscover legacy HTTP Url
*/
private static final String AutodiscoverLegacyHttpUrl = "http://%s" +
AutodiscoverLegacyPath;
- // Autodiscover SOAP HTTPS Url
+
/**
- * The Constant AutodiscoverSoapHttpsUrl.
+ * Autodiscover SOAP HTTPS Url
*/
private static final String AutodiscoverSoapHttpsUrl =
"https://%s/autodiscover/autodiscover.svc";
- // Autodiscover SOAP WS-Security HTTPS Url
- /**
- * The Constant AutodiscoverSoapWsSecurityHttpsUrl.
- */
- private static final String AutodiscoverSoapWsSecurityHttpsUrl =
- AutodiscoverSoapHttpsUrl +
- "/wssecurity";
/**
- * Autodiscover SOAP WS-Security symmetrickey HTTPS Url
- */
- private static final String AutodiscoverSoapWsSecuritySymmetricKeyHttpsUrl =
- AutodiscoverSoapHttpsUrl + "/wssecurity/symmetrickey";
-
- /**
- * Autodiscover SOAP WS-Security x509cert HTTPS Url
- */
- private static final String AutodiscoverSoapWsSecurityX509CertHttpsUrl =
- AutodiscoverSoapHttpsUrl + "/wssecurity/x509cert";
-
-
- // Autodiscover request namespace
- /**
- * The Constant AutodiscoverRequestNamespace.
+ * Autodiscover request namespace
*/
private static final String AutodiscoverRequestNamespace =
"http://schemas.microsoft.com/exchange/autodiscover/" +
"outlook/requestschema/2006";
- // Maximum number of Url (or address) redirections that will be followed by
- // an Autodiscover call
+
/**
- * The Constant AutodiscoverMaxRedirections.
+ * Maximum number of Url (or address) redirections that will be followed by an Autodiscover call
*/
- protected static final int AutodiscoverMaxRedirections = 10;
- // HTTP header indicating that SOAP Autodiscover service is enabled.
+ private static final int AutodiscoverMaxRedirections = 10;
+
/**
- * The Constant AutodiscoverSoapEnabledHeaderName.
+ * HTTP header indicating that SOAP Autodiscover service is enabled.
*/
private static final String AutodiscoverSoapEnabledHeaderName =
"X-SOAP-Enabled";
- // HTTP header indicating that WS-Security Autodiscover service is enabled.
+
/**
- * The Constant AutodiscoverWsSecurityEnabledHeaderName.
+ * HTTP header indicating that WS-Security Autodiscover service is enabled.
*/
private static final String AutodiscoverWsSecurityEnabledHeaderName =
"X-WSSecurity-Enabled";
-
- /**
- * HTTP header indicating that WS-Security/SymmetricKey Autodiscover service is enabled.
- */
-
- private static final String AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName =
- "X-WSSecurity-SymmetricKey-Enabled";
-
-
/**
- * HTTP header indicating that WS-Security/X509Cert Autodiscover service is enabled.
- */
-
- private static final String AutodiscoverWsSecurityX509CertEnabledHeaderName =
- "X-WSSecurity-X509Cert-Enabled";
-
-
- // Minimum request version for Autodiscover SOAP service.
- /**
- * The Constant MinimumRequestVersionForAutoDiscoverSoapService.
+ * Minimum request version for Autodiscover SOAP service.
*/
private static final ExchangeVersion
MinimumRequestVersionForAutoDiscoverSoapService =
ExchangeVersion.Exchange2010;
/**
- * Default implementation of AutodiscoverRedirectionUrlValidationCallback.
- * Always returns true indicating that the URL can be used.
- *
- * @param redirectionUrl the redirection url
- * @return Returns true.
- * @throws AutodiscoverLocalException the autodiscover local exception
+ * Hardcoded O365 vars, as O365 discovery is borked
*/
- private boolean defaultAutodiscoverRedirectionUrlValidationCallback(
- String redirectionUrl) throws AutodiscoverLocalException {
- throw new AutodiscoverLocalException(String.format(
- Strings.AutodiscoverRedirectBlocked, redirectionUrl));
- }
+ private static final String o365AutodiscoverHost = "autodiscover-s.outlook.com";
+
+ private static final String o365EwsUrl = "https://outlook.office365.com/EWS/Exchange.asmx";
// Legacy Autodiscover
@@ -221,37 +163,15 @@ TSettings getLegacyUserSettingsAtUrl(
this.traceHttpRequestHeaders(
TraceFlags.AutodiscoverRequestHttpHeaders,
request);
- // OutputStreamWriter out = new
- // OutputStreamWriter(request.getOutputStream());
OutputStream urlOutStream = request.getOutputStream();
- // If tracing is enabled, we generate the request in-memory so that we
- // can pass it along to the ITraceListener. Then we copy the stream to
- // the request stream.
- if (this.isTraceEnabledFor(TraceFlags.AutodiscoverRequest)) {
- ByteArrayOutputStream memoryStream = new ByteArrayOutputStream();
-
- PrintWriter writer = new PrintWriter(memoryStream);
- this.writeLegacyAutodiscoverRequest(emailAddress, settings, writer);
- writer.flush();
-
- this.traceXml(TraceFlags.AutodiscoverRequest, memoryStream);
- // out.write(memoryStream.toString());
- // out.close();
- memoryStream.writeTo(urlOutStream);
- urlOutStream.flush();
- urlOutStream.close();
- memoryStream.close();
- } else {
- PrintWriter writer = new PrintWriter(urlOutStream);
- this.writeLegacyAutodiscoverRequest(emailAddress, settings, writer);
-
- /* Flush Start */
- writer.flush();
- urlOutStream.flush();
- urlOutStream.close();
- /* Flush End */
- }
+ PrintWriter writer = new PrintWriter(urlOutStream);
+ this.writeLegacyAutodiscoverRequest(emailAddress, settings, writer);
+
+ writer.flush();
+ urlOutStream.flush();
+ urlOutStream.close();
+
request.executeRequest();
request.getResponseCode();
URI redirectUrl;
@@ -262,44 +182,17 @@ TSettings getLegacyUserSettingsAtUrl(
return settings;
}
InputStream serviceResponseStream = request.getInputStream();
- // If tracing is enabled, we read the entire response into a
- // MemoryStream so that we
- // can pass it along to the ITraceListener. Then we parse the response
- // from the
- // MemoryStream.
- if (this.isTraceEnabledFor(TraceFlags.AutodiscoverResponse)) {
- ByteArrayOutputStream memoryStream = new ByteArrayOutputStream();
-
- while (true) {
- int data = serviceResponseStream.read();
- if (-1 == data) {
- break;
- } else {
- memoryStream.write(data);
- }
- }
- memoryStream.flush();
- this.traceResponse(request, memoryStream);
- ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream(
- memoryStream.toByteArray());
- EwsXmlReader reader = new EwsXmlReader(memoryStreamIn);
- reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT));
- settings.loadFromXml(reader);
-
- } else {
- EwsXmlReader reader = new EwsXmlReader(serviceResponseStream);
- reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT));
- settings.loadFromXml(reader);
- }
+ EwsXmlReader reader = new EwsXmlReader(serviceResponseStream);
+ reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT));
+ settings.loadFromXml(reader);
serviceResponseStream.close();
} finally {
if (request != null) {
try {
request.close();
- } catch (Exception e2) {
- // Ignore exceptions while closing the request.
+ } catch (Exception ignored) {
}
}
}
@@ -316,8 +209,7 @@ TSettings getLegacyUserSettingsAtUrl(
* @throws java.io.IOException Signals that an I/O exception has occurred.
*/
private void writeLegacyAutodiscoverRequest(String emailAddress,
- ConfigurationSettingsBase settings, PrintWriter writer)
- throws IOException {
+ ConfigurationSettingsBase settings, PrintWriter writer) {
writer.write(String.format("",
AutodiscoverRequestNamespace));
writer.write("");
@@ -352,7 +244,7 @@ private URI getRedirectUrl(String domainName)
HttpWebRequest request = null;
try {
- request = new HttpClientWebRequest(httpClient, httpContext);
+ request = new HttpClientWebRequest(getHttpClient(), httpContext);
try {
request.setUrl(URI.create(url).toURL());
@@ -363,6 +255,7 @@ private URI getRedirectUrl(String domainName)
request.setRequestMethod("GET");
request.setAllowAutoRedirect(false);
+ request.setTimeout(timeout);
// Do NOT allow authentication as this single request will be made over plain HTTP.
request.setAllowAuthentication(false);
@@ -385,8 +278,7 @@ private URI getRedirectUrl(String domainName)
if (request != null) {
try {
request.close();
- } catch (Exception e) {
- // Ignore exceptions when closing the request
+ } catch (Exception ignored) {
}
}
}
@@ -408,12 +300,11 @@ private URI getRedirectUrl(String domainName)
private boolean tryGetRedirectionResponse(HttpWebRequest request,
OutParam redirectUrl) throws XMLStreamException, IOException,
EWSHttpException {
- // redirectUrl = null;
if (AutodiscoverRequest.isRedirectionResponse(request)) {
// Get the redirect location and verify that it's valid.
String location = request.getResponseHeaderField("Location");
- if (!(location == null || location.isEmpty())) {
+ if (location != null && !location.isEmpty()) {
try {
redirectUrl.setParam(new URI(location));
@@ -454,13 +345,8 @@ private boolean tryGetRedirectionResponse(HttpWebRequest request,
* @return The requested configuration settings.
* @throws Exception the exception
*/
- protected
- TSettings getLegacyUserSettings(
- Class cls, String emailAddress) throws Exception {
- /*int currentHop = 1;
- return this.internalGetConfigurationSettings(cls, emailAddress,
- currentHop);*/
-
+ private
+ TSettings getLegacyUserSettings(Class cls, String emailAddress) throws Exception {
// If Url is specified, call service directly.
if (this.url != null) {
// this.Uri is intended for Autodiscover SOAP service, convert to Legacy endpoint URL.
@@ -469,22 +355,16 @@ TSettings getLegacyUserSettings(
}
// If Domain is specified, figure out the endpoint Url and call service.
- else if (!(this.domain == null || this.domain.isEmpty())) {
+ else if (this.domain != null && !this.domain.isEmpty()) {
URI autodiscoverUrl = new URI(String.format(AutodiscoverLegacyHttpsUrl, this.domain));
return this.getLegacyUserSettingsAtUrl(cls,
emailAddress, autodiscoverUrl);
} else {
- // No Url or Domain specified, need to
- //figure out which endpoint to use.
+ // No Url or Domain specified, need to figure out which endpoint to use.
int currentHop = 1;
OutParam outParam = new OutParam();
outParam.setParam(currentHop);
- List redirectionEmailAddresses = new ArrayList();
- return this.internalGetLegacyUserSettings(
- cls,
- emailAddress,
- redirectionEmailAddresses,
- outParam);
+ return this.internalGetLegacyUserSettings(cls, emailAddress, outParam);
}
}
@@ -502,36 +382,22 @@ else if (!(this.domain == null || this.domain.isEmpty())) {
TSettings internalGetLegacyUserSettings(
Class cls,
String emailAddress,
- List redirectionEmailAddresses,
OutParam currentHop)
throws Exception {
String domainName = EwsUtilities.domainFromEmailAddress(emailAddress);
- int scpUrlCount;
- OutParam outParamInt = new OutParam();
- List urls = this.getAutodiscoverServiceUrls(domainName, outParamInt);
- scpUrlCount = outParamInt.getParam();
+ List urls = this.getAutodiscoverServiceUrls(domainName);
if (urls.size() == 0) {
throw new ServiceValidationException(
Strings.AutodiscoverServiceRequestRequiresDomainOrUrl);
}
- // Assume caller is not inside the Intranet, regardless of whether SCP
- // Urls
- // were returned or not. SCP Urls are only relevent if one of them
- // returns
- // valid Autodiscover settings.
- this.isExternal = true;
-
int currentUrlIndex = 0;
- // Used to save exception for later reporting.
- Exception delayedException = null;
TSettings settings;
do {
URI autodiscoverUrl = urls.get(currentUrlIndex);
- boolean isScpUrl = currentUrlIndex < scpUrlCount;
try {
settings = this.getLegacyUserSettingsAtUrl(cls,
@@ -539,11 +405,6 @@ TSettings internalGetLegacyUserSettings(
switch (settings.getResponseType()) {
case Success:
- // Not external if Autodiscover endpoint found via SCP
- // returned the settings.
- if (isScpUrl) {
- this.isExternal = false;
- }
this.url = autodiscoverUrl;
return settings;
case RedirectUrl:
@@ -554,15 +415,11 @@ TSettings internalGetLegacyUserSettings(
.traceMessage(
TraceFlags.AutodiscoverResponse,
String
- .format(
- "Autodiscover " +
- "service " +
- "returned " +
- "redirection URL '%s'.",
+ .format("Autodiscover service returned redirection URL '%s'.",
settings
.getRedirectTarget()));
- urls.add(currentUrlIndex, new URI(
+ urls.set(currentUrlIndex, new URI(
settings.getRedirectTarget()));
break;
@@ -576,51 +433,19 @@ TSettings internalGetLegacyUserSettings(
this
.traceMessage(
- TraceFlags.AutodiscoverResponse,
- String
- .format(
- "Autodiscover " +
- "service " +
- "returned " +
- "redirection email " +
- "address '%s'.",
+ TraceFlags.AutodiscoverResponse, String.format(
+ "Autodiscover service returned redirection email address '%s'.",
settings
.getRedirectTarget()));
- // Bug E14:255576 If this email address was already tried, we may have a loop
- // in SCP lookups. Disable consideration of SCP records.
- this.disableScpLookupIfDuplicateRedirection(
- settings.getRedirectTarget(),
- redirectionEmailAddresses);
-
return this.internalGetLegacyUserSettings(cls,
settings.getRedirectTarget(),
- redirectionEmailAddresses,
currentHop);
} else {
throw new AutodiscoverLocalException(
Strings.MaximumRedirectionHopsExceeded);
}
case Error:
- // Don't treat errors from an SCP-based Autodiscover service
- // to be conclusive.
- // We'll try the next one and record the error for later.
- if (isScpUrl) {
- this
- .traceMessage(
- TraceFlags.AutodiscoverConfiguration,
- "Error returned by " +
- "Autodiscover service " +
- "found via SCP, treating " +
- "as inconclusive.");
-
- delayedException = new AutodiscoverRemoteException(
- Strings.AutodiscoverError, settings.getError());
- currentUrlIndex++;
- } else {
- throw new AutodiscoverRemoteException(
- Strings.AutodiscoverError, settings.getError());
- }
- break;
+ throw new AutodiscoverRemoteException(Strings.AutodiscoverError, settings.getError());
default:
EwsUtilities
.EwsAssert(false,
@@ -646,32 +471,12 @@ TSettings internalGetLegacyUserSettings(
// The content at the URL wasn't a valid response, let's try the next.
currentUrlIndex++;
} catch (Exception ex) {
- HttpWebRequest response = null;
- URI redirectUrl;
- OutParam outParam1 = new OutParam();
- if ((response != null) &&
- this.tryGetRedirectionResponse(response, outParam1)) {
- redirectUrl = outParam1.getParam();
- this.traceMessage(TraceFlags.AutodiscoverConfiguration,
- String.format(
- "Host returned a redirection to url %s",
- redirectUrl.toString()));
+ this.traceMessage(TraceFlags.AutodiscoverConfiguration,
+ String.format("%s failed: %s (%s)", url, ex
+ .getClass().getName(), ex.getMessage()));
- currentHop.setParam(currentHop.getParam() + 1);
- urls.add(currentUrlIndex, redirectUrl);
- } else {
- if (response != null) {
- this.processHttpErrorResponse(response, ex);
-
- }
-
- this.traceMessage(TraceFlags.AutodiscoverConfiguration,
- String.format("%s failed: %s (%s)", url, ex
- .getClass().getName(), ex.getMessage()));
-
- // The url did not work, let's try the next.
- currentUrlIndex++;
- }
+ // The url did not work, let's try the next.
+ currentUrlIndex++;
}
} while (currentUrlIndex < urls.size());
@@ -701,11 +506,6 @@ TSettings internalGetLegacyUserSettings(
return outParam.getParam();
}
- // If there was an earlier exception, throw it.
- if (delayedException != null) {
- throw delayedException;
- }
-
throw new AutodiscoverLocalException(Strings.AutodiscoverCouldNotBeLocated);
}
}
@@ -717,7 +517,7 @@ TSettings internalGetLegacyUserSettings(
* @return Autodiscover URL (may be null if lookup failed)
* @throws Exception the exception
*/
- protected URI getRedirectionUrlFromDnsSrvRecord(String domainName)
+ private URI getRedirectionUrlFromDnsSrvRecord(String domainName)
throws Exception {
this
@@ -731,7 +531,7 @@ protected URI getRedirectionUrlFromDnsSrvRecord(String domainName)
String hostname = this.dnsClient
.findAutodiscoverHostFromSrv(domainName);
- if (!(hostname == null || hostname.isEmpty())) {
+ if (hostname != null && !hostname.isEmpty()) {
this
.traceMessage(TraceFlags.AutodiscoverConfiguration,
String.format(
@@ -766,8 +566,6 @@ protected URI getRedirectionUrlFromDnsSrvRecord(String domainName)
Class cls, String emailAddress, URI redirectionUrl,
OutParam settings) throws AutodiscoverLocalException,
AutodiscoverRemoteException, Exception {
- List redirectionEmailAddresses = new ArrayList();
-
// Bug 60274: Performing a non-SSL HTTP GET to retrieve a redirection
// URL is potentially unsafe. We allow the caller
// to specify delegate to be called to determine whether we are allowed
@@ -788,39 +586,22 @@ protected URI getRedirectionUrlFromDnsSrvRecord(String domainName)
Strings.AutodiscoverError, settings.getParam()
.getError());
case RedirectAddress:
- // If this email address was already tried,
- //we may have a loop
- // in SCP lookups. Disable consideration of SCP records.
- this.disableScpLookupIfDuplicateRedirection(settings.getParam().getRedirectTarget(),
- redirectionEmailAddresses);
OutParam outParam = new OutParam();
outParam.setParam(currentHop);
settings.setParam(
this.internalGetLegacyUserSettings(cls,
- emailAddress,
- redirectionEmailAddresses,
+ settings.getParam().getRedirectTarget(),
outParam));
- currentHop = outParam.getParam();
return true;
case RedirectUrl:
try {
redirectionUrl = new URI(settings.getParam()
.getRedirectTarget());
} catch (URISyntaxException ex) {
- this
- .traceMessage(
- TraceFlags.
- AutodiscoverConfiguration,
- String
- .format(
- "Service " +
- "returned " +
- "invalid " +
- "redirection " +
- "URL %s",
- settings
- .getParam()
- .getRedirectTarget()));
+ this.traceMessage(TraceFlags.
+ AutodiscoverConfiguration, String
+ .format("Service returned invalid redirection URL %s",
+ settings.getParam().getRedirectTarget()));
return false;
}
break;
@@ -852,36 +633,13 @@ protected URI getRedirectionUrlFromDnsSrvRecord(String domainName)
redirectionUrl, ex.getMessage()));
return false;
} catch (Exception ex) {
- // TODO: BUG response is always null
- HttpWebRequest response = null;
- OutParam outParam = new OutParam();
- if ((response != null)
- && this.tryGetRedirectionResponse(response,
- outParam)) {
- redirectionUrl = outParam.getParam();
- this
- .traceMessage(
- TraceFlags.AutodiscoverConfiguration,
- String
- .format(
- "Host returned a " +
- "redirection" +
- " to url %s",
- redirectionUrl));
-
- } else {
- if (response != null) {
- this.processHttpErrorResponse(response, ex);
- }
-
- this
- .traceMessage(
- TraceFlags.AutodiscoverConfiguration,
- String.format("%s failed: %s (%s)",
- url, ex.getClass().getName(),
- ex.getMessage()));
- return false;
- }
+ this
+ .traceMessage(
+ TraceFlags.AutodiscoverConfiguration,
+ String.format("%s failed: %s (%s)",
+ url, ex.getClass().getName(),
+ ex.getMessage()));
+ return false;
}
}
}
@@ -889,25 +647,6 @@ protected URI getRedirectionUrlFromDnsSrvRecord(String domainName)
return false;
}
- /**
- * Disables SCP lookup if duplicate email address redirection.
- *
- * @param emailAddress The email address to use.
- * @param redirectionEmailAddresses The list of prior redirection email addresses.
- */
- private void disableScpLookupIfDuplicateRedirection(
- String emailAddress,
- List redirectionEmailAddresses) {
- // SMTP addresses are case-insensitive so entries are converted to lower-case.
- emailAddress = emailAddress.toLowerCase();
-
- if (redirectionEmailAddresses.contains(emailAddress)) {
- this.enableScpLookup = false;
- } else {
- redirectionEmailAddresses.add(emailAddress);
- }
- }
-
/**
* Gets user settings from Autodiscover legacy endpoint.
*
@@ -915,18 +654,10 @@ private void disableScpLookupIfDuplicateRedirection(
* @param requestedSettings The requested settings.
* @return GetUserSettingsResponse
*/
- protected GetUserSettingsResponse internalGetLegacyUserSettings(
- String emailAddress,
+ private GetUserSettingsResponse internalGetLegacyUserSettings(String emailAddress,
List requestedSettings) throws Exception {
- // Cannot call legacy Autodiscover service with WindowsLive credentials
-
- /*if ((this.getCredentials() != null) && (this.getCredentials() instanceof WindowsLiveCredentials)) {
- throw new AutodiscoverLocalException(
- Strings.WLIDCredentialsCannotBeUsedWithLegacyAutodiscover);
- }*/
-
// Cannot call legacy Autodiscover service with WindowsLive and other WSSecurity-based credentials
- if ((this.getCredentials() != null) && (this.getCredentials() instanceof WSSecurityBasedCredentials)) {
+ if (this.getCredentials() instanceof WSSecurityBasedCredentials) {
throw new AutodiscoverLocalException(Strings.WLIDCredentialsCannotBeUsedWithLegacyAutodiscover);
}
@@ -934,8 +665,6 @@ protected GetUserSettingsResponse internalGetLegacyUserSettings(
OutlookConfigurationSettings.class,
emailAddress);
-
-
return settings.convertSettings(emailAddress, requestedSettings);
}
@@ -947,18 +676,14 @@ protected GetUserSettingsResponse internalGetLegacyUserSettings(
* @param requestedSettings The requested settings.
* @return GetUserSettingsResponse
*/
- protected GetUserSettingsResponse internalGetSoapUserSettings(
- String smtpAddress,
+ private GetUserSettingsResponse internalGetSoapUserSettings(String smtpAddress,
List requestedSettings) throws Exception {
List smtpAddresses = new ArrayList();
smtpAddresses.add(smtpAddress);
- List redirectionEmailAddresses = new ArrayList();
- redirectionEmailAddresses.add(smtpAddress.toLowerCase());
-
for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) {
GetUserSettingsResponse response = this.getUserSettings(smtpAddresses,
- requestedSettings).getTResponseAtIndex(0);
+ requestedSettings);
switch (response.getErrorCode()) {
case RedirectAddress:
@@ -972,12 +697,6 @@ protected GetUserSettingsResponse internalGetSoapUserSettings(
toLowerCase());
this.url = null;
this.domain = null;
-
- // If this email address was already tried,
- //we may have a loop
- // in SCP lookups. Disable consideration of SCP records.
- this.disableScpLookupIfDuplicateRedirection(response.getRedirectTarget(),
- redirectionEmailAddresses);
break;
case RedirectUrl:
@@ -986,7 +705,6 @@ protected GetUserSettingsResponse internalGetSoapUserSettings(
String.format("Autodiscover service returned redirection URL '%s'.",
response.getRedirectTarget()));
- //this.url = new URI(response.getRedirectTarget());
this.url = this.getCredentials().adjustUrl(new URI(response.getRedirectTarget()));
break;
@@ -1008,49 +726,26 @@ protected GetUserSettingsResponse internalGetSoapUserSettings(
* @return GetUserSettingsResponseCollection Object.
* @throws Exception the exception
*/
- protected GetUserSettingsResponseCollection getUserSettings(
- final List smtpAddresses, List settings)
+ private GetUserSettingsResponse getUserSettings(final List smtpAddresses,
+ List settings)
throws Exception {
EwsUtilities.validateParam(smtpAddresses, "smtpAddresses");
EwsUtilities.validateParam(settings, "settings");
- return this.getSettings(
- GetUserSettingsResponseCollection.class, UserSettingName.class,
- smtpAddresses, settings, null, this,
- new IFuncDelegate() {
- public String func() throws FormatException {
- return EwsUtilities
- .domainFromEmailAddress(smtpAddresses.get(0));
- }
- });
+ return this.getSettings(smtpAddresses, settings);
}
/**
* Gets user or domain settings using Autodiscover SOAP service.
*
- * @param the generic type
- * @param the generic type
- * @param cls the cls
- * @param cls1 the cls1
* @param identities Either the domains or the SMTP addresses of the users.
* @param settings The settings.
- * @param requestedVersion Requested version of the Exchange service.
- * @param getSettingsMethod The method to use.
- * @param getDomainMethod The method to calculate the domain value.
* @return TGetSettingsResponse Collection.
* @throws Exception the exception
*/
- private
- TGetSettingsResponseCollection getSettings(
- Class cls,
- Class cls1,
- List identities,
- List settings,
- ExchangeVersion requestedVersion,
- IFunctionDelegate, List,
- TGetSettingsResponseCollection> getSettingsMethod,
- IFuncDelegate getDomainMethod) throws Exception {
- TGetSettingsResponseCollection response;
+ private GetUserSettingsResponse getSettings(List identities,
+ List settings) throws Exception {
+ GetUserSettingsResponseCollection response;
// Autodiscover service only exists in E14 or later.
if (this.getRequestedServerVersion().compareTo(
@@ -1063,65 +758,41 @@ TGetSettingsResponseCollection getSettings(
// If Url is specified, call service directly.
if (this.url != null) {
URI autodiscoverUrl = this.url;
- response = getSettingsMethod.func(identities, settings,
- requestedVersion, this.url);
+ response = internalGetUserSettings(identities, settings, this.url);
this.url = autodiscoverUrl;
- return response;
+ return response.getTResponseAtIndex(0);
}
// If Domain is specified, determine endpoint Url and call service.
else if (!(this.domain == null || this.domain.isEmpty())) {
URI autodiscoverUrl = this.getAutodiscoverEndpointUrl(this.domain);
- response = getSettingsMethod.func(identities, settings,
- requestedVersion,
- autodiscoverUrl);
+ response = internalGetUserSettings(identities, settings, autodiscoverUrl);
// If we got this far, response was successful, set Url.
this.url = autodiscoverUrl;
- return response;
+ return response.getTResponseAtIndex(0);
}
// No Url or Domain specified, need to figure out which endpoint(s) to
// try.
else {
- // Assume caller is not inside the Intranet, regardless of whether
- // SCP Urls
- // were returned or not. SCP Urls are only relevent if one of them
- // returns
- // valid Autodiscover settings.
- this.isExternal = true;
-
URI autodiscoverUrl;
- String domainName = getDomainMethod.func();
- int scpHostCount;
- OutParam outParam = new OutParam();
- List hosts = this.getAutodiscoverServiceHosts(domainName,
- outParam);
- scpHostCount = outParam.getParam();
+ String domainName = EwsUtilities.domainFromEmailAddress(identities.get(0));
+ List hosts = this.getAutodiscoverServiceHosts(domainName);
if (hosts.size() == 0) {
throw new ServiceValidationException(
Strings.AutodiscoverServiceRequestRequiresDomainOrUrl);
}
- for (int currentHostIndex = 0; currentHostIndex < hosts.size(); currentHostIndex++) {
- String host = hosts.get(currentHostIndex);
- boolean isScpHost = currentHostIndex < scpHostCount;
+ for (String host : hosts) {
OutParam outParams = new OutParam();
if (this.tryGetAutodiscoverEndpointUrl(host, outParams)) {
autodiscoverUrl = outParams.getParam();
- response = getSettingsMethod.func(identities, settings,
- requestedVersion,
- autodiscoverUrl);
+ response = internalGetUserSettings(identities, settings, autodiscoverUrl);
// If we got this far, the response was successful, set Url.
this.url = autodiscoverUrl;
- // Not external if Autodiscover endpoint found via SCP
- // returned the settings.
- if (isScpHost) {
- this.isExternal = false;
- }
-
- return response;
+ return response.getTResponseAtIndex(0);
}
}
@@ -1136,14 +807,18 @@ else if (!(this.domain == null || this.domain.isEmpty())) {
this.tryGetAutodiscoverEndpointUrl(autodiscoverUrl
.getHost(), outParamUrl)) {
autodiscoverUrl = outParamUrl.getParam();
- response = getSettingsMethod.func(identities, settings,
- requestedVersion,
- autodiscoverUrl);
+
+ // Shortcut for O365, as autodiscover does not always work well there
+ if(autodiscoverUrl.getHost().equals(o365AutodiscoverHost)) {
+ return createO365UserSettingsResponse();
+ }
+
+ response = internalGetUserSettings(identities, settings, autodiscoverUrl);
// If we got this far, the response was successful, set Url.
this.url = autodiscoverUrl;
- return response;
+ return response.getTResponseAtIndex(0);
}
// Last Chance: try to read autodiscover SRV Record from DNS. If we
@@ -1158,14 +833,12 @@ else if (!(this.domain == null || this.domain.isEmpty())) {
this.tryGetAutodiscoverEndpointUrl(autodiscoverUrl
.getHost(), outParamUrl)) {
autodiscoverUrl = outParamUrl.getParam();
- response = getSettingsMethod.func(identities, settings,
- requestedVersion,
- autodiscoverUrl);
+ response = internalGetUserSettings(identities, settings, autodiscoverUrl);
// If we got this far, the response was successful, set Url.
this.url = autodiscoverUrl;
- return response;
+ return response.getTResponseAtIndex(0);
} else {
throw new AutodiscoverLocalException(
Strings.AutodiscoverCouldNotBeLocated);
@@ -1178,22 +851,18 @@ else if (!(this.domain == null || this.domain.isEmpty())) {
*
* @param smtpAddresses The SMTP addresses of the users.
* @param settings The settings.
- * @param requestedVersion Requested version of the Exchange service.
* @param autodiscoverUrl The autodiscover URL.
* @return GetUserSettingsResponse collection.
* @throws ServiceLocalException the service local exception
* @throws Exception the exception
*/
- private GetUserSettingsResponseCollection internalGetUserSettings(
- List smtpAddresses, List settings,
- ExchangeVersion requestedVersion,
- URI autodiscoverUrl) throws ServiceLocalException, Exception {
+ private GetUserSettingsResponseCollection internalGetUserSettings(List smtpAddresses,
+ List settings, URI autodiscoverUrl) throws ServiceLocalException, Exception {
// The response to GetUserSettings can be a redirection. Execute
// GetUserSettings until we get back
// a valid response or we've followed too many redirections.
for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) {
- GetUserSettingsRequest request = new GetUserSettingsRequest(this,
- autodiscoverUrl);
+ GetUserSettingsRequest request = new GetUserSettingsRequest(this, autodiscoverUrl);
request.setSmtpAddresses(smtpAddresses);
request.setSettings(settings);
GetUserSettingsResponseCollection response = request.execute();
@@ -1220,76 +889,6 @@ private GetUserSettingsResponseCollection internalGetUserSettings(
Strings.MaximumRedirectionHopsExceeded);
}
- /**
- * Gets the domain settings using Autodiscover SOAP service.
- *
- * @param domains The domains.
- * @param settings The settings.
- * @param requestedVersion Requested version of the Exchange service.
- * @return GetDomainSettingsResponse collection.
- * @throws Exception the exception
- */
- protected GetDomainSettingsResponseCollection getDomainSettings(
- final List domains, List settings,
- ExchangeVersion requestedVersion)
- throws Exception {
- EwsUtilities.validateParam(domains, "domains");
- EwsUtilities.validateParam(settings, "settings");
-
- return this.getSettings(
- GetDomainSettingsResponseCollection.class,
- DomainSettingName.class, domains, settings,
- requestedVersion, this,
- new IFuncDelegate() {
- public String func() {
- return domains.get(0);
- }
- });
- }
-
- /**
- * Gets settings for one or more domains.
- *
- * @param domains The domains.
- * @param settings The settings.
- * @param requestedVersion Requested version of the Exchange service.
- * @param autodiscoverUrl The autodiscover URL.
- * @return GetDomainSettingsResponse Collection.
- * @throws ServiceLocalException the service local exception
- * @throws Exception the exception
- */
- private GetDomainSettingsResponseCollection internalGetDomainSettings(
- List domains, List settings,
- ExchangeVersion requestedVersion,
- URI autodiscoverUrl) throws ServiceLocalException, Exception {
- // The response to GetDomainSettings can be a redirection. Execute
- // GetDomainSettings until we get back
- // a valid response or we've followed too many redirections.
- for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) {
- GetDomainSettingsRequest request = new GetDomainSettingsRequest(
- this, autodiscoverUrl);
- request.setDomains(domains);
- request.setSettings(settings);
- request.setRequestedVersion(requestedVersion);
- GetDomainSettingsResponseCollection response = request.execute();
-
- // Did we get redirected?
- if (response.getErrorCode() == AutodiscoverErrorCode.RedirectUrl
- && response.getRedirectionUrl() != null) {
- autodiscoverUrl = response.getRedirectionUrl();
- } else {
- return response;
- }
- }
-
- this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format(
- "Maximum number of redirection hops %d exceeded",
- AutodiscoverMaxRedirections));
-
- throw new AutodiscoverLocalException(
- Strings.MaximumRedirectionHopsExceeded);
- }
-
/**
* Gets the autodiscover endpoint URL.
*
@@ -1332,10 +931,7 @@ private boolean tryGetAutodiscoverEndpointUrl(String host,
// available.
if ((!endpoints.contains(AutodiscoverEndpoints.Soap)) &&
(!endpoints.contains(
- AutodiscoverEndpoints.WsSecurity))
- // (endpoints .contains( AutodiscoverEndpoints.WSSecuritySymmetricKey) ) &&
- //(endpoints .contains( AutodiscoverEndpoints.WSSecurityX509Cert))
- ) {
+ AutodiscoverEndpoints.WsSecurity))) {
this
.traceMessage(
TraceFlags.AutodiscoverConfiguration,
@@ -1348,62 +944,7 @@ private boolean tryGetAutodiscoverEndpointUrl(String host,
return false;
}
- // If we have WLID credentials, make sure that we have a WS-Security
- // endpoint
- /*
- if (this.getCredentials() instanceof WindowsLiveCredentials) {
- if (endpoints.contains(AutodiscoverEndpoints.WsSecurity)) {
- this
- .traceMessage(
- TraceFlags.AutodiscoverConfiguration,
- String
- .format(
- "No Autodiscover " +
- "WS-Security " +
- "endpoint is available" +
- " for host %s",
- host));
-
- return false;
- } else {
- url.setParam(new URI(String.format(
- AutodiscoverSoapWsSecurityHttpsUrl, host)));
- }
- }
- else if (this.getCredentials() instanceof PartnerTokenCredentials)
- {
- if (endpoints.contains( AutodiscoverEndpoints.WSSecuritySymmetricKey))
- {
- this.traceMessage(
- TraceFlags.AutodiscoverConfiguration,
- String.format("No Autodiscover WS-Security/SymmetricKey endpoint is available for host {0}", host));
-
- return false;
- }
- else
- {
- url.setParam( new URI(String.format(AutodiscoverSoapWsSecuritySymmetricKeyHttpsUrl, host)));
- }
- }
- else if (this.getCredentials()instanceof X509CertificateCredentials)
- {
- if ((endpoints.contains(AutodiscoverEndpoints.WSSecurityX509Cert))
- {
- this.traceMessage(
- TraceFlags.AutodiscoverConfiguration,
- String.format("No Autodiscover WS-Security/X509Cert endpoint is available for host {0}", host));
-
- return false;
- }
- else
- {
- url.setParam( new URI(String.format(AutodiscoverSoapWsSecurityX509CertHttpsUrl, host)));
- }
- }
- */
return true;
-
-
} else {
this
.traceMessage(
@@ -1422,23 +963,18 @@ else if (this.getCredentials()instanceof X509CertificateCredentials)
* Gets the list of autodiscover service URLs.
*
* @param domainName Domain name.
- * @param scpHostCount Count of hosts found via SCP lookup.
* @return List of Autodiscover URLs.
* @throws java.net.URISyntaxException the URI Syntax exception
*/
- protected List getAutodiscoverServiceUrls(String domainName,
- OutParam scpHostCount) throws URISyntaxException {
- List urls;
-
- urls = new ArrayList();
-
- scpHostCount.setParam(urls.size());
+ private List getAutodiscoverServiceUrls(String domainName)
+ throws URISyntaxException {
+ List urls = new ArrayList();
// As a fallback, add autodiscover URLs base on the domain name.
urls.add(new URI(String.format(AutodiscoverLegacyHttpsUrl,
- domainName)));
+ "autodiscover." + domainName)));
urls.add(new URI(String.format(AutodiscoverLegacyHttpsUrl,
- "autodiscover." + domainName)));
+ domainName)));
return urls;
}
@@ -1447,16 +983,13 @@ protected List getAutodiscoverServiceUrls(String domainName,
* Gets the list of autodiscover service hosts.
*
* @param domainName Domain name.
- * @param outParam the out param
* @return List of hosts.
* @throws java.net.URISyntaxException the uRI syntax exception
* @throws ClassNotFoundException the class not found exception
*/
- protected List getAutodiscoverServiceHosts(String domainName,
- OutParam outParam) throws URISyntaxException,
- ClassNotFoundException {
+ private List getAutodiscoverServiceHosts(String domainName) throws URISyntaxException {
- List urls = this.getAutodiscoverServiceUrls(domainName, outParam);
+ List urls = this.getAutodiscoverServiceUrls(domainName);
List lst = new ArrayList();
for (URI url : urls) {
lst.add(url.getHost());
@@ -1486,7 +1019,7 @@ private boolean tryGetEnabledEndpointsForHost(String host,
HttpWebRequest request = null;
try {
- request = new HttpClientWebRequest(httpClient, httpContext);
+ request = new HttpClientWebRequest(getHttpClient(), httpContext);
try {
request.setUrl(autoDiscoverUrl.toURL());
@@ -1499,6 +1032,7 @@ private boolean tryGetEnabledEndpointsForHost(String host,
request.setAllowAutoRedirect(false);
request.setPreAuthenticate(false);
request.setUseDefaultCredentials(this.getUseDefaultCredentials());
+ request.setTimeout(timeout);
prepareCredentials(request);
@@ -1566,22 +1100,6 @@ private EnumSet getEndpointsFromHttpWebResponse(
AutodiscoverWsSecurityEnabledHeaderName).isEmpty())) {
endpoints.add(AutodiscoverEndpoints.WsSecurity);
}
-
- /* if (! (request.getResponseHeaders().get(
- AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName) !=null || request
- .getResponseHeaders().get(
- AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName).isEmpty()))
- {
- endpoints .add( AutodiscoverEndpoints.WSSecuritySymmetricKey);
- }
- if (!(request.getResponseHeaders().get(
- AutodiscoverWsSecurityX509CertEnabledHeaderName)!=null ||
- request.getResponseHeaders().get(
- AutodiscoverWsSecurityX509CertEnabledHeaderName).isEmpty()))
-
- {
- endpoints .add(AutodiscoverEndpoints.WSSecurityX509Cert);
- }*/
return endpoints;
}
@@ -1595,8 +1113,7 @@ private EnumSet getEndpointsFromHttpWebResponse(
* @throws java.io.IOException Signals that an I/O exception has occurred.
* @throws microsoft.exchange.webservices.data.EWSHttpException the eWS http exception
*/
- protected void traceResponse(HttpWebRequest request,
- ByteArrayOutputStream memoryStream) throws XMLStreamException,
+ void traceResponse(HttpWebRequest request, ByteArrayOutputStream memoryStream) throws XMLStreamException,
IOException, EWSHttpException {
this.processHttpResponseHeaders(
TraceFlags.AutodiscoverResponseHttpHeaders, request);
@@ -1624,11 +1141,9 @@ protected void traceResponse(HttpWebRequest request,
* @throws ServiceLocalException the service local exception
* @throws java.net.URISyntaxException the uRI syntax exception
*/
- protected HttpWebRequest prepareHttpWebRequestForUrl(URI url)
+ HttpWebRequest prepareHttpWebRequestForUrl(URI url)
throws ServiceLocalException, URISyntaxException {
- return this.prepareHttpWebRequestForUrl(url, false,
- // acceptGzipEncoding
- false); // allowAutoRedirect
+ return this.prepareHttpWebRequestForUrl(url, false,false);
}
/**
@@ -1642,11 +1157,11 @@ protected HttpWebRequest prepareHttpWebRequestForUrl(URI url)
*/
private boolean callRedirectionUrlValidationCallback(String redirectionUrl)
throws AutodiscoverLocalException {
- IAutodiscoverRedirectionUrl callback =
- (this.redirectionUrlValidationCallback == null) ? this
- : this.redirectionUrlValidationCallback;
- return callback
- .autodiscoverRedirectionUrlValidationCallback(redirectionUrl);
+ if (this.redirectionUrlValidationCallback != null) {
+ return redirectionUrlValidationCallback.autodiscoverRedirectionUrlValidationCallback(redirectionUrl);
+ }
+
+ return false;
}
/**
@@ -1665,141 +1180,17 @@ protected void processHttpErrorResponse(HttpWebRequest httpWebResponse,
TraceFlags.AutodiscoverResponse);
}
- /*
- * (non-Javadoc)
- *
- * @see microsoft.exchange.webservices.AutodiscoverRedirectionUrlInterface#
- * autodiscoverRedirectionUrlValidationCallback(java.lang.String)
- */
- public boolean autodiscoverRedirectionUrlValidationCallback(
- String redirectionUrl) throws AutodiscoverLocalException {
- return defaultAutodiscoverRedirectionUrlValidationCallback(
- redirectionUrl);
- }
-
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- public AutodiscoverService() throws ArgumentException {
- this(ExchangeVersion.Exchange2010);
- }
-
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @param requestedServerVersion The requested server version.
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- public AutodiscoverService(ExchangeVersion requestedServerVersion)
- throws ArgumentException {
- this(null, null, requestedServerVersion);
- }
-
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @param domain The domain that will be used to determine the URL of the
- * service.
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- public AutodiscoverService(String domain) throws ArgumentException {
- this(null, domain);
- }
-
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @param domain The domain that will be used to determine the URL of the
- * service.
- * @param requestedServerVersion The requested server version.
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- public AutodiscoverService(String domain,
- ExchangeVersion requestedServerVersion) throws ArgumentException {
- this(null, domain, requestedServerVersion);
- }
-
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @param url The URL of the service.
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- public AutodiscoverService(URI url) throws ArgumentException {
- this(url, url.getHost());
- }
-
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @param url The URL of the service.
- * @param requestedServerVersion The requested server version.
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- public AutodiscoverService(URI url,
- ExchangeVersion requestedServerVersion) throws ArgumentException {
- this(url, url.getHost(), requestedServerVersion);
- }
-
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @param url The URL of the service.
- * @param domain The domain that will be used to determine the URL of the
- * service.
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- protected AutodiscoverService(URI url, String domain)
- throws ArgumentException {
- super();
- EwsUtilities.validateDomainNameAllowNull(domain, "domain");
- this.url = url;
- this.domain = domain;
- this.dnsClient = new AutodiscoverDnsClient(this);
- }
-
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @param url The URL of the service.
- * @param domain The domain that will be used to determine the URL of the
- * service.
- * @param requestedServerVersion The requested server version.
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- protected AutodiscoverService(URI url, String domain,
- ExchangeVersion requestedServerVersion) throws ArgumentException {
- super(requestedServerVersion);
- EwsUtilities.validateDomainNameAllowNull(domain, "domain");
-
- this.url = url;
- this.domain = domain;
- this.dnsClient = new AutodiscoverDnsClient(this);
- }
-
/**
* Initializes a new instance of the AutodiscoverService class.
*
* @param service The other service.
* @param requestedServerVersion The requested server version.
*/
- protected AutodiscoverService(ExchangeServiceBase service,
- ExchangeVersion requestedServerVersion) {
+ AutodiscoverService(ExchangeServiceBase service, ExchangeVersion requestedServerVersion) {
super(service, requestedServerVersion);
this.dnsClient = new AutodiscoverDnsClient(this);
}
- /**
- * Initializes a new instance of the "AutodiscoverService" class.
- *
- * @param service The service.
- */
- protected AutodiscoverService(ExchangeServiceBase service) {
- super(service, service.getRequestedServerVersion());
- }
-
/**
* Retrieves the specified settings for single SMTP address.
*
@@ -1812,8 +1203,7 @@ protected AutodiscoverService(ExchangeServiceBase service) {
* This method handles will run the entire Autodiscover "discovery"
* algorithm and will follow address and URL redirections.
*/
- public GetUserSettingsResponse getUserSettings(String userSmtpAddress,
- UserSettingName... userSettingNames) throws Exception {
+ GetUserSettingsResponse getUserSettings(String userSmtpAddress, UserSettingName... userSettingNames) throws Exception {
List requestedSettings = new ArrayList();
requestedSettings.addAll(Arrays.asList(userSettingNames));
@@ -1837,166 +1227,6 @@ public GetUserSettingsResponse getUserSettings(String userSmtpAddress,
}
- /**
- * Retrieves the specified settings for a set of users.
- *
- * @param userSmtpAddresses the user smtp addresses
- * @param userSettingNames The user setting names.
- * @return A GetUserSettingsResponseCollection object containing the
- * responses for each individual user.
- * @throws Exception the exception
- */
- public GetUserSettingsResponseCollection getUsersSettings(
- Iterable userSmtpAddresses,
- UserSettingName... userSettingNames) throws Exception {
- if (this.getRequestedServerVersion().compareTo(MinimumRequestVersionForAutoDiscoverSoapService) < 0) {
- throw new ServiceVersionException(
- String.format(Strings.AutodiscoverServiceIncompatibleWithRequestVersion,
- MinimumRequestVersionForAutoDiscoverSoapService));
- }
- List smtpAddresses = new ArrayList();
- smtpAddresses.addAll((Collection extends String>) userSmtpAddresses);
- List settings = new ArrayList();
- settings.addAll(Arrays.asList(userSettingNames));
- return this.getUserSettings(smtpAddresses, settings);
- }
-
- /**
- * Retrieves the specified settings for a domain.
- *
- * @param domain The domain.
- * @param requestedVersion Requested version of the Exchange service.
- * @param domainSettingNames The domain setting names.
- * @return A DomainResponse object containing the requested settings for the
- * specified domain.
- * @throws Exception the exception
- */
- public GetDomainSettingsResponse getDomainSettings(String domain,
- ExchangeVersion requestedVersion,
- DomainSettingName... domainSettingNames) throws Exception {
- List domains = new ArrayList(1);
- domains.add(domain);
-
- List settings = new ArrayList();
- settings.addAll(Arrays.asList(domainSettingNames));
-
- return this.getDomainSettings(domains, settings, requestedVersion).
- getTResponseAtIndex(0);
- }
-
- /**
- * Retrieves the specified settings for a set of domains.
- *
- * @param domains the domains
- * @param requestedVersion Requested version of the Exchange service.
- * @param domainSettingNames The domain setting names.
- * @return A GetDomainSettingsResponseCollection object containing the
- * responses for each individual domain.
- * @throws Exception the exception
- */
- public GetDomainSettingsResponseCollection getDomainSettings(
- Iterable domains, ExchangeVersion requestedVersion,
- DomainSettingName... domainSettingNames)
- throws Exception {
- List settings = new ArrayList();
- settings.addAll(Arrays.asList(domainSettingNames));
-
- List domainslst = new ArrayList();
- domainslst.addAll((Collection extends String>) domains);
-
- return this.getDomainSettings(domainslst, settings, requestedVersion);
- }
-
- /**
- * Try to get the partner access information for the given target tenant.
- *
- * @param targetTenantDomain The target domain or user email address.
- * @param partnerAccessCredentials The partner access credentials.
- * @param targetTenantAutodiscoverUrl The autodiscover url for the given tenant.
- * @return True if the partner access information was retrieved, false otherwise.
- */
-
- /** commented as the code belongs to Partener Token credentials. */
-
- /* public boolean tryGetPartnerAccess(
- String targetTenantDomain,
- OutParam partnerAccessCredentials,
- OutParam targetTenantAutodiscoverUrl)
- {
- EwsUtilities.validateNonBlankStringParam(targetTenantDomain, "targetTenantDomain");
-
- // the user should set the url to its own tenant's autodiscover url.
- //
- if (this.url == null)
- {
- throw new ServiceValidationException(Strings.PartnerTokenRequestRequiresUrl);
- }
-
- if (this.getRequestedServerVersion().ordinal() < ExchangeVersion.Exchange2010_SP1.ordinal())
- {
- throw new ServiceVersionException(
- String.format(
- Strings.PartnerTokenIncompatibleWithRequestVersion,
- ExchangeVersion.Exchange2010_SP1));
- }
-
- partnerAccessCredentials = null;
- targetTenantAutodiscoverUrl = null;
-
- String smtpAddress = targetTenantDomain;
- if (!smtpAddress.contains("@"))
- {
- smtpAddress = "SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}@" + targetTenantDomain;
- }
-
- List smtpAddresses = new ArrayList();
- smtpAddresses.add(smtpAddress);
- List settings = new ArrayList();
- settings.add(UserSettingName.ExternalEwsUrl);
-
- GetUserSettingsRequest request = new GetUserSettingsRequest(this, this.url, true expectPartnerToken );
- request.setSmtpAddresses(smtpAddresses);
- request.setSettings(settings);
- GetUserSettingsResponseCollection response = request.execute();
-
- if (request.getPartnerToken()!=null && !request.getPartnerToken().isEmpty())
- || request.getPartnerTokenReference()!=null && !request.getPartnerTokenReference().isEmpty() ))
- {
- return false;
- }
-
- if (request.getErrorCode() == AutodiscoverErrorCode.NoError)
- {
- GetUserSettingsResponse firstResponse = request.getResponse(0);
- if (firstResponse.getErrorCode() == AutodiscoverErrorCode.NoError)
- {
- targetTenantAutodiscoverUrl = this.url;
- }
- else if (firstResponse.getErrorCode() == AutodiscoverErrorCode.RedirectUrl)
- {
- targetTenantAutodiscoverUrl = new URI(firstResponse.getRedirectTarget());
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
-
- partnerAccessCredentials = new PartnerTokenCredentials(
- request.getPartnerToken(),
- request.getPartnerTokenReference());
-
- targetTenantAutodiscoverUrl = partnerAccessCredentials.adjustUrl(
- targetTenantAutodiscoverUrl);
-
- return true;
- }
-*/
-
/**
* Gets the domain this service is bound to. When this property is
* set, the domain
@@ -2050,25 +1280,6 @@ public void setUrl(URI value) {
this.url = value;
}
- public Boolean isExternal() {
- return this.isExternal;
- }
-
- protected void setIsExternal(Boolean value) {
- this.isExternal = value;
- }
-
-
- /**
- * Gets the redirection url validation callback.
- *
- * @return the redirection url validation callback
- */
- public IAutodiscoverRedirectionUrl
- getRedirectionUrlValidationCallback() {
- return this.redirectionUrlValidationCallback;
- }
-
/**
* Sets the redirection url validation callback.
*
@@ -2098,42 +1309,15 @@ protected void setDnsServerAddress(String value) {
}
/**
- * Gets a value indicating whether the AutodiscoverService should
- * perform SCP (ServiceConnectionPoint) record lookup when determining
- * the Autodiscover service URL.
- *
- * @return the enable scp lookup
+ * @return Dummy response containing the O365 EWS url.
*/
- public boolean getEnableScpLookup() {
- return this.enableScpLookup;
- }
+ private GetUserSettingsResponse createO365UserSettingsResponse() {
+ GetUserSettingsResponse response = new GetUserSettingsResponse();
- /**
- * Sets the enable scp lookup.
- *
- * @param value the new enable scp lookup
- */
- public void setEnableScpLookup(boolean value) {
- this.enableScpLookup = value;
- }
+ response.setErrorCode(AutodiscoverErrorCode.NoError);
+ response.getSettings().put(UserSettingName.ExternalEwsUrl, o365EwsUrl);
+ response.getSettings().put(UserSettingName.InternalEwsUrl, o365EwsUrl);
- /*
- * (non-Javadoc)
- *
- * @see
- * microsoft.exchange.webservices.FuncDelegateInterface#func(java.util.List,
- * java.util.List, java.net.URI)
- */
- @Override
- public Object func(List arg1, List arg2, ExchangeVersion arg3, URI arg4)
- throws ServiceLocalException, Exception {
- if (arg2.get(0).getClass().equals(DomainSettingName.class)) {
- return internalGetDomainSettings(arg1, arg2, arg3, arg4);
- } else if (arg2.get(0).getClass().equals(UserSettingName.class)) {
- return internalGetUserSettings(arg1, arg2, arg3, arg4);
- } else {
- return null;
- }
+ return response;
}
-
}
diff --git a/src/main/java/microsoft/exchange/webservices/data/EwsSSLProtocolSocketFactory.java b/src/main/java/microsoft/exchange/webservices/data/EwsSSLProtocolSocketFactory.java
deleted file mode 100644
index b81f87d84..000000000
--- a/src/main/java/microsoft/exchange/webservices/data/EwsSSLProtocolSocketFactory.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * The MIT License
- * Copyright (c) 2012 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package microsoft.exchange.webservices.data;
-
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLContexts;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.TrustManager;
-import java.security.KeyManagementException;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-
-/**
- *
- * EwsSSLProtocolSocketFactory can be used to creats SSL {@link java.net.Socket}s
- * that accept self-signed certificates.
- *
- *
- * This socket factory SHOULD NOT be used for productive systems
- * due to security reasons, unless it is a concious decision and
- * you are perfectly aware of security implications of accepting
- * self-signed certificates
- *
- *
- *
- * Example of using custom protocol socket factory for a specific host:
- *
- * Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
- *
- * URI uri = new URI("https://localhost/", true);
- * // use relative url only
- * GetMethod httpget = new GetMethod(uri.getPathQuery());
- * HostConfiguration hc = new HostConfiguration();
- * hc.setHost(uri.getHost(), uri.getPort(), easyhttps);
- * HttpClient client = new HttpClient();
- * client.executeMethod(hc, httpget);
- *
- *
- *
- * Example of using custom protocol socket factory per default instead of the standard one:
- *
- * Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
- * Protocol.registerProtocol("https", easyhttps);
- *
- * HttpClient client = new HttpClient();
- * GetMethod httpget = new GetMethod("https://localhost/");
- * client.executeMethod(httpget);
- *
- *
- *
- *
- * DISCLAIMER: HttpClient developers DO NOT actively support this component.
- * The component is provided as a reference material, which may be inappropriate
- * for use without additional customization.
- *
- */
-
-class EwsSSLProtocolSocketFactory extends SSLConnectionSocketFactory {
-
- /**
- * The SSL Context.
- */
- private SSLContext sslcontext = null;
-
- /**
- * Constructor for EasySSLProtocolSocketFactory.
- *
- * @throws SSLException
- */
- public EwsSSLProtocolSocketFactory(SSLContext context) {
- super(context, SSLConnectionSocketFactory.STRICT_HOSTNAME_VERIFIER);
- this.sslcontext = context;
- }
-
-
-
- public SSLContext getContext() {
- return this.sslcontext;
- }
-
-
-
- public static EwsSSLProtocolSocketFactory build(TrustManager trustManager)
- throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
- SSLContext sslContext = SSLContexts.createDefault();
- sslContext.init(
- null,
- new TrustManager[] {new EwsX509TrustManager(null, trustManager)},
- null
- );
- return new EwsSSLProtocolSocketFactory(sslContext);
- }
-
- public boolean equals(Object obj) {
- return ((obj != null) && obj.getClass().equals(EwsSSLProtocolSocketFactory.class));
- }
-
- public int hashCode() {
- return EwsSSLProtocolSocketFactory.class.hashCode();
- }
-}
diff --git a/src/main/java/microsoft/exchange/webservices/data/EwsX509TrustManager.java b/src/main/java/microsoft/exchange/webservices/data/EwsX509TrustManager.java
deleted file mode 100644
index a0230451a..000000000
--- a/src/main/java/microsoft/exchange/webservices/data/EwsX509TrustManager.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * The MIT License
- * Copyright (c) 2012 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package microsoft.exchange.webservices.data;
-
-/**
- * EwsX509TrustManager is used for SSL handshake.
- *
- */
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-class EwsX509TrustManager implements X509TrustManager {
- /**
- * The Standard TrustManager.
- */
- private X509TrustManager standardTrustManager = null;
-
- /**
- * Constructor for EasyX509TrustManager.
- */
- public EwsX509TrustManager(KeyStore keystore, TrustManager trustManager)
- throws NoSuchAlgorithmException, KeyStoreException {
- super();
- if (trustManager == null) {
- TrustManagerFactory factory =
- TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- factory.init(keystore);
- TrustManager[] trustmanagers = factory.getTrustManagers();
- if (trustmanagers.length == 0) {
- throw new NoSuchAlgorithmException("no trust manager found");
- }
- this.standardTrustManager = (X509TrustManager) trustmanagers[0];
- } else {
- standardTrustManager = (X509TrustManager) trustManager;
- }
- }
-
- /**
- * @see javax.net.ssl.X509TrustManager#checkClientTrusted(java.security.cert.X509Certificate[], String authType)
- */
- public void checkClientTrusted(X509Certificate[] certificates, String authType)
- throws CertificateException {
- standardTrustManager.checkClientTrusted(certificates, authType);
- }
-
- /**
- * @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[], String authType)
- */
- public void checkServerTrusted(X509Certificate[] certificates, String authType)
- throws CertificateException {
-
- if ((certificates != null) && (certificates.length == 1)) {
- certificates[0].checkValidity();
- } else {
- standardTrustManager.checkServerTrusted(certificates, authType);
- }
- }
-
- /**
- * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
- */
- public X509Certificate[] getAcceptedIssuers() {
- return this.standardTrustManager.getAcceptedIssuers();
- }
-}
diff --git a/src/main/java/microsoft/exchange/webservices/data/ExchangeService.java b/src/main/java/microsoft/exchange/webservices/data/ExchangeService.java
index 79e0a193b..717bdf6ef 100644
--- a/src/main/java/microsoft/exchange/webservices/data/ExchangeService.java
+++ b/src/main/java/microsoft/exchange/webservices/data/ExchangeService.java
@@ -28,13 +28,20 @@
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
/**
* Represents a binding to the Exchange Web Services.
*/
-public final class ExchangeService extends ExchangeServiceBase implements
- IAutodiscoverRedirectionUrl {
+public final class ExchangeService extends ExchangeServiceBase {
/**
* The url.
@@ -66,8 +73,6 @@ public final class ExchangeService extends ExchangeServiceBase implements
*/
private UnifiedMessaging unifiedMessaging;
- private boolean enableScpLookup = true;
-
/**
* When false, used to indicate that we should use "Exchange2007" as the server version String rather than
* Exchange2007_SP1 (@see #getExchange2007CompatibilityMode).
@@ -3431,20 +3436,6 @@ public void updateInboxRules(Iterable operations,
request.execute();
}
- /**
- * Default implementation of AutodiscoverRedirectionUrlValidationCallback.
- * Always returns true indicating that the URL can be used.
- *
- * @param redirectionUrl the redirection url
- * @return Returns true.
- * @throws AutodiscoverLocalException the autodiscover local exception
- */
- private boolean defaultAutodiscoverRedirectionUrlValidationCallback(
- String redirectionUrl) throws AutodiscoverLocalException {
- throw new AutodiscoverLocalException(String.format(
- Strings.AutodiscoverRedirectBlocked, redirectionUrl));
- }
-
/**
* Initializes the Url property to the Exchange Web Services URL for the
* specified e-mail address by calling the Autodiscover service.
@@ -3453,7 +3444,7 @@ private boolean defaultAutodiscoverRedirectionUrlValidationCallback(
* @throws Exception the exception
*/
public void autodiscoverUrl(String emailAddress) throws Exception {
- this.autodiscoverUrl(emailAddress, this);
+ this.autodiscoverUrl(emailAddress, null);
}
/**
@@ -3543,7 +3534,6 @@ private URI getAutodiscoverUrl(String emailAddress,
requestedServerVersion);
autodiscoverService
.setRedirectionUrlValidationCallback(validateRedirectionUrlCallback);
- autodiscoverService.setEnableScpLookup(this.getEnableScpLookup());
GetUserSettingsResponse response = autodiscoverService.getUserSettings(
emailAddress, UserSettingName.InternalEwsUrl,
@@ -3551,8 +3541,7 @@ private URI getAutodiscoverUrl(String emailAddress,
switch (response.getErrorCode()) {
case NoError:
- return this.getEwsUrlFromResponse(response, autodiscoverService
- .isExternal().TRUE);
+ return this.getEwsUrlFromResponse(response);
case InvalidUser:
throw new ServiceRemoteException(String.format(Strings.InvalidUser,
@@ -3573,38 +3562,21 @@ private URI getAutodiscoverUrl(String emailAddress,
}
}
- private URI getEwsUrlFromResponse(GetUserSettingsResponse response,
- boolean isExternal) throws URISyntaxException,
- AutodiscoverLocalException {
- String uriString;
-
- // Bug E14:59063 -- Figure out which URL to use: Internal or External.
- // Bug E14:67646 -- AutoDiscover may not return an external protocol.
- // First try external, then internal.
- // Bug E14:82650 -- Either protocol
- // may be returned without a configured URL.
- OutParam outParam = new OutParam();
- if ((isExternal && response.tryGetSettingValue(String.class,
- UserSettingName.ExternalEwsUrl, outParam))) {
- uriString = outParam.getParam();
- if (!(uriString == null || uriString.isEmpty())) {
- return new URI(uriString);
- }
+ private URI getEwsUrlFromResponse(GetUserSettingsResponse response)
+ throws URISyntaxException, AutodiscoverLocalException {
+ String url = (String) response.getSettings().get(UserSettingName.ExternalEwsUrl);
+
+ if (url != null && !url.isEmpty()) {
+ return new URI(url);
}
- if ((response.tryGetSettingValue(String.class,
- UserSettingName.InternalEwsUrl, outParam) || response
- .tryGetSettingValue(String.class,
- UserSettingName.ExternalEwsUrl, outParam))) {
- uriString = outParam.getParam();
- if (!(uriString == null || uriString.isEmpty())) {
- return new URI(uriString);
- }
+
+ url = (String) response.getSettings().get(UserSettingName.InternalEwsUrl);
+
+ if (url != null && !url.isEmpty()) {
+ return new URI(url);
}
- // If Autodiscover doesn't return an
- // internal or external EWS URL, throw an exception.
- throw new AutodiscoverLocalException(
- Strings.AutodiscoverDidNotReturnEwsUrl);
+ throw new AutodiscoverLocalException(Strings.AutodiscoverDidNotReturnEwsUrl);
}
// region Diagnostic Method -- Only used by test
@@ -3816,22 +3788,6 @@ public UnifiedMessaging getUnifiedMessaging() {
return this.unifiedMessaging;
}
- /**
- * Gets or sets a value indicating whether the AutodiscoverUrl method should
- * perform SCP (Service Connection Point) record lookup when determining the
- * Autodiscover service URL.
- *
- * @return enable scp lookup flag.
- */
- public boolean getEnableScpLookup() {
- return this.enableScpLookup;
- }
-
-
- public void setEnableScpLookup(boolean value) {
- this.enableScpLookup = value;
- }
-
/**
* Returns true whether Exchange2007 compatibility mode is enabled, false otherwise.
*/
@@ -3907,17 +3863,4 @@ public Collection getServerTimeZones() {
return timeZoneList;
}
-
- /*
- * (non-Javadoc)
- *
- * @seemicrosoft.exchange.webservices.AutodiscoverRedirectionUrlInterface#
- * autodiscoverRedirectionUrlValidationCallback(java.lang.String)
- */
- public boolean autodiscoverRedirectionUrlValidationCallback(
- String redirectionUrl) throws AutodiscoverLocalException {
- return defaultAutodiscoverRedirectionUrlValidationCallback(redirectionUrl);
-
- }
-
}
diff --git a/src/main/java/microsoft/exchange/webservices/data/ExchangeServiceBase.java b/src/main/java/microsoft/exchange/webservices/data/ExchangeServiceBase.java
index 5abc10117..f1bc2bdd0 100644
--- a/src/main/java/microsoft/exchange/webservices/data/ExchangeServiceBase.java
+++ b/src/main/java/microsoft/exchange/webservices/data/ExchangeServiceBase.java
@@ -23,12 +23,16 @@
package microsoft.exchange.webservices.data;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
@@ -36,6 +40,7 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
+
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
@@ -43,15 +48,15 @@
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.security.KeyManagementException;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.TimeZone;
/**
* Represents an abstract binding to an Exchange Service.
@@ -81,7 +86,7 @@ public abstract class ExchangeServiceBase implements Closeable {
/**
* The timeout.
*/
- private int timeout = 100000;
+ protected int timeout = 100000;
/**
* The trace enabled.
@@ -129,12 +134,14 @@ public abstract class ExchangeServiceBase implements Closeable {
private WebProxy webProxy;
- protected CloseableHttpClient httpClient;
+ private CloseableHttpClient httpClient;
- protected HttpClientContext httpContext = HttpClientContext.create();
+ protected HttpClientContext httpContext;
protected HttpClientWebRequest request = null;
+ private SSLConnectionSocketFactory sslConnectionSocketFactory;
+
// protected static HttpStatusCode AccountIsLocked = (HttpStatusCode)456;
/**
@@ -150,7 +157,7 @@ public abstract class ExchangeServiceBase implements Closeable {
*/
protected ExchangeServiceBase() {
setUseDefaultCredentials(true);
- initializeHttpClient();
+ initializeHttpContext();
}
protected ExchangeServiceBase(ExchangeVersion requestedServerVersion) {
@@ -170,38 +177,59 @@ protected ExchangeServiceBase(ExchangeServiceBase service, ExchangeVersion reque
this.userAgent = service.getUserAgent();
this.acceptGzipEncoding = service.getAcceptGzipEncoding();
this.httpHeaders = service.getHttpHeaders();
- }
+ this.sslConnectionSocketFactory = service.getSslConnectionSocketFactory();
+ }
+
+ protected CloseableHttpClient getHttpClient() {
+ if (httpClient == null) {
+ Registry
+ registry =
+ RegistryBuilder.create()
+ .register("http", new PlainConnectionSocketFactory()).register("https",
+ sslConnectionSocketFactory
+ != null
+ ? sslConnectionSocketFactory
+ : SSLConnectionSocketFactory
+ .getSocketFactory()).build();
+
+ HttpClientConnectionManager httpConnectionManager = new BasicHttpClientConnectionManager(registry);
+ RequestConfig
+ requestConfig =
+ RequestConfig.custom().setConnectionRequestTimeout(300000).setConnectTimeout(3000000)
+ .setSocketTimeout(300000).build();
+ HttpClientBuilder
+ httpClientBuilder =
+ HttpClients.custom().setConnectionManager(httpConnectionManager)
+ .setTargetAuthenticationStrategy(new CookieProcessingTargetAuthenticationStrategy())
+ .setDefaultRequestConfig(requestConfig);
+
+ if (!acceptGzipEncoding) {
+ httpClientBuilder.disableContentCompression();
+ }
- private void initializeHttpClient() {
- EwsSSLProtocolSocketFactory factory;
- try {
- factory = EwsSSLProtocolSocketFactory.build(null);
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("Could not initialize HttpClientConnectionManager.", e);
- } catch (KeyStoreException e) {
- throw new RuntimeException("Could not initialize HttpClientConnectionManager.", e);
- } catch (KeyManagementException e) {
- throw new RuntimeException("Could not initialize HttpClientConnectionManager.", e);
+ httpClient = httpClientBuilder.build();
}
- Registry registry = RegistryBuilder.create()
- .register("http", new PlainConnectionSocketFactory())
- .register("https", factory)
- .build();
+ return httpClient;
+ }
- HttpClientConnectionManager httpConnectionManager = new BasicHttpClientConnectionManager(registry);
- HttpClientBuilder httpClientBuilder = HttpClients.custom().setConnectionManager(httpConnectionManager)
- .setTargetAuthenticationStrategy(new CookieProcessingTargetAuthenticationStrategy());
- httpClient = httpClientBuilder.build();
+ private void initializeHttpContext() {
+ // Use an own cookie store, instead of the httpClient's global store, so cookies get reset on reinitialization
+ CookieStore cookieStore = new BasicCookieStore();
+ httpContext = HttpClientContext.create();
+ httpContext.setCookieStore(cookieStore);
}
- @Override
+ @Override
public void close() {
- try {
- httpClient.close();
- } catch (IOException e) {
- // Ignore exceptions while closing the HttpClient.
- }
+ if (httpClient != null) {
+ try {
+ httpClient.close();
+ } catch (IOException e) {
+ // Ignore exceptions while closing the HttpClient.
+ }
+ httpClient = null;
+ }
}
// Event handlers
@@ -245,7 +273,7 @@ protected HttpWebRequest prepareHttpWebRequestForUrl(URI url, boolean acceptGzip
throw new ServiceLocalException(strErr);
}
- request = new HttpClientWebRequest(httpClient, httpContext);
+ request = new HttpClientWebRequest(getHttpClient(), httpContext);
try {
request.setUrl(url.toURL());
} catch (MalformedURLException e) {
@@ -579,6 +607,9 @@ public ExchangeCredentials getCredentials() {
public void setCredentials(ExchangeCredentials credentials) {
this.credentials = credentials;
this.useDefaultCredentials = false;
+
+ // Reset the httpContext, to remove any existing authentication cookies from subsequent requests
+ initializeHttpContext();
}
/**
@@ -605,8 +636,11 @@ public void setUseDefaultCredentials(boolean value) {
if (value) {
this.credentials = null;
}
- }
+ // Reset the httpContext, to remove any existing authentication cookies from subsequent requests
+ initializeHttpContext();
+ }
+
/**
* Gets the timeout used when sending HTTP requests and when receiving HTTP
* responses, in milliseconds.
@@ -831,4 +865,12 @@ protected static byte[] getSessionKey() {
return ExchangeServiceBase.binarySecret;
}
}
+
+ public SSLConnectionSocketFactory getSslConnectionSocketFactory() {
+ return sslConnectionSocketFactory;
+ }
+
+ public void setSslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory) {
+ this.sslConnectionSocketFactory = sslConnectionSocketFactory;
+ }
}
diff --git a/src/main/java/microsoft/exchange/webservices/data/ExecuteDiagnosticMethodResponse.java b/src/main/java/microsoft/exchange/webservices/data/ExecuteDiagnosticMethodResponse.java
index d7f4286de..8bf6ef54e 100644
--- a/src/main/java/microsoft/exchange/webservices/data/ExecuteDiagnosticMethodResponse.java
+++ b/src/main/java/microsoft/exchange/webservices/data/ExecuteDiagnosticMethodResponse.java
@@ -120,9 +120,9 @@ public Document retriveDocument(XMLEventReader xmlEventReader)
}
String xmlns = EwsUtilities.WSTrustFebruary2005Namespace;//"http://schemas.xmlsoap.org/wsdl/";
- ite = ele.getNamespaces();
- while (ite.hasNext()) {
- Namespace ns = (Namespace) ite.next();
+ Iterator ite2 = ele.getNamespaces();
+ while (ite2.hasNext()) {
+ Namespace ns = ite2.next();
String name = ns.getPrefix();
if (!name.isEmpty()) {
element.setAttributeNS(xmlns, name,
diff --git a/src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsRequest.java b/src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsRequest.java
deleted file mode 100644
index 5a4a084f0..000000000
--- a/src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsRequest.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * The MIT License
- * Copyright (c) 2012 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package microsoft.exchange.webservices.data;
-
-import javax.xml.stream.XMLStreamException;
-import java.net.URI;
-import java.util.List;
-
-/**
- * Represents a GetDomainSettings request.
- */
-class GetDomainSettingsRequest extends AutodiscoverRequest {
-
- /**
- * Action Uri of Autodiscover.GetDomainSettings method.
- */
- private static final String GetDomainSettingsActionUri =
- EwsUtilities.AutodiscoverSoapNamespace +
- "/Autodiscover/GetDomainSettings";
-
- /**
- * The domains.
- */
- private List domains;
-
- /**
- * The settings.
- */
- private List settings;
-
- private ExchangeVersion requestedVersion;
-
- /**
- * Initializes a new instance of the
- * class.
- *
- * @param service the service
- * @param url the url
- */
- protected GetDomainSettingsRequest(AutodiscoverService service, URI url) {
- super(service, url);
- }
-
- /**
- * Validates the request.
- *
- * @throws Exception the exception
- */
- @Override
- protected void validate() throws Exception {
- super.validate();
-
- EwsUtilities.validateParam(this.getDomains(), "domains");
- EwsUtilities.validateParam(this.getSettings(), "settings");
-
- if (this.getSettings().size() == 0) {
- throw new ServiceValidationException(
- Strings.InvalidAutodiscoverSettingsCount);
- }
-
- if (domains.size() == 0) {
- throw new ServiceValidationException(
- Strings.InvalidAutodiscoverDomainsCount);
- }
-
- for (String domain : this.getDomains()) {
- if (domain == null || domain.isEmpty()) {
- throw new ServiceValidationException(
- Strings.InvalidAutodiscoverDomain);
- }
- }
- }
-
- /**
- * Executes this instance.
- *
- * @return the gets the domain settings response collection
- * @throws microsoft.exchange.webservices.data.ServiceLocalException the service local exception
- * @throws Exception the exception
- */
- protected GetDomainSettingsResponseCollection execute()
- throws ServiceLocalException, Exception {
- GetDomainSettingsResponseCollection responses =
- (GetDomainSettingsResponseCollection) this
- .internalExecute();
- if (responses.getErrorCode() == AutodiscoverErrorCode.NoError) {
- this.PostProcessResponses(responses);
- }
- return responses;
- }
-
- /**
- * Post-process responses to GetDomainSettings.
- *
- * @param responses The GetDomainSettings responses.
- */
- private void PostProcessResponses(
- GetDomainSettingsResponseCollection responses) {
- // Note:The response collection may not include all of the requested
- // domains if the request has been throttled.
- for (int index = 0; index < responses.getCount(); index++) {
- responses.getResponses().get(index).setDomain(
- this.getDomains().get(index));
- }
- }
-
- /**
- * Gets the name of the request XML element.
- *
- * @return Request XML element name.
- */
- @Override
- protected String getRequestXmlElementName() {
- return XmlElementNames.GetDomainSettingsRequestMessage;
- }
-
- /**
- * Gets the name of the response XML element.
- *
- * @return Response XML element name.
- */
- @Override
- protected String getResponseXmlElementName() {
- return XmlElementNames.GetDomainSettingsResponseMessage;
- }
-
- /**
- * Gets the WS-Addressing action name.
- *
- * @return WS-Addressing action name.
- */
- @Override
- protected String getWsAddressingActionName() {
- return GetDomainSettingsActionUri;
- }
-
- /**
- * Creates the service response.
- *
- * @return AutodiscoverResponse
- */
- @Override
- protected AutodiscoverResponse createServiceResponse() {
- return new GetDomainSettingsResponseCollection();
- }
-
- /**
- * Writes the attributes to XML.
- *
- * @param writer The writer.
- * @throws ServiceXmlSerializationException the service xml serialization exception
- */
- @Override
- protected void writeAttributesToXml(EwsServiceXmlWriter writer)
- throws ServiceXmlSerializationException {
- writer.writeAttributeValue("xmlns",
- EwsUtilities.AutodiscoverSoapNamespacePrefix,
- EwsUtilities.AutodiscoverSoapNamespace);
- }
-
- /**
- * Writes request to XML.
- *
- * @param writer The writer.
- * @throws javax.xml.stream.XMLStreamException the xML stream exception
- * @throws ServiceXmlSerializationException the service xml serialization exception
- */
- @Override
- protected void writeElementsToXml(EwsServiceXmlWriter writer)
- throws XMLStreamException, ServiceXmlSerializationException {
- writer.writeStartElement(XmlNamespace.Autodiscover,
- XmlElementNames.Request);
-
- writer.writeStartElement(XmlNamespace.Autodiscover,
- XmlElementNames.Domains);
-
- for (String domain : this.getDomains()) {
- if (!(domain == null || domain.isEmpty())) {
- writer.writeElementValue(XmlNamespace.Autodiscover,
- XmlElementNames.Domain, domain);
- }
- }
- writer.writeEndElement(); // Domains
-
- writer.writeStartElement(XmlNamespace.Autodiscover,
- XmlElementNames.RequestedSettings);
- for (DomainSettingName setting : settings) {
- writer.writeElementValue(XmlNamespace.Autodiscover,
- XmlElementNames.Setting, setting);
- }
-
- writer.writeEndElement(); // RequestedSettings
-
- if (this.requestedVersion != null) {
- writer.writeElementValue(XmlNamespace.Autodiscover,
- XmlElementNames.RequestedVersion, this.requestedVersion);
- }
-
- writer.writeEndElement(); // Request
- }
-
- /**
- * Gets the domains.
- *
- * @return the domains
- */
- protected List getDomains() {
- return domains;
- }
-
- /**
- * Sets the domains.
- *
- * @param value the new domains
- */
- protected void setDomains(List value) {
- domains = value;
- }
-
- /**
- * Gets or sets the settings.
- *
- * @return the settings
- */
- protected List getSettings() {
- return settings;
- }
-
- /**
- * Sets the settings.
- *
- * @param value the new settings
- */
- protected void setSettings(List value) {
- settings = value;
- }
-
- /**
- * Gets or sets the requestedVersion.
- *
- * @return the requestedVersion
- */
- protected ExchangeVersion getRequestedVersion() {
- return requestedVersion;
- }
-
- /**
- * Sets the requestedVersion.
- *
- * @param value the new requestedVersion
- */
- protected void setRequestedVersion(ExchangeVersion value) {
- requestedVersion = value;
- }
-
-}
diff --git a/src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsResponse.java b/src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsResponse.java
deleted file mode 100644
index 0c5de32cb..000000000
--- a/src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsResponse.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * The MIT License
- * Copyright (c) 2012 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package microsoft.exchange.webservices.data;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents the response to a GetDomainSettings call for an individual domain.
- */
-public final class GetDomainSettingsResponse extends AutodiscoverResponse {
-
- /**
- * The domain.
- */
- private String domain;
-
- /**
- * The redirect target.
- */
- private String redirectTarget;
-
- /**
- * The settings.
- */
- private Map settings;
-
- /**
- * The domain setting errors.
- */
- private Collection domainSettingErrors;
-
- /**
- * Initializes a new instance of the
- * class.
- */
- public GetDomainSettingsResponse() {
- super();
- this.domain = "";
- this.settings = new HashMap();
- this.domainSettingErrors = new ArrayList();
- }
-
- /**
- * Gets the domain this response applies to.
- *
- * @return the domain
- */
- public String getDomain() {
- return this.domain;
- }
-
- /**
- * Sets the domain.
- *
- * @param value the new domain
- */
- protected void setDomain(String value) {
- this.domain = value;
- }
-
- /**
- * Gets the redirectionTarget (URL or email address).
- *
- * @return the redirect target
- */
- public String getRedirectTarget() {
- return this.redirectTarget;
- }
-
- /**
- * Gets the requested settings for the domain.
- *
- * @return the settings
- */
- public Map getSettings() {
- return this.settings;
- }
-
- /**
- * Gets error information for settings that could not be returned.
- *
- * @return the domain setting errors
- */
- public Collection getDomainSettingErrors() {
- return this.domainSettingErrors;
- }
-
- /**
- * Loads response from XML.
- *
- * @param reader The reader.
- * @param endElementName End element name.
- * @throws Exception the exception
- */
- @Override
- protected void loadFromXml(EwsXmlReader reader, String endElementName)
- throws Exception {
- do {
- reader.read();
-
- if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) {
- if (reader.getLocalName()
- .equals(XmlElementNames.RedirectTarget)) {
- this.redirectTarget = reader.readElementValue();
- } else if (reader.getLocalName().equals(
- XmlElementNames.DomainSettingErrors)) {
- this.loadDomainSettingErrorsFromXml(reader);
- } else if (reader.getLocalName().equals(
- XmlElementNames.DomainSettings)) {
- try {
- this.loadDomainSettingsFromXml(reader);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- super.loadFromXml(reader, endElementName);
- break;
- }
- }
- } while (!reader
- .isEndElement(XmlNamespace.Autodiscover, endElementName));
- }
-
- /**
- * Loads from XML.
- *
- * @param reader The reader.
- * @throws Exception the exception
- */
- protected void loadDomainSettingsFromXml(EwsXmlReader reader)
- throws Exception {
- if (!reader.isEmptyElement()) {
- do {
- reader.read();
-
- if ((reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) &&
- (reader.getLocalName()
- .equals(XmlElementNames.DomainSetting))) {
- String settingClass = reader.readAttributeValue(
- XmlNamespace.XmlSchemaInstance,
- XmlAttributeNames.Type);
-
- if (settingClass
- .equals(XmlElementNames.DomainStringSetting)) {
-
- this.readSettingFromXml(reader);
- } else {
- EwsUtilities
- .EwsAssert(
- false,
- "GetDomainSettingsResponse." +
- "LoadDomainSettingsFromXml",
- String
- .format(
- "%s,%s",
- "Invalid setting " +
- "class '%s' returned",
- settingClass));
- break;
- }
- }
- } while (!reader.isEndElement(XmlNamespace.Autodiscover,
- XmlElementNames.DomainSettings));
- } else {
- reader.read();
- }
- }
-
- /**
- * Reads domain setting from XML.
- *
- * @param reader The reader.
- * @throws Exception the exception
- */
- private void readSettingFromXml(EwsXmlReader reader) throws Exception {
- DomainSettingName name = null;
- Object value = null;
-
- do {
- reader.read();
-
- if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) {
- if (reader.getLocalName().equals(
- XmlElementNames.DomainStringSetting)) {
- name = reader.readElementValue(DomainSettingName.class);
- } else if (reader.getLocalName().equals(XmlElementNames.Value)) {
- value = reader.readElementValue();
- }
- }
- } while (!reader.isEndElement(XmlNamespace.Autodiscover,
- XmlElementNames.DomainSetting));
-
- EwsUtilities.EwsAssert(name != null,
- "GetDomainSettingsResponse.ReadSettingFromXml",
- "Missing name element in domain setting");
-
- this.settings.put(name, value);
- }
-
- /**
- * Loads the domain setting errors.
- *
- * @param reader The reader.
- * @throws Exception the exception
- */
- private void loadDomainSettingErrorsFromXml(EwsXmlReader reader)
- throws Exception {
- if (!reader.isEmptyElement()) {
- do {
- reader.read();
-
- if ((reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) &&
- (reader.getLocalName()
- .equals(XmlElementNames.DomainSettingError))) {
- DomainSettingError error = new DomainSettingError();
- error.loadFromXml(reader);
- domainSettingErrors.add(error);
- }
- } while (!reader.isEndElement(XmlNamespace.Autodiscover,
- XmlElementNames.DomainSettingErrors));
- } else {
- reader.read();
- }
- }
-}
diff --git a/src/main/java/microsoft/exchange/webservices/data/GetUserSettingsResponse.java b/src/main/java/microsoft/exchange/webservices/data/GetUserSettingsResponse.java
index 139b8efc1..5c825c6d4 100644
--- a/src/main/java/microsoft/exchange/webservices/data/GetUserSettingsResponse.java
+++ b/src/main/java/microsoft/exchange/webservices/data/GetUserSettingsResponse.java
@@ -64,27 +64,6 @@ public GetUserSettingsResponse() {
this.setUserSettingErrors(new ArrayList());
}
- /**
- * Tries the get the user setting value.
- *
- * @param cls Type of user setting.
- * @param setting The setting.
- * @param value The setting value.
- * @return True if setting was available.
- */
- public boolean tryGetSettingValue(Class cls,
- UserSettingName setting, OutParam value) {
- Object objValue;
- if (this.getSettings().containsKey(setting)) {
- objValue = this.getSettings().get(setting);
- value.setParam((T) objValue);
- return true;
- } else {
- value.setParam(null);
- return false;
- }
- }
-
/**
* Gets the SMTP address this response applies to.
*
diff --git a/src/main/java/microsoft/exchange/webservices/data/HttpClientWebRequest.java b/src/main/java/microsoft/exchange/webservices/data/HttpClientWebRequest.java
index 7d31c9b21..073d49659 100644
--- a/src/main/java/microsoft/exchange/webservices/data/HttpClientWebRequest.java
+++ b/src/main/java/microsoft/exchange/webservices/data/HttpClientWebRequest.java
@@ -25,20 +25,26 @@
import org.apache.http.Header;
import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.NTCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.AuthSchemes;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.SocketConfig;
-import org.apache.http.impl.client.*;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -53,7 +59,7 @@ class HttpClientWebRequest extends HttpWebRequest {
/**
* The Http Method.
*/
- private HttpPost httpPost = null;
+ private HttpRequestBase httpRequest = null;
private CloseableHttpResponse response = null;
private final CloseableHttpClient httpClient;
@@ -78,15 +84,15 @@ public void close() throws IOException {
// If that is not possible, we simply cleanup the whole connection
if (response != null && response.getEntity() != null) {
EntityUtils.consume(response.getEntity());
- } else if (httpPost != null) {
- httpPost.releaseConnection();
+ } else if (httpRequest != null) {
+ httpRequest.releaseConnection();
}
- // We set httpPost to null to prevent the connection from being closed again by an accidental
+ // We set httpRequest to null to prevent the connection from being closed again by an accidental
// second call to close()
// The response is kept, in case something in the library still wants to read something from it,
// like response code or headers
- httpPost = null;
+ httpRequest = null;
}
/**
@@ -94,22 +100,26 @@ public void close() throws IOException {
*/
@Override
public void prepareConnection() {
- httpPost = new HttpPost(getUrl().toString());
+ if (getRequestMethod().equals("POST")) {
+ httpRequest = new HttpPost(getUrl().toString());
+ } else {
+ httpRequest = new HttpGet(getUrl().toString());
+ }
// Populate headers.
- httpPost.addHeader("Content-type", getContentType());
- httpPost.addHeader("User-Agent", getUserAgent());
- httpPost.addHeader("Accept", getAccept());
- httpPost.addHeader("Keep-Alive", "300");
- httpPost.addHeader("Connection", "Keep-Alive");
+ httpRequest.addHeader("Content-type", getContentType());
+ httpRequest.addHeader("User-Agent", getUserAgent());
+ httpRequest.addHeader("Accept", getAccept());
+ httpRequest.addHeader("Keep-Alive", "300");
+ httpRequest.addHeader("Connection", "Keep-Alive");
if (isAcceptGzipEncoding()) {
- httpPost.addHeader("Accept-Encoding", "gzip,deflate");
+ httpRequest.addHeader("Accept-Encoding", "gzip,deflate");
}
if (getHeaders() != null) {
for (Map.Entry httpHeader : getHeaders().entrySet()) {
- httpPost.addHeader(httpHeader.getKey(), httpHeader.getValue());
+ httpRequest.addHeader(httpHeader.getKey(), httpHeader.getValue());
}
}
@@ -148,7 +158,15 @@ public void prepareConnection() {
httpContext.setCredentialsProvider(credentialsProvider);
- httpPost.setConfig(requestConfigBuilder.build());
+ // Reset auth state is authentication previously failed, otherwise we will keep failing,
+ // as HttpClient does not retry authentication once it has failed
+ // See eveoh/mytimetable#2088
+ if (httpContext.getTargetAuthState() != null &&
+ httpContext.getTargetAuthState().getState() == AuthProtocolState.FAILURE) {
+ httpContext.getTargetAuthState().reset();
+ }
+
+ httpRequest.setConfig(requestConfigBuilder.build());
}
/**
@@ -196,11 +214,10 @@ public InputStream getErrorStream() throws EWSHttpException {
*/
@Override
public OutputStream getOutputStream() throws EWSHttpException {
- OutputStream os = null;
throwIfRequestIsNull();
- os = new ByteArrayOutputStream();
+ OutputStream os = new ByteArrayOutputStream();
- httpPost.setEntity(new ByteArrayOSRequestEntity(os));
+ ((HttpPost) httpRequest).setEntity(new ByteArrayOSRequestEntity(os));
return os;
}
@@ -288,7 +305,7 @@ public String getResponseContentType() throws EWSHttpException {
@Override
public int executeRequest() throws EWSHttpException, IOException {
throwIfRequestIsNull();
- response = httpClient.execute(httpPost, httpContext);
+ response = httpClient.execute(httpRequest, httpContext);
return response.getStatusLine().getStatusCode(); // ?? don't know what is wanted in return
}
@@ -321,7 +338,7 @@ public String getResponseText() throws EWSHttpException {
* @throws EWSHttpException the eWS http exception
*/
private void throwIfRequestIsNull() throws EWSHttpException {
- if (null == httpPost) {
+ if (null == httpRequest) {
throw new EWSHttpException("Connection not established");
}
}
@@ -342,7 +359,7 @@ public Map getRequestProperty() throws EWSHttpException {
throwIfRequestIsNull();
Map map = new HashMap();
- Header[] hM = httpPost.getAllHeaders();
+ Header[] hM = httpRequest.getAllHeaders();
for (Header header : hM) {
map.put(header.getName(), header.getValue());
}
diff --git a/src/main/java/microsoft/exchange/webservices/data/IFunctionDelegate.java b/src/main/java/microsoft/exchange/webservices/data/IFunctionDelegate.java
deleted file mode 100644
index 29225d818..000000000
--- a/src/main/java/microsoft/exchange/webservices/data/IFunctionDelegate.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * The MIT License
- * Copyright (c) 2012 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package microsoft.exchange.webservices.data;
-
-import javax.xml.stream.XMLStreamException;
-import java.io.IOException;
-import java.net.URI;
-import java.util.List;
-
-/**
- * The Interface FuncDelegateInterface.
- *
- * @param the generic type
- * @param the generic type
- * @param the generic type
- * @param the generic type
- */
-interface IFunctionDelegate, T2 extends List>, TResult> {
-
- /**
- * Func.
- *
- * @param arg1 the arg1
- * @param arg2 the arg2
- * @param arg3 the arg3
- * @return the t result
- * @throws AutodiscoverLocalException the autodiscover local exception
- * @throws javax.xml.stream.XMLStreamException the xML stream exception
- * @throws java.io.IOException Signals that an I/O exception has occurred.
- * @throws ServiceLocalException the service local exception
- * @throws Exception the exception
- */
- TResult func(T1 arg1, T2 arg2, ExchangeVersion arg3, URI arg4)
- throws AutodiscoverLocalException, XMLStreamException, IOException,
- ServiceLocalException, Exception;
-
-}
diff --git a/src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsResponseCollection.java b/src/main/java/microsoft/exchange/webservices/data/OlsonTimeZoneDefinition.java
similarity index 55%
rename from src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsResponseCollection.java
rename to src/main/java/microsoft/exchange/webservices/data/OlsonTimeZoneDefinition.java
index b8f58f2c4..86a5dc375 100644
--- a/src/main/java/microsoft/exchange/webservices/data/GetDomainSettingsResponseCollection.java
+++ b/src/main/java/microsoft/exchange/webservices/data/OlsonTimeZoneDefinition.java
@@ -23,46 +23,33 @@
package microsoft.exchange.webservices.data;
-/**
- * Represents a collection of responses to GetDomainSettings.
- */
-public final class GetDomainSettingsResponseCollection extends
- AutodiscoverResponseCollection {
- /**
- * Initializes a new instance of the AutodiscoverResponseCollection class.
- */
- protected GetDomainSettingsResponseCollection() {
- }
+import microsoft.exchange.webservices.data.util.TimeZoneUtils;
- /**
- * Create a response instance.
- *
- * @return GetDomainSettingsResponse.
- */
- @Override
- protected GetDomainSettingsResponse createResponseInstance() {
- return new GetDomainSettingsResponse();
- }
+import java.util.Date;
+import java.util.TimeZone;
+
+/**
+ * A TimeZoneDefinition class that allows mapping from a Java/Olson TimeZone to a MS TimeZone.
+ */
+public class OlsonTimeZoneDefinition extends TimeZoneDefinition {
/**
- * Gets the name of the response collection XML element.
- *
- * @return Response collection XMl element name.
+ * Create a TimeZoneDefinition compatible with java.util.TimeZone
+ * @param timeZone a java time zone object, will be converted to Microsoft timezone.
*/
- @Override
- protected String getResponseCollectionXmlElementName() {
- return XmlElementNames.DomainResponses;
+ public OlsonTimeZoneDefinition(TimeZone timeZone) {
+ final String microsoftTimeZoneName = TimeZoneUtils.getMicrosoftTimeZoneName(timeZone);
+ if (microsoftTimeZoneName != null) {
+ this.id = microsoftTimeZoneName;
+ }
+ this.name = timeZone.getDisplayName(timeZone.inDaylightTime(new Date()), TimeZone.LONG);
}
- /**
- * Gets the name of the response instance XML element.
- *
- * @return Response instance XMl element name.
- */
@Override
- protected String getResponseInstanceXmlElementName() {
- return XmlElementNames.DomainResponse;
+ public void validate() throws ServiceLocalException {
+ if (this.id == null) {
+ throw new ServiceLocalException("Invalid TimeZone (" + this.name + ") Specified");
+ }
}
-
}
diff --git a/src/main/java/microsoft/exchange/webservices/data/SafeXmlSchema.java b/src/main/java/microsoft/exchange/webservices/data/SafeXmlSchema.java
deleted file mode 100644
index 7e7bc6c2c..000000000
--- a/src/main/java/microsoft/exchange/webservices/data/SafeXmlSchema.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * The MIT License
- * Copyright (c) 2012 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package microsoft.exchange.webservices.data;
-
-import javax.xml.bind.ValidationEventHandler;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.validation.Schema;
-import javax.xml.validation.Validator;
-import javax.xml.validation.ValidatorHandler;
-import java.io.InputStream;
-
-/**
- * XmlSchema with protection against DTD parsing in read overloads
- */
-public class SafeXmlSchema extends Schema {
-
- @Override
- public Validator newValidator() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ValidatorHandler newValidatorHandler() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * Reads an XML Schema from the supplied stream.
- *
- * @param stream The supplied data stream.
- * @param validationEventHandler The validation event handler that receives information about the XML Schema syntax errors
- * @return The XmlSchema object representing the XML Schema.
- * @throws javax.xml.stream.XMLStreamException
- */
- public static Schema Read(InputStream stream, ValidationEventHandler validationEventHandler)
- throws XMLStreamException {
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
-
- return (Schema) inputFactory.createXMLEventReader(stream);
- }
-
- /**
- * Reads an XML Schema from the supplied TextReader.
- *
- * @param reader The TextReader containing the XML Schema to read
- * @param validationEventHandler The validation event handler that receives information about the XML Schema syntax errors.
- * @return The XmlSchema object representing the XML Schema.
- * @throws javax.xml.stream.XMLStreamException
- */
-
- public static Schema Read(XMLStreamReader reader, ValidationEventHandler validationEventHandler)
- throws XMLStreamException {
-
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
-
- return (Schema) inputFactory.createXMLEventReader(reader);
- }
-
-}
diff --git a/src/main/java/microsoft/exchange/webservices/data/ServiceRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/ServiceRequestBase.java
index 59510ba04..92d937ee6 100644
--- a/src/main/java/microsoft/exchange/webservices/data/ServiceRequestBase.java
+++ b/src/main/java/microsoft/exchange/webservices/data/ServiceRequestBase.java
@@ -24,7 +24,6 @@
package microsoft.exchange.webservices.data;
import javax.xml.stream.XMLStreamException;
-import javax.xml.ws.http.HTTPException;
import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
@@ -419,13 +418,6 @@ protected T readResponse(HttpWebRequest response) throws Exception {
}
return serviceResponse;
- } catch (HTTPException e) {
- if (e.getMessage() != null) {
- this.getService().processHttpResponseHeaders(
- TraceFlags.EwsResponseHttpHeaders, response);
- }
- throw new ServiceRequestException(String.format(
- Strings.ServiceRequestFailed, e.getMessage()), e);
} catch (IOException e) {
throw new ServiceRequestException(String.format(
Strings.ServiceRequestFailed, e.getMessage()), e);
diff --git a/src/main/java/microsoft/exchange/webservices/data/SimpleServiceRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/SimpleServiceRequestBase.java
index fb265f453..49ca2645b 100644
--- a/src/main/java/microsoft/exchange/webservices/data/SimpleServiceRequestBase.java
+++ b/src/main/java/microsoft/exchange/webservices/data/SimpleServiceRequestBase.java
@@ -26,7 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.xml.ws.http.HTTPException;
import java.io.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
@@ -60,8 +59,7 @@ protected T internalExecute() throws ServiceLocalException, Exception {
return this.readResponse(response);
} catch (IOException ex) {
// Wrap exception.
- throw new ServiceRequestException(String.
- format(Strings.ServiceRequestFailed, ex.getMessage(), ex));
+ throw new ServiceRequestException(String.format(Strings.ServiceRequestFailed, ex.getMessage()), ex);
} catch (Exception e) {
if (response != null) {
this.getService().processHttpResponseHeaders(TraceFlags.
diff --git a/src/main/java/microsoft/exchange/webservices/data/StreamingSubscriptionConnection.java b/src/main/java/microsoft/exchange/webservices/data/StreamingSubscriptionConnection.java
deleted file mode 100644
index ff11be1bc..000000000
--- a/src/main/java/microsoft/exchange/webservices/data/StreamingSubscriptionConnection.java
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- * The MIT License
- * Copyright (c) 2012 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package microsoft.exchange.webservices.data;
-
-import java.io.Closeable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Represents a connection to an ongoing stream of events.
- */
-public final class StreamingSubscriptionConnection implements Closeable,
- HangingServiceRequestBase.IHandleResponseObject,
- HangingServiceRequestBase.IHangingRequestDisconnectHandler {
-
- /**
- * Mapping of streaming id to subscriptions currently on the connection.
- */
- private Map subscriptions;
-
- /**
- * connection lifetime, in minutes
- */
- private int connectionTimeout;
-
- /**
- * ExchangeService instance used to make the EWS call.
- */
- private ExchangeService session;
-
- /**
- * Value indicating whether the class is disposed.
- */
- private boolean isDisposed;
-
- /**
- * Currently used instance of a GetStreamingEventsRequest connected to EWS.
- */
- private GetStreamingEventsRequest currentHangingRequest;
-
-
- public interface INotificationEventDelegate {
- /**
- * Represents a delegate that is invoked when notifications are received
- * from the server
- *
- * @param sender The StreamingSubscriptionConnection instance that received
- * the events.
- * @param args The event data.
- */
- void notificationEventDelegate(Object sender, NotificationEventArgs args);
- }
-
-
- /**
- * Notification events Occurs when notifications are received from the
- * server.
- */
- private List onNotificationEvent = new ArrayList();
-
- /**
- * Set event to happen when property Notify.
- *
- * @param notificationEvent notification event
- */
- public void addOnNotificationEvent(
- INotificationEventDelegate notificationEvent) {
- onNotificationEvent.add(notificationEvent);
- }
-
- /**
- * Remove the event from happening when property Notify.
- *
- * @param notificationEvent notification event
- */
- public void removeNotificationEvent(
- INotificationEventDelegate notificationEvent) {
- onNotificationEvent.remove(notificationEvent);
- }
-
- /**
- * Clears notification events list.
- */
- public void clearNotificationEvent() {
- onNotificationEvent.clear();
- }
-
- public interface ISubscriptionErrorDelegate {
-
- /**
- * Represents a delegate that is invoked when an error occurs within a
- * streaming subscription connection.
- *
- * @param sender The StreamingSubscriptionConnection instance within which
- * the error occurred.
- * @param args The event data.
- */
- void subscriptionErrorDelegate(Object sender,
- SubscriptionErrorEventArgs args);
- }
-
-
- /**
- * Subscription events Occur when a subscription encounters an error.
- */
- private List onSubscriptionError = new ArrayList();
-
- /**
- * Set event to happen when property subscriptionError.
- *
- * @param subscriptionError subscription event
- */
- public void addOnSubscriptionError(
- ISubscriptionErrorDelegate subscriptionError) {
- onSubscriptionError.add(subscriptionError);
- }
-
- /**
- * Remove the event from happening when property subscription.
- *
- * @param subscriptionError subscription event
- */
- public void removeSubscriptionError(
- ISubscriptionErrorDelegate subscriptionError) {
- onSubscriptionError.remove(subscriptionError);
- }
-
- /**
- * Clears subscription events list.
- */
- public void clearSubscriptionError() {
- onSubscriptionError.clear();
- }
-
- /**
- * Disconnect events Occurs when a streaming subscription connection is
- * disconnected from the server.
- */
- private List onDisconnect = new ArrayList();
-
- /**
- * Set event to happen when property disconnect.
- *
- * @param disconnect disconnect event
- */
- public void addOnDisconnect(ISubscriptionErrorDelegate disconnect) {
- onDisconnect.add(disconnect);
- }
-
- /**
- * Remove the event from happening when property disconnect.
- *
- * @param disconnect disconnect event
- */
- public void removeDisconnect(ISubscriptionErrorDelegate disconnect) {
- onDisconnect.remove(disconnect);
- }
-
- /**
- * Clears disconnect events list.
- */
- public void clearDisconnect() {
- onDisconnect.clear();
- }
-
- /**
- * Initializes a new instance of the StreamingSubscriptionConnection class.
- *
- * @param service The ExchangeService instance this connection uses to connect
- * to the server.
- * @param lifetime The maximum time, in minutes, the connection will remain open.
- * Lifetime must be between 1 and 30.
- * @throws Exception
- */
- public StreamingSubscriptionConnection(ExchangeService service, int lifetime)
- throws Exception {
- EwsUtilities.validateParam(service, "service");
-
- EwsUtilities.validateClassVersion(service,
- ExchangeVersion.Exchange2010_SP1, this.getClass().getName());
-
- if (lifetime < 1 || lifetime > 30) {
- throw new ArgumentOutOfRangeException("lifetime");
- }
-
- this.session = service;
- this.subscriptions = new HashMap();
- this.connectionTimeout = lifetime;
- }
-
- /**
- * Initializes a new instance of the StreamingSubscriptionConnection class.
- *
- * @param service The ExchangeService instance this connection uses to connect
- * to the server.
- * @param subscriptions Iterable subcriptions
- * @param lifetime The maximum time, in minutes, the connection will remain open.
- * Lifetime must be between 1 and 30.
- * @throws Exception
- */
- public StreamingSubscriptionConnection(ExchangeService service,
- Iterable subscriptions, int lifetime)
- throws Exception {
- this(service, lifetime);
- EwsUtilities.validateParamCollection(subscriptions.iterator(),
- "subscriptions");
- for (StreamingSubscription subscription : subscriptions) {
- this.subscriptions.put(subscription.getId(), subscription);
- }
- }
-
- /**
- * Adds a subscription to this connection.
- *
- * @param subscription The subscription to add.
- * @throws Exception Thrown when AddSubscription is called while connected.
- */
- public void addSubscription(StreamingSubscription subscription)
- throws Exception {
- this.throwIfDisposed();
- EwsUtilities.validateParam(subscription, "subscription");
- this.validateConnectionState(false,
- Strings.CannotAddSubscriptionToLiveConnection);
-
- synchronized (this) {
- if (this.subscriptions.containsKey(subscription.getId())) {
- return;
- }
- this.subscriptions.put(subscription.getId(), subscription);
- }
- }
-
- /**
- * Removes the specified streaming subscription from the connection.
- *
- * @param subscription The subscription to remove.
- * @throws Exception Thrown when RemoveSubscription is called while connected.
- */
- public void removeSubscription(StreamingSubscription subscription)
- throws Exception {
- this.throwIfDisposed();
-
- EwsUtilities.validateParam(subscription, "subscription");
-
- this.validateConnectionState(false,
- Strings.CannotRemoveSubscriptionFromLiveConnection);
-
- synchronized (this) {
- this.subscriptions.remove(subscription.getId());
- }
- }
-
- /**
- * Opens this connection so it starts receiving events from the server.This
- * results in a long-standing call to EWS.
- *
- * @throws Exception
- * @throws ServiceLocalException Thrown when Open is called while connected.
- */
- public void open() throws ServiceLocalException, Exception {
- synchronized (this) {
- this.throwIfDisposed();
-
- this.validateConnectionState(false,
- Strings.CannotCallConnectDuringLiveConnection);
-
- if (this.subscriptions.size() == 0) {
- throw new ServiceLocalException(
- Strings.NoSubscriptionsOnConnection);
- }
-
- this.currentHangingRequest = new GetStreamingEventsRequest(
- this.session, this, this.subscriptions.keySet(),
- this.connectionTimeout);
-
- this.currentHangingRequest.addOnDisconnectEvent(this);
-
- this.currentHangingRequest.internalExecute();
- }
- }
-
- /**
- * Called when the request is disconnected.
- *
- * @param sender The sender.
- * @param args The Microsoft.Exchange.WebServices.Data.
- * HangingRequestDisconnectEventArgs instance containing the
- * event data.
- */
- private void onRequestDisconnect(Object sender,
- HangingRequestDisconnectEventArgs args) {
- this.internalOnDisconnect(args.getException());
- }
-
- /**
- * Closes this connection so it stops receiving events from the server.This
- * terminates a long-standing call to EWS.
- */
- public void close() {
- synchronized (this) {
- try {
- this.throwIfDisposed();
-
- this.validateConnectionState(true,
- Strings.CannotCallDisconnectWithNoLiveConnection);
-
- // Further down in the stack, this will result in a
- // call to our OnRequestDisconnect event handler,
- // doing the necessary cleanup.
- this.currentHangingRequest.disconnect();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Internal helper method called when the request disconnects.
- *
- * @param ex The exception that caused the disconnection. May be null.
- */
- private void internalOnDisconnect(Exception ex) {
- if (!onDisconnect.isEmpty()) {
- for (ISubscriptionErrorDelegate disconnect : onDisconnect) {
- disconnect.subscriptionErrorDelegate(this,
- new SubscriptionErrorEventArgs(null, ex));
- }
- }
- this.currentHangingRequest = null;
- }
-
- /**
- * Gets a value indicating whether this connection is opened
- *
- * @throws Exception
- */
- public boolean getIsOpen() throws Exception {
-
- this.throwIfDisposed();
- if (this.currentHangingRequest == null) {
- return false;
- } else {
- return this.currentHangingRequest.isConnected();
- }
-
- }
-
- /**
- * Validates the state of the connection.
- *
- * @param isConnectedExpected Value indicating whether we expect to be currently connected.
- * @param errorMessage The error message.
- * @throws Exception
- */
- private void validateConnectionState(boolean isConnectedExpected,
- String errorMessage) throws Exception {
- if ((isConnectedExpected && !this.getIsOpen())
- || (!isConnectedExpected && this.getIsOpen())) {
- throw new ServiceLocalException(errorMessage);
- }
- }
-
- /**
- * Handles the service response object.
- *
- * @param response The response.
- * @throws microsoft.exchange.webservices.data.ArgumentException
- */
- private void handleServiceResponseObject(Object response)
- throws ArgumentException {
- GetStreamingEventsResponse gseResponse = (GetStreamingEventsResponse) response;
-
- if (gseResponse == null) {
- throw new ArgumentException();
- } else {
- if (gseResponse.getResult() == ServiceResult.Success
- || gseResponse.getResult() == ServiceResult.Warning) {
- if (gseResponse.getResults().getNotifications().size() > 0) {
- // We got notifications; dole them out.
- this.issueNotificationEvents(gseResponse);
- } else {
- // // This was just a heartbeat, nothing to do here.
- }
- } else if (gseResponse.getResult() == ServiceResult.Error) {
- if (gseResponse.getErrorSubscriptionIds() == null
- || gseResponse.getErrorSubscriptionIds().size() == 0) {
- // General error
- this.issueGeneralFailure(gseResponse);
- } else {
- // subscription-specific errors
- this.issueSubscriptionFailures(gseResponse);
- }
- }
- }
- }
-
- /**
- * Issues the subscription failures.
- *
- * @param gseResponse The GetStreamingEvents response.
- */
- private void issueSubscriptionFailures(
- GetStreamingEventsResponse gseResponse) {
- ServiceResponseException exception = new ServiceResponseException(
- gseResponse);
-
- for (String id : gseResponse.getErrorSubscriptionIds()) {
- StreamingSubscription subscription = null;
-
- synchronized (this) {
- // Client can do any good or bad things in the below event
- // handler
- if (this.subscriptions != null
- && this.subscriptions.containsKey(id)) {
- subscription = this.subscriptions.get(id);
- }
-
- }
- if (subscription != null) {
- SubscriptionErrorEventArgs eventArgs = new SubscriptionErrorEventArgs(
- subscription, exception);
-
- if (!onSubscriptionError.isEmpty()) {
- for (ISubscriptionErrorDelegate subError : onSubscriptionError) {
- subError.subscriptionErrorDelegate(this, eventArgs);
- }
- }
- }
- if (gseResponse.getErrorCode() != ServiceError.ErrorMissedNotificationEvents) {
- // Client can do any good or bad things in the above event
- // handler
- synchronized (this) {
- if (this.subscriptions != null
- && this.subscriptions.containsKey(id)) {
- // We are no longer servicing the subscription.
- this.subscriptions.remove(id);
- }
- }
- }
- }
- }
-
- /**
- * Issues the general failure.
- *
- * @param gseResponse The GetStreamingEvents response.
- */
- private void issueGeneralFailure(GetStreamingEventsResponse gseResponse) {
- SubscriptionErrorEventArgs eventArgs = new SubscriptionErrorEventArgs(
- null, new ServiceResponseException(gseResponse));
-
- if (!onSubscriptionError.isEmpty()) {
- for (ISubscriptionErrorDelegate subError : onSubscriptionError) {
- subError.subscriptionErrorDelegate(this, eventArgs);
- }
- }
- }
-
- /**
- * Issues the notification events.
- *
- * @param gseResponse The GetStreamingEvents response.
- */
- private void issueNotificationEvents(GetStreamingEventsResponse gseResponse) {
-
- for (GetStreamingEventsResults.NotificationGroup events : gseResponse
- .getResults().getNotifications()) {
- StreamingSubscription subscription = null;
-
- synchronized (this) {
- // Client can do any good or bad things in the below event
- // handler
- if (this.subscriptions != null
- && this.subscriptions
- .containsKey(events.subscriptionId)) {
- subscription = this.subscriptions
- .get(events.subscriptionId);
- }
- }
- if (subscription != null) {
- NotificationEventArgs eventArgs = new NotificationEventArgs(
- subscription, events.events);
-
- if (!onNotificationEvent.isEmpty()) {
- for (INotificationEventDelegate notifyEvent : onNotificationEvent) {
- notifyEvent.notificationEventDelegate(this, eventArgs);
- }
- }
- }
- }
- }
-
- /**
- * Finalizes an instance of the StreamingSubscriptionConnection class.
- */
- @Override
- protected void finalize() throws Throwable {
- this.dispose(false);
- }
-
- /**
- * Frees resources associated with this StreamingSubscriptionConnection.
- */
- public void dispose() {
- this.dispose(true);
- }
-
- /**
- * Performs application-defined tasks associated with freeing, releasing, or
- * resetting unmanaged resources.
- *
- * @param suppressFinalizer Value indicating whether to suppress the garbage collector's
- * finalizer.
- */
- private void dispose(boolean suppressFinalizer) {
- if (suppressFinalizer) {
- System.runFinalizersOnExit(false);
- }
-
- synchronized (this) {
- if (!this.isDisposed) {
- if (this.currentHangingRequest != null) {
- this.currentHangingRequest = null;
- }
-
- this.subscriptions = null;
- this.session = null;
-
- this.isDisposed = true;
- }
- }
- }
-
- /**
- * Throws if disposed.
- *
- * @throws Exception
- */
- private void throwIfDisposed() throws Exception {
- if (this.isDisposed) {
- throw new Exception(this.getClass().getName());
- }
- }
-
- @Override
- public void handleResponseObject(Object response) throws ArgumentException {
- this.handleServiceResponseObject(response);
- }
-
- @Override
- public void hangingRequestDisconnectHandler(Object sender,
- HangingRequestDisconnectEventArgs args) {
- this.onRequestDisconnect(sender, args);
- }
-
-}
diff --git a/src/main/java/microsoft/exchange/webservices/data/util/TimeZoneUtils.java b/src/main/java/microsoft/exchange/webservices/data/util/TimeZoneUtils.java
new file mode 100644
index 000000000..fd4396c3f
--- /dev/null
+++ b/src/main/java/microsoft/exchange/webservices/data/util/TimeZoneUtils.java
@@ -0,0 +1,614 @@
+/*
+ * The MIT License
+ * Copyright (c) 2012 Microsoft Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package microsoft.exchange.webservices.data.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+/**
+ * Miscellany timezone functions
+ */
+public class TimeZoneUtils {
+ //a map of olson name > Microsoft Name
+ final static private Map olsonTimeZoneToMs = new HashMap();
+
+ static {
+ olsonTimeZoneToMs.put("Africa/Abidjan", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Accra", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Addis_Ababa", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Algiers", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Asmara", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Asmera", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Bamako", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Bangui", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Banjul", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Bissau", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Blantyre", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Brazzaville", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Bujumbura", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Cairo", "Egypt Standard Time");
+ olsonTimeZoneToMs.put("Africa/Casablanca", "Morocco Standard Time");
+ olsonTimeZoneToMs.put("Africa/Ceuta", "Romance Standard Time");
+ olsonTimeZoneToMs.put("Africa/Conakry", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Dakar", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Dar_es_Salaam", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Djibouti", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Douala", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/El_Aaiun", "Morocco Standard Time");
+ olsonTimeZoneToMs.put("Africa/Freetown", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Gaborone", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Harare", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Johannesburg", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Juba", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Kampala", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Khartoum", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Kigali", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Kinshasa", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Lagos", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Libreville", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Lome", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Luanda", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Lubumbashi", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Lusaka", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Malabo", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Maputo", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Maseru", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Mbabane", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Mogadishu", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Monrovia", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Nairobi", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Ndjamena", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Niamey", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Nouakchott", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Ouagadougou", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Porto-Novo", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Sao_Tome", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Timbuktu", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Africa/Tripoli", "Libya Standard Time");
+ olsonTimeZoneToMs.put("Africa/Tunis", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Africa/Windhoek", "Namibia Standard Time");
+ olsonTimeZoneToMs.put("America/Anchorage", "Alaskan Standard Time");
+ olsonTimeZoneToMs.put("America/Anguilla", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Antigua", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Araguaina", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Buenos_Aires", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Catamarca", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/ComodRivadavia", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Cordoba", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Jujuy", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/La_Rioja", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Mendoza", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Rio_Gallegos", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Salta", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/San_Juan", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/San_Luis", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Tucuman", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Argentina/Ushuaia", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Aruba", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Asuncion", "Paraguay Standard Time");
+ olsonTimeZoneToMs.put("America/Atikokan", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Bahia", "Bahia Standard Time");
+ olsonTimeZoneToMs.put("America/Bahia_Banderas", "Central Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("America/Barbados", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Belem", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Belize", "Central America Standard Time");
+ olsonTimeZoneToMs.put("America/Blanc-Sablon", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Boa_Vista", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Bogota", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Boise", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Buenos_Aires", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Cambridge_Bay", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Campo_Grande", "Central Brazilian Standard Time");
+ olsonTimeZoneToMs.put("America/Cancun", "Eastern Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("America/Caracas", "Venezuela Standard Time");
+ olsonTimeZoneToMs.put("America/Catamarca", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Cayenne", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Cayman", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Chicago", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Chihuahua", "Mountain Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("America/Coral_Harbour", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Cordoba", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Costa_Rica", "Central America Standard Time");
+ olsonTimeZoneToMs.put("America/Creston", "US Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Cuiaba", "Central Brazilian Standard Time");
+ olsonTimeZoneToMs.put("America/Curacao", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Danmarkshavn", "UTC");
+ olsonTimeZoneToMs.put("America/Dawson", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Dawson_Creek", "US Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Denver", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Detroit", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Dominica", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Edmonton", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Eirunepe", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/El_Salvador", "Central America Standard Time");
+ olsonTimeZoneToMs.put("America/Ensenada", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Fort_Wayne", "US Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Fortaleza", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Glace_Bay", "Atlantic Standard Time");
+ olsonTimeZoneToMs.put("America/Godthab", "Greenland Standard Time");
+ olsonTimeZoneToMs.put("America/Goose_Bay", "Atlantic Standard Time");
+ olsonTimeZoneToMs.put("America/Grand_Turk", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Grenada", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Guadeloupe", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Guatemala", "Central America Standard Time");
+ olsonTimeZoneToMs.put("America/Guayaquil", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Guyana", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Halifax", "Atlantic Standard Time");
+ olsonTimeZoneToMs.put("America/Havana", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Hermosillo", "US Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Indiana/Indianapolis", "US Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Indiana/Knox", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Indiana/Marengo", "US Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Indiana/Petersburg", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Indiana/Tell_City", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Indiana/Vevay", "US Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Indiana/Vincennes", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Indiana/Winamac", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Indianapolis", "US Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Inuvik", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Iqaluit", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Jamaica", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Jujuy", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Juneau", "Alaskan Standard Time");
+ olsonTimeZoneToMs.put("America/Kentucky/Louisville", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Kentucky/Monticello", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Knox_IN", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Kralendijk", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/La_Paz", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Lima", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Los_Angeles", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Louisville", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Lower_Princes", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Maceio", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Managua", "Central America Standard Time");
+ olsonTimeZoneToMs.put("America/Manaus", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Marigot", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Martinique", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Matamoros", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Mazatlan", "Mountain Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("America/Mendoza", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Menominee", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Merida", "Central Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("America/Mexico_City", "Central Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("America/Moncton", "Atlantic Standard Time");
+ olsonTimeZoneToMs.put("America/Monterrey", "Central Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("America/Montevideo", "Montevideo Standard Time");
+ olsonTimeZoneToMs.put("America/Montreal", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Montserrat", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Nassau", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/New_York", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Nipigon", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Nome", "Alaskan Standard Time");
+ olsonTimeZoneToMs.put("America/Noronha", "UTC-02");
+ olsonTimeZoneToMs.put("America/North_Dakota/Beulah", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/North_Dakota/Center", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/North_Dakota/New_Salem", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Ojinaga", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Panama", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Pangnirtung", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Paramaribo", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Phoenix", "US Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Port-au-Prince", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Port_of_Spain", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Porto_Acre", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Porto_Velho", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Puerto_Rico", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Rainy_River", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Rankin_Inlet", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Recife", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Regina", "Canada Central Standard Time");
+ olsonTimeZoneToMs.put("America/Resolute", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Rio_Branco", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Rosario", "Argentina Standard Time");
+ olsonTimeZoneToMs.put("America/Santa_Isabel", "Pacific Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("America/Santarem", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Santiago", "Pacific SA Standard Time");
+ olsonTimeZoneToMs.put("America/Santo_Domingo", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Sao_Paulo", "E. South America Standard Time");
+ olsonTimeZoneToMs.put("America/Scoresbysund", "Azores Standard Time");
+ olsonTimeZoneToMs.put("America/Shiprock", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("America/Sitka", "Alaskan Standard Time");
+ olsonTimeZoneToMs.put("America/St_Barthelemy", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/St_Johns", "Newfoundland Standard Time");
+ olsonTimeZoneToMs.put("America/St_Kitts", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/St_Lucia", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/St_Thomas", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/St_Vincent", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Swift_Current", "Canada Central Standard Time");
+ olsonTimeZoneToMs.put("America/Tegucigalpa", "Central America Standard Time");
+ olsonTimeZoneToMs.put("America/Thule", "Atlantic Standard Time");
+ olsonTimeZoneToMs.put("America/Thunder_Bay", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Tijuana", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Toronto", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("America/Tortola", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Vancouver", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Virgin", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("America/Whitehorse", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Winnipeg", "Central Standard Time");
+ olsonTimeZoneToMs.put("America/Yakutat", "Alaskan Standard Time");
+ olsonTimeZoneToMs.put("America/Yellowknife", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/Casey", "W. Australia Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/Davis", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/DumontDUrville", "West Pacific Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/Macquarie", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/Mawson", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/McMurdo", "New Zealand Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/Palmer", "Pacific SA Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/Rothera", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/South_Pole", "New Zealand Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/Syowa", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Antarctica/Vostok", "Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Arctic/Longyearbyen", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Asia/Aden", "Arab Standard Time");
+ olsonTimeZoneToMs.put("Asia/Almaty", "Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Amman", "Jordan Standard Time");
+ olsonTimeZoneToMs.put("Asia/Anadyr", "Russia Time Zone 11");
+ olsonTimeZoneToMs.put("Asia/Aqtau", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Aqtobe", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Ashgabat", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Ashkhabad", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Baghdad", "Arabic Standard Time");
+ olsonTimeZoneToMs.put("Asia/Bahrain", "Arab Standard Time");
+ olsonTimeZoneToMs.put("Asia/Baku", "Azerbaijan Standard Time");
+ olsonTimeZoneToMs.put("Asia/Bangkok", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Beirut", "Middle East Standard Time");
+ olsonTimeZoneToMs.put("Asia/Bishkek", "Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Brunei", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Asia/Calcutta", "India Standard Time");
+ olsonTimeZoneToMs.put("Asia/Chita", "North Asia East Standard Time");
+ olsonTimeZoneToMs.put("Asia/Choibalsan", "Ulaanbaatar Standard Time");
+ olsonTimeZoneToMs.put("Asia/Chongqing", "China Standard Time");
+ olsonTimeZoneToMs.put("Asia/Chungking", "China Standard Time");
+ olsonTimeZoneToMs.put("Asia/Colombo", "Sri Lanka Standard Time");
+ olsonTimeZoneToMs.put("Asia/Dacca", "Bangladesh Standard Time");
+ olsonTimeZoneToMs.put("Asia/Damascus", "Syria Standard Time");
+ olsonTimeZoneToMs.put("Asia/Dhaka", "Bangladesh Standard Time");
+ olsonTimeZoneToMs.put("Asia/Dili", "Tokyo Standard Time");
+ olsonTimeZoneToMs.put("Asia/Dubai", "Arabian Standard Time");
+ olsonTimeZoneToMs.put("Asia/Dushanbe", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Harbin", "China Standard Time");
+ olsonTimeZoneToMs.put("Asia/Ho_Chi_Minh", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Hong_Kong", "China Standard Time");
+ olsonTimeZoneToMs.put("Asia/Hovd", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Irkutsk", "North Asia East Standard Time");
+ olsonTimeZoneToMs.put("Asia/Istanbul", "Turkey Standard Time");
+ olsonTimeZoneToMs.put("Asia/Jakarta", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Jayapura", "Tokyo Standard Time");
+ olsonTimeZoneToMs.put("Asia/Jerusalem", "Israel Standard Time");
+ olsonTimeZoneToMs.put("Asia/Kabul", "Afghanistan Standard Time");
+ olsonTimeZoneToMs.put("Asia/Kamchatka", "Russia Time Zone 11");
+ olsonTimeZoneToMs.put("Asia/Karachi", "Pakistan Standard Time");
+ olsonTimeZoneToMs.put("Asia/Kashgar", "Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Kathmandu", "Nepal Standard Time");
+ olsonTimeZoneToMs.put("Asia/Katmandu", "Nepal Standard Time");
+ olsonTimeZoneToMs.put("Asia/Khandyga", "Yakutsk Standard Time");
+ olsonTimeZoneToMs.put("Asia/Kolkata", "India Standard Time");
+ olsonTimeZoneToMs.put("Asia/Krasnoyarsk", "North Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Kuala_Lumpur", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Asia/Kuching", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Asia/Kuwait", "Arab Standard Time");
+ olsonTimeZoneToMs.put("Asia/Macao", "China Standard Time");
+ olsonTimeZoneToMs.put("Asia/Macau", "China Standard Time");
+ olsonTimeZoneToMs.put("Asia/Magadan", "Magadan Standard Time");
+ olsonTimeZoneToMs.put("Asia/Makassar", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Asia/Manila", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Asia/Muscat", "Arabian Standard Time");
+ olsonTimeZoneToMs.put("Asia/Nicosia", "GTB Standard Time");
+ olsonTimeZoneToMs.put("Asia/Novokuznetsk", "North Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Novosibirsk", "N. Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Omsk", "N. Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Oral", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Phnom_Penh", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Pontianak", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Pyongyang", "Korea Standard Time");
+ olsonTimeZoneToMs.put("Asia/Qatar", "Arab Standard Time");
+ olsonTimeZoneToMs.put("Asia/Qyzylorda", "Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Rangoon", "Myanmar Standard Time");
+ olsonTimeZoneToMs.put("Asia/Riyadh", "Arab Standard Time");
+ olsonTimeZoneToMs.put("Asia/Saigon", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Sakhalin", "Vladivostok Standard Time");
+ olsonTimeZoneToMs.put("Asia/Samarkand", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Seoul", "Korea Standard Time");
+ olsonTimeZoneToMs.put("Asia/Shanghai", "China Standard Time");
+ olsonTimeZoneToMs.put("Asia/Singapore", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Asia/Srednekolymsk", "Russia Time Zone 10");
+ olsonTimeZoneToMs.put("Asia/Taipei", "Taipei Standard Time");
+ olsonTimeZoneToMs.put("Asia/Tashkent", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Tbilisi", "Georgian Standard Time");
+ olsonTimeZoneToMs.put("Asia/Tehran", "Iran Standard Time");
+ olsonTimeZoneToMs.put("Asia/Tel_Aviv", "Israel Standard Time");
+ olsonTimeZoneToMs.put("Asia/Thimbu", "Bangladesh Standard Time");
+ olsonTimeZoneToMs.put("Asia/Thimphu", "Bangladesh Standard Time");
+ olsonTimeZoneToMs.put("Asia/Tokyo", "Tokyo Standard Time");
+ olsonTimeZoneToMs.put("Asia/Ujung_Pandang", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Asia/Ulaanbaatar", "Ulaanbaatar Standard Time");
+ olsonTimeZoneToMs.put("Asia/Ulan_Bator", "Ulaanbaatar Standard Time");
+ olsonTimeZoneToMs.put("Asia/Urumqi", "Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Ust-Nera", "Vladivostok Standard Time");
+ olsonTimeZoneToMs.put("Asia/Vientiane", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Asia/Vladivostok", "Vladivostok Standard Time");
+ olsonTimeZoneToMs.put("Asia/Yakutsk", "Yakutsk Standard Time");
+ olsonTimeZoneToMs.put("Asia/Yekaterinburg", "Ekaterinburg Standard Time");
+ olsonTimeZoneToMs.put("Asia/Yerevan", "Caucasus Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Azores", "Azores Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Bermuda", "Atlantic Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Canary", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Cape_Verde", "Cape Verde Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Faeroe", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Faroe", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Jan_Mayen", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Madeira", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Reykjavik", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/South_Georgia", "UTC-02");
+ olsonTimeZoneToMs.put("Atlantic/St_Helena", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Atlantic/Stanley", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("Australia/ACT", "AUS Eastern Standard Time");
+ olsonTimeZoneToMs.put("Australia/Adelaide", "Cen. Australia Standard Time");
+ olsonTimeZoneToMs.put("Australia/Brisbane", "E. Australia Standard Time");
+ olsonTimeZoneToMs.put("Australia/Broken_Hill", "Cen. Australia Standard Time");
+ olsonTimeZoneToMs.put("Australia/Canberra", "AUS Eastern Standard Time");
+ olsonTimeZoneToMs.put("Australia/Currie", "Tasmania Standard Time");
+ olsonTimeZoneToMs.put("Australia/Darwin", "AUS Central Standard Time");
+ olsonTimeZoneToMs.put("Australia/Hobart", "Tasmania Standard Time");
+ olsonTimeZoneToMs.put("Australia/Lindeman", "E. Australia Standard Time");
+ olsonTimeZoneToMs.put("Australia/Melbourne", "AUS Eastern Standard Time");
+ olsonTimeZoneToMs.put("Australia/NSW", "AUS Eastern Standard Time");
+ olsonTimeZoneToMs.put("Australia/North", "AUS Central Standard Time");
+ olsonTimeZoneToMs.put("Australia/Perth", "W. Australia Standard Time");
+ olsonTimeZoneToMs.put("Australia/Queensland", "E. Australia Standard Time");
+ olsonTimeZoneToMs.put("Australia/South", "Cen. Australia Standard Time");
+ olsonTimeZoneToMs.put("Australia/Sydney", "AUS Eastern Standard Time");
+ olsonTimeZoneToMs.put("Australia/Tasmania", "Tasmania Standard Time");
+ olsonTimeZoneToMs.put("Australia/Victoria", "AUS Eastern Standard Time");
+ olsonTimeZoneToMs.put("Australia/West", "W. Australia Standard Time");
+ olsonTimeZoneToMs.put("Australia/Yancowinna", "Cen. Australia Standard Time");
+ olsonTimeZoneToMs.put("Brazil/Acre", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("Brazil/DeNoronha", "UTC-02");
+ olsonTimeZoneToMs.put("Brazil/East", "E. South America Standard Time");
+ olsonTimeZoneToMs.put("Brazil/West", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("CST6CDT", "Central Standard Time");
+ olsonTimeZoneToMs.put("Canada/Atlantic", "Atlantic Standard Time");
+ olsonTimeZoneToMs.put("Canada/Central", "Central Standard Time");
+ olsonTimeZoneToMs.put("Canada/East-Saskatchewan", "Canada Central Standard Time");
+ olsonTimeZoneToMs.put("Canada/Eastern", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("Canada/Mountain", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("Canada/Newfoundland", "Newfoundland Standard Time");
+ olsonTimeZoneToMs.put("Canada/Pacific", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("Canada/Saskatchewan", "Canada Central Standard Time");
+ olsonTimeZoneToMs.put("Canada/Yukon", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("Chile/Continental", "Pacific SA Standard Time");
+ olsonTimeZoneToMs.put("Cuba", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("EST", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("EST5EDT", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("Egypt", "Egypt Standard Time");
+ olsonTimeZoneToMs.put("Eire", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT", "UTC");
+ olsonTimeZoneToMs.put("Etc/GMT+0", "UTC");
+ olsonTimeZoneToMs.put("Etc/GMT+1", "Cape Verde Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT+10", "Hawaiian Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT+11", "UTC-11");
+ olsonTimeZoneToMs.put("Etc/GMT+12", "Dateline Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT+2", "UTC-02");
+ olsonTimeZoneToMs.put("Etc/GMT+3", "SA Eastern Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT+4", "SA Western Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT+5", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT+6", "Central America Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT+7", "US Mountain Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-0", "UTC");
+ olsonTimeZoneToMs.put("Etc/GMT-1", "W. Central Africa Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-10", "West Pacific Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-11", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-12", "UTC+12");
+ olsonTimeZoneToMs.put("Etc/GMT-13", "Tonga Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-14", "Line Islands Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-2", "South Africa Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-3", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-4", "Arabian Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-5", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-6", "Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-7", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-8", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT-9", "Tokyo Standard Time");
+ olsonTimeZoneToMs.put("Etc/GMT0", "UTC");
+ olsonTimeZoneToMs.put("Etc/Greenwich", "UTC");
+ olsonTimeZoneToMs.put("Etc/UCT", "UTC");
+ olsonTimeZoneToMs.put("Etc/UTC", "UTC");
+ olsonTimeZoneToMs.put("Etc/Universal", "UTC");
+ olsonTimeZoneToMs.put("Etc/Zulu", "UTC");
+ olsonTimeZoneToMs.put("Europe/Amsterdam", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Andorra", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Athens", "GTB Standard Time");
+ olsonTimeZoneToMs.put("Europe/Belfast", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Europe/Belgrade", "Central Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Berlin", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Bratislava", "Central Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Brussels", "Romance Standard Time");
+ olsonTimeZoneToMs.put("Europe/Bucharest", "GTB Standard Time");
+ olsonTimeZoneToMs.put("Europe/Budapest", "Central Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Busingen", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Chisinau", "GTB Standard Time");
+ olsonTimeZoneToMs.put("Europe/Copenhagen", "Romance Standard Time");
+ olsonTimeZoneToMs.put("Europe/Dublin", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Europe/Gibraltar", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Guernsey", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Europe/Helsinki", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Isle_of_Man", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Europe/Istanbul", "Turkey Standard Time");
+ olsonTimeZoneToMs.put("Europe/Jersey", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Europe/Kaliningrad", "Kaliningrad Standard Time");
+ olsonTimeZoneToMs.put("Europe/Kiev", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Lisbon", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Europe/Ljubljana", "Central Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/London", "GMT Standard Time");
+ olsonTimeZoneToMs.put("Europe/Luxembourg", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Madrid", "Romance Standard Time");
+ olsonTimeZoneToMs.put("Europe/Malta", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Mariehamn", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Minsk", "Belarus Standard Time");
+ olsonTimeZoneToMs.put("Europe/Monaco", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Moscow", "Russian Standard Time");
+ olsonTimeZoneToMs.put("Europe/Nicosia", "GTB Standard Time");
+ olsonTimeZoneToMs.put("Europe/Oslo", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Paris", "Romance Standard Time");
+ olsonTimeZoneToMs.put("Europe/Podgorica", "Central Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Prague", "Central Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Riga", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Rome", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Samara", "Russia Time Zone 3");
+ olsonTimeZoneToMs.put("Europe/San_Marino", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Sarajevo", "Central European Standard Time");
+ olsonTimeZoneToMs.put("Europe/Simferopol", "Russian Standard Time");
+ olsonTimeZoneToMs.put("Europe/Skopje", "Central European Standard Time");
+ olsonTimeZoneToMs.put("Europe/Sofia", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Stockholm", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Tallinn", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Tirane", "Central Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Tiraspol", "GTB Standard Time");
+ olsonTimeZoneToMs.put("Europe/Uzhgorod", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Vaduz", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Vatican", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Vienna", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("Europe/Vilnius", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Volgograd", "Russian Standard Time");
+ olsonTimeZoneToMs.put("Europe/Warsaw", "Central European Standard Time");
+ olsonTimeZoneToMs.put("Europe/Zagreb", "Central European Standard Time");
+ olsonTimeZoneToMs.put("Europe/Zaporozhye", "FLE Standard Time");
+ olsonTimeZoneToMs.put("Europe/Zurich", "W. Europe Standard Time");
+ olsonTimeZoneToMs.put("GB", "GMT Standard Time");
+ olsonTimeZoneToMs.put("GB-Eire", "GMT Standard Time");
+ olsonTimeZoneToMs.put("GMT", "UTC");
+ olsonTimeZoneToMs.put("GMT+0", "UTC");
+ olsonTimeZoneToMs.put("GMT-0", "UTC");
+ olsonTimeZoneToMs.put("GMT0", "UTC");
+ olsonTimeZoneToMs.put("Greenwich", "UTC");
+ olsonTimeZoneToMs.put("HST", "Hawaiian Standard Time");
+ olsonTimeZoneToMs.put("Hongkong", "China Standard Time");
+ olsonTimeZoneToMs.put("Iceland", "Greenwich Standard Time");
+ olsonTimeZoneToMs.put("Indian/Antananarivo", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Indian/Chagos", "Central Asia Standard Time");
+ olsonTimeZoneToMs.put("Indian/Christmas", "SE Asia Standard Time");
+ olsonTimeZoneToMs.put("Indian/Cocos", "Myanmar Standard Time");
+ olsonTimeZoneToMs.put("Indian/Comoro", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Indian/Kerguelen", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Indian/Mahe", "Mauritius Standard Time");
+ olsonTimeZoneToMs.put("Indian/Maldives", "West Asia Standard Time");
+ olsonTimeZoneToMs.put("Indian/Mauritius", "Mauritius Standard Time");
+ olsonTimeZoneToMs.put("Indian/Mayotte", "E. Africa Standard Time");
+ olsonTimeZoneToMs.put("Indian/Reunion", "Mauritius Standard Time");
+ olsonTimeZoneToMs.put("Iran", "Iran Standard Time");
+ olsonTimeZoneToMs.put("Israel", "Israel Standard Time");
+ olsonTimeZoneToMs.put("Jamaica", "SA Pacific Standard Time");
+ olsonTimeZoneToMs.put("Japan", "Tokyo Standard Time");
+ olsonTimeZoneToMs.put("Kwajalein", "UTC+12");
+ olsonTimeZoneToMs.put("Libya", "Libya Standard Time");
+ olsonTimeZoneToMs.put("MST", "US Mountain Standard Time");
+ olsonTimeZoneToMs.put("MST7MDT", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("Mexico/BajaNorte", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("Mexico/BajaSur", "Mountain Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("Mexico/General", "Central Standard Time (Mexico)");
+ olsonTimeZoneToMs.put("NZ", "New Zealand Standard Time");
+ olsonTimeZoneToMs.put("Navajo", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("PRC", "China Standard Time");
+ olsonTimeZoneToMs.put("PST8PDT", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Apia", "Samoa Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Auckland", "New Zealand Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Bougainville", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Chuuk", "West Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Efate", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Enderbury", "Tonga Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Fakaofo", "Tonga Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Fiji", "Fiji Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Funafuti", "UTC+12");
+ olsonTimeZoneToMs.put("Pacific/Galapagos", "Central America Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Guadalcanal", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Guam", "West Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Honolulu", "Hawaiian Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Johnston", "Hawaiian Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Kiritimati", "Line Islands Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Kosrae", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Kwajalein", "UTC+12");
+ olsonTimeZoneToMs.put("Pacific/Majuro", "UTC+12");
+ olsonTimeZoneToMs.put("Pacific/Midway", "UTC-11");
+ olsonTimeZoneToMs.put("Pacific/Nauru", "UTC+12");
+ olsonTimeZoneToMs.put("Pacific/Niue", "UTC-11");
+ olsonTimeZoneToMs.put("Pacific/Noumea", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Pago_Pago", "UTC-11");
+ olsonTimeZoneToMs.put("Pacific/Palau", "Tokyo Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Pohnpei", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Ponape", "Central Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Port_Moresby", "West Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Rarotonga", "Hawaiian Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Saipan", "West Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Samoa", "UTC-11");
+ olsonTimeZoneToMs.put("Pacific/Tahiti", "Hawaiian Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Tarawa", "UTC+12");
+ olsonTimeZoneToMs.put("Pacific/Tongatapu", "Tonga Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Truk", "West Pacific Standard Time");
+ olsonTimeZoneToMs.put("Pacific/Wake", "UTC+12");
+ olsonTimeZoneToMs.put("Pacific/Wallis", "UTC+12");
+ olsonTimeZoneToMs.put("Pacific/Yap", "West Pacific Standard Time");
+ olsonTimeZoneToMs.put("Poland", "Central European Standard Time");
+ olsonTimeZoneToMs.put("Portugal", "GMT Standard Time");
+ olsonTimeZoneToMs.put("ROC", "Taipei Standard Time");
+ olsonTimeZoneToMs.put("ROK", "Korea Standard Time");
+ olsonTimeZoneToMs.put("Singapore", "Singapore Standard Time");
+ olsonTimeZoneToMs.put("Turkey", "Turkey Standard Time");
+ olsonTimeZoneToMs.put("UCT", "UTC");
+ olsonTimeZoneToMs.put("US/Alaska", "Alaskan Standard Time");
+ olsonTimeZoneToMs.put("US/Arizona", "US Mountain Standard Time");
+ olsonTimeZoneToMs.put("US/Central", "Central Standard Time");
+ olsonTimeZoneToMs.put("US/East-Indiana", "US Eastern Standard Time");
+ olsonTimeZoneToMs.put("US/Eastern", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("US/Hawaii", "Hawaiian Standard Time");
+ olsonTimeZoneToMs.put("US/Indiana-Starke", "Central Standard Time");
+ olsonTimeZoneToMs.put("US/Michigan", "Eastern Standard Time");
+ olsonTimeZoneToMs.put("US/Mountain", "Mountain Standard Time");
+ olsonTimeZoneToMs.put("US/Pacific", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("US/Pacific-New", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("US/Samoa", "UTC-11");
+ olsonTimeZoneToMs.put("UTC", "UTC");
+ olsonTimeZoneToMs.put("Universal", "UTC");
+ olsonTimeZoneToMs.put("W-SU", "Russian Standard Time");
+ olsonTimeZoneToMs.put("Zulu", "UTC");
+ //additions outside of Unicode list
+ olsonTimeZoneToMs.put("America/Adak", "Hawaiian Standard Time,(UTC-10:00) Hawaii");
+ olsonTimeZoneToMs.put("America/Atka", "Hawaiian Standard Time,(UTC-10:00) Hawaii");
+ olsonTimeZoneToMs.put("America/Metlakatla", "Pacific Standard Time");
+ olsonTimeZoneToMs.put("America/Miquelon", "South America Standard Time");
+ olsonTimeZoneToMs.put("Asia/Gaza", "Middle East Standard Time");
+ }
+
+ /**
+ * Convert Olson TimeZone to Microsoft TimeZone Generated using Unicode CLDR project Example:
+ * https://gist.github.com/scottmac/655675e9b4d4913c539c
+ *
+ * @param timeZone java timezone (Olson)
+ * @return a microsoft timezone identifier (ala Eastern Standard Time)
+ */
+ public static String getMicrosoftTimeZoneName(TimeZone timeZone) {
+ return olsonTimeZoneToMs.get(timeZone.getID());
+ }
+
+}
diff --git a/src/test/java/microsoft/exchange/webservices/data/GetUserSettingsRequestTest.java b/src/test/java/microsoft/exchange/webservices/data/GetUserSettingsRequestTest.java
deleted file mode 100644
index b42a814b2..000000000
--- a/src/test/java/microsoft/exchange/webservices/data/GetUserSettingsRequestTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * The MIT License
- * Copyright (c) 2012 Microsoft Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-package microsoft.exchange.webservices.data;
-
-
-import org.hamcrest.core.IsNot;
-import org.hamcrest.core.IsNull;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import javax.xml.stream.XMLStreamException;
-import java.io.ByteArrayOutputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Testclass for methods of GetUserSettingsRequest
- */
-@RunWith(Parameterized.class)
-public class GetUserSettingsRequestTest extends BaseTest {
-
- /**
- * The ExchangeVersion which is under test
- */
- private final ExchangeVersion exchangeVersion;
-
- /**
- * The AutodiscoverService which is under test
- */
- private final AutodiscoverService autodiscoverService;
-
- /**
- * A mocked URI via HTTPS
- */
- private final URI uriMockHttps = URI.create("https://localhost");
-
- /**
- * A mocked URI via HTTP
- */
- private final URI uriMockHttp = URI.create("http://localhost");
-
- /**
- * Returns the Parameters which where handled to the constructor
- *
- * @return the available Services
- * @throws ArgumentException
- */
- @Parameterized.Parameters
- public static List