Search in sources :

Example 6 with Credentials

use of org.teiid.security.Credentials 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)

Aggregations

Credentials (org.teiid.security.Credentials)6 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)5 Properties (java.util.Properties)3 Subject (javax.security.auth.Subject)3 Test (org.junit.Test)3 SecurityDomainContext (org.jboss.as.security.plugins.SecurityDomainContext)2 AuthenticationManager (org.jboss.security.AuthenticationManager)2 SimplePrincipal (org.jboss.security.SimplePrincipal)2 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)2 VDBRepository (org.teiid.deployers.VDBRepository)2 Principal (java.security.Principal)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 LoginException (javax.security.auth.login.LoginException)1 GSSCredential (org.ietf.jgss.GSSCredential)1 JBossSecurityContext (org.jboss.security.plugins.JBossSecurityContext)1 InvalidSessionException (org.teiid.client.security.InvalidSessionException)1 LogonException (org.teiid.client.security.LogonException)1 LogonResult (org.teiid.client.security.LogonResult)1 SessionServiceException (org.teiid.dqp.service.SessionServiceException)1