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();
}
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);
}
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();
}
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);
}
}
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);
}
}
}
Aggregations