climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject [2/4] climate git commit: CLIMATE-772 - Update esgf with new server name and use client rather than server certificate.
Date Fri, 25 Mar 2016 18:38:33 GMT
CLIMATE-772 - Update esgf with new server name and use client rather than server certificate.


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/981c8251
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/981c8251
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/981c8251

Branch: refs/heads/master
Commit: 981c8251cc5ec886843d8769eb651a18e167ef48
Parents: ef55160
Author: MichaelArthurAnderson <michael.arthur.anderson@gmail.com>
Authored: Fri Mar 25 11:39:26 2016 -0400
Committer: MichaelArthurAnderson <michael.arthur.anderson@gmail.com>
Committed: Fri Mar 25 11:39:26 2016 -0400

----------------------------------------------------------------------
 ocw/esgf/constants.py | 13 ++++---------
 ocw/esgf/logon.py     | 13 ++++++++-----
 ocw/esgf/logon2.py    | 43 -------------------------------------------
 ocw/esgf/main.py      | 17 +++++++----------
 4 files changed, 19 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/981c8251/ocw/esgf/constants.py
----------------------------------------------------------------------
diff --git a/ocw/esgf/constants.py b/ocw/esgf/constants.py
index 860a489..8d30848 100644
--- a/ocw/esgf/constants.py
+++ b/ocw/esgf/constants.py
@@ -21,16 +21,11 @@
 # default location of ESGF user credentials
 ESGF_CREDENTIALS = "~/.esg/credentials.pem"
 
-# URL for ESGF certificate service
-#CERT_SERVICE_URL = "https://localhost:8443/esgf-idp/idp/getcert.htm"
-CERT_SERVICE_URL = "https://esg-datanode.jpl.nasa.gov/esgf-idp/idp/getcert.htm"
-
-# Basic authentication realm
-REALM = "ESGF"
+JPL_HOSTNAME = "esgf-node.jpl.nasa.gov"
 
 # DN of JPL MyProxy server (needs to be explicitely set somtimes)
-JPL_MYPROXY_SERVER_DN = "/O=ESGF/OU=esg-datanode.jpl.nasa.gov/CN=host/esg-vm.jpl.nasa.gov"
+JPL_MYPROXY_SERVER_DN = "/O=ESGF/OU=ESGF.ORG/CN=esgf-node.jpl.nasa.gov"
 
 # URL of ESGF search service to contact
-JPL_SEARCH_SERVICE_URL = "http://esg-datanode.jpl.nasa.gov/esg-search/search"
-DEFAULT_ESGF_SEARCH = "http://esg-datanode.jpl.nasa.gov/esg-search/search"
+JPL_SEARCH_SERVICE_URL = "http://esgf-node.jpl.nasa.gov/esg-search/search"
+DEFAULT_ESGF_SEARCH = "http://esgf-node.jpl.nasa.gov/esg-search/search"

http://git-wip-us.apache.org/repos/asf/climate/blob/981c8251/ocw/esgf/logon.py
----------------------------------------------------------------------
diff --git a/ocw/esgf/logon.py b/ocw/esgf/logon.py
index c7f3478..031e968 100644
--- a/ocw/esgf/logon.py
+++ b/ocw/esgf/logon.py
@@ -19,13 +19,14 @@
 '''
 RCMES module to logon onto the ESGF.
 '''
+import os
 
 from pyesgf.logon import LogonManager
-import os
 
-from ocw.esgf.constants import JPL_MYPROXY_SERVER_DN
+from ocw.esgf.constants import JPL_MYPROXY_SERVER_DN, JPL_HOSTNAME
 
 def logon(openid, password):
+
     '''
     Function to retrieve a short-term X.509 certificate that can be used to authenticate
with ESGF.
     The certificate is written in the location ~/.esg/credentials.pem.
@@ -33,11 +34,13 @@ def logon(openid, password):
     '''
     
     # Must configure the DN of the JPL MyProxy server if using a JPL openid
-    if "esg-datanode.jpl.nasa.gov" in openid:  
+    if JPL_HOSTNAME in openid:
         os.environ['MYPROXY_SERVER_DN'] = JPL_MYPROXY_SERVER_DN
-        
+
     lm = LogonManager()
-    lm.logon_with_openid(openid,password)
+
+    lm.logon_with_openid(openid, password)
+
     return lm.is_logged_on()
     
     

http://git-wip-us.apache.org/repos/asf/climate/blob/981c8251/ocw/esgf/logon2.py
----------------------------------------------------------------------
diff --git a/ocw/esgf/logon2.py b/ocw/esgf/logon2.py
deleted file mode 100644
index 46724f7..0000000
--- a/ocw/esgf/logon2.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# 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.
-#
-'''
-RCMES module to logon onto the ESGF by contacting the IdP RESTful service.
-'''
-
-from ocw.esgf.constants import ESGF_CREDENTIALS, CERT_SERVICE_URL, REALM
-
-import urllib2
-from os.path import expanduser
-
-def logon2(openid, password):
-    '''
-    Function to retrieve a short-term X.509 certificate that can be used to authenticate
with ESGF.
-    The certificate is written in the location specified by ESGF_CREDENTIALS.
-    '''
-    
-    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
-    password_mgr.add_password(REALM, CERT_SERVICE_URL, openid, password)
-    handler = urllib2.HTTPBasicAuthHandler(password_mgr)
-    opener = urllib2.build_opener(urllib2.HTTPHandler, handler)
-    request = opener.open(CERT_SERVICE_URL)
-    #print request.read()
-    
-    localFilePath = expanduser(ESGF_CREDENTIALS)
-    certFile=open(localFilePath, 'w')
-    certFile.write(request.read())

http://git-wip-us.apache.org/repos/asf/climate/blob/981c8251/ocw/esgf/main.py
----------------------------------------------------------------------
diff --git a/ocw/esgf/main.py b/ocw/esgf/main.py
index 65c2a1c..54ddf62 100644
--- a/ocw/esgf/main.py
+++ b/ocw/esgf/main.py
@@ -22,27 +22,24 @@ Example main program for ESGF-RCMES integration.
 '''
 
 # constant parameters
-USER_OPENID = "https://esg-datanode.jpl.nasa.gov/esgf-idp/openid/lucacinquini"
-USER_PASSWORD = "*****"
 DATA_DIRECTORY = "/tmp"
 
 from ocw.esgf.logon import logon
-from ocw.esgf.logon2 import logon2
 from ocw.esgf.search import SearchClient
 from ocw.esgf.download import download
 
 def main():
     '''Example driver program'''
-    
+
+    username = raw_input('Enter your ESGF Username:\n')
+    password = raw_input('Enter your ESGF Password:\n')
+
     # step 1: obtain short-term certificate
     print 'Retrieving ESGF certificate...'
     # logon using client-side MyProxy libraries
-    #if logon(USER_OPENID, USER_PASSWORD):
-    #    print "...done."
-    # logon through server-side MyProxy service
-    if logon2(USER_OPENID, USER_PASSWORD):
-        print "...done"
-    
+    if logon(username, password):
+        print "...done."
+
     # step 2: execute faceted search for files
     urls = main_obs4mips()
     #urls = main_cmip5()


Mime
View raw message