Skip to content

Commit

Permalink
Merge pull request #111 from ellert/master
Browse files Browse the repository at this point in the history
Make tomcat7 the default profile and rebase patches accordingly.
  • Loading branch information
kofemann committed Feb 3, 2014
2 parents 361db1c + 82dced2 commit 068396b
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 205 deletions.
166 changes: 83 additions & 83 deletions gridftp/src/test/java/org/globus/ftp/test/SimpleTarTransfer.java
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
package org.globus.ftp.test;

import org.globus.ftp.GridFTPClient;
import org.globus.ftp.Session;
import org.globus.gsi.gssapi.auth.IdentityAuthorization;
import org.globus.util.ConfigUtil;
import org.gridforum.jgss.ExtendedGSSCredential;
import org.gridforum.jgss.ExtendedGSSManager;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class SimpleTarTransfer {

public static void main(String[] args) throws Exception {
String tarAlias = "tar";
String host = "localhost";//args[0];
int port = 60000;//new Integer(args[1]).intValue();
String sourceParentDir = "/tmp";// args[2];
String sourceDir = "tartest";//args[3];
String destFile = "/tmp/target.tar";

GSSCredential cred = getDefaultCredential();
String tarCommand = createDownloadTarSiteCommand(sourceParentDir, sourceDir, tarAlias);
GridFTPClient client = createClient(host, port, cred, tarCommand);
downloadTarToFile(client, sourceDir, destFile);
}

static GridFTPClient createClient(String host, int port, GSSCredential cred, String tarCommand) throws Exception {
GridFTPClient client = null;
client = new GridFTPClient(host, port);
client.setAuthorization(new IdentityAuthorization("/O=Grid/OU=GlobusTest/OU=simpleCA-ubuntu/CN=Vijay Anand"));
client.authenticate(cred);
client.setType(Session.TYPE_IMAGE);
try {
client.site(tarCommand);
} catch (Exception e) {
throw new Exception("popen driver not supported", e);
}
client.setPassive();
client.setLocalActive();
return client;
}

static String createDownloadTarSiteCommand(String sourceParentDir, String sourceDir, String tarAlias) {
StringBuffer sb = new StringBuffer();
sb.append("SETDISKSTACK popen:argv=#");
sb.append(tarAlias);
sb.append("#cf#-#-C#");
sb.append(sourceParentDir);
sb.append("#");
sb.append(sourceDir);
return sb.toString();
}

static void downloadTarToFile(GridFTPClient client, String sourceDir, String destFile) throws Exception {
try {
client.get(sourceDir, new File(destFile));
} finally {
if (client != null) {
client.close(true);
}
}
}

static GSSCredential getDefaultCredential() throws IOException, GSSException {
File proxyFile = new File(ConfigUtil.discoverProxyLocation());
byte[] proxyBytes = new byte[(int) proxyFile.length()];
FileInputStream in = new FileInputStream(proxyFile);
try {
in.read(proxyBytes);
} finally {
in.close();
}
ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance();
return manager.createCredential(proxyBytes, ExtendedGSSCredential.IMPEXP_OPAQUE,
GSSCredential.DEFAULT_LIFETIME, null, GSSCredential.INITIATE_AND_ACCEPT);
}

}
package org.globus.ftp.test;

