class AuthenticationManager {

  public <ReturnType, CreateArgType, ConsumedType> void registerConsumerFactory(
    IAuthenticationConsumerFactory<ReturnType, CreateArgType, ConsumedType> factory ) throws AuthenticationFactoryException {
    if ( !factory.getConsumedType().isInterface()
      && !IAuthenticationProvider.class.isAssignableFrom( factory.getConsumedType() ) ) {
      throw new AuthenticationFactoryException( BaseMessages.getString( PKG, "AuthenticationManager.ConsumedTypeError",
        factory ) );
    }

    Map<Class<?>, IAuthenticationConsumerFactory<?, ?, ?>> createTypeMap =
      getRelevantConsumerFactoryMap( factory.getReturnType(), factory.getCreateArgType() );
    synchronized ( createTypeMap ) {
      createTypeMap.put( factory.getConsumedType(), factory );
    }
  }

}