LdapUtils { public static NamingException convertLdapException(javax.naming.NamingException ex) { Assert.notNull(ex, "NamingException must not be null"); if (javax.naming.directory.AttributeInUseException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.AttributeInUseException( (javax.naming.directory.AttributeInUseException) ex); } if (javax.naming.directory.AttributeModificationException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.AttributeModificationException( (javax.naming.directory.AttributeModificationException) ex); } if (javax.naming.CannotProceedException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.CannotProceedException((javax.naming.CannotProceedException) ex); } if (javax.naming.CommunicationException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.CommunicationException((javax.naming.CommunicationException) ex); } if (javax.naming.ConfigurationException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.ConfigurationException((javax.naming.ConfigurationException) ex); } if (javax.naming.ContextNotEmptyException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.ContextNotEmptyException((javax.naming.ContextNotEmptyException) ex); } if (javax.naming.InsufficientResourcesException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.InsufficientResourcesException( (javax.naming.InsufficientResourcesException) ex); } if (javax.naming.InterruptedNamingException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.InterruptedNamingException((javax.naming.InterruptedNamingException) ex); } if (javax.naming.directory.InvalidAttributeIdentifierException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.InvalidAttributeIdentifierException( (javax.naming.directory.InvalidAttributeIdentifierException) ex); } if (javax.naming.directory.InvalidAttributesException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.InvalidAttributesException( (javax.naming.directory.InvalidAttributesException) ex); } if (javax.naming.directory.InvalidAttributeValueException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.InvalidAttributeValueException( (javax.naming.directory.InvalidAttributeValueException) ex); } if (javax.naming.InvalidNameException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.InvalidNameException((javax.naming.InvalidNameException) ex); } if (javax.naming.directory.InvalidSearchControlsException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.InvalidSearchControlsException( (javax.naming.directory.InvalidSearchControlsException) ex); } if (javax.naming.directory.InvalidSearchFilterException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.InvalidSearchFilterException( (javax.naming.directory.InvalidSearchFilterException) ex); } if (javax.naming.ldap.LdapReferralException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.LdapReferralException((javax.naming.ldap.LdapReferralException) ex); } if (javax.naming.ReferralException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.ReferralException((javax.naming.ReferralException) ex); } if (javax.naming.SizeLimitExceededException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.SizeLimitExceededException((javax.naming.SizeLimitExceededException) ex); } if (javax.naming.TimeLimitExceededException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.TimeLimitExceededException((javax.naming.TimeLimitExceededException) ex); } if (javax.naming.LimitExceededException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.LimitExceededException((javax.naming.LimitExceededException) ex); } if (javax.naming.LinkLoopException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.LinkLoopException((javax.naming.LinkLoopException) ex); } if (javax.naming.MalformedLinkException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.MalformedLinkException((javax.naming.MalformedLinkException) ex); } if (javax.naming.LinkException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.LinkException((javax.naming.LinkException) ex); } if (javax.naming.NameAlreadyBoundException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.NameAlreadyBoundException((javax.naming.NameAlreadyBoundException) ex); } if (javax.naming.NameNotFoundException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.NameNotFoundException((javax.naming.NameNotFoundException) ex); } if (javax.naming.NoPermissionException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.NoPermissionException((javax.naming.NoPermissionException) ex); } if (javax.naming.AuthenticationException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.AuthenticationException((javax.naming.AuthenticationException) ex); } if (javax.naming.AuthenticationNotSupportedException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.AuthenticationNotSupportedException( (javax.naming.AuthenticationNotSupportedException) ex); } if (javax.naming.NamingSecurityException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.NamingSecurityException((javax.naming.NamingSecurityException) ex); } if (javax.naming.NoInitialContextException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.NoInitialContextException((javax.naming.NoInitialContextException) ex); } if (javax.naming.directory.NoSuchAttributeException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.NoSuchAttributeException( (javax.naming.directory.NoSuchAttributeException) ex); } if (javax.naming.NotContextException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.NotContextException((javax.naming.NotContextException) ex); } if (javax.naming.OperationNotSupportedException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.OperationNotSupportedException( (javax.naming.OperationNotSupportedException) ex); } if (javax.naming.PartialResultException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.PartialResultException((javax.naming.PartialResultException) ex); } if (javax.naming.directory.SchemaViolationException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.SchemaViolationException( (javax.naming.directory.SchemaViolationException) ex); } if (javax.naming.ServiceUnavailableException.class.isAssignableFrom(ex.getClass())) { return new org.springframework.ldap.ServiceUnavailableException( (javax.naming.ServiceUnavailableException) ex); } return new org.springframework.ldap.UncategorizedLdapException(ex); } private  LdapUtils(); static void closeContext(DirContext context); static NamingException convertLdapException(javax.naming.NamingException ex); static Class getActualTargetClass(DirContext context); static void collectAttributeValues(Attributes attributes, String name, Collection<Object> collection); static void collectAttributeValues(
            Attributes attributes, String name, Collection<T> collection, Class<T> clazz); static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler); static String convertCompositeNameToString(
			CompositeName compositeName); static LdapName newLdapName(Name name); static LdapName newLdapName(String distinguishedName); static LdapName removeFirst(Name dn, Name pathToRemove); static LdapName prepend(Name dn, Name pathToPrepend); static LdapName emptyLdapName(); static Rdn getRdn(Name name, String key); static Object getValue(Name name, String key); static Object getValue(Name name, int index); static String getStringValue(Name name, int index); static String getStringValue(Name name, String key); static String convertBinarySidToString(byte[] sid); static byte[] convertStringSidToBinary(String string);  }
