Updating test client to released version of jglobus 2.0.5
authorSuresh Marru <smarru@apache.org>
Tue, 26 Mar 2013 02:52:16 +0000 (02:52 +0000)
committerSuresh Marru <smarru@apache.org>
Tue, 26 Mar 2013 02:52:16 +0000 (02:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/airavata/sandbox@1460957 13f79535-47bb-0310-9956-ffa450edef68

grid-tools/gsi-myproxy-client/pom.xml
grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/CertificateManager.java
grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyCredentials.java
grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyLogon.java

index 0db9bbb..ebef881 100644 (file)
        <version>0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
 
-       <repositories>
-               <repository>
-                       <name>ogce.m2.all</name>
-                       <id>ogce.m2.all</id>
-                       <url>http://community.ucs.indiana.edu:9090/archiva/repository/ogce.m2.all</url>
-               </repository>
-       </repositories>
-
-
        <dependencies>
 
                <dependency>
-                       <groupId>cog-jglobus</groupId>
-                       <artifactId>cog-jglobus</artifactId>
-                       <version>1.8.0_1</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>cog-4_1_6_rc2</groupId>
-                       <artifactId>puretls</artifactId>
-                       <type>jar</type>
-                       <version>cog-4_1_6</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>cog-4_1_6_rc2</groupId>
-                       <artifactId>cryptix32</artifactId>
-                       <type>jar</type>
-                       <version>cog-4_1_6</version>
-               </dependency>
-
-               <dependency>
-                       <groupId>cog-4_1_6_rc2</groupId>
-                       <artifactId>jce-jdk13</artifactId>
-                       <version>131</version>
-                       <type>jar</type>
-               </dependency>
-
-               <dependency>
-                       <groupId>cog-4_1_6_rc2</groupId>
-                       <artifactId>cryptix-asn1</artifactId>
-                       <type>jar</type>
-                       <version>cog-4_1_6</version>
-               </dependency>
-               <dependency>
-                       <groupId>cog-4_1_6_rc2</groupId>
-                       <artifactId>commons-digester</artifactId>
-                       <type>jar</type>
-                       <version>cog-4_1_6</version>
+                       <groupId>org.jglobus</groupId>
+                       <artifactId>myproxy</artifactId>
+                       <version>2.0.5</version>
                </dependency>
 
                <dependency>
-                       <groupId>commons-logging</groupId>
-                       <artifactId>commons-logging</artifactId>
-                       <version>1.0.4</version>
-               </dependency>
-               <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
-                       <version>1.2.13</version>
+                       <version>1.2.17</version>
                </dependency>
 
-
        </dependencies>
        <build>
                <plugins>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-compiler-plugin</artifactId>
                                <configuration>
-                                       <source>1.5</source>
-                                       <target>1.5</target>
+                                       <source>1.6</source>
+                                       <target>1.6</target>
                                </configuration>
                        </plugin>
-                       <plugin>
+<!--                   <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-dependency-plugin</artifactId>
                                <executions>
                                        </execution>
                                </executions>
                        </plugin>
              </plugins>
-->           </plugins>
        </build>
 
 </project>
index 68c6ed8..fe09058 100755 (executable)
@@ -27,7 +27,7 @@ import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.globus.gsi.CertUtil;
+import org.globus.gsi.util.CertificateLoadUtil;
 import org.globus.util.ClassLoaderUtils;
 
 public class CertificateManager {
@@ -72,8 +72,7 @@ public class CertificateManager {
         while (true) {
             X509Certificate certificate;
             try {
-                certificate = CertUtil.loadCertificate(stream);
-                // certificate = CertificateLoadUtil.loadCertificate(stream); //**
+                certificate = CertificateLoadUtil.loadCertificate(stream);
             } catch (GeneralSecurityException e) {
                 String message = "Certificates are invalid";
                 throw new RuntimeException(message, e);
index cbb9e7e..f48d4f3 100644 (file)
@@ -25,12 +25,14 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.Serializable;
+import java.security.KeyStore;
 import java.security.cert.X509Certificate;
 
 import org.apache.log4j.Logger;
-import org.globus.gsi.GlobusCredential;
-import org.globus.gsi.TrustedCertificates;
+import org.globus.gsi.X509Credential;
 import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
+import org.globus.gsi.provider.GlobusProvider;
+import org.globus.gsi.provider.KeyStoreParametersFactory;
 import org.globus.myproxy.MyProxy;
 import org.ietf.jgss.GSSCredential;
 
@@ -75,10 +77,8 @@ public class MyProxyCredentials implements Serializable {
         try {
             if (hostcertsKeyFile != null && !user) {
                 fis = new FileInputStream(hostcertsKeyFile);
-                // X509Credential globusCred = new X509Credential(fis); //**
-                GlobusCredential globusCred = new GlobusCredential(fis);
-                this.gssCredential = new GlobusGSSCredentialImpl(globusCred, GSSCredential.INITIATE_AND_ACCEPT);
-
+                X509Credential x509Cred = new X509Credential(fis);
+                this.gssCredential = new GlobusGSSCredentialImpl(x509Cred, GSSCredential.INITIATE_AND_ACCEPT);
             } else {
                 this.gssCredential = getDefaultProxy();
             }
@@ -112,17 +112,21 @@ public class MyProxyCredentials implements Serializable {
     private void init() {
         if (trustedCertsFile != null) {
             if (new File(trustedCertsFile).isDirectory()) {
-                TrustedCertificates certificates = TrustedCertificates.load(trustedCertsFile);
-                TrustedCertificates.setDefaultTrustedCertificates(certificates);
-            } else {
+                       try {
+               KeyStore trustStore = KeyStore.getInstance(
+                                       GlobusProvider.KEYSTORE_TYPE,
+                                       GlobusProvider.PROVIDER_NAME);
+                       trustStore.load(KeyStoreParametersFactory
+                                       .createTrustStoreParameters(trustedCertsFile + "/*.0"));
                 this.trustedCertificates = CertificateManager.getTrustedCertificate(trustedCertsFile);
-
-                TrustedCertificates certificatesArray = new TrustedCertificates(this.trustedCertificates);
-                TrustedCertificates.setDefaultTrustedCertificates(certificatesArray);
-            }
+                       } catch (Exception e) {
+                               e.printStackTrace(); 
+                       }
+                }
         }
     }
 
+    
     public GSSCredential renewProxy() throws Exception {
         init();
 
@@ -133,10 +137,10 @@ public class MyProxyCredentials implements Serializable {
             int lifeHours = myproxyLifeTime * SECS_PER_HOUR;
             GSSCredential proxy = myproxy.get(myproxyUserName, myproxyPassword, lifeHours);
 
-            GlobusCredential globusCred = null; // **
+            X509Credential globusCred = null; // **
             // X509Credential globusCred = null; //**
             if (proxy instanceof GlobusGSSCredentialImpl) {
-                globusCred = ((GlobusGSSCredentialImpl) proxy).getGlobusCredential();// **
+                globusCred = ((GlobusGSSCredentialImpl) proxy).getX509Credential();// **
                 // globusCred = ((GlobusGSSCredentialImpl) proxy).getX509Credential();//**
                 log.info("got proxy from myproxy for " + myproxyUserName + " with " + myproxyLifeTime + " lifetime.");
                 String uid = myproxyUserName;
index a9f7242..2eca94c 100644 (file)
@@ -21,9 +21,7 @@
 
 package org.apache.airavata.security.myproxy;
 
-import java.io.File;
 import java.io.InputStream;
-import java.net.URL;
 import java.util.Properties;
 
 import org.apache.log4j.Logger;
@@ -35,7 +33,6 @@ public class MyProxyLogon {
     /**
         * 
         */
-    private static final long serialVersionUID = -2270092298283648553L;
     public static final String MYPROXYCLIENT_PROPERTY = "airavata-myproxy-client.properties";
     private Properties properties;
     protected GSSCredential gssCredential;
@@ -91,23 +88,13 @@ public class MyProxyLogon {
     /**
      * Load the configration file
      * 
-     * @throws GfacException
+     * @throws Exception
      */
     private void loadConfiguration() throws Exception {
         try {
             if (properties == null) {
                 ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-                File webinfDir = null;
-                URL propertyFile = classLoader.getResource(MYPROXYCLIENT_PROPERTY);
-
-                if (propertyFile != null) {
-                    File tempFile = new File(propertyFile.getFile());
-                    if (tempFile.exists()) {
-                        webinfDir = tempFile.getParentFile().getParentFile();
-                    }
-                } else {
-                    throw new Exception(" Not able to locate " + MYPROXYCLIENT_PROPERTY);
-                }
                 InputStream propertyStream = classLoader.getResourceAsStream(MYPROXYCLIENT_PROPERTY);
                 properties = new Properties();
                 if (credentials == null) {