Search in sources :

Example 1 with ILogon

use of org.teiid.client.security.ILogon in project teiid by teiid.

the class SocketServerConnection method connect.

private ILogon connect(HostInfo hostInfo) throws CommunicationException, IOException {
    hostInfo.setSsl(secure);
    this.serverInstance = connectionFactory.getServerInstance(hostInfo);
    this.logonResult = logonResults.get(hostInfo);
    ILogon newLogon = this.serverInstance.getService(ILogon.class);
    if (this.logonResult != null) {
        try {
            newLogon.assertIdentity(logonResult.getSessionToken());
        } catch (TeiidException e) {
            // session is no longer valid
            disconnect();
        }
    }
    return newLogon;
}
Also used : ILogon(org.teiid.client.security.ILogon) TeiidException(org.teiid.core.TeiidException)

Example 2 with ILogon

use of org.teiid.client.security.ILogon in project teiid by teiid.

the class TestSocketServerConnection method testRetry.

/**
 * Since the original instance is still open, this will be a transparent retry
 */
@Test
public void testRetry() throws Exception {
    SocketServerConnection connection = createConnection(new SingleInstanceCommunicationException());
    connection.setFailOver(true);
    connection.setFailOverPingInterval(50);
    ILogon logon = connection.getService(ILogon.class);
    Thread.sleep(70);
    logon.ping();
}
Also used : ILogon(org.teiid.client.security.ILogon) Test(org.junit.Test)

Example 3 with ILogon

use of org.teiid.client.security.ILogon in project teiid by teiid.

the class TestSocketServerConnection method testImmediateFail.

@Test(expected = CommunicationException.class)
public void testImmediateFail() throws Exception {
    SocketServerConnection connection = createConnection(new CommunicationException());
    ILogon logon = connection.getService(ILogon.class);
    logon.ping();
}
Also used : CommunicationException(org.teiid.net.CommunicationException) ILogon(org.teiid.client.security.ILogon) Test(org.junit.Test)

Example 4 with ILogon

use of org.teiid.client.security.ILogon in project teiid by teiid.

the class TestSocketServerInstanceImpl method testSuccessfulHandshake.

@Test
public void testSuccessfulHandshake() throws Exception {
    final FakeObjectChannel channel = new FakeObjectChannel(Arrays.asList(new Handshake(), new SocketTimeoutException()));
    SocketServerInstanceImpl instance = createInstance(channel);
    // no remote server is hooked up, so this will timeout
    ILogon logon = instance.getService(ILogon.class);
    try {
        logon.logon(new Properties());
        // $NON-NLS-1$
        fail("Exception expected");
    } catch (SingleInstanceCommunicationException e) {
        assertTrue(e.getCause() instanceof TimeoutException);
    }
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) Properties(java.util.Properties) ILogon(org.teiid.client.security.ILogon) TimeoutException(java.util.concurrent.TimeoutException) SocketTimeoutException(java.net.SocketTimeoutException) Test(org.junit.Test)

Example 5 with ILogon

use of org.teiid.client.security.ILogon in project teiid by teiid.

the class TestSocketRemoting method testMethodInvocation.

@Test
public void testMethodInvocation() throws Exception {
    ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl() {

        @Override
        public ClassLoader getCallerClassloader() {
            return getClass().getClassLoader();
        }
    };
    csr.registerClientService(ILogon.class, new ILogon() {

        public ResultsFuture<?> logoff() throws InvalidSessionException {
            ResultsFuture<?> result = new ResultsFuture<Void>();
            // $NON-NLS-1$
            result.getResultsReceiver().exceptionOccurred(new TeiidComponentException("some exception"));
            return result;
        }

        public LogonResult logon(Properties connectionProperties) throws LogonException, TeiidComponentException {
            return new LogonResult();
        }

        // tests asynch where we don't care about the result
        public ResultsFuture<?> ping() throws InvalidSessionException, TeiidComponentException {
            return null;
        }

        @Override
        public ResultsFuture<?> ping(Collection<String> sessions) throws TeiidComponentException, CommunicationException {
            return null;
        }

        @Override
        public void assertIdentity(SessionToken sessionId) throws InvalidSessionException, TeiidComponentException {
        }

        @Override
        public LogonResult neogitiateGssLogin(Properties connectionProperties, byte[] serviceToken, boolean createSession) throws LogonException {
            return null;
        }
    }, // $NON-NLS-1$
    "foo");
    // $NON-NLS-1$
    csr.registerClientService(FakeService.class, new FakeServiceImpl(), "foo");
    final FakeClientServerInstance serverInstance = new FakeClientServerInstance(csr);
    SocketServerConnection connection = createFakeConnection(serverInstance);
    ILogon logon = connection.getService(ILogon.class);
    Future<?> result = logon.ping();
    assertNull(result.get(0, TimeUnit.MILLISECONDS));
    result = logon.logoff();
    try {
        result.get(0, TimeUnit.MICROSECONDS);
        // $NON-NLS-1$
        fail("exception expected");
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof TeiidComponentException);
    }
    FakeService service = connection.getService(FakeService.class);
    Future<Integer> asynchInteger = service.asynchResult();
    assertEquals(new Integer(5), asynchInteger.get(0, TimeUnit.MILLISECONDS));
    try {
        service.exceptionMethod();
        // $NON-NLS-1$
        fail("exception expected");
    } catch (TeiidProcessingException e) {
    }
    DQP dqp = connection.getService(DQP.class);
    try {
        ResultsFuture<?> future = dqp.begin();
        future.get();
        // $NON-NLS-1$
        fail("exception expected");
    } catch (Exception e) {
        // $NON-NLS-1$
        assertTrue(e.getMessage().indexOf("Component not found:") != -1);
    }
}
Also used : LogonResult(org.teiid.client.security.LogonResult) Properties(java.util.Properties) TeiidProcessingException(org.teiid.core.TeiidProcessingException) LogonException(org.teiid.client.security.LogonException) ExecutionException(java.util.concurrent.ExecutionException) InvalidSessionException(org.teiid.client.security.InvalidSessionException) DQP(org.teiid.client.DQP) CommunicationException(org.teiid.net.CommunicationException) SessionToken(org.teiid.client.security.SessionToken) ILogon(org.teiid.client.security.ILogon) InvalidSessionException(org.teiid.client.security.InvalidSessionException) TeiidComponentException(org.teiid.core.TeiidComponentException) LogonException(org.teiid.client.security.LogonException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) CommunicationException(org.teiid.net.CommunicationException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ExecutionException(java.util.concurrent.ExecutionException) ConnectionException(org.teiid.net.ConnectionException) ResultsFuture(org.teiid.client.util.ResultsFuture) TeiidComponentException(org.teiid.core.TeiidComponentException) SocketServerConnection(org.teiid.net.socket.SocketServerConnection) Test(org.junit.Test)

Aggregations

ILogon (org.teiid.client.security.ILogon)8 Test (org.junit.Test)5 CommunicationException (org.teiid.net.CommunicationException)5 IOException (java.io.IOException)3 TeiidException (org.teiid.core.TeiidException)3 ConnectionException (org.teiid.net.ConnectionException)3 UnknownHostException (java.net.UnknownHostException)2 Properties (java.util.Properties)2 InvalidSessionException (org.teiid.client.security.InvalidSessionException)2 LogonException (org.teiid.client.security.LogonException)2 TeiidComponentException (org.teiid.core.TeiidComponentException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 MalformedURLException (java.net.MalformedURLException)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1