1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc. www.novell.com
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 *******************************************************************************/
24 // Novell.Directory.Ldap.Extensions.GetReplicationFilterResponse.cs
27 // Sunil Kumar (Sunilk@novell.com)
29 // (C) 2003 Novell, Inc (http://www.novell.com)
33 using Novell
.Directory
.Ldap
;
34 using Novell
.Directory
.Ldap
.Asn1
;
35 using Novell
.Directory
.Ldap
.Utilclass
;
36 using Novell
.Directory
.Ldap
.Rfc2251
;
38 namespace Novell
.Directory
.Ldap
.Extensions
41 /// <summary> This object represent the filter returned fom a GetReplicationFilterRequest.
43 /// An object in this class is generated from an ExtendedResponse object
44 /// using the ExtendedResponseFactory class.
46 /// The GetReplicationFilterResponse extension uses the following OID:
47 /// 2.16.840.1.113719.1.27.100.38
50 public class GetReplicationFilterResponse
:LdapExtendedResponse
52 /// <summary> Returns the replicationFilter as an array of classname-attribute name pairs
55 /// <returns> String array contining a two dimensional array of strings. The first
56 /// element of each array is the class name the others are the attribute names
58 virtual public System
.String
[][] ReplicationFilter
62 return returnedFilter
;
69 // Replication filter returned by the server goes here
70 internal System
.String
[][] returnedFilter
;
72 /// <summary> Constructs an object from the responseValue which contains the replication
75 /// The constructor parses the responseValue which has the following
78 /// SEQUENCE of SEQUENCE {
79 /// classname OCTET STRING
80 /// SEQUENCE of ATTRIBUTES
83 /// ATTRIBUTES:: OCTET STRING
86 /// <exception> IOException The responseValue could not be decoded.
88 public GetReplicationFilterResponse(RfcLdapMessage rfcMessage
):base(rfcMessage
)
91 if (ResultCode
!= LdapException
.SUCCESS
)
93 returnedFilter
= new System
.String
[0][];
94 for (int i
= 0; i
< 0; i
++)
96 returnedFilter
[i
] = new System
.String
[0];
101 // parse the contents of the reply
102 sbyte[] returnedValue
= this.Value
;
103 if (returnedValue
== null)
104 throw new System
.IO
.IOException("No returned value");
106 // Create a decoder object
107 LBERDecoder decoder
= new LBERDecoder();
109 throw new System
.IO
.IOException("Decoding error");
111 // We should get back a sequence
112 Asn1Sequence returnedSequence
= (Asn1Sequence
) decoder
.decode(returnedValue
);
114 if (returnedSequence
== null)
115 throw new System
.IO
.IOException("Decoding error");
117 // How many sequences in this list
118 int numberOfSequences
= returnedSequence
.size();
119 returnedFilter
= new System
.String
[numberOfSequences
][];
121 // Parse each returned sequence object
122 for (int classNumber
= 0; classNumber
< numberOfSequences
; classNumber
++)
125 // Get the next Asn1Sequence
126 Asn1Sequence asn1_innerSequence
= (Asn1Sequence
) returnedSequence
.get_Renamed(classNumber
);
127 if (asn1_innerSequence
== null)
128 throw new System
.IO
.IOException("Decoding error");
130 // Get the asn1 encoded classname
131 Asn1OctetString asn1_className
= (Asn1OctetString
) asn1_innerSequence
.get_Renamed(0);
132 if (asn1_className
== null)
135 // Get the attribute List
136 Asn1Sequence asn1_attributeList
= (Asn1Sequence
) asn1_innerSequence
.get_Renamed(1);
137 if (asn1_attributeList
== null)
138 throw new System
.IO
.IOException("Decoding error");
140 int numberOfAttributes
= asn1_attributeList
.size();
141 returnedFilter
[classNumber
] = new System
.String
[numberOfAttributes
+ 1];
144 returnedFilter
[classNumber
][0] = asn1_className
.stringValue();
145 if ((System
.Object
) returnedFilter
[classNumber
][0] == null)
146 throw new System
.IO
.IOException("Decoding error");
148 for (int attributeNumber
= 0; attributeNumber
< numberOfAttributes
; attributeNumber
++)
151 // Get the asn1 encoded attribute name
152 Asn1OctetString asn1_attributeName
= (Asn1OctetString
) asn1_attributeList
.get_Renamed(attributeNumber
);
153 if (asn1_attributeName
== null)
154 throw new System
.IO
.IOException("Decoding error");
156 // Get attributename string
157 returnedFilter
[classNumber
][attributeNumber
+ 1] = asn1_attributeName
.stringValue();
158 if ((System
.Object
) returnedFilter
[classNumber
][attributeNumber
+ 1] == null)
159 throw new System
.IO
.IOException("Decoding error");