def shib_login(self, provider, idp_username, idp_password, proxy_username, proxy_password): idp = TaskbarIdp(provider) c = TaskbarCredMgr(idp_username, idp_password) cj = MozillaCookieJar() shibopener = Shibboleth(idp, c, cj) slcsresp = shibopener.openurl("https://slcs1.arcs.org.au/SLCS/login") #create token, cert request, etc token, dn, reqURL, elements = parse_req_response(slcsresp) print "parsed slcsresp" #send to auth server to create myproxy import urllib, urllib2, time url = 'http://lanyard.bestgrid.org/create_myproxy/' # write ur URL here #url = 'http://prj-gl4-d01.cs.auckland.ac.nz:6543/create_myproxy' values = {'auth_token' : token, #write ur specific key/value pair 'dn' : dn, 'reqURL' : reqURL, 'elements' : elements, 'myproxy_username' : proxy_username, 'myproxy_passphrase' : proxy_password } print str(token) + "\n" + str(dn) + "\n" + str(elements) + "\n" + str(reqURL) + "\n" try: data = urllib.urlencode(values) req = urllib2.Request(url, data) response = urllib2.urlopen(req) the_page = response.read() print the_page except Exception, detail: print "Err ", detail
def main(*args): # Populate our options, -h/--help is already there for you. usage = "usage: %prog [options] URL" optp = optparse.OptionParser(usage=usage) optp.add_option("-u", "--username", help="the username to login as.") optp.add_option("-d", "--storedir", dest="store_dir", help="the directory to store the certificate/key and \ config file", metavar="DIR", default=path.join(homedir, ".shibboleth")) optp.add_option("-i", "--idp", help="unique ID of the IdP used to log in") optp.add_option('-v', '--verbose', dest='verbose', action='count', help="Increase verbosity (specify multiple times for more)") # Parse the arguments (defaults to parsing sys.argv). opts, args = optp.parse_args() # Here would be a good place to check what came in on the command line and # call optp.error("Useful message") to exit if all it not well. log_level = logging.WARNING # default if opts.verbose == 1: log_level = logging.INFO elif opts.verbose >= 2: log_level = logging.DEBUG # Set up basic configuration, out to stderr with a reasonable # default format. logging.basicConfig(level=log_level) if not args: optp.print_help() return if not path.exists(opts.store_dir): os.mkdir(opts.store_dir) sp = args[0] idp = Idp(opts.idp) c = CredentialManager() if opts.username: c.username = opts.username # if the cookies file exists load it cookies_file = path.join(opts.store_dir, 'cookies.txt') cj = MozillaCookieJar(filename=cookies_file) if path.exists(cookies_file): cj.load() shibboleth = Shibboleth(idp, c, cj) shibboleth.openurl(sp) print("Successfully authenticated to %s" % sp) cj.save()
def login_dialog_popup(self,blah): idp = TaskbarIdp() c = TaskbarCredMgr() cj = MozillaCookieJar() shibopener = Shibboleth(idp, c, cj) try: print "Trying to populate list" slcsresp = shibopener.openurl("https://slcs1.arcs.org.au/SLCS/login") print "Succeeded" except Exception, reason: print reason pass
class ListIDPs(Idp): def set_idps(self, idps): """ set the list of possible idps """ self.raw_idps = idps self.idps = idps.keys() self.idps.sort() raise IdpListException("Exit Auth Chain") idps = ListIDPs() c = SimpleCredentialManager('ARCS_test', 'ARCS_test') shib = Shibboleth(idps, c) try: shib.openurl(aaf_sp_url) except IdpListException: pass class TestShibboleth(unittest.TestCase): def setUp(self): pass def test_pass(self): """this test exists to prevent and error from the class defining no tests """