'Get the L{IResource} which the given request is authorized to receive.
If the proper authorization headers are present, the resource will be
requested from the portal.  If not, an anonymous login attempt will be
made.'

def _authorizedResource(self, request):

    authheader = request.getHeader('authorization')
    if (not authheader):
        return util.DeferredResource(self._login(Anonymous()))
    (factory, respString) = self._selectParseHeader(authheader)
    if (factory is None):
        return UnauthorizedResource(self._credentialFactories)
    try:
        credentials = factory.decode(respString, request)
    except error.LoginFailed:
        return UnauthorizedResource(self._credentialFactories)
    except:
        log.err(None, 'Unexpected    failure    from    credentials    factory')
        return ErrorPage(500, None, None)
    else:
        return util.DeferredResource(self._login(credentials))
