Esempio n. 1
0
    def matchName(self, packetName):
        """
        Implementation of the check for match.

        :param Name packetName: The packet name, which is already stripped of
          signature components if this is a signed Interest name.
        :return: True for a match.
        :rtype: bool
        """
        return ConfigNameRelation.checkNameRelation(self._relation, self._name,
                                                    packetName)
Esempio n. 2
0
    def matchName(self, packetName):
        """
        Implementation of the check for match.

        :param Name packetName: The packet name, which is already stripped of
          signature components if this is a signed Interest name.
        :return: True for a match.
        :rtype: bool
        """
        return ConfigNameRelation.checkNameRelation(
          self._relation, self._name, packetName)
Esempio n. 3
0
    def checkNames(self, packetName, keyLocatorName, state):
        """
        :param Name packetName:
        :param Name keyLocatorName:
        :param ValidationState state:
        :rtype: bool
        """
        if not self._packetNameRegex.match(packetName):
            state.fail(
                ValidationError(
                    ValidationError.POLICY_ERROR,
                    "The packet " + packetName.toUri() + " (KeyLocator=" +
                    keyLocatorName.toUri() +
                    ") does not match the hyper relation packet name regex " +
                    self._packetNameRegex.getExpr()))
            return False
        if not self._keyNameRegex.match(keyLocatorName):
            state.fail(
                ValidationError(
                    ValidationError.POLICY_ERROR,
                    "The packet " + packetName.toUri() + " (KeyLocator=" +
                    keyLocatorName.toUri() +
                    ") does not match the hyper relation key name regex " +
                    self._keyNameRegex.getExpr()))
            return False

        keyNameMatchExpansion = self._keyNameRegex.expand(
            self._keyNameExpansion)
        packetNameMatchExpansion = self._packetNameRegex.expand(
            self._packetNameExpansion)
        result = ConfigNameRelation.checkNameRelation(
            self._hyperRelation, keyNameMatchExpansion,
            packetNameMatchExpansion)
        if not result:
            state.fail(
                ValidationError(
                    ValidationError.POLICY_ERROR,
                    "KeyLocator check failed: hyper relation " +
                    ConfigNameRelation.toString(self._hyperRelation) +
                    " packet name match=" + packetNameMatchExpansion.toUri() +
                    ", key name match=" + keyNameMatchExpansion.toUri() +
                    " of packet " + packetName.toUri() + " (KeyLocator=" +
                    keyLocatorName.toUri() + ") is invalid"))

        return result
Esempio n. 4
0
    def checkNames(self, packetName, keyLocatorName, state):
        """
        :param Name packetName:
        :param Name keyLocatorName:
        :param ValidationState state:
        :rtype: bool
        """
        # packetName is not used in this check.

        identity = PibKey.extractIdentityFromKeyName(keyLocatorName)
        result = ConfigNameRelation.checkNameRelation(
          self._relation, self._name, identity)
        if not result:
            state.fail(ValidationError(ValidationError.POLICY_ERROR,
              "KeyLocator check failed: name relation " + self._name.toUri() + " " +
              ConfigNameRelation.toString(self._relation) + " for packet " +
              packetName.toUri() + " is invalid (KeyLocator=" +
              keyLocatorName.toUri() + ", identity=" + identity.toUri() + ")"))

        return result
Esempio n. 5
0
    def checkNames(self, packetName, keyLocatorName, state):
        """
        :param Name packetName:
        :param Name keyLocatorName:
        :param ValidationState state:
        :rtype: bool
        """
        if not self._packetNameRegex.match(packetName):
            state.fail(ValidationError(ValidationError.POLICY_ERROR,
              "The packet " + packetName.toUri() + " (KeyLocator=" +
              keyLocatorName.toUri() +
              ") does not match the hyper relation packet name regex " +
              self._packetNameRegex.getExpr()))
            return False
        if not self._keyNameRegex.match(keyLocatorName):
            state.fail(ValidationError(ValidationError.POLICY_ERROR,
              "The packet " + packetName.toUri() + " (KeyLocator=" +
              keyLocatorName.toUri() +
              ") does not match the hyper relation key name regex " +
              self._keyNameRegex.getExpr()))
            return False

        keyNameMatchExpansion = self._keyNameRegex.expand(self._keyNameExpansion)
        packetNameMatchExpansion = self._packetNameRegex.expand(
          self._packetNameExpansion)
        result = ConfigNameRelation.checkNameRelation(
          self._hyperRelation, keyNameMatchExpansion, packetNameMatchExpansion)
        if not result:
            state.fail(ValidationError(ValidationError.POLICY_ERROR,
              "KeyLocator check failed: hyper relation " +
              ConfigNameRelation.toString(self._hyperRelation) +
              " packet name match=" + packetNameMatchExpansion.toUri() +
              ", key name match=" + keyNameMatchExpansion.toUri() + " of packet " +
              packetName.toUri() + " (KeyLocator=" + keyLocatorName.toUri() +
              ") is invalid"))

        return result
Esempio n. 6
0
    def checkNames(self, packetName, keyLocatorName, state):
        """
        :param Name packetName:
        :param Name keyLocatorName:
        :param ValidationState state:
        :rtype: bool
        """
        # packetName is not used in this check.

        identity = PibKey.extractIdentityFromKeyName(keyLocatorName)
        result = ConfigNameRelation.checkNameRelation(self._relation,
                                                      self._name, identity)
        if not result:
            state.fail(
                ValidationError(
                    ValidationError.POLICY_ERROR,
                    "KeyLocator check failed: name relation " +
                    self._name.toUri() + " " +
                    ConfigNameRelation.toString(self._relation) +
                    " for packet " + packetName.toUri() +
                    " is invalid (KeyLocator=" + keyLocatorName.toUri() +
                    ", identity=" + identity.toUri() + ")"))

        return result