diff options
author | Boris Kirzner <borisk@mono-cvs.ximian.com> | 2005-04-05 19:22:59 +0400 |
---|---|---|
committer | Boris Kirzner <borisk@mono-cvs.ximian.com> | 2005-04-05 19:22:59 +0400 |
commit | 3123437ec767d1ba498d1a9ec272b24d13712d64 (patch) | |
tree | f2fba70541f5d60194347b0860b94e12a0c10956 /mcs/class/Novell.Directory.Ldap | |
parent | d09d9b2dbff2c72958cb44753842e1f48e896850 (diff) |
Fix for : According to RFC 2251 newSuperior should be sent as context-specific 0 type rather than octet string.
RfcLdapSuperDN.cs : added new class that represents context-specific 0 type.
RfcModifyDNRequest.cs : constructor now receives RfcLdapSuperDN.
svn path=/trunk/mcs/; revision=42574
Diffstat (limited to 'mcs/class/Novell.Directory.Ldap')
-rw-r--r-- | mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs | 102 | ||||
-rwxr-xr-x | mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs | 15 |
2 files changed, 104 insertions, 13 deletions
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs new file mode 100644 index 00000000000..a9a80363aac --- /dev/null +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs @@ -0,0 +1,102 @@ +// +// Novell.Directory.Ldap.Rfc2251.RfcLdapSuperDN.cs +// +// Author: +// Boris Kirzner (borisk@mainsoft.com) +// + +using System; +using Novell.Directory.Ldap.Asn1; + +namespace Novell.Directory.Ldap.Rfc2251
+{
+ ///<summary>Represents an [0] LDAP DN OPTIONAL used as newSuperior attribute of
+ /// ModifyDNRequest (For more detail on this Syntax refer to rfc2251).
+ /// </summary>
+ public class RfcLdapSuperDN : Asn1Tagged
+ {
+ private sbyte[] content;
+
+ /// <summary>
+ /// ASN.1 [0] LDAP DN OPTIONAL tag definition.
+ /// </summary>
+ public static readonly int TAG = 0x00;
+
+ /// <summary> ID is added for Optimization.
+ /// Id needs only be one Value for every instance, thus we create it only once.
+ /// </summary>
+ protected static readonly Asn1Identifier ID = new Asn1Identifier(Asn1Identifier.CONTEXT, false, TAG);
+
+ /// <summary> Constructs an RfcLDAPSuperDN object from a String object.
+ /// </summary>
+ /// <param name="content"> A string value that will be contained in the this RfcLDAPSuperDN object </param>
+ public RfcLdapSuperDN(String s) : base(ID, new Asn1OctetString(s), false) //type is encoded IMPLICITLY
+ {
+ try {
+ System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8"); + byte[] ibytes = encoder.GetBytes(s); + sbyte[] sbytes=SupportClass.ToSByteArray(ibytes); + + this.content = sbytes;
+ }
+ catch(System.IO.IOException uee) {
+ throw new System.SystemException(uee.ToString());
+ }
+ }
+
+ /// <summary> Constructs an RfcLDAPSuperDN object from a byte array. </summary>
+ /// <param name="content"> A byte array representing the string that will be contained in the this RfcLDAPSuperDN object </param>
+ [CLSCompliantAttribute(false)]
+ public RfcLdapSuperDN(sbyte[] ba) : base(ID, new Asn1OctetString(ba), false) //type is encoded IMPLICITLY
+ {
+ this.content = ba;
+ }
+
+ /// <summary> Encodes the current instance into the + /// specified output stream using the specified encoder object. + /// + /// </summary> + /// <param name="enc">Encoder object to use when encoding self. + /// + /// </param> + /// <param name="out">The output stream onto which the encoded byte + /// stream is written. + /// </param> + public override void encode(Asn1Encoder enc, System.IO.Stream out_Renamed) + { + enc.encode(this, out_Renamed); + return ; + }
+
+ /// <summary> Returns the content of this RfcLdapSuperDN as a byte array.</summary> + [CLSCompliantAttribute(false)] + public sbyte[] byteValue() + { + return content; + } + + + /// <summary> Returns the content of this RfcLdapSuperDN as a String.</summary> + public System.String stringValue() + { + System.String s = null; + try { + System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("utf-8"); + char[] dchar = encoder.GetChars(SupportClass.ToByteArray(content)); + s = new String(dchar); + } + catch (System.IO.IOException uee) { + throw new System.SystemException(uee.ToString()); + } + return s; + } + + + /// <summary> Return a String representation of this RfcLdapSuperDN.</summary> + public override System.String ToString() + { + return base.ToString() + " " + stringValue(); + }
+
+ }
+}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs index 5d921f5b8fb..72d4ff9a4ba 100755 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs +++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs @@ -52,30 +52,19 @@ namespace Novell.Directory.Ldap.Rfc2251 //************************************************************************* // Constructors for ModifyDNRequest //************************************************************************* - - // according to RFC 2251 : - // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
- // entry LDAPDN,
- // newrdn RelativeLDAPDN,
- // deleteoldrdn BOOLEAN,
- // newSuperior [0] LDAPDN OPTIONAL
- // } - // i.e. newSuperior is a context-specific 0. - static readonly Asn1Identifier superiorId = new Asn1Identifier(Asn1Identifier.CONTEXT,false,0x0); - + /// <summary> </summary> public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN newrdn, Asn1Boolean deleteoldrdn):this(entry, newrdn, deleteoldrdn, null) { } /// <summary> </summary> - public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN newrdn, Asn1Boolean deleteoldrdn, RfcLdapDN newSuperior):base(4) + public RfcModifyDNRequest(RfcLdapDN entry, RfcRelativeLdapDN newrdn, Asn1Boolean deleteoldrdn, RfcLdapSuperDN newSuperior):base(4) { add(entry); add(newrdn); add(deleteoldrdn); if (newSuperior != null) { - newSuperior.setIdentifier(superiorId); add(newSuperior); } } |