Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getUserData():
userData = []
username = credentials.getUsername()
if not username or username == "anonymous":
userData.append( "username : 'Anonymous'" )
else:
userData.append( "username : '%s'" % username )
userData.append( "group : '%s'" % credentials.getSelectedGroup() )
properties = credentials.getProperties( credentials.getSelectedGroup() )
if len( properties ) > 0:
userData.append( "groupProperties : %s" % properties )
else:
userData.append( "groupProperties : []" )
availableGroups = list()
for groupName in credentials.getAvailableGroups():
properties = credentials.getProperties( groupName )
if not len( properties ) > 0:
continue
if ( "Pilot" in properties ) or ( "GenericPilot" in properties ):
continue
url = diracURL( controller = 'web/userdata',
action = 'changeGroup',
id = groupName )
availableGroups.append( "{ text : '%s', url : '%s' }" %
( groupName , url ) )
userData.append( "groupMenu : [%s]" % ",".join( availableGroups ) )
dn = credentials.getUserDN()
if not dn:
if 'REQUEST_URI' in request.environ:
uri = str( request.environ[ 'REQUEST_URI' ] )
else:
"""
Get p12 file and passwords as input. Split p12 to user key and certificate
and creating proxy for groups user belongs to. Upload proxy to proxy store
"""
# Otherwise the browser would offer to download a file
response.headers['Content-type'] = "text/html"
username = getUsername()
gLogger.info("Start upload proxy out of p12 for user: %s" % (username))
disclaimer = "\nNo proxy was created\nYour private info was safely deleted"
disclaimer = disclaimer + " from DIRAC service"
if username == "anonymous":
error = "Please, send a registration request first"
gLogger.error("Anonymous is not allowed")
gLogger.debug("Service response: %s" % error)
return {"success":"false","error":error}
groupList = getAvailableGroups()
groups = ", ".join(groupList)
gLogger.info("Available groups for the user %s: %s" % (username,groups))
if not len(groupList) > 0:
gLogger.error("User is not registered in any group")
error = "Seems that user %s is not register in any group" % username
error = error + disclaimer
gLogger.debug("Service response: %s" % error)
return {"success":"false","error":error}
store = list()
gLogger.debug("Request's body:")
for key in request.params.keys():
try:
gLogger.debug("%s - %s" % (key,request.params[key]))
except Exception,x:
gLogger.error("Exception: %s" % str(x))
error = "An exception has happen '%s'" % str(x)
def changeGroup( self ):
return self.__changeURLPropertyAndRedirect( 'dgroup', credentials.getAvailableGroups() )
def htmlUserInfo():
username = credentials.getUsername()
if not username or username == "anonymous":
htmlData = "Anonymous"
else:
selectedGroup = credentials.getSelectedGroup()
availableGroups = [ ( groupName, diracURL( controller = 'web/userdata', action = 'changeGroup', id = groupName ) ) for groupName in credentials.getAvailableGroups() ]
htmlData = "%s@%s" % ( username, yuiWidgets.dropDownMenu( "UserGroupPos", selectedGroup, availableGroups ) )
dn = credentials.getUserDN()
if dn:
htmlData += " (%s)" % dn
else:
if 'REQUEST_URI' in request.environ:
uri = str( request.environ[ 'REQUEST_URI' ] )
else:
uri = ""
htmlData += " (<a href="https://%s%s">certificate login</a>)" % ( str( request.environ[ 'HTTP_HOST' ] ), uri )
return htmlData
"""
Get p12 file and passwords as input. Split p12 to user key and certificate
and creating proxy for groups user belongs to. Upload proxy to proxy store
"""
# Otherwise the browser would offer to download a file
response.headers['Content-type'] = "text/html"
username = getUsername()
gLogger.info("Start upload proxy out of p12 for user: %s" % (username))
disclaimer = "\nNo proxy was created\nYour private info was safely deleted"
disclaimer = disclaimer + " from DIRAC service"
if username == "anonymous":
error = "Please, send a registration request first"
gLogger.error("Anonymous is not allowed")
gLogger.debug("Service response: %s" % error)
return {"success":"false","error":error}
groupList = getAvailableGroups()
groups = ", ".join(groupList)
gLogger.info("Available groups for the user %s: %s" % (username,groups))
if not len(groupList) > 0:
gLogger.error("User is not registered in any group")
error = "Seems that user %s is not register in any group" % username
error = error + disclaimer
gLogger.debug("Service response: %s" % error)
return {"success":"false","error":error}
store = list()
gLogger.debug("Request's body:")
for key in request.params.keys():
try:
gLogger.debug("%s - %s" % (key,request.params[key]))
except Exception,x:
gLogger.error("Exception: %s" % str(x))
error = "An exception has happen '%s'" % str(x)