'Deal with the response url from a Discovery Service
:param url: the url the user was redirected back to or
:param query: just the query part of the URL.
:param returnIDParam: This is where the identifier of the IdP is
place if it was specified in the query. Default is \'entityID\'
:return: The IdP identifier or "" if none was given'

@staticmethod
def parse_discovery_service_response(url='', query='', returnIDParam='entityID'):

    if url:
        part = urlparse(url)
        qsd = parse_qs(part[4])
    elif query:
        qsd = parse_qs(query)
    else:
        qsd = {}
    try:
        return qsd[returnIDParam][0]
    except KeyError:
        return ''
