Search in sources :

Example 11 with AuthenticationProvider

use of org.apache.qpid.server.model.AuthenticationProvider in project qpid-broker-j by apache.

the class RedirectingVirtualHostNodeTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    _broker = BrokerTestHelper.createBrokerMock();
    SystemConfig<?> systemConfig = (SystemConfig<?>) _broker.getParent();
    when(systemConfig.getObjectFactory()).thenReturn(new ConfiguredObjectFactoryImpl(mock(Model.class)));
    _taskExecutor = new CurrentThreadTaskExecutor();
    _taskExecutor.start();
    when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
    when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
    AuthenticationProvider dummyAuthProvider = mock(AuthenticationProvider.class);
    when(dummyAuthProvider.getName()).thenReturn("dummy");
    when(dummyAuthProvider.getId()).thenReturn(UUID.randomUUID());
    when(dummyAuthProvider.getMechanisms()).thenReturn(Arrays.asList("PLAIN"));
    when(_broker.getChildren(eq(AuthenticationProvider.class))).thenReturn(Collections.singleton(dummyAuthProvider));
    final Map<String, Object> attributes = new HashMap<>();
    attributes.put(Port.NAME, getTestName());
    attributes.put(Port.PORT, 0);
    attributes.put(Port.AUTHENTICATION_PROVIDER, "dummy");
    attributes.put(Port.TYPE, "AMQP");
    _port = (AmqpPort) _broker.getObjectFactory().create(Port.class, attributes, _broker);
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) HashMap(java.util.HashMap) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) ConfiguredObjectFactoryImpl(org.apache.qpid.server.model.ConfiguredObjectFactoryImpl)

Example 12 with AuthenticationProvider

use of org.apache.qpid.server.model.AuthenticationProvider in project qpid-broker-j by apache.

the class PlainPasswordDatabaseAuthenticationManagerTest method testRemoveUser.

public void testRemoveUser() {
    _passwordFile = TestFileUtils.createTempFile(this, ".user.password", "user:password");
    Map<String, Object> providerAttrs = new HashMap<>();
    providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.TYPE, PROVIDER_TYPE);
    providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.PATH, _passwordFile.getAbsolutePath());
    providerAttrs.put(PlainPasswordDatabaseAuthenticationManager.NAME, getTestName());
    AuthenticationProvider provider = _objectFactory.create(AuthenticationProvider.class, providerAttrs, _broker);
    assertThat(provider.getChildren(User.class).size(), is(equalTo(1)));
    User user = (User) provider.getChildByName(User.class, "user");
    user.delete();
    assertThat(provider.getChildren(User.class).size(), is(equalTo(0)));
}
Also used : User(org.apache.qpid.server.model.User) HashMap(java.util.HashMap) PasswordCredentialManagingAuthenticationProvider(org.apache.qpid.server.model.PasswordCredentialManagingAuthenticationProvider) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider)

Example 13 with AuthenticationProvider

use of org.apache.qpid.server.model.AuthenticationProvider in project qpid-broker-j by apache.

the class PlainPasswordFileAuthenticationManagerFactoryTest method testPlainInstanceCreated.

public void testPlainInstanceCreated() throws Exception {
    _configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE);
    _configuration.put("path", _emptyPasswordFile.getAbsolutePath());
    AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
    assertNotNull(manager);
    assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager);
    assertTrue(((PrincipalDatabaseAuthenticationManager) manager).getPrincipalDatabase() instanceof PlainPasswordFilePrincipalDatabase);
}
Also used : AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) PlainPasswordFilePrincipalDatabase(org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase)

Example 14 with AuthenticationProvider

use of org.apache.qpid.server.model.AuthenticationProvider in project qpid-broker-j by apache.

the class PlainPasswordFileAuthenticationManagerFactoryTest method testPasswordFileNotFound.

public void testPasswordFileNotFound() throws Exception {
    // delete the file
    _emptyPasswordFile.delete();
    _configuration.put(AuthenticationProvider.TYPE, PlainPasswordDatabaseAuthenticationManager.PROVIDER_TYPE);
    _configuration.put("path", _emptyPasswordFile.getAbsolutePath());
    AuthenticationProvider manager = _factory.create(AuthenticationProvider.class, _configuration, _broker);
    assertNotNull(manager);
    assertTrue(manager instanceof PrincipalDatabaseAuthenticationManager);
    assertTrue(((PrincipalDatabaseAuthenticationManager) manager).getPrincipalDatabase() instanceof PlainPasswordFilePrincipalDatabase);
}
Also used : AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) PlainPasswordFilePrincipalDatabase(org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase)

Aggregations

AuthenticationProvider (org.apache.qpid.server.model.AuthenticationProvider)14 HashMap (java.util.HashMap)8 PasswordCredentialManagingAuthenticationProvider (org.apache.qpid.server.model.PasswordCredentialManagingAuthenticationProvider)4 Broker (org.apache.qpid.server.model.Broker)3 SystemConfig (org.apache.qpid.server.model.SystemConfig)3 User (org.apache.qpid.server.model.User)3 SubjectCreator (org.apache.qpid.server.security.SubjectCreator)3 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)2 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 AuthenticatedPrincipal (org.apache.qpid.server.security.auth.AuthenticatedPrincipal)2 UsernamePrincipal (org.apache.qpid.server.security.auth.UsernamePrincipal)2 PlainPasswordFilePrincipalDatabase (org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase)2 File (java.io.File)1 InetSocketAddress (java.net.InetSocketAddress)1 Principal (java.security.Principal)1 X509Certificate (java.security.cert.X509Certificate)1 Subject (javax.security.auth.Subject)1 X500Principal (javax.security.auth.x500.X500Principal)1 SystemLauncher (org.apache.qpid.server.SystemLauncher)1