import org.globus.ftp.GridFTPClient;
import org.globus.ftp.Session;
import org.globus.gsi.gssapi.auth.IdentityAuthorization;
import org.globus.util.ConfigUtil;
import org.gridforum.jgss.ExtendedGSSCredential;
import org.gridforum.jgss.ExtendedGSSManager;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class SimpleTarTransfer {

public static void main(String[] args) throws Exception {
String tarAlias = "tar";
String host = "localhost";//args[0];
int port = 60000;//new Integer(args[1]).intValue();
String sourceParentDir = "/tmp";// args[2];
String sourceDir = "tartest";//args[3];
String destFile = "/tmp/target.tar";

GSSCredential cred = getDefaultCredential();
String tarCommand = createDownloadTarSiteCommand(sourceParentDir, sourceDir, tarAlias);
GridFTPClient client = createClient(host, port, cred, tarCommand);
downloadTarToFile(client, sourceDir, destFile);
}

static GridFTPClient createClient(String host, int port, GSSCredential cred, String tarCommand) throws Exception {
GridFTPClient client = null;
client = new GridFTPClient(host, port);
client.setAuthorization(new IdentityAuthorization("/O=Grid/OU=GlobusTest/OU=simpleCA-ubuntu/CN=Vijay Anand"));
client.authenticate(cred);
client.setType(Session.TYPE_IMAGE);
try {
client.site(tarCommand);
} catch (Exception e) {
throw new Exception("popen driver not supported", e);
}
client.setPassive();
client.setLocalActive();
return client;
}

static String createDownloadTarSiteCommand(String sourceParentDir, String sourceDir, String tarAlias) {
StringBuffer sb = new StringBuffer();
sb.append("SETDISKSTACK popen:argv=#");
sb.append(tarAlias);
sb.append("#cf#-#-C#");
sb.append(sourceParentDir);
sb.append("#");
sb.append(sourceDir);
return sb.toString();
}

static void downloadTarToFile(GridFTPClient client, String sourceDir, String destFile) throws Exception {
try {
client.get(sourceDir, new File(destFile));
} finally {
if (client != null) {
client.close(true);
}
}
}

static GSSCredential getDefaultCredential() throws IOException, GSSException {
File proxyFile = new File(ConfigUtil.discoverProxyLocation());
byte[] proxyBytes = new byte[(int) proxyFile.length()];
FileInputStream in = new FileInputStream(proxyFile);
try {
in.read(proxyBytes);
} finally {
in.close();
}
ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance();
return manager.createCredential(proxyBytes, ExtendedGSSCredential.IMPEXP_OPAQUE,
GSSCredential.DEFAULT_LIFETIME, null, GSSCredential.INITIATE_AND_ACCEPT);
}

}
38 changes: 19 additions & 19 deletions ssl-proxies-tomcat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
<profiles>
<profile>
<id>tomcat7</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.32</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
<version>7.0.32</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>tomcat6</id>
<build>
<plugins>
<plugin>
Expand All @@ -18,7 +36,7 @@
<version>1.1.1</version>
<configuration>
<patches>
<patch>jglobus-tomcat7.patch</patch>
<patch>jglobus-tomcat6.patch</patch>
</patches>
<strip>5</strip>
</configuration>
Expand All @@ -34,24 +52,6 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.32</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-coyote</artifactId>
<version>7.0.32</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>tomcat6</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.globus.gsi.tomcat;


import org.apache.tomcat.util.net.AbstractEndpoint;
import org.apache.tomcat.util.net.ServerSocketFactory;
import org.apache.tomcat.util.net.jsse.JSSEImplementation;

Expand All @@ -14,8 +15,8 @@ public String getImplementationName() {
return "GlobusSSLImplementation";
}

