11-28-2016 10:16 AM
I'm trying to create an action which accesses LDAP.
If I define the action bean in /extension/subsystems/Synchronization/ldap/ldap1/my-ldap-context.xml then I would normally expect to be able to access it using org.alfresco.repo.management.subsystems.SubsystemProxyFactory but that doesn't work for the Authentication subsystem.
Cannot convert value of type [org.alfresco.repo.management.subsystems.DefaultChildApplicationContextManager] to required type [org.alfresco.repo.management.subsystems.ApplicationContextFactory] for property 'sourceApplicationContextFactory':
If I pull the bean definitions (<import resource="classpath:alfresco/subsystems/Authentication/common-ldap-context.xml"/>) into my context/actions-context.xml then chaos ensues
What does work is to redefine ldapInitialDirContextFactory in the context file but that's not ideal.
Any thoughts?
Thanks.
11-28-2016 11:32 AM
You don't need to define your action bean in /extension/subsystems/Synchronization/ldap/ldap1/my-ldap-context.xml or import common-ldap-context.xml. You can define your action in regular way.
You can try to do it like this:
1.Make your action implements spring InitializingBean and In your action reference interface ChildApplicationContextManager
public class YourAction implements InitializingBean{
private ChildApplicationContextManager authenticationContextManager;
private LDAPInitialDirContextFactory ldapInitialDirContextFactory;
public void setAuthenticationContextManager(ChildApplicationContextManager authenticationContextManager) {
this.authenticationContextManager = authenticationContextManager;
}
@Override
public void afterPropertiesSet() throws Exception {
for(String contextName : authenticationContextManager.getInstanceIds()){
ApplicationContext ctx = authenticationContextManager.getApplicationContext(contextName);
try{
ldapInitialDirContextFactory = LDAPInitialDirContextFactory)
ctx.getBean(LDAPInitialDirContextFactory.class);
} catch(NoSuchBeanDefinitionException e) {}
}
}
}
2.And in your action spring file inject Authentication bean to your action authenticationContextManager property
<property name="authenticationContextManager" ref="Authentication" />
3. override afterPropertiesSet method of your action and get ldapInitialDirContextFactory bean like previous code.
11-28-2016 11:32 AM
You don't need to define your action bean in /extension/subsystems/Synchronization/ldap/ldap1/my-ldap-context.xml or import common-ldap-context.xml. You can define your action in regular way.
You can try to do it like this:
1.Make your action implements spring InitializingBean and In your action reference interface ChildApplicationContextManager
public class YourAction implements InitializingBean{
private ChildApplicationContextManager authenticationContextManager;
private LDAPInitialDirContextFactory ldapInitialDirContextFactory;
public void setAuthenticationContextManager(ChildApplicationContextManager authenticationContextManager) {
this.authenticationContextManager = authenticationContextManager;
}
@Override
public void afterPropertiesSet() throws Exception {
for(String contextName : authenticationContextManager.getInstanceIds()){
ApplicationContext ctx = authenticationContextManager.getApplicationContext(contextName);
try{
ldapInitialDirContextFactory = LDAPInitialDirContextFactory)
ctx.getBean(LDAPInitialDirContextFactory.class);
} catch(NoSuchBeanDefinitionException e) {}
}
}
}
2.And in your action spring file inject Authentication bean to your action authenticationContextManager property
<property name="authenticationContextManager" ref="Authentication" />
3. override afterPropertiesSet method of your action and get ldapInitialDirContextFactory bean like previous code.
12-06-2018 05:17 AM
I see this has had quite a lot of views recently so thought it might be helpful to add a link to the implementation I ended up with:
cggh-alfresco-extensions/auth-platform-jar at master · cggh/cggh-alfresco-extensions · GitHub
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.