airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject svn commit: r1459367 - in /airavata/sandbox/grid-tools/gsi-myproxy-client: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/airavata/ src/main/java/org/apache/airavata/security/ src/main/java/org/ap...
Date Thu, 21 Mar 2013 15:46:20 GMT
Author: smarru
Date: Thu Mar 21 15:46:19 2013
New Revision: 1459367

URL: http://svn.apache.org/r1459367
Log:
adding sample test code to address AIRAVATA-638

Added:
    airavata/sandbox/grid-tools/gsi-myproxy-client/README
    airavata/sandbox/grid-tools/gsi-myproxy-client/pom.xml   (with props)
    airavata/sandbox/grid-tools/gsi-myproxy-client/run.sh   (with props)
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/CertificateManager.java
  (with props)
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyCredentials.java
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyLogon.java
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/ServiceConstants.java
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/resources/
    airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/resources/airavata-myproxy-client.properties.template

Added: airavata/sandbox/grid-tools/gsi-myproxy-client/README
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gsi-myproxy-client/README?rev=1459367&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gsi-myproxy-client/README (added)
+++ airavata/sandbox/grid-tools/gsi-myproxy-client/README Thu Mar 21 15:46:19 2013
@@ -0,0 +1,18 @@
+Apache Airavata GRAM Client - README
+Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0
+--------------------------------------------------------------------------------
+
+About
+=====
+Apache Airavata, a software framework to executing and managing computational jobs on 
+distributed computing resources including local clusters, supercomputers, national grids,

+academic and commercial clouds. 
+
+The airavata-myproxy-client is a test suite to run stand alone tests to test MyProxy Service
+
+CA Trusted Certificates
+===========================
+* The XSEDE project maintains a repo of International Grid Certificate Authorities
+* The certificate tar file can be downloaded from https://software.xsede.org/security/xsede-certs.tar.gz
+* Once the certificates are downloaded locally, the airavata-myproxy-client.properties has
to be configured. 
+

Added: airavata/sandbox/grid-tools/gsi-myproxy-client/pom.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gsi-myproxy-client/pom.xml?rev=1459367&view=auto
==============================================================================
Binary file - no diff available.

Propchange: airavata/sandbox/grid-tools/gsi-myproxy-client/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = application/xml

Added: airavata/sandbox/grid-tools/gsi-myproxy-client/run.sh
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gsi-myproxy-client/run.sh?rev=1459367&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gsi-myproxy-client/run.sh (added)
+++ airavata/sandbox/grid-tools/gsi-myproxy-client/run.sh Thu Mar 21 15:46:19 2013
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+for i in target/lib/*.jar
+do
+  CLASSPATH=$CLASSPATH:$i
+done
+
+CLASSPATH=$CLASSPATH:target/airavata-myproxy-client-0.1-SNAPSHOT.jar:./config
+
+echo $CLASSPATH
+
+java -classpath $CLASSPATH org.apache.airavata.security.myproxy.MyProxyLogon $*

Propchange: airavata/sandbox/grid-tools/gsi-myproxy-client/run.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/CertificateManager.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/CertificateManager.java?rev=1459367&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/CertificateManager.java
(added)
+++ airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/CertificateManager.java
Thu Mar 21 15:46:19 2013
@@ -0,0 +1,89 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.security.myproxy;
+
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.globus.gsi.CertUtil;
+import org.globus.util.ClassLoaderUtils;
+
+public class CertificateManager {
+
+    private static X509Certificate[] trustedCertificates;
+
+    /**
+     * Load CA certificates from a file included in the XBaya jar.
+     * 
+     * @return The trusted certificates.
+     */
+    public static X509Certificate[] getTrustedCertificate(String certificate) {
+        if (trustedCertificates != null) {
+            return trustedCertificates;
+        }
+
+        List<X509Certificate> extremeTrustedCertificates = getTrustedCertificates(certificate);
+
+        List<X509Certificate> allTrustedCertificates = new ArrayList<X509Certificate>();
+        allTrustedCertificates.addAll(extremeTrustedCertificates);
+
+        trustedCertificates = allTrustedCertificates.toArray(new X509Certificate[allTrustedCertificates.size()]);
+        return trustedCertificates;
+    }
+
+    private static List<X509Certificate> getTrustedCertificates(String pass) {
+        // ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); //**
+        // InputStream stream = classLoader.getResourceAsStream(pass); //**
+        InputStream stream = ClassLoaderUtils.getResourceAsStream(pass); // **
+        if (stream == null) {
+            throw new RuntimeException("Failed to get InputStream to " + pass);
+        }
+        return readTrustedCertificates(stream);
+    }
+
+    /**
+     * @param stream
+     * @return List of X509Certificate
+     */
+    public static List<X509Certificate> readTrustedCertificates(InputStream stream)
{
+        ArrayList<X509Certificate> certificates = new ArrayList<X509Certificate>();
+        while (true) {
+            X509Certificate certificate;
+            try {
+                certificate = CertUtil.loadCertificate(stream);
+                // certificate = CertificateLoadUtil.loadCertificate(stream); //**
+            } catch (GeneralSecurityException e) {
+                String message = "Certificates are invalid";
+                throw new RuntimeException(message, e);
+            }
+            if (certificate == null) {
+                break;
+            }
+            certificates.add(certificate);
+        }
+        return certificates;
+    }
+
+}

