@Test public void testPostProcessBeforeInitializationWithLdapPathAwareNoBasePathSet() throws Exception { final LdapContextSource expectedContextSource = new LdapContextSource(); String expectedPath = "dc=example, dc=com"; expectedContextSource.setBase(expectedPath); tested = new BaseLdapPathBeanPostProcessor() { BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() { return expectedContextSource; } }; Object result = tested.postProcessBeforeInitialization(ldapPathAwareMock, "someName"); verify(ldapPathAwareMock).setBaseLdapPath(new DistinguishedName(expectedPath)); assertThat(result).isSameAs(ldapPathAwareMock); }
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) { if(bean instanceof BaseLdapNameAware) { BaseLdapNameAware baseLdapNameAware = (BaseLdapNameAware) bean; if (basePath != null) { baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(ldapPathSource.getBaseLdapName())); } } else if (bean instanceof BaseLdapPathAware) { BaseLdapPathAware baseLdapPathAware = (BaseLdapPathAware) bean; if (basePath != null) { baseLdapPathAware.setBaseLdapPath(new DistinguishedName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapPathAware.setBaseLdapPath(ldapPathSource.getBaseLdapPath().immutableDistinguishedName()); } } return bean; }
BaseLdapPathBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware, Ordered { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { if(bean instanceof BaseLdapNameAware) { BaseLdapNameAware baseLdapNameAware = (BaseLdapNameAware) bean; if (basePath != null) { baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(ldapPathSource.getBaseLdapName())); } } else if (bean instanceof BaseLdapPathAware) { BaseLdapPathAware baseLdapPathAware = (BaseLdapPathAware) bean; if (basePath != null) { baseLdapPathAware.setBaseLdapPath(new DistinguishedName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapPathAware.setBaseLdapPath(ldapPathSource.getBaseLdapPath().immutableDistinguishedName()); } } return bean; } }
BaseLdapPathBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware, Ordered { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { if(bean instanceof BaseLdapNameAware) { BaseLdapNameAware baseLdapNameAware = (BaseLdapNameAware) bean; if (basePath != null) { baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(ldapPathSource.getBaseLdapName())); } } else if (bean instanceof BaseLdapPathAware) { BaseLdapPathAware baseLdapPathAware = (BaseLdapPathAware) bean; if (basePath != null) { baseLdapPathAware.setBaseLdapPath(new DistinguishedName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapPathAware.setBaseLdapPath(ldapPathSource.getBaseLdapPath().immutableDistinguishedName()); } } return bean; }  }
BaseLdapPathBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware, Ordered { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { if(bean instanceof BaseLdapNameAware) { BaseLdapNameAware baseLdapNameAware = (BaseLdapNameAware) bean; if (basePath != null) { baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(ldapPathSource.getBaseLdapName())); } } else if (bean instanceof BaseLdapPathAware) { BaseLdapPathAware baseLdapPathAware = (BaseLdapPathAware) bean; if (basePath != null) { baseLdapPathAware.setBaseLdapPath(new DistinguishedName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapPathAware.setBaseLdapPath(ldapPathSource.getBaseLdapPath().immutableDistinguishedName()); } } return bean; }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName); @Override void setApplicationContext(ApplicationContext applicationContext); void setBasePath(DistinguishedName basePath); void setBasePath(String basePath); void setBaseLdapPathSourceName(String contextSourceName); void setOrder(int order); int getOrder(); }
BaseLdapPathBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware, Ordered { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { if(bean instanceof BaseLdapNameAware) { BaseLdapNameAware baseLdapNameAware = (BaseLdapNameAware) bean; if (basePath != null) { baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapNameAware.setBaseLdapPath(LdapUtils.newLdapName(ldapPathSource.getBaseLdapName())); } } else if (bean instanceof BaseLdapPathAware) { BaseLdapPathAware baseLdapPathAware = (BaseLdapPathAware) bean; if (basePath != null) { baseLdapPathAware.setBaseLdapPath(new DistinguishedName(basePath)); } else { BaseLdapPathSource ldapPathSource = getBaseLdapPathSourceFromApplicationContext(); baseLdapPathAware.setBaseLdapPath(ldapPathSource.getBaseLdapPath().immutableDistinguishedName()); } } return bean; }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName); @Override void setApplicationContext(ApplicationContext applicationContext); void setBasePath(DistinguishedName basePath); void setBasePath(String basePath); void setBaseLdapPathSourceName(String contextSourceName); void setOrder(int order); int getOrder();  }