Constructor<?>[] constructors = consumerClass.getConstructors(); if ( constructors.length != 1 ) { throw new AuthenticationFactoryException( BaseMessages.getString( PKG, "DefaultAuthenticationConsumerFactory.Constructor", getClass().getName(), consumerClass.getCanonicalName() ) ); Class<?>[] parameterTypes = constructor.getParameterTypes(); if ( parameterTypes.length != 1 ) { throw new AuthenticationFactoryException( BaseMessages.getString( PKG, "DefaultAuthenticationConsumerFactory.Constructor.Arg", getClass().getName(), consumerClass .getCanonicalName() ) ); throw new AuthenticationFactoryException( BaseMessages.getString( PKG, "DefaultAuthenticationConsumerFactory.Consume", consumerClass.getCanonicalName() ) );
public static AuthenticationManager getAuthenticationManager() { AuthenticationManager manager = new AuthenticationManager(); manager.registerAuthenticationProvider( new NoAuthenticationAuthenticationProvider() ); // TODO: Register providers from metastore for ( PluginInterface plugin : PluginRegistry.getInstance().getPlugins( AuthenticationConsumerPluginType.class ) ) { try { Object pluginMain = PluginRegistry.getInstance().loadClass( plugin ); if ( pluginMain instanceof AuthenticationConsumerType ) { Class<? extends AuthenticationConsumer<?, ?>> consumerClass = ( (AuthenticationConsumerType) pluginMain ).getConsumerClass(); manager.registerConsumerClass( consumerClass ); } else { throw new KettlePluginException( BaseMessages.getString( PKG, "AuthenticationPersistenceManager.NotConsumerType", pluginMain, AuthenticationConsumerType.class ) ); } } catch ( KettlePluginException e ) { log.logError( e.getMessage(), e ); } catch ( AuthenticationFactoryException e ) { log.logError( e.getMessage(), e ); } } return manager; }
public <ReturnType, CreateArgType, ConsumedType> void registerConsumerFactory( AuthenticationConsumerFactory<ReturnType, CreateArgType, ConsumedType> factory ) throws AuthenticationFactoryException { if ( !factory.getConsumedType().isInterface() && !AuthenticationProvider.class.isAssignableFrom( factory.getConsumedType() ) ) { throw new AuthenticationFactoryException( BaseMessages.getString( PKG, "AuthenticationManager.ConsumedTypeError", factory ) ); } Map<Class<?>, AuthenticationConsumerFactory<?, ?, ?>> createTypeMap = getRelevantConsumerFactoryMap( factory.getReturnType(), factory.getCreateArgType() ); synchronized ( createTypeMap ) { createTypeMap.put( factory.getConsumedType(), factory ); } }