Propchange: airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/CertificateManager.java
------------------------------------------------------------------------------
    svn:executable = *

Added: airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyCredentials.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyCredentials.java?rev=1459367&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyCredentials.java
(added)
+++ airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyCredentials.java
Thu Mar 21 15:46:19 2013
@@ -0,0 +1,318 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.security.myproxy;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.Serializable;
+import java.security.cert.X509Certificate;
+
+import org.apache.log4j.Logger;
+import org.globus.gsi.GlobusCredential;
+import org.globus.gsi.TrustedCertificates;
+import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
+import org.globus.myproxy.MyProxy;
+import org.ietf.jgss.GSSCredential;
+
+public class MyProxyCredentials implements Serializable {
+
+    private static final long serialVersionUID = -2471014486509046212L;
+    protected String myproxyHostname;
+    protected String myproxyUserName;
+    protected String myproxyPassword;
+    protected int myproxyPortNumber;
+    protected GSSCredential gssCredential;
+    protected String portalUserName;
+    private String hostcertsKeyFile;
+    private String trustedCertsFile;
+
+    protected int myproxyLifeTime = 14400;
+    final static int SECS_PER_MIN = 60;
+    final static int SECS_PER_HOUR = 3600;
+
+    private boolean initialized = false;
+    private boolean user = true;
+    protected X509Certificate[] trustedCertificates;
+
+    private static final Logger log = Logger.getLogger(MyProxyCredentials.class);
+
+    public MyProxyCredentials() {
+        // default constructor
+    }
+
+    public MyProxyCredentials(String myproxyServer, int myproxyPort, String myproxyUsername,
String myproxyPassphrase,
+            int myproxyLifetime) {
+        this.myproxyHostname = myproxyServer;
+        this.myproxyPortNumber = myproxyPort;
+        this.myproxyUserName = myproxyUsername;
+        this.myproxyPassword = myproxyPassphrase;
+        this.myproxyLifeTime = myproxyLifetime;
+
+    }
+
+    public GSSCredential getGssCredential() throws Exception {
+        FileInputStream fis = null;
+        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);
+
+            } else {
+                this.gssCredential = getDefaultProxy();
+            }
+            if (gssCredential != null) {
+                return gssCredential;
+            }
+        } catch (Exception e) {
+            log.error("Failed to load proxy credential from ProxyManager");
+            e.printStackTrace();
+            throw e;
+        } finally {
+            if (fis != null) {
+                fis.close();
+            }
+        }
+
+        // then we will try the MyProxy
+        if (getMyproxyUserName() != null && getMyproxyPassword() != null) {
+            gssCredential = renewProxy();
+        }
+        return gssCredential;
+    }
+
+    public GSSCredential getDefaultProxy() throws Exception {
+        init();
+        MyProxy myproxy = new MyProxy(this.myproxyHostname, this.myproxyPortNumber);
+        log.info("USER=" + this.myproxyUserName + ",PASS=" + this.myproxyPassword + ",TIME="
+ this.myproxyLifeTime);
+        return myproxy.get(this.myproxyUserName, this.myproxyPassword, this.myproxyLifeTime);
+    }
+
+    private void init() {
+        if (trustedCertsFile != null) {
+            if (new File(trustedCertsFile).isDirectory()) {
+                TrustedCertificates certificates = TrustedCertificates.load(trustedCertsFile);
+                TrustedCertificates.setDefaultTrustedCertificates(certificates);
+            } else {
+                this.trustedCertificates = CertificateManager.getTrustedCertificate(trustedCertsFile);
+
+                TrustedCertificates certificatesArray = new TrustedCertificates(this.trustedCertificates);
+                TrustedCertificates.setDefaultTrustedCertificates(certificatesArray);
+            }
+        }
+    }
+
+    public GSSCredential renewProxy() throws Exception {
+        init();
+
+        FileOutputStream fout = null;
+        try {
+            String proxyloc = null;
+            MyProxy myproxy = new MyProxy(myproxyHostname, myproxyPortNumber);
+            int lifeHours = myproxyLifeTime * SECS_PER_HOUR;
+            GSSCredential proxy = myproxy.get(myproxyUserName, myproxyPassword, lifeHours);
+
+            GlobusCredential globusCred = null; // **
+            // X509Credential globusCred = null; //**
+            if (proxy instanceof GlobusGSSCredentialImpl) {
+                globusCred = ((GlobusGSSCredentialImpl) proxy).getGlobusCredential();// **
+                // globusCred = ((GlobusGSSCredentialImpl) proxy).getX509Credential();//**
+                log.info("got proxy from myproxy for " + myproxyUserName + " with " + myproxyLifeTime
+ " lifetime.");
+                String uid = myproxyUserName;
+                if (proxyloc == null) {
+                    log.info("uid: " + uid);
+                    proxyloc = "/tmp/x509up_u" + uid;
+                }
+                File proxyfile = new File(proxyloc);
+                log.info("proxy location: " + proxyfile.getAbsolutePath());
+                if (proxyfile.exists() == false) {
+                    String dirpath = proxyloc.substring(0, proxyloc.lastIndexOf('/'));
+                    File dir = new File(dirpath);
+                    if (dir.exists() == false) {
+                        dir.mkdirs();
+                        log.info("new directory " + dirpath + " is created.");
+                    }
+                    proxyfile.createNewFile();
+                    log.info("new proxy file " + proxyloc + " is created.");
+                }
+                fout = new FileOutputStream(proxyfile);
+                globusCred.save(fout);
+                String osName = System.getProperty("os.name");
+                if (!osName.contains("Windows")) {
+                    Runtime.getRuntime().exec("/bin/chmod 600 " + proxyloc);
+                }
+                log.info("Proxy file renewed to " + proxyloc + " for the user " + myproxyUserName
+ " with "
+                        + myproxyLifeTime + " lifetime.");
+
+            }
+            return proxy;
+        } catch (Exception e) {
+            throw new Exception(e);
+        } finally {
+            if (fout != null) {
+                fout.close();
+            }
+        }
+    }
+
+    /**
+     * @return the myproxyHostname
+     */
+    public String getMyproxyHostname() {
+        return myproxyHostname;
+    }
+
+    /**
+     * @param myproxyHostname
+     *            the myproxyHostname to set
+     */
+    public void setMyproxyHostname(String myproxyHostname) {
+        this.myproxyHostname = myproxyHostname;
+    }
+
+    /**
+     * @return the myproxyUserName
+     */
+    public String getMyproxyUserName() {
+        return myproxyUserName;
+    }
+
+    /**
+     * @param myproxyUserName
+     *            the myproxyUserName to set
+     */
+    public void setMyproxyUserName(String myproxyUserName) {
+        this.myproxyUserName = myproxyUserName;
+    }
+
+    /**
+     * @return the myproxyPassword
+     */
+    public String getMyproxyPassword() {
+        return myproxyPassword;
+    }
+
+    /**
+     * @param myproxyPassword
+     *            the myproxyPassword to set
+     */
+    public void setMyproxyPassword(String myproxyPassword) {
+        this.myproxyPassword = myproxyPassword;
+    }
+
+    /**
+     * @return the myproxyLifeTime
+     */
+    public int getMyproxyLifeTime() {
+        return myproxyLifeTime;
+    }
+
+    /**
+     * @param myproxyLifeTime
+     *            the myproxyLifeTime to set
+     */
+    public void setMyproxyLifeTime(int myproxyLifeTime) {
+        this.myproxyLifeTime = myproxyLifeTime;
+    }
+
+    /**
+     * @return the myproxyPortNumber
+     */
+    public int getMyproxyPortNumber() {
+        return myproxyPortNumber;
+    }
+
+    /**
+     * @param myproxyPortNumber
+     *            the myproxyPortNumber to set
+     */
+    public void setMyproxyPortNumber(int myproxyPortNumber) {
+        this.myproxyPortNumber = myproxyPortNumber;
+    }
+
+    /**
+     * @return the portalUserName
+     */
+    public String getPortalUserName() {
+        return portalUserName;
+    }
+
+    /**
+     * @param portalUserName
+     *            the portalUserName to set
+     */
+    public void setPortalUserName(String portalUserName) {
+        this.portalUserName = portalUserName;
+    }
+
+    /**
+     * Returns the initialized.
+     * 
+     * @return The initialized
+     */
+    public boolean isInitialized() {
+        return this.initialized;
+    }
+
+    /**
+     * Sets initialized.
+     * 
+     * @param initialized
+     *            The initialized to set.
+     */
+    public void setInitialized(boolean initialized) {
+        this.initialized = initialized;
+    }
+
+    /**
+     * @param hostcertsKeyFile
+     *            the hostcertsKeyFile to set
+     */
+    public void setHostcertsKeyFile(String hostcertsKeyFile) {
+        this.hostcertsKeyFile = hostcertsKeyFile;
+    }
+
+    /**
+     * @return the hostcertsKeyFile
+     */
+    public String getHostcertsKeyFile() {
+        return hostcertsKeyFile;
+    }
+
+    /**
+     * @param trustedCertsFile
+     *            the trustedCertsFile to set
+     */
+    public void setTrustedCertsFile(String trustedCertsFile) {
+        this.trustedCertsFile = trustedCertsFile;
+    }
+
+    /**
+     * @return the trustedCertsFile
+     */
+    public String getTrustedCertsFile() {
+        return trustedCertsFile;
+    }
+
+}

