List of usage examples for javax.servlet.http HttpSession getAttribute
public Object getAttribute(String name);
null
if no object is bound under the name. From source file:de.anycook.session.Session.java
/** * Ueberprueft, ob bereits eine INstanz von Sessionhandler in der Session gespeichert ist, wenn * wird eine neue erzeugt.//from w w w . j a va 2s. c om * * @param session HttpSession des Users * @return instanz von Sessionhandler */ static public Session init(HttpSession session) { if (session.getAttribute("shandler") != null) { return (Session) session.getAttribute("shandler"); } Session shandler = new Session(); session.setAttribute("shandler", shandler); return shandler; }
From source file:com.swiftcorp.portal.common.util.WebUtils.java
public static int getUserWorkingLevel(HttpServletRequest request) { int workingLevel = GlobalConstants.SYSTEM_LEVEL; HttpSession session = request.getSession(); Integer ulObj = (Integer) session.getAttribute(SESSION_KEYS.WORKING_LEVEL); if (ulObj != null) { workingLevel = ulObj.intValue(); }//from w ww.j a v a 2s. c om return workingLevel; }
From source file:edu.cornell.mannlib.vivo.orcid.controller.OrcidConfirmationState.java
static OrcidConfirmationState fetch(HttpServletRequest req) { HttpSession session = req.getSession(); Object o = session.getAttribute(ATTRIBUTE_NAME); if (o instanceof OrcidConfirmationState) { return (OrcidConfirmationState) o; } else {/*from www . j av a 2 s. c o m*/ OrcidConfirmationState ocs = new OrcidConfirmationState(); session.setAttribute(ATTRIBUTE_NAME, ocs); return ocs; } }
From source file:be.fedict.eid.applet.service.impl.handler.SignatureDataMessageHandler.java
public static String getDigestAlgo(HttpSession session) { String digestAlgo = (String) session.getAttribute(DIGEST_ALGO_SESSION_ATTRIBUTE); return digestAlgo; }
From source file:com.imaginea.mongodb.controllers.BaseController.java
/** * Validates connectionId with the connectionId Array present in session. * * @param connectionId Mongo Db config information provided to user at time of login. * @param logger Logger to write error message to * @param request Request made by client containing session attributes. * @return null if connectionId is valid else error object. *//*from ww w .j a va 2 s. c om*/ protected static String validateConnectionId(String connectionId, Logger logger, HttpServletRequest request) { HttpSession session = request.getSession(); Set<String> existingConnectionIdsInSession = (Set<String>) session .getAttribute("existingConnectionIdsInSession"); if (existingConnectionIdsInSession == null) { InvalidHTTPRequestException e = new InvalidHTTPRequestException(ErrorCodes.INVALID_SESSION, "Invalid Session"); return formErrorResponse(logger, e); } String response = null; if (connectionId == null || !existingConnectionIdsInSession.contains(connectionId)) { InvalidHTTPRequestException e = new InvalidHTTPRequestException(ErrorCodes.INVALID_CONNECTION, "Invalid Connection"); return formErrorResponse(logger, e); } return response; }
From source file:info.magnolia.cms.security.Authenticator.java
/** * checks user session for attribute "user node" * @param request current HttpServletRequest * @return <code>true</code> if the user is authenticated, <code>false</code> otherwise *//* ww w .j ava2 s . com*/ public static boolean isAuthenticated(HttpServletRequest request) { HttpSession httpsession = request.getSession(false); if (httpsession != null) { Object user = httpsession.getAttribute(ATTRIBUTE_JAAS_SUBJECT); return user != null; } return false; }
From source file:com.bluexml.side.framework.alfresco.shareLanguagePicker.LanguageSetter.java
public static String getLanguageFromLayoutParam(HttpServletRequest req, RequestContext context) throws ServletException { logger.debug("# getLanguageFromLayoutParam ..."); User user = context.getUser();//from w w w .j a va 2s . c o m String userId = context.getUserId(); String urlLang = req.getParameter(SHARE_LANG); HttpSession currentSession = req.getSession(); String sessionLang = (String) currentSession.getAttribute(SHARE_LANG); if (logger.isTraceEnabled()) { logger.trace("urlLang : " + urlLang); logger.trace("sessionLang : " + sessionLang); } // set language String language = null; // is no user or guest use browser language if (user != null && !userId.toLowerCase().equals("guest")) { if (urlLang != null) { language = urlLang; if (logger.isDebugEnabled()) { logger.debug("Use language in url :" + urlLang); } } else if (sessionLang != null && currentSession.getAttribute(userSessionok) != null) { // only if language already loaded from preference if (logger.isDebugEnabled()) { logger.debug("Use language stored in session :" + sessionLang); } language = sessionLang; } else { // initialize user language try { language = getUserLanguage(userId, req); logger.debug("Use language from user preferences :" + language); } catch (ConnectorServiceException e) { throw new ServletException(e); } catch (JSONException e) { throw new ServletException(e); } if (language == null) { // language not yet set so use default from browser language = getLanguageFromBrowser(req); logger.debug("Use language from browser :" + language); } currentSession.setAttribute(userSessionok, true); } } else { // language not yet set so use default from browser language = getLanguageFromBrowser(req); logger.debug("no user or Guest, use language from browser :" + language); } return language; }
From source file:info.magnolia.cms.security.Authenticator.java
/** * Get JAAS authenticated subject/*from w w w . j a v a 2 s . co m*/ * @param request * @return Authenticated JAAS subject */ public static Subject getSubject(HttpServletRequest request) { HttpSession httpsession = request.getSession(false); if (httpsession != null) { return (Subject) httpsession.getAttribute(ATTRIBUTE_JAAS_SUBJECT); } return null; }
From source file:com.bsb.cms.commons.web.MossActionUtils.java
/** * session?/*from w ww . ja va 2 s .c om*/ * @param session * @return */ public static User getUser(HttpSession session) { User user = null; Object o = session.getAttribute(USER_KEY); if (o != null) { user = (User) o; } return user; }
From source file:com.thruzero.common.jsf.utils.FlashUtils.java
private static FlashHack getFlashHack(boolean createIfNonExistant) { FlashHack result = null;//from w w w .j a va 2 s . c o m HttpSession session = FacesUtils.getSession(createIfNonExistant); if (session != null) { result = (FlashHack) session.getAttribute(FLASH_HACK_SESSION_KEY); if (result == null && createIfNonExistant) { result = new FlashHack(); session.setAttribute(FLASH_HACK_SESSION_KEY, result); } } return result; }