/// <summary> /// Initializes a new instance of the <see cref="RfcMatchingRuleAssertion"/> class. /// Creates a MatchingRuleAssertion. /// The value null may be passed for an optional value that is not used. /// </summary> /// <param name="matchingRule">Optional matching rule.</param> /// <param name="type">Optional attribute description.</param> /// <param name="matchValue">The assertion value.</param> /// <param name="dnAttributes">Asn1Boolean value. (default false)</param> public RfcMatchingRuleAssertion( RfcLdapString matchingRule, RfcLdapString type, Asn1OctetString matchValue, Asn1Boolean dnAttributes = null) : base(4) { if (matchingRule != null) { Add(new Asn1Tagged(new Asn1Identifier(1), matchingRule, false)); } if (type != null) { Add(new Asn1Tagged(new Asn1Identifier(2), type, false)); } Add(new Asn1Tagged(new Asn1Identifier(3), matchValue, false)); // if dnAttributes if false, that is the default value and we must not // encode it. (See RFC 2251 5.1 number 4) if (dnAttributes != null && dnAttributes.BooleanValue()) { Add(new Asn1Tagged(new Asn1Identifier(4), dnAttributes, false)); } }
public RfcMatchingRuleAssertion( string matchingRule, string type, sbyte[] matchValue, Asn1Boolean attributes = null) : base(4) { if (matchingRule != null) { Add(new Asn1Tagged(new Asn1Identifier(1), new Asn1OctetString(matchingRule), false)); } if (type != null) { Add(new Asn1Tagged(new Asn1Identifier(2), new Asn1OctetString(type), false)); } Add(new Asn1Tagged(new Asn1Identifier(3), new Asn1OctetString(matchValue), false)); // if dnAttributes if false, that is the default value and we must not // encode it. (See RFC 2251 5.1 number 4) if (attributes?.BooleanValue() == true) { Add(new Asn1Tagged(new Asn1Identifier(4), attributes, false)); } }
/// <summary> /// BER Encode an Asn1Boolean directly into the specified output stream. /// </summary> /// <param name="b">The Asn1Boolean object to encode</param> /// <param name="stream">The stream.</param> public void Encode(Asn1Boolean b, Stream stream) { // Encode the id Encode(b.GetIdentifier(), stream); // Encode the length stream.WriteByte(0x01); // Encode the boolean content stream.WriteByte((byte)(b.BooleanValue() ? 0xff : 0x00)); }
/// <summary> /// BER Encode an Asn1Boolean directly into the specified output stream. /// </summary> /// <param name="b">The Asn1Boolean object to encode</param> /// <param name="stream">The stream.</param> public virtual void Encode(Asn1Boolean b, Stream stream) { /* Encode the id */ Encode(b.GetIdentifier(), stream); /* Encode the length */ stream.WriteByte(0x01); /* Encode the boolean content*/ stream.WriteByte((byte)(b.BooleanValue() ? (sbyte)Identity(0xff) : (sbyte)0x00)); }
/// <summary> /// Initializes a new instance of the <see cref="RfcControl"/> class. /// Note: criticality is only added if true, as per RFC 2251 sec 5.1 part /// (4): If a value of a type is its default value, it MUST be /// absent. /// </summary> /// <param name="controlType">Type of the control.</param> /// <param name="criticality">The criticality.</param> /// <param name="controlValue">The control value.</param> public RfcControl(RfcLdapOID controlType, Asn1Boolean criticality, Asn1OctetString controlValue) : base(3) { Add(controlType); if (criticality.BooleanValue()) { Add(criticality); } if (controlValue != null) { Add(controlValue); } }
/// <summary> /// Creates a MatchingRuleAssertion. /// The value null may be passed for an optional value that is not used. /// </summary> /// <param name="matchValue"> /// The assertion value. /// </param> /// <param name="matchingRule"> /// Optional matching rule. /// </param> /// <param name="type"> /// Optional attribute description. /// </param> /// <param name="dnAttributes"> /// Asn1Boolean value. (default false). /// </param> public RfcMatchingRuleAssertion(RfcMatchingRuleId matchingRule, RfcAttributeDescription type, RfcAssertionValue matchValue, Asn1Boolean dnAttributes) : base(4) { if (matchingRule != null) { Add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.Context, false, 1), matchingRule, false)); } if (type != null) { Add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.Context, false, 2), type, false)); } Add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.Context, false, 3), matchValue, false)); // if dnAttributes if false, that is the default value and we must not // encode it. (See RFC 2251 5.1 number 4) if (dnAttributes != null && dnAttributes.BooleanValue()) { Add(new Asn1Tagged(new Asn1Identifier(Asn1Identifier.Context, false, 4), dnAttributes, false)); } }
/// <summary> /// BER Encode an Asn1Boolean directly into the specified output stream. /// </summary> /// <param name="b">The Asn1Boolean object to encode.</param> /// <param name="stream">The stream.</param> public static void Encode(Asn1Boolean b, Stream stream) { Encode(b.GetIdentifier(), stream); stream.WriteByte(0x01); stream.WriteByte((byte)(b.BooleanValue() ? 0xff : 0x00)); }