Exemple #1
0
  @Override
  public void assertIdentity(SessionToken checkSession)
      throws InvalidSessionException, TeiidComponentException {
    if (checkSession == null) {
      // disassociate
      this.updateDQPContext(new SessionMetadata());
      return;
    }
    SessionMetadata sessionInfo = null;
    try {
      sessionInfo = this.service.validateSession(checkSession.getSessionID());
    } catch (SessionServiceException e) {
      throw new TeiidComponentException(RuntimePlugin.Event.TEIID40062, e);
    }

    if (sessionInfo == null) {
      throw new InvalidSessionException(RuntimePlugin.Event.TEIID40063);
    }

    SessionToken st = sessionInfo.getSessionToken();
    if (!st.equals(checkSession)) {
      throw new InvalidSessionException(RuntimePlugin.Event.TEIID40064);
    }
    this.updateDQPContext(sessionInfo);
  }
Exemple #2
0
 /**
  * Create an unauthenticated session
  *
  * @param userName
  * @param app
  * @param vdb
  * @return
  */
 public static SessionMetadata createTemporarySession(
     String userName, String app, VDBMetaData vdb) {
   long creationTime = System.currentTimeMillis();
   SessionMetadata newSession = new SessionMetadata();
   newSession.setSessionToken(new SessionToken(userName));
   newSession.setSessionId(newSession.getSessionToken().getSessionID());
   newSession.setUserName(userName);
   newSession.setCreatedTime(creationTime);
   newSession.setApplicationName(app);
   newSession.setVDBName(vdb.getName());
   newSession.setVDBVersion(vdb.getVersion());
   newSession.setVdb(vdb);
   newSession.setEmbedded(true);
   return newSession;
 }
Exemple #3
0
  private LogonResult logon(Properties connProps, byte[] krb5ServiceTicket) throws LogonException {
    // DQPWorkContext workContext = DQPWorkContext.getWorkContext();
    // String oldSessionId = workContext.getSessionId();
    String applicationName = connProps.getProperty(TeiidURL.CONNECTION.APP_NAME);
    // user may be null if using trustedToken to log on
    String user =
        connProps.getProperty(TeiidURL.CONNECTION.USER_NAME, CoreConstants.DEFAULT_ANON_USERNAME);
    // password may be null if using trustedToken to log on
    String password = connProps.getProperty(TeiidURL.CONNECTION.PASSWORD);
    Credentials credential = null;
    if (password != null) {
      credential = new Credentials(password.toCharArray());
    }

    try {
      SessionMetadata sessionInfo =
          service.createSession(user, credential, applicationName, connProps, true);
      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(),
              sessionInfo.getVDBVersion(),
              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);
    }
  }