Search in sources :

Example 11 with SessionMetadata

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

the class EmbeddedServer method startVDBRepository.

private void startVDBRepository() {
    this.repo.addListener(new VDBLifeCycleListener() {

        @Override
        public void added(String name, CompositeVDB vdb) {
        }

        @Override
        public void removed(String name, CompositeVDB vdb) {
            if (replicator != null) {
                replicator.stop(vdb.getVDB().getAttachment(GlobalTableStore.class));
            }
            rs.clearForVDB(vdb.getVDBKey());
            ppc.clearForVDB(vdb.getVDBKey());
            for (SessionMetadata session : sessionService.getSessionsLoggedInToVDB(vdb.getVDBKey())) {
                try {
                    sessionService.closeSession(session.getSessionId());
                } catch (InvalidSessionException e) {
                }
            }
        }

        @Override
        public void finishedDeployment(String name, CompositeVDB vdb) {
            if (!vdb.getVDB().getStatus().equals(Status.ACTIVE)) {
                return;
            }
            GlobalTableStore gts = CompositeGlobalTableStore.createInstance(vdb, dqp.getBufferManager(), replicator);
            vdb.getVDB().addAttchment(GlobalTableStore.class, gts);
        }

        @Override
        public void beforeRemove(String name, CompositeVDB vdb) {
        }
    });
    this.repo.setSystemFunctionManager(SystemMetadata.getInstance().getSystemFunctionManager());
    this.repo.start();
}
Also used : InvalidSessionException(org.teiid.client.security.InvalidSessionException) CompositeVDB(org.teiid.deployers.CompositeVDB) GlobalTableStore(org.teiid.query.tempdata.GlobalTableStore) CompositeGlobalTableStore(org.teiid.deployers.CompositeGlobalTableStore) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) VDBLifeCycleListener(org.teiid.deployers.VDBLifeCycleListener)

Example 12 with SessionMetadata

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

the class SessionServiceImpl method pingServer.

@Override
public void pingServer(String sessionID) throws InvalidSessionException {
    SessionMetadata info = getSessionInfo(sessionID, false);
    info.setLastPingTime(System.currentTimeMillis());
    // $NON-NLS-1$
    LogManager.logDetail(LogConstants.CTX_SECURITY, "Keep-alive ping received for session:", sessionID);
}
Also used : SessionMetadata(org.teiid.adminapi.impl.SessionMetadata)

Example 13 with SessionMetadata

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

the class SessionServiceImpl method closeSession.

@Override
public void closeSession(String sessionID) throws InvalidSessionException {
    if (LogManager.isMessageToBeRecorded(LogConstants.CTX_SECURITY, MessageLevel.DETAIL)) {
        // $NON-NLS-1$
        LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] { "closeSession", sessionID });
    }
    SessionMetadata info = getSessionInfo(sessionID, true);
    if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, new AuditMessage("session", "logoff", info));
    }
    if (info.getVDBName() != null) {
        try {
            dqp.terminateSession(info.getSessionId());
        } catch (Exception e) {
            LogManager.logWarning(LogConstants.CTX_SECURITY, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40018));
        }
    }
    info.setSecurityContext(null);
    info.setClosed();
    info.getSessionVariables().clear();
}
Also used : AuditMessage(org.teiid.logging.AuditMessage) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) LoginException(javax.security.auth.login.LoginException) InvalidSessionException(org.teiid.client.security.InvalidSessionException) SessionServiceException(org.teiid.dqp.service.SessionServiceException) LogonException(org.teiid.client.security.LogonException)

Example 14 with SessionMetadata

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

the class LogonImpl method logon.

