Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Kumar <sunilk@mono-cvs.ximian.com>2004-03-03 10:58:54 +0300
committerSunil Kumar <sunilk@mono-cvs.ximian.com>2004-03-03 10:58:54 +0300
commite910781f72a1fe009e7dfb56477c909b4146f372 (patch)
treee736c2da8605e457add2d5878b7121e708d5bb24 /mcs/class/Novell.Directory.Ldap
parenta93a08de0cfa047eaab1e022be7ff8bd935701cd (diff)
Modified extensions to use register functionality provided in ExtResponseFactory
svn path=/trunk/mcs/; revision=23642
Diffstat (limited to 'mcs/class/Novell.Directory.Ldap')
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs16
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs15
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs16
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs16
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs18
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs16
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs108
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources4
-rwxr-xr-xmcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs39
9 files changed, 180 insertions, 68 deletions
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs
index 195f7524978..68bd376e7bb 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetBindDNRequest.cs
@@ -56,6 +56,22 @@ namespace Novell.Directory.Ldap.Extensions
/// </summary>
public class GetBindDNRequest:LdapExtendedOperation
{
+
+ static GetBindDNRequest()
+ {
+ /*
+ * Register the extendedresponse class which is returned by the
+ * server in response to a ListReplicasRequest
+ */
+ try
+ {
+ LdapExtendedResponse.register(ReplicationConstants.GET_IDENTITY_NAME_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetBindDNResponse"));
+ }
+ catch (System.Exception e)
+ {
+ System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
+ }
+ }
/// <summary> Constructs an extended operation object for retrieving the bind dn.
///
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs
index 1fbd6456e62..85d193e1da8 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetEffectivePrivilegesRequest.cs
@@ -61,6 +61,21 @@ namespace Novell.Directory.Ldap.Extensions
/// </summary>
public class GetEffectivePrivilegesRequest:LdapExtendedOperation
{
+ static GetEffectivePrivilegesRequest()
+ {
+ /*
+ * Register the extendedresponse class which is returned by the
+ * server in response to a ListReplicasRequest
+ */
+ try
+ {
+ LdapExtendedResponse.register(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetEffectivePrivilegesResponse"));
+ }
+ catch (System.Exception e)
+ {
+ System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
+ }
+ }
/// <summary> Constructs an extended operation object for checking effective rights.
///
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs
index 23c35619902..3abda121d47 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicaInfoRequest.cs
@@ -60,6 +60,22 @@ namespace Novell.Directory.Ldap.Extensions
public class GetReplicaInfoRequest:LdapExtendedOperation
{
+ static GetReplicaInfoRequest()
+ {
+ /*
+ * Register the extendedresponse class which is returned by the
+ * server in response to a ListReplicasRequest
+ */
+ try
+ {
+ LdapExtendedResponse.register(ReplicationConstants.GET_REPLICA_INFO_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetReplicaInfoResponse"));
+ }
+ catch (System.Exception e)
+ {
+ System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
+ }
+ }
+
/// <summary>
/// Constructs an extended operations object for reading replica information.
///
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs
index 487f52ac714..4a34342ebec 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/GetReplicationFilterRequest.cs
@@ -58,6 +58,22 @@ namespace Novell.Directory.Ldap.Extensions
public class GetReplicationFilterRequest:LdapExtendedOperation
{
+ static GetReplicationFilterRequest()
+ {
+ /*
+ * Register the extendedresponse class which is returned by the
+ * server in response to a ListReplicasRequest
+ */
+ try
+ {
+ LdapExtendedResponse.register(ReplicationConstants.GET_REPLICATION_FILTER_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.GetReplicationFilterResponse"));
+ }
+ catch (System.Exception e)
+ {
+ System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
+ }
+ }
+
/// <summary>
/// Constructs an extended operations object which contains the ber encoded
/// replication filter.
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs
index 1ec70df9ab2..fd6b005bfa8 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/ListReplicasRequest.cs
@@ -54,7 +54,22 @@ namespace Novell.Directory.Ldap.Extensions
/// </summary>
public class ListReplicasRequest:LdapExtendedOperation
{
-
+ static ListReplicasRequest()
+ {
+ /*
+ * Register the extendedresponse class which is returned by the
+ * server in response to a ListReplicasRequest
+ */
+ try
+ {
+ LdapExtendedResponse.register(ReplicationConstants.LIST_REPLICAS_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.ListReplicasResponse"));
+ }
+ catch (System.Exception e)
+ {
+ System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
+ }
+ }
+
/// <summary> Constructs an extended operation object for listing replicas.
///
/// </summary>
@@ -66,7 +81,6 @@ namespace Novell.Directory.Ldap.Extensions
/// </exception>
public ListReplicasRequest(System.String serverName):base(ReplicationConstants.LIST_REPLICAS_REQ, null)
{
-
try
{
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs
index 9fa0398434a..65274033a5a 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Extensions/PartitionEntryCountRequest.cs
@@ -59,6 +59,22 @@ namespace Novell.Directory.Ldap.Extensions
/// </summary>
public class PartitionEntryCountRequest:LdapExtendedOperation
{
+
+ static PartitionEntryCountRequest()
+ {
+ /*
+ * Register the extendedresponse class which is returned by the
+ * server in response to a ListReplicasRequest
+ */
+ try
+ {
+ LdapExtendedResponse.register(ReplicationConstants.NAMING_CONTEXT_COUNT_RES, System.Type.GetType("Novell.Directory.Ldap.Extensions.PartitionEntryCountResponse"));
+ }
+ catch (System.Exception e)
+ {
+ System.Console.Error.WriteLine("Could not register Extended Response -" + " Class not found");
+ }
+ }
/// <summary> Constructs an extended operation object for counting entries
/// in a naming context.
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs
index e3093df87e6..52f4a567e95 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Utilclass/ExtResponseFactory.cs
@@ -1,50 +1,22 @@
-/******************************************************************************
-* The MIT License
-* Copyright (c) 2003 Novell Inc. www.novell.com
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the Software), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*******************************************************************************/
-//
-// Novell.Directory.Ldap.Utilclass.ExtResponseFactory.cs
-//
-// Author:
-// Sunil Kumar (Sunilk@novell.com)
-//
-// (C) 2003 Novell, Inc (http://www.novell.com)
-//
using System;
using Novell.Directory.Ldap;
using Novell.Directory.Ldap.Extensions;
using Novell.Directory.Ldap.Rfc2251;
+
namespace Novell.Directory.Ldap.Utilclass
{
+
/// <summary>
/// Takes an LdapExtendedResponse and returns an object
/// (that implements the base class ParsedExtendedResponse)
/// based on the OID.
///
- /// You can then call methods defined in the child
+ /// <p>You can then call methods defined in the child
/// class to parse the contents of the response. The methods available
/// depend on the child class. All child classes inherit from the
- /// ParsedExtendedResponse.
+ /// ParsedExtendedResponse.</p>
///
/// </summary>
public class ExtResponseFactory
@@ -56,62 +28,68 @@ namespace Novell.Directory.Ldap.Utilclass
/// </summary>
/// <param name="inResponse"> The LdapExtendedReponse object as returned by the
/// extendedOperation method in the LdapConnection object.
- ///
/// </param>
/// <returns> An object of base class LdapExtendedResponse. The actual child
/// class of this returned object depends on the operation being
/// performed.
- ///
/// </returns>
- /// <exception> LdapException A general exception which includes an error message
- /// and an Ldap error code.
- /// </exception>
static public LdapExtendedResponse convertToExtendedResponse(RfcLdapMessage inResponse)
{
LdapExtendedResponse tempResponse = new LdapExtendedResponse(inResponse);
-
// Get the oid stored in the Extended response
System.String inOID = tempResponse.ID;
- if ((System.Object) inOID == null)
- return tempResponse;
- // Is this an OID we support, if yes then build the
- // detailed LdapExtendedResponse object
+ RespExtensionSet regExtResponses = LdapExtendedResponse.RegisteredResponses;
try
{
- if (inOID.Equals(ReplicationConstants.NAMING_CONTEXT_COUNT_RES))
- {
- return new PartitionEntryCountResponse(inResponse);
- }
- if (inOID.Equals(ReplicationConstants.GET_IDENTITY_NAME_RES))
+ System.Type extRespClass = regExtResponses.findResponseExtension(inOID);
+ if (extRespClass == null)
{
- return new GetBindDNResponse(inResponse);
- }
- if (inOID.Equals(ReplicationConstants.GET_EFFECTIVE_PRIVILEGES_RES))
- {
- return new GetEffectivePrivilegesResponse(inResponse);
- }
- if (inOID.Equals(ReplicationConstants.GET_REPLICA_INFO_RES))
- {
- return new GetReplicaInfoResponse(inResponse);
+ return tempResponse;
}
- if (inOID.Equals(ReplicationConstants.LIST_REPLICAS_RES))
+ System.Type[] argsClass = new System.Type[]{typeof(RfcLdapMessage)};
+ System.Object[] args = new System.Object[]{inResponse};
+ System.Exception ex;
+ try
{
- return new ListReplicasResponse(inResponse);
+ System.Reflection.ConstructorInfo extConstructor = extRespClass.GetConstructor(argsClass);
+ try
+ {
+ System.Object resp = null;
+ resp = extConstructor.Invoke(args);
+ return (LdapExtendedResponse) resp;
+ }
+ catch (System.UnauthorizedAccessException e)
+ {
+ ex = e;
+ }
+ catch (System.Reflection.TargetInvocationException e)
+ {
+ ex = e;
+ }
+ catch (System.Exception e)
+ {
+ // Could not create the ResponseControl object
+ // All possible exceptions are ignored. We fall through
+ // and create a default LdapControl object
+ ex = e;
+ }
}
- if (inOID.Equals(ReplicationConstants.GET_REPLICATION_FILTER_RES))
+ catch (System.MethodAccessException e)
{
- return new GetReplicationFilterResponse(inResponse);
+ // bad class was specified, fall through and return a
+ // default LdapExtendedResponse object
+ ex = e;
}
- else
- return tempResponse;
}
- catch (System.IO.IOException ioe)
+ catch (System.FieldAccessException e)
{
- throw new LdapException(ExceptionMessages.DECODING_ERROR, LdapException.DECODING_ERROR, (System.String) null);
}
+ // If we get here we did not have a registered extendedresponse
+ // for this oid. Return a default LdapExtendedResponse object.
+ return tempResponse;
}
}
-}
+} \ No newline at end of file
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources
index 11ed067bc81..c0d02f05bdf 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.dll.sources
@@ -1,7 +1,9 @@
Novell.Directory.Ldap/AssemblyInfo.cs
+Novell.Directory.Ldap/SupportClass.cs
Novell.Directory.Ldap.Utilclass/Base64.cs
Novell.Directory.Ldap.Utilclass/DN.cs
Novell.Directory.Ldap.Utilclass/RDN.cs
+Novell.Directory.Ldap.Utilclass/RespExtensionSet.cs
Novell.Directory.Ldap.Utilclass/BindProperties.cs
Novell.Directory.Ldap.Utilclass/ReferralInfo.cs
Novell.Directory.Ldap.Utilclass/ArrayEnumeration.cs
@@ -81,7 +83,6 @@ Novell.Directory.Ldap.Rfc2251/RfcLdapMessage.cs
Novell.Directory.Ldap.Rfc2251/RfcUnbindRequest.cs
Novell.Directory.Ldap.Rfc2251/RfcExtendedRequest.cs
Novell.Directory.Ldap.Rfc2251/RfcExtendedResponse.cs
-Novell.Directory.Ldap/SupportClass.cs
Novell.Directory.Ldap/LdapConnection.cs
Novell.Directory.Ldap/LdapAuthHandler.cs
Novell.Directory.Ldap/LdapBindHandler.cs
@@ -92,6 +93,7 @@ Novell.Directory.Ldap/LdapCompareAttrNames.cs
Novell.Directory.Ldap/LdapCompareRequest.cs
Novell.Directory.Ldap/LdapModification.cs
Novell.Directory.Ldap/LdapAddRequest.cs
+Novell.Directory.Ldap/LdapDSConstants.cs
Novell.Directory.Ldap/LdapResponseQueue.cs
Novell.Directory.Ldap/LdapDeleteRequest.cs
Novell.Directory.Ldap/LdapLocalException.cs
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs
index a69d2eef172..31de8529653 100755
--- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs
+++ b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap/LdapExtendedResponse.cs
@@ -32,6 +32,7 @@
using System;
using Novell.Directory.Ldap.Rfc2251;
using Novell.Directory.Ldap.Asn1;
+using RespExtensionSet = Novell.Directory.Ldap.Utilclass.RespExtensionSet;
namespace Novell.Directory.Ldap
{
@@ -61,6 +62,23 @@ namespace Novell.Directory.Ldap
}
}
+
+ static LdapExtendedResponse()
+ {
+ registeredResponses = new RespExtensionSet();
+ }
+
+ public static RespExtensionSet RegisteredResponses
+ {
+ /* package */
+
+ get
+ {
+ return registeredResponses;
+ }
+
+ }
+
/// <summary> Returns the value part of the response in raw bytes.
///
/// </summary>
@@ -79,6 +97,7 @@ namespace Novell.Directory.Ldap
}
}
+ private static RespExtensionSet registeredResponses;
/// <summary> Creates an LdapExtendedResponse object which encapsulates
/// a server response to an asynchronous extended operation request.
@@ -90,5 +109,25 @@ namespace Novell.Directory.Ldap
public LdapExtendedResponse(RfcLdapMessage message):base(message)
{
}
+
+ /// <summary> Registers a class to be instantiated on receipt of a extendedresponse
+ /// with the given OID.
+ ///
+ /// <p>Any previous registration for the OID is overridden. The
+ /// extendedResponseClass object MUST be an extension of
+ /// LDAPExtendedResponse. </p>
+ ///
+ /// </summary>
+ /// <param name="oid"> The object identifier of the control.
+ /// </param>
+ /// <param name="extendedResponseClass"> A class which can instantiate an
+ /// LDAPExtendedResponse.
+ /// </param>
+ public static void register(System.String oid, System.Type extendedResponseClass)
+ {
+ registeredResponses.registerResponseExtension(oid, extendedResponseClass);
+ return ;
+ }
+
}
}