public <ReturnType, ConsumedType> void registerConsumerClass( Class<? extends AuthenticationConsumer<? extends ReturnType, ? extends ConsumedType>> consumerClass ) throws AuthenticationFactoryException { registerConsumerFactory( new DefaultAuthenticationConsumerFactory( consumerClass ) ); }
@SuppressWarnings( { "rawtypes", "unchecked" } ) @Override public <ReturnType, CreateArgType, ConsumedType> AuthenticationPerformer<ReturnType, CreateArgType> create( AuthenticationProvider authenticationProvider, AuthenticationConsumerFactory<ReturnType, CreateArgType, ConsumedType> authenticationConsumerFactory ) { if ( authenticationConsumerFactory.getConsumedType().isInstance( authenticationProvider ) ) { return new DefaultAuthenticationPerformer( authenticationProvider, authenticationConsumerFactory ); } else if ( AuthenticationConsumerInvocationHandler.isCompatible( authenticationConsumerFactory.getConsumedType(), authenticationProvider ) ) { return new ClassloaderBridgingAuthenticationPerformer<ReturnType, CreateArgType, ConsumedType>( authenticationProvider, authenticationConsumerFactory ); } return null; } }
@Override public <ReturnType, CreateArgType, ConsumedType> AuthenticationPerformer<ReturnType, CreateArgType> create( AuthenticationProvider authenticationProvider, AuthenticationConsumerFactory<ReturnType, CreateArgType, ConsumedType> authenticationConsumer ) { if ( AuthenticationConsumerInvocationHandler.isCompatible( authenticationConsumer.getConsumedType(), authenticationProvider ) ) { return new ClassloaderBridgingAuthenticationPerformer<ReturnType, CreateArgType, ConsumedType>( authenticationProvider, authenticationConsumer ); } return null; } } );
@Test public void testDefaultAuthenticationConsumerFactorySucceedsWithConsumer() throws AuthenticationFactoryException { new DefaultAuthenticationConsumerFactory( DelegatingKerberosConsumer.class ); } }
@Test( expected = AuthenticationFactoryException.class ) public void testDefaultAuthenticationConsumerFactoryFailsWithMultipleConstructors() throws AuthenticationFactoryException { new DefaultAuthenticationConsumerFactory( TwoConstructorConsumer.class ); }
@Test( expected = AuthenticationFactoryException.class ) public void testDefaultAuthenticationConsumerFactoryFailsNoConsumeMethod() throws AuthenticationFactoryException { new DefaultAuthenticationConsumerFactory( NoConsumeConsumer.class ); }
@Test( expected = AuthenticationFactoryException.class ) public void testDefaultAuthenticationConsumerFactoryFailsWithWrongConstructorArgCount() throws AuthenticationFactoryException { new DefaultAuthenticationConsumerFactory( TwoConstructorArgConsumer.class ); }