Added: airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyLogon.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyLogon.java?rev=1459367&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyLogon.java
(added)
+++ airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/MyProxyLogon.java
Thu Mar 21 15:46:19 2013
@@ -0,0 +1,193 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+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;
+import org.globus.myproxy.MyProxy;
+import org.ietf.jgss.GSSCredential;
+
+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;
+
+    private MyProxyCredentials credentials;
+    private static final Logger log = Logger.getLogger(MyProxyLogon.class);
+
+    /**
+     * 
+     * Constructs a ApplicationGlobalContext.
+     * 
+     * @throws GfacGUIException
+     */
+
+    public MyProxyLogon() throws Exception {
+        log.setLevel(org.apache.log4j.Level.INFO);
+        loadConfiguration();
+
+    }
+
+    public static void main(String[] args) {
+        try {
+            MyProxyLogon myproxy = new MyProxyLogon();
+            myproxy.login();
+            String proxyName = myproxy.getGssCredential().getName().toString();
+            int proxyTime = myproxy.getGssCredential().getRemainingLifetime();
+            System.out.println("Proxy Name is: " + proxyName);
+            System.out.println("Proxy Life Time is: " + proxyTime);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 
+     * @throws GfacException
+     */
+    public void login() throws Exception {
+        gssCredential = credentials.getGssCredential();
+    }
+
+    public static String getProperty(String name) {
+        try {
+            MyProxyLogon context = new MyProxyLogon();
+            return context.getProperties().getProperty(name);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+
+    }
+
+    /**
+     * Load the configration file
+     * 
+     * @throws GfacException
+     */
+    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) {
+                    this.credentials = new MyProxyCredentials();
+                }
+                if (propertyStream != null) {
+                    properties.load(propertyStream);
+                    String myproxyServerTmp = properties.getProperty(ServiceConstants.MYPROXY_SERVER);
+                    if (myproxyServerTmp != null) {
+                        this.credentials.setMyproxyHostname(myproxyServerTmp.trim());
+                    }
+                    String myproxyPortTemp = properties.getProperty(ServiceConstants.MYPROXY_PORT);
+                    if (myproxyPortTemp != null && myproxyPortTemp.trim().length()
> 0) {
+                        this.credentials.setMyproxyPortNumber(Integer.parseInt(myproxyPortTemp.trim()));
+                    } else {
+                        this.credentials.setMyproxyPortNumber(MyProxy.DEFAULT_PORT);
+                    }
+                    String myproxyuser = properties.getProperty(ServiceConstants.MYPROXY_USERNAME);
+                    if (myproxyuser != null) {
+                        this.credentials.setMyproxyUserName(myproxyuser);
+                    }
+                    String myproxypass = properties.getProperty(ServiceConstants.MYPROXY_PASSWD);
+                    if (myproxypass != null) {
+                        this.credentials.setMyproxyPassword(myproxypass);
+                    }
+                    String myproxytime = properties.getProperty(ServiceConstants.MYPROXY_LIFETIME);
+                    if (myproxytime != null) {
+                        this.credentials.setMyproxyLifeTime(Integer.parseInt(myproxytime));
+                    }
+                    this.credentials.setTrustedCertsFile(properties.getProperty(ServiceConstants.TRUSTED_CERTS_FILE));
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getLocalizedMessage());
+            throw new Exception(e);
+        }
+
+    }
+
+    /**
+     * @return the properties
+     */
+    public Properties getProperties() {
+        return properties;
+    }
+
+    /**
+     * @param properties
+     *            the properties to set
+     */
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
+    /**
+     * Returns the gssCredential.
+     * 
+     * @return The gssCredential
+     */
+    public GSSCredential getGssCredential() {
+        return this.gssCredential;
+    }
+
+    /**
+     * Sets gssCredential.
+     * 
+     * @param gssCredential
+     *            The gssCredential to set.
+     */
+    public void setGssCredential(GSSCredential gssCredential) {
+        this.gssCredential = gssCredential;
+    }
+
+    public MyProxyCredentials getCredentials() {
+        return credentials;
+    }
+
+    public void setCredentials(MyProxyCredentials credentials) {
+        this.credentials = credentials;
+    }
+}

