LDAPv3-0.1.2.0: Lightweight Directory Access Protocol (LDAP) version 3
Copyright© Herbert Valerio Riedel 2023
LicenseGPL-2.0-or-later
Safe HaskellTrustworthy
LanguageHaskell2010

LDAPv3.OID

Description

LDAP OID Helpers

This module provides helpers for dealing with the representation of Object Identifiers (OID) in LDAP.

Since: 0.1.2

Synopsis

Textually encoded OIDs

type LDAPOID = OID Source #

Object identifier (RFC4511 Section 4.1.2)

LDAPOID ::= OCTET STRING -- Constrained to <numericoid>
                         -- [RFC4512]

Since: 0.1.0

newtype OID Source #

Numeric Object Identifier (OID)

numericoid = number 1*( DOT number )
number  = DIGIT / ( LDIGIT 1*DIGIT )
DIGIT   = %x30 / LDIGIT       ; "0"-"9"
LDIGIT  = %x31-39             ; "1"-"9"

NB: The current type definition and its StringRepr instance currently allows to represent and parse more than the ABNF described above; moreover, the ABNF is also more liberal as it doesn't express the constraints imposed upon the first two arcs by X.660 and ASN.1. See also isWellFormedOid.

Since: 0.1.0

Constructors

OID (NonEmpty Natural) 

Instances

Instances details
Eq OID Source # 
Instance details

Defined in LDAPv3.OID

Methods

(==) :: OID -> OID -> Bool #

(/=) :: OID -> OID -> Bool #

Ord OID Source # 
Instance details

Defined in LDAPv3.OID

Methods

compare :: OID -> OID -> Ordering #

(<) :: OID -> OID -> Bool #

(<=) :: OID -> OID -> Bool #

(>) :: OID -> OID -> Bool #

(>=) :: OID -> OID -> Bool #

max :: OID -> OID -> OID #

min :: OID -> OID -> OID #

Show OID Source # 
Instance details

Defined in LDAPv3.OID

Methods

showsPrec :: Int -> OID -> ShowS #

show :: OID -> String #

showList :: [OID] -> ShowS #

NFData OID Source # 
Instance details

Defined in LDAPv3.OID

Methods

rnf :: OID -> () #

StringRepr OID Source # 
Instance details

Defined in LDAPv3.OID

IsWellFormedOid OID Source # 
Instance details

Defined in LDAPv3.OID

Newtype OID (NonEmpty Natural) Source # 
Instance details

Defined in LDAPv3.OID

Binary encoded OIDs

data OBJECT_IDENTIFIER Source #

ASN.1 OBJECT IDENTIFIER

The OID type uses the textual LDAP encoding when converted to/from ASN.1 whereas this type provides the proper ASN.1 encoding as defined per X.690 section 8.19 (accessible via its Binary instance).

Since: 0.1.2

Instances

Instances details
Eq OBJECT_IDENTIFIER Source # 
Instance details

Defined in LDAPv3.OID

Ord OBJECT_IDENTIFIER Source #

Lexicographic ordering

Instance details

Defined in LDAPv3.OID

Show OBJECT_IDENTIFIER Source # 
Instance details

Defined in LDAPv3.OID

Binary OBJECT_IDENTIFIER Source #

Encodes as ASN.1 BER/DER with UNIVERSAL 6 tag as per X.690 section 8.19

Instance details

Defined in LDAPv3.OID

NFData OBJECT_IDENTIFIER Source # 
Instance details

Defined in LDAPv3.OID

Methods

rnf :: OBJECT_IDENTIFIER -> () #

StringRepr OBJECT_IDENTIFIER Source # 
Instance details

Defined in LDAPv3.OID

IsWellFormedOid OBJECT_IDENTIFIER Source #

Trivial instance as OBJECT_IDENTIFIER values are always well-formed by construction

Instance details

Defined in LDAPv3.OID

object_identifier'toOID :: OBJECT_IDENTIFIER -> OID Source #

Convert OBJECT_IDENTIFIER into OID representation

Since: 0.1.2

object_identifier'fromOID :: OID -> Maybe OBJECT_IDENTIFIER Source #

Try to OID representation into OBJECT_IDENTIFIER representation

NB: This will return Nothing iff isWellFormedOid returns False on the input argument.

Since: 0.1.2

object_identifier'toBin :: OBJECT_IDENTIFIER -> ShortByteString Source #

Encode as raw ASN.1 BER/DER value (i.e. without tag & length)

NB: As this function simply returns the internal representation this operation has zero cost.

Since: 0.1.2

object_identifier'fromBin :: ShortByteString -> Maybe OBJECT_IDENTIFIER Source #

Decode from raw ASN.1 BER/DER value (i.e. without tag & length)

All byte sequences are deemed well-formed raw ASN.1 OID encodings that satisfy the simple rules below (which ought to result in the same syntax as the rules specified in X.690 section 8.19.):

  • The sequence must end with an octet with a value below 0x80 (i.e. unset MSB), and
  • any 0x80 octet must be directly preceded by an octet which must have a value equal or greater than 0x80 (i.e. set MSB).

In case these rules are not satisfied this function returns Nothing.

NB: As this encoding matches the internal representation the resulting OBJECT_IDENTIFIER merely newtype-wraps the input argument on success.

Since: 0.1.2

Convenience helpers

class IsWellFormedOid t where Source #

Typeclass for isWellFormedOid operation

Since: 0.1.2

Methods

isWellFormedOid :: t -> Bool Source #

Determine whether OID representation is deemed well-formed

An OID is considered well-formed iff it has

  • at least two arcs,
  • the first arc is one of 0, 1, or 2, and
  • if the first arc is not 2, the second arc value is within the range [0 .. 39].

Additionally, for string types the IETF-style ASCII dot notation with normalized (i.e. without redundant leading zeros) decimal numbers is expected (e.g. 1.23.456.7.890) as expressed by the numericoid ABNF production shown below:

numericoid = number 1*( DOT number )
number  = DIGIT / ( LDIGIT 1*DIGIT )
DIGIT   = %x30 / LDIGIT       ; "0"-"9"
LDIGIT  = %x31-39             ; "1"-"9"

Since: 0.1.2

Instances

Instances details
IsWellFormedOid Text Source # 
Instance details

Defined in LDAPv3.OID

IsWellFormedOid Text Source # 
Instance details

Defined in LDAPv3.OID

IsWellFormedOid ShortText Source # 
Instance details

Defined in LDAPv3.OID

Methods

isWellFormedOid :: ShortText -> Bool Source #

IsWellFormedOid OBJECT_IDENTIFIER Source #

Trivial instance as OBJECT_IDENTIFIER values are always well-formed by construction

Instance details

Defined in LDAPv3.OID

IsWellFormedOid OID Source # 
Instance details

Defined in LDAPv3.OID