/** * Create a redirection response. * * @param httpWebResponse The HTTP web response. * @return AutodiscoverResponse autodiscoverResponse object. * @throws javax.xml.stream.XMLStreamException the xML stream exception * @throws java.io.IOException Signals that an I/O exception has occurred. * @throws microsoft.exchange.webservices.data.exception.EWSHttpException the eWS http exception */ private AutodiscoverResponse createRedirectionResponse(HttpWebRequest httpWebResponse) throws XMLStreamException, IOException, EWSHttpException { String location = httpWebResponse.getResponseHeaderField("Location"); if (!(location == null || location.isEmpty())) { try { URI redirectionUri = new URI(location); if (redirectionUri.getScheme().toLowerCase().equals("http") || redirectionUri.getScheme().toLowerCase().equals("https")) { AutodiscoverResponse response = this.createServiceResponse(); response.setErrorCode(AutodiscoverErrorCode.RedirectUrl); response.setRedirectionUrl(redirectionUri); return response; } this.service.traceMessage( TraceFlags.AutodiscoverConfiguration, String.format( "Invalid redirection" + " URL '%s' " + "returned by Autodiscover " + "service.", redirectionUri.toString())); } catch (URISyntaxException ex) { this.service.traceMessage( TraceFlags.AutodiscoverConfiguration, String.format( "Invalid redirection " + "location '%s' " + "returned by Autodiscover " + "service.", location)); } } else { this.service.traceMessage( TraceFlags.AutodiscoverConfiguration, "Redirection response returned by Autodiscover " + "service without redirection location."); } return null; }