'Build an ACLToken from the request.'

@staticmethod
def BuildToken(request, execution_time):

    if (request.method in ['GET', 'HEAD']):
        reason = request.args.get('reason', '')
    elif (request.method in ['POST', 'DELETE', 'PATCH']):
        reason = utils.SmartUnicode(urllib2.unquote(request.headers.get('X-Grr-Reason', '')))
    token = access_control.ACLToken(username=request.user, reason=reason, process='GRRAdminUI', expiry=(rdfvalue.RDFDatetime.Now() + execution_time))
    for field in ['Remote_Addr', 'X-Forwarded-For']:
        remote_addr = request.headers.get(field, '')
        if remote_addr:
            token.source_ips.append(remote_addr)
    return token
