コード例 #1
0
class Control(Sequence):
    """
        Control ::= SEQUENCE {
                 controlType             LDAPOID,
                 criticality             BOOLEAN DEFAULT FALSE,
                 controlValue            OCTET STRING OPTIONAL }
    """
    componentType = NamedTypes(
        NamedType('controlType', LDAPOID()),
        DefaultedNamedType('criticality', Boolean(False)),
        OptionalNamedType('controlValue', OctetString()),
    )

    def setComponentByPosition(self,
                               idx,
                               value=None,
                               verifyConstraints=True,
                               exactTypes=False,
                               matchTags=True,
                               matchConstraints=True):
        if idx == 0:  # controlType
            try:
                cls = KNOWN_CONTROLS[value]
                if self.__class__ != cls:
                    self.__class__ = cls
            except KeyError:
                pass
        return Sequence.setComponentByPosition(self, idx, value,
                                               verifyConstraints, exactTypes,
                                               matchTags, matchConstraints)
コード例 #2
0
class Control(Sequence):
    # Control ::= SEQUENCE {
    #     controlType             LDAPOID,
    #     criticality             BOOLEAN DEFAULT FALSE,
    #     controlValue            OCTET STRING OPTIONAL }
    componentType = NamedTypes(NamedType('controlType', LDAPOID()),
                               DefaultedNamedType('criticality', Criticality()),
                               OptionalNamedType('controlValue', ControlValue()))
コード例 #3
0
class MatchingRuleAssertion(Sequence):
    # MatchingRuleAssertion ::= SEQUENCE {
    #     matchingRule    [1] MatchingRuleId OPTIONAL,
    #     type            [2] AttributeDescription OPTIONAL,
    #     matchValue      [3] AssertionValue,
    #     dnAttributes    [4] BOOLEAN DEFAULT FALSE }
    componentType = NamedTypes(OptionalNamedType('matchingRule', MatchingRule()),
                               OptionalNamedType('type', Type()),
                               NamedType('matchValue', MatchValue()),
                               DefaultedNamedType('dnAttributes', DnAttributes()))
コード例 #4
0
class SimplePagedResultsControl(Control):
    """
        pagedResultsControl ::= SEQUENCE {
                controlType     1.2.840.113556.1.4.319,
                criticality     BOOLEAN DEFAULT FALSE,
                controlValue    pagedSearchControlValue }
    """
    componentType = NamedTypes(
        NamedType('controlType', LDAPOID()),
        DefaultedNamedType('criticality', Boolean(False)),
        OptionalNamedType('controlValue', OctetString()),
    )

    def __init__(self, criticality=False, size=1000, cookie='', **kwargs):
        Control.__init__(self, **kwargs)
        self['controlType'] = CONTROL_PAGEDRESULTS
        self['criticality'] = criticality
        self._size = size
        self._cookie = cookie
        self._encodeControlValue()

    def _encodeControlValue(self):
        self['controlValue'] = encoder.encode(
            SimplePagedSearchControlValue().setComponents(
                self._size, self._cookie))

    def _decodeControlValue(self):
        self._size, self._cookie = decoder.decode(
            self['controlValue'], asn1Spec=SimplePagedSearchControlValue())[0]

    def getCriticality(self):
        return self['criticality']

    def setCritical(self, value):
        self['criticality'] = value

    def getSize(self):
        self._decodeControlValue()
        return self._size

    def setSize(self, value):
        self._size = value
        self._encodeControlValue()

    def getCookie(self):
        self._decodeControlValue()
        return self._cookie

    def setCookie(self, value):
        self._cookie = value
        self._encodeControlValue()
コード例 #5
0
class MatchingRuleAssertion(Sequence):
    """
        MatchingRuleAssertion ::= SEQUENCE {
             matchingRule    [1] MatchingRuleId OPTIONAL,
             type            [2] AttributeDescription OPTIONAL,
             matchValue      [3] AssertionValue,
             dnAttributes    [4] BOOLEAN DEFAULT FALSE }
    """
    tagSet = Sequence.tagSet.tagImplicitly(
        Tag(tagClassContext, tagFormatConstructed, 9))
    componentType = NamedTypes(
        OptionalNamedType('matchingRule', MatchingRuleId()),
        OptionalNamedType('type', TypeDescription()),
        NamedType('matchValue', matchValueAssertion()),
        DefaultedNamedType('dnAttributes', DnAttributes(False)),
    )