#NEWLINE# def RenderAjax( self , request , response ) : #NEWLINE# #INDENT# 'Run the flow for granting access.' #NEWLINE# approval_urn = rdfvalue . RDFURN ( request . REQ . get ( 'acl' , '/' ) ) #NEWLINE# ( _ , namespace , _ ) = approval_urn . Split ( 3 ) #NEWLINE# if ( namespace == 'hunts' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( _ , _ , hunt_id , user , reason ) = approval_urn . Split ( ) #NEWLINE# self . subject = rdfvalue . RDFURN ( namespace ) . Add ( hunt_id ) #NEWLINE# self . user = user #NEWLINE# self . reason = utils . DecodeReasonString ( reason ) #NEWLINE# #UNINDENT# except ( ValueError , TypeError ) : #NEWLINE# #INDENT# raise access_control . UnauthorizedAccess ( 'Approval object is not well formed.' ) #NEWLINE# #UNINDENT# flow . GRRFlow . StartFlow ( flow_name = 'GrantHuntApprovalFlow' , subject_urn = self . subject , reason = self . reason , delegate = self . user , token = request . token ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( namespace == 'cron' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( _ , _ , cron_job_name , user , reason ) = approval_urn . Split ( ) #NEWLINE# self . subject = rdfvalue . RDFURN ( namespace ) . Add ( cron_job_name ) #NEWLINE# self . user = user #NEWLINE# self . reason = utils . DecodeReasonString ( reason ) #NEWLINE# #UNINDENT# except ( ValueError , TypeError ) : #NEWLINE# #INDENT# raise access_control . UnauthorizedAccess ( 'Approval object is not well formed.' ) #NEWLINE# #UNINDENT# flow . GRRFlow . StartFlow ( flow_name = 'GrantCronJobApprovalFlow' , subject_urn = self . subject , reason = self . reason , delegate = self . user , token = request . token ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if aff4 . AFF4Object . VFSGRRClient . CLIENT_ID_RE . match ( namespace ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( _ , client_id , user , reason ) = approval_urn . Split ( ) #NEWLINE# self . subject = client_id #NEWLINE# self . user = user #NEWLINE# self . reason = utils . DecodeReasonString ( reason ) #NEWLINE# #UNINDENT# except ( ValueError , TypeError ) : #NEWLINE# #INDENT# raise access_control . UnauthorizedAccess ( 'Approval object is not well formed.' ) #NEWLINE# #UNINDENT# flow . GRRFlow . StartFlow ( client_id = client_id , flow_name = 'GrantClientApprovalFlow' , reason = self . reason , delegate = self . user , subject_urn = rdf_client . ClientURN ( self . subject ) , token = request . token ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise access_control . UnauthorizedAccess ( 'Approval object is not well formed.' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return renderers . TemplateRenderer . Layout ( self , request , response , apply_template = self . ajax_template )