Пример #1
0
def checkVomsExtension  (proxyfile, printERRORS):
	"""
	Retrieve vomses from proxy and check whether it is contained
	"""
	uc = UCredential(proxyfile)
	vomses = uc.getVoNames()
	
	if wmsui_utils.info.debug and printERRORS:
		# No voms in certificate: print error
		printableError = uc.get_error()
		if printableError:
			errMsg( 'Warning' , "UI_NO_VOMS",printableError)
	if vomses:
		return [0, vomses[0]]
	else:
		return [0,""]
Пример #2
0
def check_proxy(*valid) :
	if valid:
		valid=valid[0]
		hours, minutes  = valid.split(":")
		secondsLeft = int(hours)*60*60 + int(minutes)*60
	uid = os.getuid()
	pid = os.getpid()
	proxy_file_name = ''
	INST = info.prefix
	if not INST:
		exit(1)
	#Initialize proxy certificate file name
	try:
		proxy_file_name = os.environ['X509_USER_PROXY']
	except:
		proxy_file_name = os.sep + "tmp" + os.sep+ "x509up_u" + repr(uid)
	#Check if Proxy certificate already exists
	#voms =  info.confAdVo.getStringValue("VirtualOrganisation")[0]
	if os.path.isfile(proxy_file_name):
		#Retrieve Proxy Information ( new Approach )
		uc = UCredential (proxy_file_name)
		timeleft = uc.getExpiration()  - int( time.time() ) -time.timezone
		err = uc.get_error()
		if err != "":
			#ERROR
			errMsg ( "Error" , "API_NATIVE_ERROR" , "UcWrapper::getExpiration"  , err )
			wmsui_utils.exit (1)
		info.issuer =uc.getIssuer()
		if not valid:
			# timeleft should be at least 20 minutes
			secondsLeft = 20*60
			valid = "00:20"
		if timeleft>secondsLeft:
			printERRORS=0
			return checkVomsExtension(proxy_file_name,printERRORS)[0]
		elif timeleft>0:
			if info.prgname=="glite-job-submit":
				errMsg("Error",'UI_PROXY_DURATION' , valid )
				return 1
		else:
			errMsg("Error",'UI_PROXY_EXPIRED' )
			return 1

	else:
		# The Proxy Does not exist
		errMsg("Error",'UI_PROXY_NOT_FOUND')
		return 1