Search in sources :

Example 11 with VDBRepository

use of org.teiid.deployers.VDBRepository in project teiid by teiid.

the class TestSessionServiceImpl method testActiveVDBWithVersion.

@Test
public void testActiveVDBWithVersion() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
    Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
    ssi.setVDBRepository(repo);
    ssi.getActiveVDB("name", "1");
    Mockito.verify(repo, Mockito.times(1)).getLiveVDB("name", "1");
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) VDBRepository(org.teiid.deployers.VDBRepository) Test(org.junit.Test)

Example 12 with VDBRepository

use of org.teiid.deployers.VDBRepository in project teiid by teiid.

the class TestSessionServiceImpl method testSecurityDomain.

@Test
public void testSecurityDomain() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
    vdb.addProperty(SessionServiceImpl.SECURITY_DOMAIN_PROPERTY, "domain");
    Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
    ssi.setVDBRepository(repo);
    Properties properties = new Properties();
    properties.setProperty(TeiidURL.JDBC.VDB_NAME, "name.1");
    SessionMetadata s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x", new Credentials(new char[] { 'y' }), "z", properties);
    assertEquals("domain", s.getSecurityDomain());
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) VDBRepository(org.teiid.deployers.VDBRepository) Properties(java.util.Properties) Credentials(org.teiid.security.Credentials) Test(org.junit.Test)

Example 13 with VDBRepository

use of org.teiid.deployers.VDBRepository in project teiid by teiid.

the class TestSessionServiceImpl method testLegacySecurityDomain.

@Test
public void testLegacySecurityDomain() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
    Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
    ssi.setVDBRepository(repo);
    ssi.setSecurityDomain("sd");
    Properties properties = new Properties();
    properties.setProperty(TeiidURL.JDBC.VDB_NAME, "name.1");
    SessionMetadata s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
    assertEquals("sd", s.getSecurityDomain());
    s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x", new Credentials(new char[] { 'y' }), "z", properties);
    assertEquals("sd", s.getSecurityDomain());
    ssi.setAllowSecurityDomainQualifier(true);
    ssi.setSecurityDomain("sd");
    s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
    assertEquals("sd", s.getSecurityDomain());
    assertEquals("x", s.getUserName());
    ssi.setAllowSecurityDomainQualifier(false);
    s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
    assertEquals("sd", s.getSecurityDomain());
    assertEquals("x@sd", s.getUserName());
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) VDBRepository(org.teiid.deployers.VDBRepository) Properties(java.util.Properties) Credentials(org.teiid.security.Credentials) Test(org.junit.Test)

Example 14 with VDBRepository

use of org.teiid.deployers.VDBRepository in project teiid by teiid.

the class TestLogonImpl method testLogonAuthenticationType.

@Test
public void testLogonAuthenticationType() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setStatus(Status.ACTIVE);
    Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
    ssi.setVDBRepository(repo);
    ssi.setSecurityDomain("SC");
    // default transport - what Teiid has before TEIID-2863
    // this is transport default
    ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
    DQPWorkContext.setWorkContext(new DQPWorkContext());
    Properties p = buildProperties("fred", "name");
    // $NON-NLS-1$
    LogonImpl impl = new LogonImpl(ssi, "fakeCluster");
    LogonResult result = impl.logon(p);
    assertEquals("fred", result.getUserName());
    // if no preference then choose USERPASSWORD
    // this is transport default
    ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
    DQPWorkContext.setWorkContext(new DQPWorkContext());
    p = buildProperties("fred", "name");
    // $NON-NLS-1$
    impl = new LogonImpl(ssi, "fakeCluster");
    result = impl.logon(p);
    assertEquals("fred", result.getUserName());
    // if user name is set to "GSS", then the preference is set to "GSS"
    // this is transport default
    ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
    DQPWorkContext.setWorkContext(new DQPWorkContext());
    p = buildProperties("GSS", "name");
    // $NON-NLS-1$
    FakeGssLogonImpl fimpl = new FakeGssLogonImpl(ssi, "fakeCluster");
    fimpl.addToken("bytes".getBytes(), new Subject());
    p.put(ILogon.KRB5TOKEN, "bytes".getBytes());
    result = fimpl.logon(p);
    assertEquals("GSS", result.getUserName());
    // if the transport default defined as GSS, then preference is USERPASSWORD, additional challenge
    ssi.setAuthenticationType(AuthenticationType.GSS);
    DQPWorkContext.setWorkContext(new DQPWorkContext());
    p = buildProperties("fred", "name");
    // $NON-NLS-1$
    impl = new LogonImpl(ssi, "fakeCluster");
    result = impl.logon(p);
    assertEquals(AuthenticationType.GSS, result.getProperty("authType"));
}
Also used : DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) LogonResult(org.teiid.client.security.LogonResult) VDBRepository(org.teiid.deployers.VDBRepository) Properties(java.util.Properties) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Example 15 with VDBRepository

