Tabnine Logo
SessionManager
Code IndexAdd Tabnine to your IDE (free)

How to use
SessionManager
in
com.oberasoftware.jasdb.api.security

Best Java code snippets using com.oberasoftware.jasdb.api.security.SessionManager (Showing top 5 results out of 315)

origin: oberasoftware/jasdb

/**
 * Creates a local DB session with credentials
 * @param credentials The credentials
 * @throws JasDBStorageException If unable to request the session
 */
public LocalDBSession(Credentials credentials) throws JasDBException {
  this();
  SessionManager sessionManager = ApplicationContextProvider.getApplicationContext().getBean(SessionManager.class);
  userSession = sessionManager.startSession(credentials);
}
origin: oberasoftware/jasdb

  private void validateSession() throws JasDBStorageException {
    if(session == null || !sessionManager.sessionValid(session.getSessionId())) {
      throw new JasDBSecurityException("Unable to change security principals, not logged in or session expired");
    }
  }
}
origin: oberasoftware/jasdb

private void checkToken(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws IOException, ServletException {
  try {
    String token = httpServletRequest.getHeader("oauth_token");
    String sessionId = httpServletRequest.getHeader("sessionid");
    LOG.debug("Token: {} for session: {}", token, sessionId);
    if(StringUtils.stringNotEmpty(token) && StringUtils.stringNotEmpty(sessionId)) {
      UserSession session = sessionManager.getSession(sessionId);
      if(session != null) {
        CryptoEngine cryptoEngine = CryptoFactory.getEngine();
        String expectedTokenHash = cryptoEngine.hash(sessionId, token);
        if (expectedTokenHash.equals(session.getAccessToken())) {
          httpServletRequest.setAttribute("session", new UserSessionImpl(sessionId, token, session.getEncryptedContentKey(), session.getUser()));
          filterChain.doFilter(httpServletRequest, httpServletResponse);
        } else {
          handleErrorResponse(httpServletResponse, UNAUTHORIZED_CODE, "Invalid token");
        }
      } else {
        handleErrorResponse(httpServletResponse, UNAUTHORIZED_CODE, "Invalid token");
      }
    } else {
      handleErrorResponse(httpServletResponse, UNAUTHORIZED_CODE, "No token");
    }
  } catch(JasDBStorageException e) {
    LOG.error("Unknown error happened when processing token", e);
    handleErrorResponse(httpServletResponse, 500, "Unknown error");
  }
}
origin: oberasoftware/jasdb

/**
 * Creates a local DB session bound to a specific instance with given credentials
 * @param instanceId The instance
 * @param credentials The credentials
 * @throws JasDBStorageException If unable to request the session
 */
public LocalDBSession(String instanceId, Credentials credentials) throws JasDBException {
  this(instanceId);
  SessionManager sessionManager = ApplicationContextProvider.getApplicationContext().getBean(SessionManager.class);
  userSession = sessionManager.startSession(credentials);
}
origin: oberasoftware/jasdb

@RequestMapping(method = RequestMethod.POST, value = "/token", produces = "application/json", consumes = "application/json")
public @ResponseBody
ResponseEntity<String> getToken(HttpServletRequest request) {
  if(request.isSecure()) {
    try {
      String clientId = request.getParameter("client_id");
      String clientSecret = request.getParameter("client_secret");
      LOG.debug("Client: {} host: {}", clientId, request.getRemoteHost());
      UserSession session = sessionManager.startSession(new BasicCredentials(clientId, request.getRemoteHost(), clientSecret));
      LOG.debug("Loaded session: {}", session);
      String responseMessage = String.format(GRANT_VALID, session.getAccessToken(), session.getSessionId(), "jasdb", 3600);
      return new ResponseEntity<>(responseMessage, HttpStatus.OK);
    } catch(JasDBSecurityException e) {
      return getErrorResponse("Invalid credentials");
    } catch(JasDBStorageException e) {
      return getErrorResponse("Unknown error");
    }
  } else {
    return getErrorResponse("Insecure connection");
  }
}
com.oberasoftware.jasdb.api.securitySessionManager

Most used methods

  • startSession
  • getSession
  • sessionValid

Popular in Java

  • Start an intent from android
  • getSystemService (Context)
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Kernel (java.awt.image)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now