Package org.teiid.adminapi.impl

Examples of org.teiid.adminapi.impl.SessionMetadata


            credential = new Credentials(password.toCharArray());
        }
       
        boolean adminConnection = Boolean.parseBoolean(connProps.getProperty(TeiidURL.CONNECTION.ADMIN));
    try {
      SessionMetadata sessionInfo = service.createSession(user,credential, applicationName, connProps, adminConnection, true);
          updateDQPContext(sessionInfo);
          if (DQPWorkContext.getWorkContext().getClientAddress() == null) {
        sessionInfo.setEmbedded(true);
          }
          if (oldToken != null) {
            try {
          this.service.closeSession(oldToken.getSessionID());
        } catch (InvalidSessionException e) {
        }
          }
      return new LogonResult(sessionInfo.getSessionToken(), sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
    } catch (LoginException e) {
      throw new LogonException(e.getMessage());
    } catch (SessionServiceException e) {
      throw new LogonException(e, e.getMessage());
    }
View Full Code Here


    return ResultsFuture.NULL_FUTURE;
  }

  @Override
  public void assertIdentity(SessionToken checkSession) throws InvalidSessionException, TeiidComponentException {
    SessionMetadata sessionInfo = null;
    try {
      sessionInfo = this.service.validateSession(checkSession.getSessionID());
    } catch (SessionServiceException e) {
      throw new TeiidComponentException(e);
    }
   
    if (sessionInfo == null) {
      throw new InvalidSessionException();
    }
   
    SessionToken st = sessionInfo.getSessionToken();
    if (!st.equals(checkSession)) {
      throw new InvalidSessionException();
    }
    this.updateDQPContext(sessionInfo);
  }
View Full Code Here

  public void closeSession(String sessionID) throws InvalidSessionException {
    LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"closeSession", sessionID}); //$NON-NLS-1$
    if (sessionID == null) {
      throw new InvalidSessionException(RuntimePlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
    }
    SessionMetadata info = this.sessionCache.remove(sessionID);
    if (info == null) {
      throw new InvalidSessionException(RuntimePlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
    }
    if (info.getVDBName() != null) {
            try {
          dqp.terminateSession(info.getSessionId());
            } catch (Exception e) {
                LogManager.logWarning(LogConstants.CTX_SECURITY,e,"Exception terminitating session"); //$NON-NLS-1$
            }
    }

        // try to log out of the context.
        try {
          LoginContext context = info.getLoginContext();
          if (context != null) {
            context.logout();
          }
    } catch (LoginException e) {
       LogManager.logWarning(LogConstants.CTX_SECURITY,e,"Exception terminitating session"); //$NON-NLS-1$
View Full Code Here

        }       
       
        long creationTime = System.currentTimeMillis();

        // Return a new session info object
        SessionMetadata newSession = new SessionMetadata();
        newSession.setSessionToken(new SessionToken(userName));
        newSession.setSessionId(newSession.getSessionToken().getSessionID());
        newSession.setUserName(userName);
        newSession.setCreatedTime(creationTime);
        newSession.setApplicationName(applicationName);
        newSession.setClientHostName(properties.getProperty(TeiidURL.CONNECTION.CLIENT_HOSTNAME));
        newSession.setIPAddress(properties.getProperty(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS));
        newSession.setSecurityDomain(securityDomain);
        if (vdb != null) {
          newSession.setVDBName(vdb.getName());
          newSession.setVDBVersion(vdb.getVersion());
        }
       
        // these are local no need for monitoring.
        newSession.setLoginContext(loginContext);
        newSession.setSecurityContext(securityContext);
        newSession.setVdb(vdb);
        LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful for \"", userName, "\" - created SessionID \"", newSession.getSessionToken().getSessionID(), "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        this.sessionCache.put(newSession.getSessionId(), newSession);
        return newSession;
  }
View Full Code Here

    return results;
  }

  @Override
  public void pingServer(String sessionID) throws InvalidSessionException {
    SessionMetadata info = getSessionInfo(sessionID);
    info.setLastPingTime(System.currentTimeMillis());
    this.sessionCache.put(sessionID, info);
    LogManager.logDetail(LogConstants.CTX_SECURITY, "Keep-alive ping received for session:", sessionID); //$NON-NLS-1$
  }
View Full Code Here

    }
  }

  @Override
  public SessionMetadata validateSession(String sessionID) throws InvalidSessionException, SessionServiceException {
    SessionMetadata info = getSessionInfo(sessionID);
    return info;
  }