public ServerSocketFactory getServerSocketFactory() {
return new GlobusSSLSocketFactory();
public ServerSocketFactory getServerSocketFactory(AbstractEndpoint endpoint) {
return new GlobusSSLSocketFactory(endpoint);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package org.globus.gsi.tomcat;

import org.apache.tomcat.util.net.AbstractEndpoint;
import org.apache.tomcat.util.net.jsse.JSSESocketFactory;
import org.globus.gsi.X509ProxyCertPathParameters;
import org.globus.gsi.jsse.GlobusSSLHelper;
Expand Down Expand Up @@ -45,8 +46,17 @@ public class GlobusSSLSocketFactory extends JSSESocketFactory {
static {
Security.addProvider(new GlobusProvider());
}



protected Object crlLocation;
protected Object signingPolicyLocation;
protected Object rejectLimitedProxyEntry;

public GlobusSSLSocketFactory(AbstractEndpoint endpoint) {
super(endpoint);
crlLocation = endpoint.getAttribute("crlLocation");
signingPolicyLocation = endpoint.getAttribute("signingPolicyLocation");
rejectLimitedProxyEntry = endpoint.getAttribute("rejectLimitedProxy");
}

/**
* Create a Globus trust manager which supports proxy certificates. This requires that the CRL store, and
Expand All @@ -62,20 +72,20 @@ public class GlobusSSLSocketFactory extends JSSESocketFactory {
protected TrustManager[] getTrustManagers(String keystoreType, String keystoreProvider, String algorithm)
throws Exception {
KeyStore trustStore = getTrustStore(keystoreType, keystoreProvider);

CertStore crlStore = null;
Object crlLocation = attributes.get("crlLocation");
if (crlLocation != null) {
crlStore = GlobusSSLHelper.findCRLStore((String) attributes.get("crlLocation"));
crlStore = GlobusSSLHelper.findCRLStore((String) crlLocation);
}
Object signingPolicyLocation = attributes.get("signingPolicyLocation");

ResourceSigningPolicyStore policyStore = null;
if (signingPolicyLocation != null) {
policyStore = Stores.getSigningPolicyStore((String) attributes.get("signingPolicyLocation"));
policyStore = Stores.getSigningPolicyStore((String) signingPolicyLocation);
}
Object rejectLimitedProxyEntry = attributes.get("rejectLimitedProxy");

boolean rejectLimitedProxy = rejectLimitedProxyEntry != null &&
Boolean.parseBoolean(attributes.get("rejectLimitedProxy").toString());
Boolean.parseBoolean((String) rejectLimitedProxyEntry);

X509ProxyCertPathParameters parameters = new X509ProxyCertPathParameters(trustStore, crlStore, policyStore,
rejectLimitedProxy);
TrustManager trustManager = new PKITrustManager(new X509ProxyCertPathValidator(), parameters);
Expand Down
60 changes: 47 additions & 13 deletions ssl-proxies-tomcat/src/main/patches/jglobus-tomcat5.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
diff -ur JGlobus.orig/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLSocketFactory.java JGlobus/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLSocketFactory.java
--- JGlobus.orig/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLSocketFactory.java 2013-03-27 03:48:51.000000000 +0100
+++ JGlobus/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLSocketFactory.java 2013-03-27 07:02:21.107259131 +0100
@@ -15,7 +15,7 @@
diff --git a/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLImplementation.java b/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLImplementation.java
index 96fed75..1741218 100644
--- a/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLImplementation.java
+++ b/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLImplementation.java
@@ -1,7 +1,6 @@
package org.globus.gsi.tomcat;


-import org.apache.tomcat.util.net.AbstractEndpoint;
import org.apache.tomcat.util.net.ServerSocketFactory;
import org.apache.tomcat.util.net.jsse.JSSEImplementation;

@@ -15,8 +14,8 @@ public class GlobusSSLImplementation extends JSSEImplementation {
return "GlobusSSLImplementation";
}

- public ServerSocketFactory getServerSocketFactory(AbstractEndpoint endpoint) {
- return new GlobusSSLSocketFactory(endpoint);
+ public ServerSocketFactory getServerSocketFactory() {
+ return new GlobusSSLSocketFactory();
}

}
diff --git a/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLSocketFactory.java b/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLSocketFactory.java
index 3718fa3..74ef715 100644
--- a/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLSocketFactory.java
+++ b/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/GlobusSSLSocketFactory.java
@@ -15,8 +15,7 @@

package org.globus.gsi.tomcat;

-import org.apache.tomcat.util.net.AbstractEndpoint;
-import org.apache.tomcat.util.net.jsse.JSSESocketFactory;
+import org.apache.tomcat.util.net.jsse.JSSE14SocketFactory;
import org.globus.gsi.X509ProxyCertPathParameters;
import org.globus.gsi.jsse.GlobusSSLHelper;
import org.globus.gsi.provider.GlobusProvider;
@@ -40,49 +40,13 @@
@@ -41,58 +40,12 @@ import java.security.cert.CertStore;
* @version 1.0
* @since 1.0
*/
Expand All @@ -20,8 +45,17 @@ diff -ur JGlobus.orig/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/Glo
static {
Security.addProvider(new GlobusProvider());
}



- protected Object crlLocation;
- protected Object signingPolicyLocation;
- protected Object rejectLimitedProxyEntry;
-
- public GlobusSSLSocketFactory(AbstractEndpoint endpoint) {
- super(endpoint);
- crlLocation = endpoint.getAttribute("crlLocation");
- signingPolicyLocation = endpoint.getAttribute("signingPolicyLocation");
- rejectLimitedProxyEntry = endpoint.getAttribute("rejectLimitedProxy");
- }
-
- /**
- * Create a Globus trust manager which supports proxy certificates. This requires that the CRL store, and
Expand All @@ -37,20 +71,20 @@ diff -ur JGlobus.orig/ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/Glo
- protected TrustManager[] getTrustManagers(String keystoreType, String keystoreProvider, String algorithm)
- throws Exception {
- KeyStore trustStore = getTrustStore(keystoreType, keystoreProvider);
-
- CertStore crlStore = null;
- Object crlLocation = attributes.get("crlLocation");
- if (crlLocation != null) {
- crlStore = GlobusSSLHelper.findCRLStore((String) attributes.get("crlLocation"));
- crlStore = GlobusSSLHelper.findCRLStore((String) crlLocation);
- }
- Object signingPolicyLocation = attributes.get("signingPolicyLocation");
-
- ResourceSigningPolicyStore policyStore = null;
- if (signingPolicyLocation != null) {
- policyStore = Stores.getSigningPolicyStore((String) attributes.get("signingPolicyLocation"));
- policyStore = Stores.getSigningPolicyStore((String) signingPolicyLocation);
- }
- Object rejectLimitedProxyEntry = attributes.get("rejectLimitedProxy");
-
- boolean rejectLimitedProxy = rejectLimitedProxyEntry != null &&
- Boolean.parseBoolean(attributes.get("rejectLimitedProxy").toString());
- Boolean.parseBoolean((String) rejectLimitedProxyEntry);
-
- X509ProxyCertPathParameters parameters = new X509ProxyCertPathParameters(trustStore, crlStore, policyStore,
- rejectLimitedProxy);
- TrustManager trustManager = new PKITrustManager(new X509ProxyCertPathValidator(), parameters);
Expand Down
Loading

0 comments on commit 068396b

Please sign in to comment.