/** * Create a JCR session for the given HTTP servlet request with a * SecurityContext attached. * * @param servletRequest the servlet request * @return a newly created JCR session */ protected HttpSession createSession(final HttpServletRequest servletRequest) { LOGGER.debug("Returning an authenticated session in the default workspace"); return new HttpSession(repo.login(credentialsService.getCredentials(servletRequest))); }
/** * Retrieve a JCR session from an active transaction * * @param servletRequest the servlet request * @param txId the transaction id * @return a JCR session that is associated with the transaction */ protected HttpSession getSessionFromTransaction(final HttpServletRequest servletRequest, final String txId) { final Principal userPrincipal = servletRequest.getUserPrincipal(); final String userName = userPrincipal == null ? null : userPrincipal.getName(); final FedoraSession session = batchService.getSession(txId, userName); final HttpSession batchSession = new HttpSession(session); batchSession.makeBatchSession(); LOGGER.debug("Returning a session in the batch {} for user {}", batchSession, userName); return batchSession; }