Author: borisk
Date: 2005-04-05 11:22:59 -0400 (Tue, 05 Apr 2005)
New Revision: 42574
Added:
trunk/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs
Modified:
trunk/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs
Log:
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.
Added:
trunk/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs
===================================================================
---
trunk/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs
2005-04-05 15:03:54 UTC (rev 42573)
+++
trunk/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcLdapSuperDN.cs
2005-04-05 15:22:59 UTC (rev 42574)
@@ -0,0 +1,102 @@
+//
+// Novell.Directory.Ldap.Rfc2251.RfcLdapSuperDN.cs
+//
+// Author:
+// Boris Kirzner ([EMAIL PROTECTED])
+//
+
+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();
+ }
+
+ }
+}
Modified:
trunk/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs
===================================================================
---
trunk/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs
2005-04-05 15:03:54 UTC (rev 42573)
+++
trunk/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Rfc2251/RfcModifyDNRequest.cs
2005-04-05 15:22:59 UTC (rev 42574)
@@ -52,30 +52,19 @@
//*************************************************************************
// 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);
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches