File: RfcLdapSuperDN.cs

package info (click to toggle)
mono 4.6.2.7+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 778,148 kB
  • ctags: 914,052
  • sloc: cs: 5,779,509; xml: 2,773,713; ansic: 432,645; sh: 14,749; makefile: 12,361; perl: 2,488; python: 1,434; cpp: 849; asm: 531; sql: 95; sed: 16; php: 1
file content (102 lines) | stat: -rw-r--r-- 3,160 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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();
		}

	}
}