Added: airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/ServiceConstants.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/ServiceConstants.java?rev=1459367&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/ServiceConstants.java
(added)
+++ airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/java/org/apache/airavata/security/myproxy/ServiceConstants.java
Thu Mar 21 15:46:19 2013
@@ -0,0 +1,33 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+package org.apache.airavata.security.myproxy;
+
+public class ServiceConstants {
+
+	public static final String MYPROXY_SERVER = "myproxyServer";
+	public static final String MYPROXY_PORT = "myproxyPort";
+	public static final String MYPROXY_LIFETIME = "myproxy_lifetime";
+	public static final String MYPROXY_USERNAME = "myproxyUserName";
+	public static final String MYPROXY_PASSWD = "myproxyPasswd";
+	public static final String TRUSTED_CERTS_FILE = "trustedCertsFile";
+
+}

Added: airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/resources/airavata-myproxy-client.properties.template
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/resources/airavata-myproxy-client.properties.template?rev=1459367&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/resources/airavata-myproxy-client.properties.template
(added)
+++ airavata/sandbox/grid-tools/gsi-myproxy-client/src/main/resources/airavata-myproxy-client.properties.template
Thu Mar 21 15:46:19 2013
@@ -0,0 +1,7 @@
+#Download trusted certificates from - https://software.xsede.org/security/xsede-certs.tar.gz
+trustedCertsFile=./certificates/
+myproxyServer=myproxy.teragrid.org
+myproxy_lifetime=17280000
+myproxyUserName=
+myproxyPasswd=
+myproxyPort=7512



Mime
View raw message