@Test public void testConvertLdapExceptions() { assertThat( LdapUtils.convertLdapException( new javax.naming.directory.AttributeInUseException()).getClass()) .isEqualTo(org.springframework.ldap.AttributeInUseException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.directory.AttributeModificationException()) .getClass()).isEqualTo( org.springframework.ldap.AttributeModificationException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.CannotProceedException()) .getClass()).isEqualTo( org.springframework.ldap.CannotProceedException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.CommunicationException()) .getClass()).isEqualTo( org.springframework.ldap.CommunicationException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.ConfigurationException()) .getClass()).isEqualTo( org.springframework.ldap.ConfigurationException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.ContextNotEmptyException()).getClass()) .isEqualTo(org.springframework.ldap.ContextNotEmptyException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.InsufficientResourcesException()).getClass()) .isEqualTo(org.springframework.ldap.InsufficientResourcesException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.InterruptedNamingException()).getClass()) .isEqualTo(org.springframework.ldap.InterruptedNamingException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.directory.InvalidAttributeIdentifierException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidAttributeIdentifierException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.directory.InvalidAttributesException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidAttributesException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.directory.InvalidAttributeValueException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidAttributeValueException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.InvalidNameException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidNameException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.directory.InvalidSearchControlsException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidSearchControlsException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.directory.InvalidSearchFilterException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidSearchFilterException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.SizeLimitExceededException()).getClass()) .isEqualTo(org.springframework.ldap.SizeLimitExceededException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.TimeLimitExceededException()).getClass()) .isEqualTo(org.springframework.ldap.TimeLimitExceededException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.LimitExceededException()) .getClass()).isEqualTo( org.springframework.ldap.LimitExceededException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.LinkLoopException()) .getClass()).isEqualTo( org.springframework.ldap.LinkLoopException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.MalformedLinkException()) .getClass()).isEqualTo( org.springframework.ldap.MalformedLinkException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.LinkException()) .getClass()).isEqualTo( org.springframework.ldap.LinkException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.NameAlreadyBoundException()).getClass()) .isEqualTo(org.springframework.ldap.NameAlreadyBoundException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.NameNotFoundException()) .getClass()).isEqualTo( org.springframework.ldap.NameNotFoundException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.NoPermissionException()) .getClass()).isEqualTo( org.springframework.ldap.NoPermissionException.class); assertThat( LdapUtils .convertLdapException(new javax.naming.AuthenticationException()) .getClass()).isEqualTo( org.springframework.ldap.AuthenticationException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.AuthenticationNotSupportedException()) .getClass()).isEqualTo( org.springframework.ldap.AuthenticationNotSupportedException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.NoInitialContextException()).getClass()) .isEqualTo(org.springframework.ldap.NoInitialContextException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.directory.NoSuchAttributeException()).getClass()) .isEqualTo(org.springframework.ldap.NoSuchAttributeException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.NotContextException()) .getClass()).isEqualTo( org.springframework.ldap.NotContextException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.OperationNotSupportedException()).getClass()) .isEqualTo(org.springframework.ldap.OperationNotSupportedException.class); assertThat( LdapUtils.convertLdapException(new javax.naming.PartialResultException()) .getClass()).isEqualTo( org.springframework.ldap.PartialResultException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.directory.SchemaViolationException()).getClass()) .isEqualTo(org.springframework.ldap.SchemaViolationException.class); assertThat( LdapUtils.convertLdapException( new javax.naming.ServiceUnavailableException()).getClass()) .isEqualTo(org.springframework.ldap.ServiceUnavailableException.class); assertThat( LdapUtils.convertLdapException(new MockAttributeInUseException()) .getClass()).isEqualTo( org.springframework.ldap.AttributeInUseException.class); assertThat( LdapUtils.convertLdapException(new MockAttributeModificationException()) .getClass()).isEqualTo( org.springframework.ldap.AttributeModificationException.class); assertThat( LdapUtils.convertLdapException(new MockCannotProceedException()) .getClass()).isEqualTo( org.springframework.ldap.CannotProceedException.class); assertThat( LdapUtils.convertLdapException(new MockCommunicationException()) .getClass()).isEqualTo( org.springframework.ldap.CommunicationException.class); assertThat( LdapUtils.convertLdapException(new MockConfigurationException()) .getClass()).isEqualTo( org.springframework.ldap.ConfigurationException.class); assertThat( LdapUtils.convertLdapException(new MockContextNotEmptyException()) .getClass()).isEqualTo( org.springframework.ldap.ContextNotEmptyException.class); assertThat( LdapUtils.convertLdapException(new MockInsufficientResourcesException()) .getClass()).isEqualTo( org.springframework.ldap.InsufficientResourcesException.class); assertThat( LdapUtils.convertLdapException(new MockInterruptedNamingException()) .getClass()).isEqualTo( org.springframework.ldap.InterruptedNamingException.class); assertThat( LdapUtils.convertLdapException( new MockInvalidAttributeIdentifierException()).getClass()) .isEqualTo( org.springframework.ldap.InvalidAttributeIdentifierException.class); assertThat( LdapUtils.convertLdapException(new MockInvalidAttributesException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidAttributesException.class); assertThat( LdapUtils.convertLdapException(new MockInvalidAttributeValueException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidAttributeValueException.class); assertThat( LdapUtils.convertLdapException(new MockInvalidNameException()).getClass()) .isEqualTo(org.springframework.ldap.InvalidNameException.class); assertThat( LdapUtils.convertLdapException(new MockInvalidSearchControlsException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidSearchControlsException.class); assertThat( LdapUtils.convertLdapException(new MockInvalidSearchFilterException()) .getClass()).isEqualTo( org.springframework.ldap.InvalidSearchFilterException.class); assertThat( LdapUtils.convertLdapException(new MockSizeLimitExceededException()) .getClass()).isEqualTo( org.springframework.ldap.SizeLimitExceededException.class); assertThat( LdapUtils.convertLdapException(new MockTimeLimitExceededException()) .getClass()).isEqualTo( org.springframework.ldap.TimeLimitExceededException.class); assertThat( LdapUtils.convertLdapException(new MockLimitExceededException()) .getClass()).isEqualTo( org.springframework.ldap.LimitExceededException.class); assertThat(LdapUtils.convertLdapException(new MockLinkLoopException()).getClass()) .isEqualTo(org.springframework.ldap.LinkLoopException.class); assertThat( LdapUtils.convertLdapException(new MockMalformedLinkException()) .getClass()).isEqualTo( org.springframework.ldap.MalformedLinkException.class); assertThat(LdapUtils.convertLdapException(new MockLinkException()).getClass()) .isEqualTo(org.springframework.ldap.LinkException.class); assertThat( LdapUtils.convertLdapException(new MockNameAlreadyBoundException()) .getClass()).isEqualTo( org.springframework.ldap.NameAlreadyBoundException.class); assertThat( LdapUtils.convertLdapException(new MockNameNotFoundException()) .getClass()).isEqualTo( org.springframework.ldap.NameNotFoundException.class); assertThat( LdapUtils.convertLdapException(new MockNoPermissionException()) .getClass()).isEqualTo( org.springframework.ldap.NoPermissionException.class); assertThat( LdapUtils.convertLdapException(new MockAuthenticationException()) .getClass()).isEqualTo( org.springframework.ldap.AuthenticationException.class); assertThat( LdapUtils.convertLdapException( new MockAuthenticationNotSupportedException()).getClass()) .isEqualTo( org.springframework.ldap.AuthenticationNotSupportedException.class); assertThat( LdapUtils.convertLdapException(new MockNoInitialContextException()) .getClass()).isEqualTo( org.springframework.ldap.NoInitialContextException.class); assertThat( LdapUtils.convertLdapException(new MockNoSuchAttributeException()) .getClass()).isEqualTo( org.springframework.ldap.NoSuchAttributeException.class); assertThat( LdapUtils.convertLdapException(new MockNotContextException()).getClass()) .isEqualTo(org.springframework.ldap.NotContextException.class); assertThat( LdapUtils.convertLdapException(new MockOperationNotSupportedException()) .getClass()).isEqualTo( org.springframework.ldap.OperationNotSupportedException.class); assertThat( LdapUtils.convertLdapException(new MockPartialResultException()) .getClass()).isEqualTo( org.springframework.ldap.PartialResultException.class); assertThat( LdapUtils.convertLdapException(new MockSchemaViolationException()) .getClass()).isEqualTo( org.springframework.ldap.SchemaViolationException.class); assertThat( LdapUtils.convertLdapException(new MockServiceUnavailableException()) .getClass()).isEqualTo( org.springframework.ldap.ServiceUnavailableException.class); }