This class extends the AbstractSet and Implements the Set so that it can be used to maintain a list of currently registered extended responses.
Inheritance: SupportClass.AbstractSetSupport
Example #1
0
        /// <summary> Used to Convert an RfcLdapMessage object to the appropriate
        /// LdapExtendedResponse object depending on the operation being performed.
        ///
        /// </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>

        static public LdapExtendedResponse convertToExtendedResponse(RfcLdapMessage inResponse)
        {
            LdapExtendedResponse tempResponse = new LdapExtendedResponse(inResponse);

            // Get the oid stored in the Extended response
            System.String inOID = tempResponse.ID;

            RespExtensionSet regExtResponses = LdapExtendedResponse.RegisteredResponses;

            try
            {
                System.Type extRespClass = regExtResponses.findResponseExtension(inOID);
                if (extRespClass == null)
                {
                    return(tempResponse);
                }
                System.Type[]    argsClass = new System.Type[] { typeof(RfcLdapMessage) };
                System.Object[]  args      = new System.Object[] { inResponse };
                System.Exception ex;
                try
                {
                    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;
                    }
                }
                catch (System.MethodAccessException e)
                {
                    // bad class was specified, fall through and return a
                    // default  LdapExtendedResponse object
                    ex = e;
                }
            }
            catch (System.FieldAccessException e)
            {
            }
            // If we get here we did not have a registered extendedresponse
            // for this oid.  Return a default LdapExtendedResponse object.
            return(tempResponse);
        }
Example #2
0
        /**
         * Used to Convert an RfcLDAPMessage object to the appropriate
         * LDAPIntermediateResponse object depending on the operation being performed.
         *
         * @param inResponse   The LDAPIntermediateResponse object as returned by the
         *                     extendedOperation method in the LDAPConnection object.
         * <br><br>
         * @return An object of base class LDAPIntermediateResponse.  The actual child
         *         class of this returned object depends on the operation being
         *         performed.
         *
         * @exception LDAPException A general exception which includes an error message
         *                          and an LDAP error code.
         */

        static public LdapIntermediateResponse convertToIntermediateResponse(RfcLdapMessage inResponse)
        //          throws LDAPException
        {
            LdapIntermediateResponse tempResponse = new LdapIntermediateResponse(inResponse);
            // Get the oid stored in the Extended response
            String inOID = tempResponse.getID();

            RespExtensionSet regExtResponses =
                LdapIntermediateResponse.getRegisteredResponses();

            try
            {
                Type extRespClass = regExtResponses.findResponseExtension(inOID);
                if (extRespClass == null)
                {
                    return(tempResponse);
                }

                Type[]    argsClass = new Type[] { typeof(RfcLdapMessage) };
                Object[]  args      = { inResponse };
                Exception ex;
                try
                {
                    ConstructorInfo extConstructor = extRespClass.GetConstructor(argsClass);

                    try
                    {
                        Object resp = null;
                        resp = extConstructor.Invoke(args);
                        return((LdapIntermediateResponse)resp);
                    }
                    catch (UnauthorizedAccessException e)
                    {
                        ex = e;
                    }
                    catch (TargetInvocationException e)
                    {
                        ex = e;
                    }
                }
                catch (MissingMethodException e)
                {
                    // bad class was specified, fall through and return a
                    // default  LDAPIntermediateResponse object
                    ex = e;
                }
            }
            catch (MissingFieldException)
            {
                // No match with the OID
                // Do nothing. Fall through and construct a default LDAPControl object.
            }
            // If we get here we did not have a registered extendedresponse
            // for this oid.  Return a default LDAPIntermediateResponse object.
            return(tempResponse);
        }