private LogonResult logon(Properties connProps, byte[] krb5ServiceTicket, AuthenticationType authType, String user) throws LogonException {
    String vdbName = connProps.getProperty(BaseDataSource.VDB_NAME);
    String vdbVersion = connProps.getProperty(BaseDataSource.VDB_VERSION);
    String applicationName = connProps.getProperty(TeiidURL.CONNECTION.APP_NAME);
    String password = connProps.getProperty(TeiidURL.CONNECTION.PASSWORD);
    Credentials credential = null;
    if (password != null) {
        credential = new Credentials(password.toCharArray());
    }
    try {
        SessionMetadata sessionInfo = service.createSession(vdbName, vdbVersion, authType, user, credential, applicationName, connProps);
        if (connProps.get(GSSCredential.class.getName()) != null) {
            addCredentials(sessionInfo.getSubject(), (GSSCredential) connProps.get(GSSCredential.class.getName()));
        }
        updateDQPContext(sessionInfo);
        if (DQPWorkContext.getWorkContext().getClientAddress() == null) {
            sessionInfo.setEmbedded(true);
        }
        // if (oldSessionId != null) {
        // TODO: we should be smarter about disassociating the old sessions from the client.  we'll just rely on
        // ping based clean up
        // }
        LogonResult result = new LogonResult(sessionInfo.getSessionToken(), sessionInfo.getVDBName(), clusterName);
        if (krb5ServiceTicket != null) {
            result.addProperty(ILogon.KRB5TOKEN, krb5ServiceTicket);
        }
        return result;
    } catch (LoginException e) {
        throw new LogonException(e);
    } catch (SessionServiceException e) {
        throw new LogonException(e);
    }
}
Also used : GSSCredential(org.ietf.jgss.GSSCredential) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata) LogonException(org.teiid.client.security.LogonException) LogonResult(org.teiid.client.security.LogonResult) LoginException(javax.security.auth.login.LoginException) Credentials(org.teiid.security.Credentials) SessionServiceException(org.teiid.dqp.service.SessionServiceException)

Example 15 with SessionMetadata

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

the class ODBCServerRemoteImpl method updateSessionProperties.

private void updateSessionProperties() {
    String encoding = getEncoding();
    if (encoding != null) {
        // this may be unnecessary
        this.client.setEncoding(encoding, false);
    }
    String appName = this.connection.getExecutionProperty(PgBackendProtocol.APPLICATION_NAME);
    if (appName != null) {
        String existing = props.getProperty(PgBackendProtocol.APPLICATION_NAME);
        if (!EquivalenceUtil.areEqual(appName, existing)) {
            try {
                SessionMetadata sm = ((LocalServerConnection) connection.getServerConnection()).getWorkContext().getSession();
                sm.setApplicationName(appName);
            } catch (SQLException e) {
            // connection invalid
            }
            this.client.sendParameterStatus(PgBackendProtocol.APPLICATION_NAME, appName);
            this.props.put(PgBackendProtocol.APPLICATION_NAME, appName);
        }
    }
}
Also used : TeiidSQLException(org.teiid.jdbc.TeiidSQLException) SQLException(java.sql.SQLException) SessionMetadata(org.teiid.adminapi.impl.SessionMetadata)

Aggregations

SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)35 Test (org.junit.Test)14 CommandContext (org.teiid.query.util.CommandContext)9 Properties (java.util.Properties)6 InvalidSessionException (org.teiid.client.security.InvalidSessionException)6 DQPWorkContext (org.teiid.dqp.internal.process.DQPWorkContext)5 SessionServiceException (org.teiid.dqp.service.SessionServiceException)5 List (java.util.List)4 LoginException (javax.security.auth.login.LoginException)4 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)4 LogonException (org.teiid.client.security.LogonException)4 SessionToken (org.teiid.client.security.SessionToken)4 Credentials (org.teiid.security.Credentials)4 ArrayList (java.util.ArrayList)3 Subject (javax.security.auth.Subject)3 TeiidComponentException (org.teiid.core.TeiidComponentException)3 SQLException (java.sql.SQLException)2 LogonResult (org.teiid.client.security.LogonResult)2 CompositeVDB (org.teiid.deployers.CompositeVDB)2 VDBLifeCycleListener (org.teiid.deployers.VDBLifeCycleListener)2