ldap-client-0.1.0: Pure Haskell LDAP Client Library

Safe HaskellNone
LanguageHaskell2010

Ldap.Asn1.ToAsn1

Description

This module contains convertions from LDAP types to ASN.1.

Various hacks are employed because "asn1-encoding" only encodes to DER, but LDAP demands BER-encoding. So, when a definition looks suspiciously different from the spec in the comment, that's why. I hope all that will be fixed eventually.

Synopsis

Documentation

class ToAsn1 a where Source

Convert a LDAP type to ASN.1.

When it's relevant, instances include the part of RFC describing the encoding.

Methods

toAsn1 :: a -> Endo [ASN1] Source

Instances

ToAsn1 LdapOid
LDAPOID ::= OCTET STRING -- Constrained to <numericoid>
ToAsn1 LdapString
LDAPString ::= OCTET STRING -- UTF-8 encoded
ToAsn1 RelativeLdapDn
RelativeLDAPDN ::= LDAPString -- Constrained to <name-component>
ToAsn1 LdapDn
LDAPDN ::= LDAPString -- Constrained to <distinguishedName>
ToAsn1 PartialAttribute
PartialAttribute ::= SEQUENCE {
     type       AttributeDescription,
     vals       SET OF value AttributeValue }
ToAsn1 Attribute
Attribute ::= PartialAttribute(WITH COMPONENTS {
     ...,
     vals (SIZE(1..MAX))})
ToAsn1 AssertionValue
AssertionValue ::= OCTET STRING
ToAsn1 AttributeValueAssertion
AttributeValueAssertion ::= SEQUENCE {
     attributeDesc   AttributeDescription,
     assertionValue  AssertionValue }
ToAsn1 AttributeValue
AttributeValue ::= OCTET STRING
ToAsn1 AttributeDescription
AttributeDescription ::= LDAPString
ToAsn1 Control
Control ::= SEQUENCE {
     controlType             LDAPOID,
     criticality             BOOLEAN DEFAULT FALSE,
     controlValue            OCTET STRING OPTIONAL }
ToAsn1 Controls
Controls ::= SEQUENCE OF control Control
ToAsn1 AttributeList
AttributeList ::= SEQUENCE OF attribute Attribute
ToAsn1 AttributeSelection
AttributeSelection ::= SEQUENCE OF selector LDAPString
ToAsn1 MatchingRuleId
MatchingRuleId ::= LDAPString
ToAsn1 MatchingRuleAssertion
MatchingRuleAssertion ::= SEQUENCE {
     matchingRule    [1] MatchingRuleId OPTIONAL,
     type            [2] AttributeDescription OPTIONAL,
     matchValue      [3] AssertionValue,
     dnAttributes    [4] BOOLEAN DEFAULT FALSE }
ToAsn1 SubstringFilter
SubstringFilter ::= SEQUENCE {
     type           AttributeDescription,
     substrings     SEQUENCE SIZE (1..MAX) OF substring CHOICE {
          initial [0] AssertionValue,  -- can occur at most once
          any     [1] AssertionValue,
          final   [2] AssertionValue } -- can occur at most once
     }
ToAsn1 Filter
Filter ::= CHOICE {
     and             [0] SET SIZE (1..MAX) OF filter Filter,
     or              [1] SET SIZE (1..MAX) OF filter Filter,
     not             [2] Filter,
     equalityMatch   [3] AttributeValueAssertion,
     substrings      [4] SubstringFilter,
     greaterOrEqual  [5] AttributeValueAssertion,
     lessOrEqual     [6] AttributeValueAssertion,
     present         [7] AttributeDescription,
     approxMatch     [8] AttributeValueAssertion,
     extensibleMatch [9] MatchingRuleAssertion,
     ...  }
ToAsn1 AuthenticationChoice
AuthenticationChoice ::= CHOICE {
     simple                  [0] OCTET STRING,
     ...  }
ToAsn1 ProtocolClientOp
BindRequest ::= [APPLICATION 0] SEQUENCE {
     version                 INTEGER (1 ..  127),
     name                    LDAPDN,
     authentication          AuthenticationChoice }
UnbindRequest ::= [APPLICATION 2] NULL
SearchRequest ::= [APPLICATION 3] SEQUENCE {
     baseObject      LDAPDN,
     scope           ENUMERATED {
          baseObject              (0),
          singleLevel             (1),
          wholeSubtree            (2),
          ...  },
     derefAliases    ENUMERATED {
          neverDerefAliases       (0),
          derefInSearching        (1),
          derefFindingBaseObj     (2),
          derefAlways             (3) },
     sizeLimit       INTEGER (0 ..  maxInt),
     timeLimit       INTEGER (0 ..  maxInt),
     typesOnly       BOOLEAN,
     filter          Filter,
     attributes      AttributeSelection }
ModifyRequest ::= [APPLICATION 6] SEQUENCE {
     object          LDAPDN,
     changes         SEQUENCE OF change SEQUENCE {
          operation       ENUMERATED {
               add     (0),
               delete  (1),
               replace (2),
               ...  },
          modification    PartialAttribute } }
AddRequest ::= [APPLICATION 8] SEQUENCE {
     entry           LDAPDN,
     attributes      AttributeList }
DelRequest ::= [APPLICATION 10] LDAPDN
ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
     entry           LDAPDN,
     newrdn          RelativeLDAPDN,
     deleteoldrdn    BOOLEAN,
     newSuperior     [0] LDAPDN OPTIONAL }
CompareRequest ::= [APPLICATION 14] SEQUENCE {
     entry           LDAPDN,
     ava             AttributeValueAssertion }
ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
     requestName      [0] LDAPOID,
     requestValue     [1] OCTET STRING OPTIONAL }
ToAsn1 Id
MessageID ::= INTEGER (0 ..  maxInt)
ToAsn1 a => ToAsn1 [a] 
ToAsn1 a => ToAsn1 (NonEmpty a) 
ToAsn1 op => ToAsn1 (LdapMessage op)
LDAPMessage ::= SEQUENCE {
     messageID       MessageID,
     protocolOp      CHOICE {
          bindRequest           BindRequest,
          bindResponse          BindResponse,
          unbindRequest         UnbindRequest,
          searchRequest         SearchRequest,
          searchResEntry        SearchResultEntry,
          searchResDone         SearchResultDone,
          searchResRef          SearchResultReference,
          addRequest            AddRequest,
          addResponse           AddResponse,
          ... },
     controls       [0] Controls OPTIONAL }