Commit 1d5ab4b8 authored by shake's avatar shake
Browse files

Added ssl support

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@199 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent f564ef1b
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="ace-ims-ws" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.16" level="project" />
<orderEntry type="module" module-name="ace-common" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.8.2" level="project" />
</component>
</module>
......@@ -60,21 +60,18 @@ public final class IMSService
{
private static final int DEFAULT_PORT = 8080;
private static final String DEFAULT_PATH = "/ace-ims/IMSWebService?wsdl";
private static final boolean DEFAULT_SSL = false;
private IMSWebService port;
private IMSService(URL url)
{
try
{
private IMSService(URL url) {
try {
IMSWebService_Service service = new IMSWebService_Service(url,
new QName("http://ws.ims.ace.umiacs.edu/", "IMSWebService"));
port = service.getIMSWebServicePort();
((BindingProvider)port).getRequestContext()
.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
}
catch ( Exception e )
{
} catch ( Exception e ) {
throw handleException(e);
}
}
......@@ -88,24 +85,26 @@ public final class IMSService
* @return ims connection
*/
public static IMSService connect(String hostName, int portNumber,
String path)
{
String path, boolean ssl) {
Check.notEmpty("hostName", hostName);
Check.isPositive("portNumber", portNumber);
Check.notEmpty("path", path);
if ( !path.startsWith("/") )
{
if ( !path.startsWith("/") ) {
path = "/" + path;
}
String url = "http://" + hostName + ":" + portNumber + path;
try
{
return new IMSService(new URL(url));
StringBuilder url = new StringBuilder();
if ( ssl ) {
url.append("https://").append(hostName).append(":")
.append(portNumber).append(path);
}else {
url.append("http://").append(hostName).append(":")
.append(portNumber).append(path);
}
catch ( MalformedURLException mue )
{
try {
return new IMSService(new URL(url.toString()));
} catch ( MalformedURLException mue ) {
throw new IllegalArgumentException("Invalid URL: " + url);
}
}
......@@ -119,12 +118,16 @@ public final class IMSService
*/
public static IMSService connect(String hostName)
{
return IMSService.connect(hostName, DEFAULT_PORT, DEFAULT_PATH);
return IMSService.connect(hostName, DEFAULT_PORT, DEFAULT_PATH, DEFAULT_SSL);
}
public static IMSService connect(String hostName, int port)
{
return IMSService.connect(hostName, port, DEFAULT_PATH);
return IMSService.connect(hostName, port, DEFAULT_PATH, DEFAULT_SSL);
}
public static IMSService connect(String hostName, int port, boolean ssl) {
return IMSService.connect(hostName, port, DEFAULT_PATH, ssl);
}
// public TokenClass createTokenClass(TokenClass tokenClass)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment