Exemple #1
0
 def test_path(self, path):
     """Returns True if there is a path prefix that matches *path*"""
     path = uri.split_path(path)
     uri.normalize_segments(path)
     for p in self.pathPrefixes:
         if self.is_prefix(p, path):
             return True
     return False
Exemple #2
0
 def test_path(self, path):
     """Returns True if there is a path prefix that matches *path*"""
     path = uri.split_path(path)
     uri.normalize_segments(path)
     for p in self.pathPrefixes:
         if self.is_prefix(p, path):
             return True
     return False
Exemple #3
0
    def add_success_path(self, path):
        """Updates credentials based on success at path

        path
            A string of octets representing the path that these
            credentials have been used for with a successful result.

        This method implements the requirement that paths "at or deeper
        than the depth of the last symbolic element in the path field"
        should be treated as being part of the same protection space.

        The path is reduced to a path prefix by removing the last
        symbolic element and then it is tested against existing prefixes
        to ensure that the most general prefix is being stored, for
        example, if path is "/website/document" it will replace any
        existing prefixes of the form "/website/folder." with the common
        prefix "/website"."""
        if not path:
            # empty path, treat as entire space!
            path = "/"
        new_prefix = uri.split_path(path)
        if new_prefix[-1]:
            new_prefix[-1] = ""
        uri.normalize_segments(new_prefix)
        keep = True
        i = 0
        while i < len(self.pathPrefixes):
            p = self.pathPrefixes[i]
            # p could be a prefix of new_prefix
            if self.is_prefix(p, new_prefix):
                keep = False
                break
            elif self.is_prefix(new_prefix, p):
                # new_prefix could be a prefix of p
                del self.pathPrefixes[i]
                continue
            i = i + 1
        if keep:
            self.pathPrefixes.append(new_prefix)
Exemple #4
0
    def add_success_path(self, path):
        """Updates credentials based on success at path

        path
            A string of octets representing the path that these
            credentials have been used for with a successful result.

        This method implements the requirement that paths "at or deeper
        than the depth of the last symbolic element in the path field"
        should be treated as being part of the same protection space.

        The path is reduced to a path prefix by removing the last
        symbolic element and then it is tested against existing prefixes
        to ensure that the most general prefix is being stored, for
        example, if path is "/website/document" it will replace any
        existing prefixes of the form "/website/folder." with the common
        prefix "/website"."""
        if not path:
            # empty path, treat as entire space!
            path = "/"
        new_prefix = uri.split_path(path)
        if new_prefix[-1]:
            new_prefix[-1] = ""
        uri.normalize_segments(new_prefix)
        keep = True
        i = 0
        while i < len(self.pathPrefixes):
            p = self.pathPrefixes[i]
            # p could be a prefix of new_prefix
            if self.is_prefix(p, new_prefix):
                keep = False
                break
            elif self.is_prefix(new_prefix, p):
                # new_prefix could be a prefix of p
                del self.pathPrefixes[i]
                continue
            i = i + 1
        if keep:
            self.pathPrefixes.append(new_prefix)
Exemple #5
0
    def add_success_path(self, path):
        """Adds *pathPrefix* to the list of path prefixes that these
        credentials apply to.

        If pathPrefix is a more general prefix than an existing prefix
        in the list then it replaces that prefix."""
        new_prefix = uri.split_path(path)
        uri.normalize_segments(new_prefix)
        keep = True
        i = 0
        while i < len(self.pathPrefixes):
            p = self.pathPrefixes[i]
            # p could be a prefix of new_prefix
            if self.is_prefix(p, new_prefix):
                keep = False
                break
            elif self.is_prefix(new_prefix, p):
                # new_prefix could be a prefix of p
                del self.pathPrefixes[i]
                continue
            i = i + 1
        if keep:
            self.pathPrefixes.append(new_prefix)