use of org.teiid.deployers.VDBRepository in project teiid by teiid.

the class TestLogonImpl method testLogonAuthenticationTypeByVDB.

@Test
public void testLogonAuthenticationTypeByVDB() throws Exception {
    VDBRepository repo = Mockito.mock(VDBRepository.class);
    ssi.setVDBRepository(repo);
    // when VDB value is is avavailble this will not be used
    ssi.setAuthenticationType(AuthenticationType.GSS);
    // default transport - what Teiid has before TEIID-2863
    addVdb(repo, "name", "SC", AuthenticationType.USERPASSWORD.name());
    DQPWorkContext.setWorkContext(new DQPWorkContext());
    Properties p = buildProperties("fred", "name");
    // $NON-NLS-1$
    LogonImpl impl = new LogonImpl(ssi, "fakeCluster");
    LogonResult result = impl.logon(p);
    assertEquals("fred", result.getUserName());
    // if no preference then choose USERPASSWORD
    VDBMetaData metadata = addVdb(repo, "name1", "SC", AuthenticationType.USERPASSWORD.name());
    metadata.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
    DQPWorkContext.setWorkContext(new DQPWorkContext());
    // $NON-NLS-1$
    impl = new LogonImpl(ssi, "fakeCluster");
    p = buildProperties("fred", "name1");
    result = impl.logon(p);
    assertEquals("fred", result.getUserName());
    p = buildProperties("GSS", "name1");
    // $NON-NLS-1$
    FakeGssLogonImpl fimpl = new FakeGssLogonImpl(ssi, "fakeCluster");
    fimpl.addToken("bytes".getBytes(), new Subject());
    p.put(ILogon.KRB5TOKEN, "bytes".getBytes());
    result = fimpl.logon(p);
    assertEquals("GSS", result.getUserName());
    // here preference is GSS
    try {
        p = buildProperties("GSS", "name");
        result = impl.logon(p);
        assertEquals("GSS", result.getUserName());
    } catch (LogonException e) {
    }
    // if the transport default defined as GSS, then preference is USERPASSWORD, additional challenge
    addVdb(repo, "name2", "SC", "GSS");
    DQPWorkContext.setWorkContext(new DQPWorkContext());
    // $NON-NLS-1$
    impl = new LogonImpl(ssi, "fakeCluster");
    p = buildProperties("fred", "name2");
    result = impl.logon(p);
    assertEquals(AuthenticationType.GSS, result.getProperty("authType"));
    // doesn't match gss pattern
    metadata.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
    DQPWorkContext.setWorkContext(new DQPWorkContext());
    // $NON-NLS-1$
    impl = new LogonImpl(ssi, "fakeCluster");
    p = buildProperties(null, "name1");
    result = impl.logon(p);
    assertEquals("anonymous", result.getUserName());
}
Also used : DQPWorkContext(org.teiid.dqp.internal.process.DQPWorkContext) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) LogonException(org.teiid.client.security.LogonException) LogonResult(org.teiid.client.security.LogonResult) VDBRepository(org.teiid.deployers.VDBRepository) Properties(java.util.Properties) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Aggregations

VDBRepository (org.teiid.deployers.VDBRepository)15 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)12 Test (org.junit.Test)11 Properties (java.util.Properties)5 Subject (javax.security.auth.Subject)2 OperationFailedException (org.jboss.as.controller.OperationFailedException)2 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)2 LogonResult (org.teiid.client.security.LogonResult)2 DQPWorkContext (org.teiid.dqp.internal.process.DQPWorkContext)2 Credentials (org.teiid.security.Credentials)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Environment (org.jboss.as.controller.access.Environment)1 ContextNames (org.jboss.as.naming.deployment.ContextNames)1 BinderService (org.jboss.as.naming.service.BinderService)1 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)1 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 ValueService (org.jboss.msc.service.ValueService)1 Before (org.junit.Before)1