Search in sources :

Example 96 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData 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 97 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData 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 98 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData 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 99 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData 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)

Example 100 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestVDBRepository method testVDBRespositoryGetActive.

@Test
public void testVDBRespositoryGetActive() throws Exception {
    VDBRepository repo = new VDBRepository();
    CompositeVDB mock1 = Mockito.mock(CompositeVDB.class);
    VDBMetaData vdb = new VDBMetaData();
    vdb.setName("name");
    vdb.setVersion(1);
    vdb.setConnectionType(ConnectionType.NONE);
    Mockito.stub(mock1.getVDB()).toReturn(vdb);
    repo.getVdbRepo().put(new VDBKey("name", 1), mock1);
    CompositeVDB mock2 = Mockito.mock(CompositeVDB.class);
    VDBMetaData vdb2 = new VDBMetaData();
    vdb2.setName("name");
    vdb2.setVersion(2);
    vdb2.setConnectionType(ConnectionType.NONE);
    Mockito.stub(mock2.getVDB()).toReturn(vdb2);
    repo.getVdbRepo().put(new VDBKey("name", 2), mock2);
    VDBMetaData live = repo.getLiveVDB("name");
    assertEquals("2", live.getVersion());
}
Also used : VDBKey(org.teiid.vdb.runtime.VDBKey) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Test(org.junit.Test)

Aggregations

VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)121 Test (org.junit.Test)48 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)36 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 MetadataStore (org.teiid.metadata.MetadataStore)15 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)14 VDBRepository (org.teiid.deployers.VDBRepository)12 ArrayList (java.util.ArrayList)10 IOException (java.io.IOException)9 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)9 Properties (java.util.Properties)8 XMLStreamException (javax.xml.stream.XMLStreamException)8 VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)8 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)7 TeiidComponentException (org.teiid.core.TeiidComponentException)7 VDBKey (org.teiid.vdb.runtime.VDBKey)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)6 Schema (org.teiid.metadata.Schema)6 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)5