Modified Comments to Support XML Documentation
[mono.git] / mcs / class / Novell.Directory.Ldap / Novell.Directory.Ldap.Utilclass / ExtResponseFactory.cs
1 /******************************************************************************
2 * The MIT License
3 * Copyright (c) 2003 Novell Inc.  www.novell.com
4
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:
11
12 * The above copyright notice and this permission notice shall be included in 
13 * all copies or substantial portions of the Software.
14
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
21 * SOFTWARE.
22 *******************************************************************************/
23 //
24 // Novell.Directory.Ldap.Utilclass.ExtResponseFactory.cs
25 //
26 // Author:
27 //   Sunil Kumar (Sunilk@novell.com)
28 //
29 // (C) 2003 Novell, Inc (http://www.novell.com)
30 //
31
32 using System;
33 using Novell.Directory.Ldap;
34 using Novell.Directory.Ldap.Extensions;
35 using Novell.Directory.Ldap.Rfc2251;
36
37 namespace Novell.Directory.Ldap.Utilclass
38 {
39         /// <summary> 
40         /// Takes an LdapExtendedResponse and returns an object
41         /// (that implements the base class ParsedExtendedResponse)
42         /// based on the OID.
43         /// 
44         /// You can then call methods defined in the child
45         /// class to parse the contents of the response.  The methods available
46         /// depend on the child class. All child classes inherit from the
47         /// ParsedExtendedResponse.
48         /// 
49         /// </summary>
50         public class ExtResponseFactory
51         {
52                 
53                 /// <summary> Used to Convert an RfcLdapMessage object to the appropriate
54                 /// LdapExtendedResponse object depending on the operation being performed.
55                 /// 
56                 /// </summary>
57                 /// <param name="inResponse">  The LdapExtendedReponse object as returned by the
58                 /// extendedOperation method in the LdapConnection object.
59                 /// 
60                 /// </param>
61                 /// <returns> An object of base class LdapExtendedResponse.  The actual child
62                 /// class of this returned object depends on the operation being
63                 /// performed.
64                 /// 
65                 /// </returns>
66                 /// <exception> LdapException A general exception which includes an error message
67                 /// and an Ldap error code.
68                 /// </exception>
69                 
70                 static public LdapExtendedResponse convertToExtendedResponse(RfcLdapMessage inResponse)
71                 {
72                         
73                         LdapExtendedResponse tempResponse = new LdapExtendedResponse(inResponse);
74                         
75                         // Get the oid stored in the Extended response
76                         System.String inOID = tempResponse.ID;
77                         
78                         if ((System.Object) inOID == null)
79                                 return tempResponse;
80                         // Is this an OID we support, if yes then build the
81                         // detailed LdapExtendedResponse object
82                         try
83                         {
84                                 if (inOID.Equals(ReplicationConstants.NAMING_CONTEXT_COUNT_RES))
85                                 {
86                                         return new PartitionEntryCountResponse(inResponse);
87                                 }
88                                 if (inOID.Equals(ReplicationConstants.GET_IDENTITY_NAME_RES))
89                                 {
90                                         return new GetBindDNResponse(inResponse);
91                                 }
92                                 if (inOID.Equals(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_RES))
93                                 {
94                                         return new GetEffectivePrivilegesResponse(inResponse);
95                                 }
96                                 if (inOID.Equals(ReplicationConstants.GET_REPLICA_INFO_RES))
97                                 {
98                                         return new GetReplicaInfoResponse(inResponse);
99                                 }
100                                 if (inOID.Equals(ReplicationConstants.LIST_REPLICAS_RES))
101                                 {
102                                         return new ListReplicasResponse(inResponse);
103                                 }
104                                 if (inOID.Equals(ReplicationConstants.GET_REPLICATION_FILTER_RES))
105                                 {
106                                         return new GetReplicationFilterResponse(inResponse);
107                                 }
108                                 else
109                                         return tempResponse;
110                         }
111                         catch (System.IO.IOException ioe)
112                         {
113                                 throw new LdapException(ExceptionMessages.DECODING_ERROR, LdapException.DECODING_ERROR, (System.String) null);
114                         }
115                 }
116         }
117 }