Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
Got jets3t working with https. Currently the choices are:
Browse files Browse the repository at this point in the history
1) http
2) https such that *all* server certs are accepted
3) use the java system key store
  • Loading branch information
BuzzTroll committed Jul 13, 2010
1 parent 78655b4 commit ce5d9fe
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .idea/libraries/cloud_client_libs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -97,6 +97,7 @@ public AllArgs(Print print) {
private String xferS3Key;
private String xferS3BaseKey;
private String xferS3Https;
private String xferS3AllowSelfSigned;
private String s3Bucket;
private String gridftpID;
private String handle;
Expand Down Expand Up @@ -641,6 +642,14 @@ public void intakeProperties(Properties props,
sourceName);
}

if(this.xferS3AllowSelfSigned == null) {
this.xferS3AllowSelfSigned =
CloudClientUtil.getProp(props, Props.KEY_S3_ALLOW_SELF_SIGNED);
this.gotProp(Props.KEY_S3_ALLOW_SELF_SIGNED,
this.xferS3AllowSelfSigned,
sourceName);
}

if (this.xferS3Https == null) {
this.xferS3Https =
CloudClientUtil.getProp(props, Props.KEY_S3_HTTPS);
Expand Down Expand Up @@ -1037,6 +1046,14 @@ public void setXferType(String xferType) {
this.xferType = xferType;
}

public String getXferS3AllowSelfSigned() {
return this.xferS3AllowSelfSigned;
}

public void setXferS3AllowSelfSigned(String xferS3AllowSelfSigned) {
this.xferS3AllowSelfSigned = xferS3AllowSelfSigned;
}

public String getXferS3Https() {
return this.xferS3Https;
}
Expand Down
Expand Up @@ -33,6 +33,9 @@ public class Props {
public static final String
KEY_FACTORY_HOSTPORT = "vws.factory";

public static final String
KEY_S3_ALLOW_SELF_SIGNED = "vws.repository.s3acceptallcerts";

public static final String
KEY_XFER_HOSTPORT = "vws.repository";

Expand Down
Expand Up @@ -47,7 +47,18 @@ public CumulusRepositoryUtil(
{
useHttps = "false";
}
cumulusTask = new CumulusTask(args, pr, useHttps);
boolean ss;
String selfSigned = this.args.getXferS3AllowSelfSigned();
if(selfSigned == null || selfSigned.equalsIgnoreCase("true"))
{
ss = true;
}
else
{
ss = false;
}

cumulusTask = new CumulusTask(args, pr, useHttps, ss);
}

public void paramterCheck(
Expand Down
Expand Up @@ -17,6 +17,12 @@
package org.globus.workspace.cloud.client.util;

import edu.emory.mathcs.backport.java.util.concurrent.Callable;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory;
import org.apache.commons.httpclient.contrib.ssl.TrustSSLProtocolSocketFactory;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory;
import org.globus.workspace.client_core.ExecutionProblem;
import org.globus.workspace.cloud.client.AllArgs;
import org.globus.workspace.common.print.Print;
Expand Down Expand Up @@ -251,16 +257,19 @@ public class CumulusTask
private AllArgs args;
private Print print;
private String useHttps;
private boolean allowSelfSigned;


public CumulusTask(
AllArgs args,
Print pr,
String useHttps)
String useHttps,
boolean allowSelfSigned)
{
this.args = args;
this.print = pr;
this.useHttps = useHttps;
this.allowSelfSigned = allowSelfSigned;
}

public void setTask(
Expand Down Expand Up @@ -490,32 +499,48 @@ private S3Service getService()
int port = 80;
String portS = "80";
String httpsPortS = "443";
int httpsPort = 443;

if(ndx > 0)
{
portS = host.substring(ndx+1);
httpsPortS = portS;
port = new Integer(portS).intValue();
httpsPort = new Integer(httpsPortS).intValue();
host = host.substring(0, ndx);
}

Jets3tProperties j3p = new Jets3tProperties();


portS = "5555";
System.out.println(host);
j3p.setProperty("s3service.s3-endpoint", host);
j3p.setProperty("s3service.s3-endpoint-http-port", portS);
j3p.setProperty("s3service.s3-endpoint-https-port", httpsPortS);
j3p.setProperty("s3service.disable-dns-buckets", "true");
j3p.setProperty("s3service.s3-endpoint", host);
j3p.setProperty("s3service.https-only", this.useHttps);

HostConfiguration hc = null;
if(allowSelfSigned)
{
// magic needed for jets3t to work with self signed cert.
try
{
String cert = "/home/bresnaha/2944337c.0.pem";
Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
Protocol.registerProtocol("https", easyhttps);
}
catch(Exception ex)
{
throw new S3ServiceException("Could not make the self signed handler " + ex.toString(), ex);
}
hc = new HostConfiguration();
}
AWSCredentials awsCredentials = this.getAwsCredentail();
S3Service s3Service = new RestS3Service(
awsCredentials,
"cloud-client",
null,
j3p);
j3p,
hc);

return s3Service;
}
Expand Down

0 comments on commit ce5d9fe

Please sign in to comment.