Ejemplo n.º 1
0
 public ResultsFuture<?> logoff() throws InvalidSessionException {
   DQPWorkContext workContext = DQPWorkContext.getWorkContext();
   this.service.closeSession(workContext.getSessionId());
   workContext.getSession().setSessionId(null);
   workContext.getSession().getSessionVariables().clear();
   return ResultsFuture.NULL_FUTURE;
 }
Ejemplo n.º 2
0
  private String updateDQPContext(SessionMetadata s) {
    String sessionID = s.getSessionId();

    DQPWorkContext workContext = DQPWorkContext.getWorkContext();
    workContext.setSession(s);
    return sessionID;
  }
Ejemplo n.º 3
0
  public LocalServerConnection(Properties connectionProperties, boolean useCallingThread)
      throws CommunicationException, ConnectionException {
    this.connectionProperties = connectionProperties;
    this.csr = getClientServiceRegistry();

    String vdbVersion = connectionProperties.getProperty(TeiidURL.JDBC.VDB_VERSION);
    String vdbName = connectionProperties.getProperty(TeiidURL.JDBC.VDB_NAME);
    int firstIndex = vdbName.indexOf('.');
    int lastIndex = vdbName.lastIndexOf('.');
    if (firstIndex != -1 && firstIndex == lastIndex) {
      vdbVersion = vdbName.substring(firstIndex + 1);
      vdbName = vdbName.substring(0, firstIndex);
    }
    if (vdbVersion != null) {
      int waitForLoad =
          PropertiesUtils.getIntProperty(connectionProperties, EmbeddedProfile.WAIT_FOR_LOAD, -1);
      if (waitForLoad != 0) {
        this.csr.waitForFinished(vdbName, Integer.valueOf(vdbVersion), waitForLoad);
      }
    }

    workContext.setSecurityHelper(csr.getSecurityHelper());
    workContext.setUseCallingThread(useCallingThread);
    workContext.setSecurityContext(csr.getSecurityHelper().getSecurityContext());
    authenticate();
    passthrough =
        Boolean.valueOf(
            connectionProperties.getProperty(
                TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, "false")); // $NON-NLS-1$
  }
Ejemplo n.º 4
0
 private void loadViaRefresh(
     final CommandContext context, final String tableName, VDBMetaData vdb, MatTableInfo info)
     throws TeiidProcessingException, TeiidComponentException {
   info.setAsynchLoad();
   DQPWorkContext workContext = createWorkContext(context, vdb);
   final String viewName = tableName.substring(RelationalPlanner.MAT_PREFIX.length());
   workContext.runInContext(
       new Runnable() {
         @Override
         public void run() {
           executor.execute(REFRESH_SQL, Arrays.asList(viewName, Boolean.FALSE));
         }
       });
 }
Ejemplo n.º 5
0
  static AtomicRequestMessage createNewAtomicRequestMessage(int requestid, int nodeid)
      throws Exception {
    RequestMessage rm = new RequestMessage();

    DQPWorkContext workContext =
        RealMetadataFactory.buildWorkContext(EXAMPLE_BQT, RealMetadataFactory.exampleBQTVDB());
    workContext.getSession().setSessionId(String.valueOf(1));
    workContext.getSession().setUserName("foo"); // $NON-NLS-1$

    AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
    request.setCommand(
        helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT)); // $NON-NLS-1$
    request.setRequestID(new RequestID(requestid));
    request.setConnectorName("testing"); // $NON-NLS-1$
    request.setFetchSize(5);
    request.setCommandContext(new CommandContext());
    return request;
  }
Ejemplo n.º 6
0
 @Override
 public void disconnected() {
   if (workContext.getSessionId() != null) {
     workContext.runInContext(
         new Runnable() {
           @Override
           public void run() {
             try {
               csr.getClientService(ILogon.class).logoff();
             } catch (Exception e) {
               LogManager.logDetail(
                   LogConstants.CTX_TRANSPORT,
                   e,
                   "Exception closing client instance"); //$NON-NLS-1$
             }
           }
         });
   }
 }
Ejemplo n.º 7
0
 public ResultsFuture<?> ping() throws InvalidSessionException, TeiidComponentException {
   // ping is double used to alert the aliveness of the client, as well as check the server
   // instance is
   // alive by socket server instance, so that they can be cached.
   String id = DQPWorkContext.getWorkContext().getSessionId();
   if (id != null) {
     this.service.pingServer(id);
   }
   LogManager.logTrace(LogConstants.CTX_SECURITY, "Ping", id); // $NON-NLS-1$
   return ResultsFuture.NULL_FUTURE;
 }
Ejemplo n.º 8
0
 private DQPWorkContext createWorkContext(final CommandContext context, VDBMetaData vdb) {
   SessionMetadata session =
       createTemporarySession(context.getUserName(), "asynch-mat-view-load", vdb); // $NON-NLS-1$
   session.setSubject(context.getSubject());
   session.setSecurityDomain(context.getSession().getSecurityDomain());
   session.setSecurityContext(context.getSession().getSecurityContext());
   DQPWorkContext workContext = new DQPWorkContext();
   workContext.setAdmin(true);
   DQPWorkContext current = context.getDQPWorkContext();
   workContext.setSession(session);
   workContext.setPolicies(current.getAllowedDataPolicies());
   workContext.setSecurityHelper(current.getSecurityHelper());
   return workContext;
 }
Ejemplo n.º 9
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);
    }
  }