View Full Code Here

  private SessionMetadata getSessionInfo(String sessionID)
      throws InvalidSessionException {
    if (sessionID == null) {
      throw new InvalidSessionException(RuntimePlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
    }
    SessionMetadata info = this.sessionCache.get(sessionID);
    if (info == null) {
      throw new InvalidSessionException(RuntimePlugin.Util.getString("SessionServiceImpl.invalid_session", sessionID)); //$NON-NLS-1$
    }
    return info;
  }
View Full Code Here

    properties.setProperty(TeiidURL.JDBC.VDB_VERSION, String.valueOf(version));
   
    String user = "JOPR ADMIN"; //$NON-NLS-1$
    LogManager.logDetail(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.getString("admin_executing", user, command)); //$NON-NLS-1$
   
    SessionMetadata session = null;
    try {
      session = this.sessionService.createSession(user, null, "JOPR", properties, false, false); //$NON-NLS-1$
    } catch (SessionServiceException e1) {
      throw new AdminProcessingException(e1);
    } catch (LoginException e1) {
      throw new AdminProcessingException(e1);
    }

    final long requestID =  0L;
   
    DQPWorkContext context = new DQPWorkContext();
    context.setSession(session);
   
    try {
      return context.runInContext(new Callable<List<List>>() {
        @Override
        public List<List> call() throws Exception {
          ArrayList<List> results = new ArrayList<List>();
         
          long start = System.currentTimeMillis();
          RequestMessage request = new RequestMessage(command);
          request.setExecutionId(0L);
          request.setRowLimit(getMaxRowsFetchSize()); // this would limit the number of rows that are returned.
          Future<ResultsMessage> message = dqpCore.executeRequest(requestID, request);
          ResultsMessage rm = message.get(timoutInMilli, TimeUnit.MILLISECONDS);
         
              if (rm.getException() != null) {
                  throw new AdminProcessingException(rm.getException());
              }
             
              if (rm.isUpdateResult()) {
                results.addAll(new ArrayList(Arrays.asList("update count"))); //$NON-NLS-1$
                results.addAll(Arrays.asList(rm.getResults()));               
              }
              else {
                results.addAll(new ArrayList(Arrays.asList(rm.getColumnNames())));
                results.addAll(Arrays.asList(fixResults(rm.getResults())));
               
                while (rm.getFinalRow() == -1 || rm.getLastRow() < rm.getFinalRow()) {
                  long elapsed = System.currentTimeMillis() - start;
              message = dqpCore.processCursorRequest(requestID, rm.getLastRow()+1, 1024);
              rm = message.get(timoutInMilli-elapsed, TimeUnit.MILLISECONDS);
              results.addAll(Arrays.asList(fixResults(rm.getResults())));
                }
              }

              long elapsed = System.currentTimeMillis() - start;
              ResultsFuture<?> response = dqpCore.closeRequest(requestID);
              response.get(timoutInMilli-elapsed, TimeUnit.MILLISECONDS);
          return results;
        }
      });
    } catch (Throwable t) {
      throw new AdminProcessingException(t);
    } finally {
      try {
        sessionService.closeSession(session.getSessionId());
      } catch (InvalidSessionException e) { //ignore
      }     
    }
  } 
View Full Code Here

  }

 
  public static DQPWorkContext buildWorkContext() {
    DQPWorkContext workContext = new DQPWorkContext();
    SessionMetadata session = new SessionMetadata();
    workContext.setSession(session);
    session.setVDBName("vdb-name"); //$NON-NLS-1$
    session.setVDBVersion(1);
    session.setSessionId(String.valueOf(1));
    session.setUserName("foo"); //$NON-NLS-1$
    return workContext;
  }
View Full Code Here

    String applicationName = "test"; //$NON-NLS-1$
    Properties p = new Properties();
    p.setProperty(TeiidURL.CONNECTION.USER_NAME, userName);
    p.setProperty(TeiidURL.CONNECTION.APP_NAME, applicationName);

    SessionMetadata session = new SessionMetadata();
    session.setUserName(userName);
    session.setApplicationName(applicationName);
    session.setSessionId(String.valueOf(1));
    session.setSessionToken(new SessionToken(1, userName));

    Mockito.stub(ssi.createSession(userName, null, applicationName,p, false, true)).toReturn(session);

    LogonImpl impl = new LogonImpl(ssi, "fakeCluster"); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of org.teiid.adminapi.impl.SessionMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.