Example #1
0
 def renderHTTP(self, request):
     application = getApplicationForURI(request.xcap_uri)
     if not application:
         return http.Response(responsecode.NOT_FOUND,
                              stream="Application not supported")
     resource = self.resourceForURI(request.xcap_uri)
     return resource.renderHTTP(request)
Example #2
0
 def resourceForURI(self, xcap_uri):
     application = getApplicationForURI(xcap_uri)
     if not xcap_uri.node_selector:
         return XCAPDocument(xcap_uri, application)
     else:
         terminal_selector = xcap_uri.node_selector.terminal_selector
         if isinstance(terminal_selector, AttributeSelector):
             return XCAPAttribute(xcap_uri, application)
         elif isinstance(terminal_selector, NamespaceSelector):
             return XCAPNamespaceBinding(xcap_uri, application)
         else:
             return XCAPElement(xcap_uri, application)
Example #3
0
 def resourceForURI(self, xcap_uri):
     application = getApplicationForURI(xcap_uri)
     if not xcap_uri.node_selector:
         return XCAPDocument(xcap_uri, application)
     else:
         terminal_selector = xcap_uri.node_selector.terminal_selector
         if isinstance(terminal_selector, AttributeSelector):
             return XCAPAttribute(xcap_uri, application)
         elif isinstance(terminal_selector, NamespaceSelector):
             return XCAPNamespaceBinding(xcap_uri, application)
         else:
             return XCAPElement(xcap_uri, application)
Example #4
0
    def _loginSucceeded(self, avatar, request):
        """Authorizes an XCAP request after it has been authenticated."""

        interface, avatar_id = avatar  ## the avatar is the authenticated XCAP User
        xcap_uri = request.xcap_uri

        application = getApplicationForURI(xcap_uri)

        if not application:
            raise ResourceNotFound

        if interface is IAuthUser and application.is_authorized(XCAPUser.parse(avatar_id), xcap_uri):
            return HTTPAuthResource._loginSucceeded(self, avatar, request)
        elif interface is ITrustedPeer or interface is IPublicGetApplication:
            return HTTPAuthResource._loginSucceeded(self, avatar, request)
        else:
            return failure.Failure(http.HTTPError(UnauthorizedResponse(self.credentialFactories, request.remoteAddr)))
Example #5
0
    def _loginSucceeded(self, avatar, request):
        """Authorizes an XCAP request after it has been authenticated."""

        interface, avatar_id = avatar  ## the avatar is the authenticated XCAP User
        xcap_uri = request.xcap_uri

        application = getApplicationForURI(xcap_uri)

        if not application:
            raise ResourceNotFound

        if interface is IAuthUser and application.is_authorized(
                XCAPUser.parse(avatar_id), xcap_uri):
            return HTTPAuthResource._loginSucceeded(self, avatar, request)
        elif interface is ITrustedPeer or interface is IPublicGetApplication:
            return HTTPAuthResource._loginSucceeded(self, avatar, request)
        else:
            return failure.Failure(
                http.HTTPError(
                    UnauthorizedResponse(self.credentialFactories,
                                         request.remoteAddr)))
Example #6
0
 def renderHTTP(self, request):
     application = getApplicationForURI(request.xcap_uri)
     if not application:
         return http.Response(responsecode.NOT_FOUND, stream="Application not supported")
     resource = self.resourceForURI(request.xcap_uri)
     return resource.renderHTTP(request)