@SuppressWarnings( "unchecked" ) @Test public void testNoAuthProviderAndConsumer() throws AuthenticationConsumptionException, AuthenticationFactoryException { manager.registerConsumerClass( DelegatingNoAuthConsumer.class ); AuthenticationConsumer<Object, NoAuthenticationAuthenticationProvider> consumer = mock( AuthenticationConsumer.class ); manager.getAuthenticationPerformer( Object.class, AuthenticationConsumer.class, NoAuthenticationAuthenticationProvider.NO_AUTH_ID ).perform( consumer ); verify( consumer ).consume( noAuthenticationAuthenticationProvider ); }
@SuppressWarnings( { "rawtypes", "unchecked" } ) @Test public void testRegisterConsumerFactory() throws AuthenticationConsumptionException, AuthenticationFactoryException { AuthenticationConsumer<Object, KerberosAuthenticationProvider> authConsumer = mock( AuthenticationConsumer.class ); AuthenticationConsumerFactory<Object, AuthenticationConsumer, KerberosAuthenticationProvider> factory = mock( AuthenticationConsumerFactory.class ); when( factory.getReturnType() ).thenReturn( Object.class ); when( factory.getCreateArgType() ).thenReturn( AuthenticationConsumer.class ); when( factory.getConsumedType() ).thenReturn( KerberosAuthenticationProvider.class ); when( factory.create( authConsumer ) ).thenReturn( authConsumer ); KerberosAuthenticationProvider kerberosAuthenticationProvider = new KerberosAuthenticationProvider( "kerb", "kerb", true, "pass", true, "none" ); manager.registerAuthenticationProvider( kerberosAuthenticationProvider ); manager.registerConsumerFactory( factory ); manager.getAuthenticationPerformer( Object.class, AuthenticationConsumer.class, kerberosAuthenticationProvider.getId() ).perform( authConsumer ); verify( authConsumer ).consume( kerberosAuthenticationProvider ); }
@SuppressWarnings( "unchecked" ) @Test public void testUsernamePasswordProviderConsumer() throws AuthenticationConsumptionException, AuthenticationFactoryException { manager.registerConsumerClass( DelegatingNoAuthConsumer.class ); manager.registerConsumerClass( DelegatingUsernamePasswordConsumer.class ); UsernamePasswordAuthenticationProvider usernamePasswordAuthenticationProvider = new UsernamePasswordAuthenticationProvider( "upass", "u", "pass" ); manager.registerAuthenticationProvider( usernamePasswordAuthenticationProvider ); AuthenticationConsumer<Object, UsernamePasswordAuthenticationProvider> consumer = mock( AuthenticationConsumer.class ); manager.getAuthenticationPerformer( Object.class, AuthenticationConsumer.class, usernamePasswordAuthenticationProvider.getId() ).perform( consumer ); verify( consumer ).consume( usernamePasswordAuthenticationProvider ); }
@SuppressWarnings( "unchecked" ) @Test public void testKerberosProviderConsumer() throws AuthenticationConsumptionException, AuthenticationFactoryException { manager.registerConsumerClass( DelegatingNoAuthConsumer.class ); manager.registerConsumerClass( DelegatingUsernamePasswordConsumer.class ); manager.registerConsumerClass( DelegatingKerberosConsumer.class ); KerberosAuthenticationProvider kerberosAuthenticationProvider = new KerberosAuthenticationProvider( "kerb", "kerb", true, "pass", true, "none" ); manager.registerAuthenticationProvider( kerberosAuthenticationProvider ); AuthenticationConsumer<Object, KerberosAuthenticationProvider> consumer = mock( AuthenticationConsumer.class ); manager.getAuthenticationPerformer( Object.class, AuthenticationConsumer.class, kerberosAuthenticationProvider.getId() ).perform( consumer ); verify( consumer ).consume( kerberosAuthenticationProvider ); }
manager.getAuthenticationPerformer( Object.class, AuthenticationConsumer.class, kerberosAuthenticationProvider .getId() ); assertNotNull( performer );
new PropertyAuthenticationProviderParser( config.getConfigProperties(), manager ).process( PROVIDER_LIST ); AuthenticationPerformer<HadoopAuthorizationService, Properties> performer = manager.getAuthenticationPerformer( HadoopAuthorizationService.class, Properties.class, provider ); if ( performer == null ) { throw new RuntimeException( "Unable to find relevant provider for chosen authentication method (id of "