Issue #2120 Fixed SSL connection problem
Change-Id: I4a4e277ac75420bbaa621dcddb562e654211436c Former-commit-id:4a6248547a
[formerlyffc9dc1ac9
] [formerly4a6248547a
[formerlyffc9dc1ac9
] [formerly47d18e42ab
[formerly 85d7c148e78a61025fa52f8c0996f99ab6075392]]] Former-commit-id:47d18e42ab
Former-commit-id:b2545d7408
[formerly5d37e710d7
] Former-commit-id:806fb4f3db
This commit is contained in:
parent
7bba9c5a01
commit
0477abf081
3 changed files with 99 additions and 8 deletions
|
@ -1,9 +1,7 @@
|
|||
package com.raytheon.uf.edex.datadelivery.retrieval.wfs;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||
|
@ -19,7 +17,6 @@ import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
|
|||
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalGenerator;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.adapters.RetrievalAdapter;
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.raytheon.uf.edex.datadelivery.retrieval.util;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
||||
import com.raytheon.uf.common.comm.HttpClient;
|
||||
import com.raytheon.uf.common.comm.HttpClient.HttpClientResponse;
|
||||
import com.raytheon.uf.common.comm.IHttpsConfiguration;
|
||||
import com.raytheon.uf.common.comm.IHttpsCredentialsHandler;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Connection;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
@ -36,17 +39,14 @@ public class WfsConnectionUtil {
|
|||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(WfsConnectionUtil.class);
|
||||
|
||||
|
||||
public static String wfsConnect(String url, Connection conn,
|
||||
String providerName) {
|
||||
String xmlResponse = null;
|
||||
HttpClient http = null;
|
||||
|
||||
try {
|
||||
// Sets up any proxy info that might be necessary
|
||||
// TODO: consider using HTTP POST instead of GET
|
||||
ConnectionUtil.getProxyParameters();
|
||||
//url = url.replace("https://dev11:8888", "http://dev05:8085");
|
||||
http = HttpClient.getInstance();
|
||||
HttpGet get = new HttpGet();
|
||||
URI uri = new URI(url);
|
||||
|
@ -55,6 +55,9 @@ public class WfsConnectionUtil {
|
|||
&& conn.getPassword() != null) {
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Attempting credential request: " + providerName);
|
||||
http.setHandler(new WfsCredentialsHandler(conn.getUserName(),
|
||||
conn.getUnencryptedPassword()));
|
||||
http.setHttpsConfiguration(new WfsHttpsConfiguration(uri));
|
||||
http.setCredentials(uri.getHost(), uri.getPort(), providerName,
|
||||
conn.getUserName(), conn.getUnencryptedPassword());
|
||||
}
|
||||
|
@ -62,6 +65,7 @@ public class WfsConnectionUtil {
|
|||
get.setURI(uri);
|
||||
HttpClientResponse response = http.executeRequest(get);
|
||||
xmlResponse = new String(response.data);
|
||||
//System.out.println("Response: "+xmlResponse);
|
||||
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
|
@ -70,5 +74,93 @@ public class WfsConnectionUtil {
|
|||
|
||||
return xmlResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Credentials Holder
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 19, 2013 2120 dhladky Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
private static class WfsCredentialsHandler implements IHttpsCredentialsHandler {
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
@Override
|
||||
public String[] getCredentials(String message) {
|
||||
return new String[] { username,
|
||||
password };
|
||||
}
|
||||
|
||||
public WfsCredentialsHandler(String username, String password) {
|
||||
this.password = password;
|
||||
this.username = username;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* HTTPS Configuration
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 19, 2013 2120 dhladky Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
* @version 1.0
|
||||
*/
|
||||
private static class WfsHttpsConfiguration implements IHttpsConfiguration {
|
||||
|
||||
private int httpsPort = 443;
|
||||
|
||||
private int httpPort = 80;
|
||||
|
||||
public WfsHttpsConfiguration(URI uri) {
|
||||
|
||||
try {
|
||||
if (uri.getScheme().equals("http")) {
|
||||
httpPort = uri.getPort();
|
||||
} else if (uri.getScheme().equals("https")) {
|
||||
httpsPort = uri.getPort();
|
||||
if (httpsPort == -1) {
|
||||
httpsPort = 443; // The default https port
|
||||
}
|
||||
} else {
|
||||
throw new URISyntaxException(uri.toString(),
|
||||
"Invalid server");
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Syntax or URI is bad!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHttpsPort() {
|
||||
return httpsPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHttpPort() {
|
||||
return httpPort;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ import org.eclipse.jetty.servlets.ProxyServlet;
|
|||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.util.security.Credential;
|
||||
|
||||
import com.raytheon.uf.common.comm.HttpProxyTestConstants;
|
||||
|
||||
/**
|
||||
* This class sets up a Jetty Server that can serve up Proxied HttpServlets in
|
||||
* either http or https mode.
|
||||
|
@ -227,6 +229,6 @@ public class ProxiedJettyServer {
|
|||
// Run this server
|
||||
ProxiedJettyServer server = new ProxiedJettyServer(redirectHost, port,
|
||||
sport, context, realm, user, password);
|
||||
server.startServer();
|
||||
server.startSSLServer();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue