@Override public void unregisterContribution( Object contribution, String extensionPoint, ComponentInstance contributor) { if (extensionPoint.equals(EP_AUTHENTICATOR)) { AuthenticationPluginDescriptor descriptor = (AuthenticationPluginDescriptor) contribution; authenticatorsDescriptors.remove(descriptor.getName()); log.debug("unregistered AuthenticationPlugin: " + descriptor.getName()); } }
private void mergeDescriptors(AuthenticationPluginDescriptor newContrib) { AuthenticationPluginDescriptor oldDescriptor = authenticatorsDescriptors.get(newContrib.getName()); // Enable/Disable oldDescriptor.setEnabled(newContrib.getEnabled()); // Merge parameters Map<String, String> oldParameters = oldDescriptor.getParameters(); oldParameters.putAll(newContrib.getParameters()); oldDescriptor.setParameters(oldParameters); // override LoginLModule if (newContrib.getLoginModulePlugin() != null && newContrib.getLoginModulePlugin().length() > 0) { oldDescriptor.setLoginModulePlugin(newContrib.getLoginModulePlugin()); } oldDescriptor.setStateful(newContrib.getStateful()); if (newContrib.getClassName() != null) { oldDescriptor.setClassName(newContrib.getClassName()); } oldDescriptor.setNeedStartingURLSaving(newContrib.getNeedStartingURLSaving()); }
@Override public void registerContribution( Object contribution, String extensionPoint, ComponentInstance contributor) { if (extensionPoint.equals(EP_AUTHENTICATOR)) { AuthenticationPluginDescriptor descriptor = (AuthenticationPluginDescriptor) contribution; if (authenticatorsDescriptors.containsKey(descriptor.getName())) { mergeDescriptors(descriptor); log.debug("merged AuthenticationPluginDescriptor: " + descriptor.getName()); } else { authenticatorsDescriptors.put(descriptor.getName(), descriptor); log.debug("registered AuthenticationPluginDescriptor: " + descriptor.getName()); } // create the new instance AuthenticationPluginDescriptor actualDescriptor = authenticatorsDescriptors.get(descriptor.getName()); try { NuxeoAuthenticationPlugin authPlugin = actualDescriptor.getClassName().newInstance(); authPlugin.initPlugin(actualDescriptor.getParameters()); authenticators.put(actualDescriptor.getName(), authPlugin); } catch (InstantiationException e) { log.error( "Unable to create AuthPlugin for : " + actualDescriptor.getName() + "Error : " + e.getMessage(), e); } catch (IllegalAccessException e) { log.error( "Unable to create AuthPlugin for : " + actualDescriptor.getName() + "Error : " + e.getMessage(), e); } } else if (extensionPoint.equals(EP_CHAIN)) { AuthenticationChainDescriptor chainContrib = (AuthenticationChainDescriptor) contribution; log.debug("New authentication chain powered by " + contributor.getName()); authChain.clear(); authChain.addAll(chainContrib.getPluginsNames()); } else if (extensionPoint.equals(EP_OPENURL)) { OpenUrlDescriptor openUrlContrib = (OpenUrlDescriptor) contribution; openUrls.add(openUrlContrib); } else if (extensionPoint.equals(EP_STARTURL)) { StartURLPatternDescriptor startupURLContrib = (StartURLPatternDescriptor) contribution; startupURLs.addAll(startupURLContrib.getStartURLPatterns()); } else if (extensionPoint.equals(EP_PROPAGATOR)) { AuthenticationPropagatorDescriptor propagationContrib = (AuthenticationPropagatorDescriptor) contribution; // create the new instance try { propagator = propagationContrib.getClassName().newInstance(); } catch (InstantiationException e) { log.error("Unable to create propagator", e); } catch (IllegalAccessException e) { log.error("Unable to create propagator", e); } } else if (extensionPoint.equals(EP_CBFACTORY)) { CallbackHandlerFactoryDescriptor cbhfContrib = (CallbackHandlerFactoryDescriptor) contribution; // create the new instance try { cbhFactory = cbhfContrib.getClassName().newInstance(); } catch (InstantiationException e) { log.error("Unable to create callback handler factory", e); } catch (IllegalAccessException e) { log.error("Unable to create callback handler factory", e); } } else if (extensionPoint.equals(EP_SESSIONMANAGER)) { SessionManagerDescriptor smContrib = (SessionManagerDescriptor) contribution; if (smContrib.enabled) { try { NuxeoAuthenticationSessionManager sm = smContrib.getClassName().newInstance(); sessionManagers.put(smContrib.getName(), sm); } catch (Exception e) { log.error("Unable to create session manager", e); } } else { sessionManagers.remove(smContrib.getName()); } } else if (extensionPoint.equals(EP_SPECIFIC_CHAINS)) { SpecificAuthChainDescriptor desc = (SpecificAuthChainDescriptor) contribution; specificAuthChains.put(desc.name, desc); } else if (extensionPoint.equals(EP_PREFILTER)) { AuthPreFilterDescriptor desc = (AuthPreFilterDescriptor) contribution; if (preFiltersDesc == null) { preFiltersDesc = new HashMap<String, AuthPreFilterDescriptor>(); } preFiltersDesc.put(desc.getName(), desc); } else if (extensionPoint.equals(EP_LOGINSCREEN)) { LoginScreenConfig newConfig = (LoginScreenConfig) contribution; loginScreenConfig.merge(newConfig); } }