Copyright | © Herbert Valerio Riedel 2023 |
---|---|
License | GPL-2.0-or-later |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
LDAP OID Helpers
This module provides helpers for dealing with the representation of Object Identifiers (OID) in LDAP.
Since: 0.1.2
Synopsis
- type LDAPOID = OID
- newtype OID = OID (NonEmpty Natural)
- data OBJECT_IDENTIFIER
- object_identifier'toOID :: OBJECT_IDENTIFIER -> OID
- object_identifier'fromOID :: OID -> Maybe OBJECT_IDENTIFIER
- object_identifier'toBin :: OBJECT_IDENTIFIER -> ShortByteString
- object_identifier'fromBin :: ShortByteString -> Maybe OBJECT_IDENTIFIER
- class IsWellFormedOid t where
- isWellFormedOid :: t -> Bool
Textually encoded OIDs
Object identifier (RFC4511 Section 4.1.2)
LDAPOID ::= OCTET STRING -- Constrained to <numericoid> -- [RFC4512]
Since: 0.1.0
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
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
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 than0x80
(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
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
, or2
, 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
IsWellFormedOid Text Source # | |
Defined in LDAPv3.OID isWellFormedOid :: Text -> Bool Source # | |
IsWellFormedOid Text Source # | |
Defined in LDAPv3.OID isWellFormedOid :: Text -> Bool Source # | |
IsWellFormedOid ShortText Source # | |
Defined in LDAPv3.OID isWellFormedOid :: ShortText -> Bool Source # | |
IsWellFormedOid OBJECT_IDENTIFIER Source # | Trivial instance as |
Defined in LDAPv3.OID | |
IsWellFormedOid OID Source # | |
Defined in LDAPv3.OID isWellFormedOid :: OID -> Bool Source # |