Search in sources :

Example 1 with VDB

use of org.teiid.adminapi.VDB in project teiid by teiid.

the class AdminUtil method waitForVDBLoad.

static boolean waitForVDBLoad(Admin admin, String vdbName, Object vdbVersion, int timeoutInSecs) throws AdminException {
    long waitUntil = System.currentTimeMillis() + timeoutInSecs * 1000;
    if (timeoutInSecs < 0) {
        waitUntil = Long.MAX_VALUE;
    }
    boolean first = true;
    do {
        if (!first) {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                break;
            }
        } else {
            first = false;
        }
        VDB vdb = admin.getVDB(vdbName, vdbVersion != null ? vdbVersion.toString() : null);
        if (vdb != null && vdb.getStatus() != Status.LOADING) {
            return true;
        }
    } while (System.currentTimeMillis() < waitUntil);
    return false;
}
Also used : VDB(org.teiid.adminapi.VDB)

Example 2 with VDB

use of org.teiid.adminapi.VDB in project teiid by teiid.

the class SessionServiceImpl method getAuthenticationType.

@Override
public AuthenticationType getAuthenticationType(String vdbName, String version, String userName) throws LogonException {
    if (userName == null) {
        userName = CoreConstants.DEFAULT_ANON_USERNAME;
    }
    if (vdbName != null) {
        VDB vdb = null;
        try {
            vdb = getActiveVDB(vdbName, version);
        } catch (SessionServiceException e) {
            throw new LogonException(e);
        }
        if (vdb != null) {
            String gssPattern = vdb.getPropertyValue(GSS_PATTERN_PROPERTY);
            if (gssPattern != null && Pattern.matches(gssPattern, userName)) {
                return AuthenticationType.GSS;
            }
            String passwordPattern = vdb.getPropertyValue(PASSWORD_PATTERN_PROPERTY);
            if (passwordPattern != null && Pattern.matches(passwordPattern, userName)) {
                return AuthenticationType.USERPASSWORD;
            }
            String typeProperty = vdb.getPropertyValue(AUTHENTICATION_TYPE_PROPERTY);
            if (typeProperty != null) {
                return AuthenticationType.valueOf(typeProperty);
            }
        }
    }
    return this.defaultAuthenticationType;
}
Also used : VDB(org.teiid.adminapi.VDB) LogonException(org.teiid.client.security.LogonException) SessionServiceException(org.teiid.dqp.service.SessionServiceException)

Example 3 with VDB

use of org.teiid.adminapi.VDB in project teiid by teiid.

the class ODBCServerRemoteImpl method setConnectionProperties.

public static void setConnectionProperties(ConnectionImpl conn) throws SQLException {
    SessionMetadata sm = ((LocalServerConnection) conn.getServerConnection()).getWorkContext().getSession();
    VDB vdb = sm.getVdb();
    Properties p = vdb.getProperties();
    setConnectionProperties(conn, p);
}
Also used : VDB(org.teiid.adminapi.VDB) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) Properties(java.util.Properties)

Example 4 with VDB

use of org.teiid.adminapi.VDB in project teiid by teiid.

the class IntegrationTestSOAPWebService method testVDBDeployment.

@Test
public void testVDBDeployment() throws Exception {
    Collection<?> vdbs = admin.getVDBs();
    assertTrue(vdbs.isEmpty());
    assertTrue(admin.getDataSourceTemplateNames().contains("webservice"));
    String raSource = "web-ds";
    assertFalse(admin.getDataSourceNames().contains(raSource));
    admin.deploy("addressing-service.war", new FileInputStream(UnitTestUtil.getTestDataFile("addressing-service.war")));
    Properties p = new Properties();
    p.setProperty("class-name", "org.teiid.resource.adapter.ws.WSManagedConnectionFactory");
    p.setProperty("EndPoint", "http://localhost:8080/jboss-jaxws-addressing/AddressingService");
    admin.createDataSource(raSource, "webservice", p);
    assertTrue(admin.getDataSourceNames().contains(raSource));
    admin.deploy("soapsvc-vdb.xml", new FileInputStream(UnitTestUtil.getTestDataFile("soapsvc-vdb.xml")));
    vdbs = admin.getVDBs();
    assertFalse(vdbs.isEmpty());
    VDB vdb = admin.getVDB("WSMSG", "1");
    AdminUtil.waitForVDBLoad(admin, "WSMSG", 1, 3);
    vdb = admin.getVDB("WSMSG", "1");
    assertTrue(vdb.isValid());
    assertTrue(vdb.getStatus().equals(Status.ACTIVE));
    Connection conn = TeiidDriver.getInstance().connect("jdbc:teiid:WSMSG@mm://localhost:31000;user=user;password=user;", null);
    Statement stmt = conn.createStatement();
    String sql = "SELECT *\n" + "FROM ADDRESSINGSERVICE.SAYHELLO\n" + "WHERE MESSAGEID = 'UUID-100' AND SAYHELLO = 'Teiid'\n" + "AND ADDRESSINGSERVICE.SAYHELLO.To = 'http://www.w3.org/2005/08/addressing/anonymous'\n" + "AND ADDRESSINGSERVICE.SAYHELLO.ReplyTo = 'http://www.w3.org/2005/08/addressing/anonymous'\n" + "AND ADDRESSINGSERVICE.SAYHELLO.Action = 'http://www.w3.org/2005/08/addressing/ServiceIface/sayHello'";
    ResultSet rs = stmt.executeQuery(sql);
    assertTrue(rs.next());
    assertEquals("Hello World!", rs.getString(1));
    conn.close();
}
Also used : VDB(org.teiid.adminapi.VDB) Statement(java.sql.Statement) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

VDB (org.teiid.adminapi.VDB)4 Properties (java.util.Properties)2 FileInputStream (java.io.FileInputStream)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 Test (org.junit.Test)1 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)1 LogonException (org.teiid.client.security.LogonException)1 SessionServiceException (org.teiid.dqp.service.SessionServiceException)1