@staticmethod<EOL><INDENT>def redirect(url, parameters={}, request_data={}):<DEDENT>
assert isinstance(url, basestring)<EOL>assert isinstance(parameters, dict)<EOL>if url.startswith('<STR_LIT:/>'):<EOL><INDENT>url = '<STR_LIT>' % (OneLogin_Saml2_Utils.get_self_url_host(request_data), url)<EOL><DEDENT>if re.search('<STR_LIT>', url) is None:<EOL><INDENT>raise OneLogin_Saml2_Error(<EOL>'<STR_LIT>' + url,<EOL>OneLogin_Saml2_Error.REDIRECT_INVALID_URL<EOL>)<EOL><DEDENT>if url.find('<STR_LIT:?>') < <NUM_LIT:0>:<EOL><INDENT>param_prefix = '<STR_LIT:?>'<EOL><DEDENT>else:<EOL><INDENT>param_prefix = '<STR_LIT:&>'<EOL><DEDENT>for name, value in parameters.items():<EOL><INDENT>if value is None:<EOL><INDENT>param = quote_plus(name)<EOL><DEDENT>elif isinstance(value, list):<EOL><INDENT>param = '<STR_LIT>'<EOL>for val in value:<EOL><INDENT>param += quote_plus(name) + '<STR_LIT>' + quote_plus(val) + '<STR_LIT:&>'<EOL><DEDENT>if len(param) > <NUM_LIT:0>:<EOL><INDENT>param = param[<NUM_LIT:0>:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>param = quote_plus(name) + '<STR_LIT:=>' + quote_plus(value)<EOL><DEDENT>if param:<EOL><INDENT>url += param_prefix + param<EOL>param_prefix = '<STR_LIT:&>'<EOL><DEDENT><DEDENT>return url<EOL>
Executes a redirection to the provided url (or return the target url).

:param url: The target url
:type: string

:param parameters: Extra parameters to be passed as part of the url
:type: dict

:param request_data: The request as a dict
:type: dict

:returns: Url
:rtype: string