Example usage for javax.servlet.http HttpSession getId

List of usage examples for javax.servlet.http HttpSession getId

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession getId.

Prototype

public String getId();

Source Link

Document

Returns a string containing the unique identifier assigned to this session.

Usage

From source file:org.apache.catalina.authenticator.AuthenticatorBase.java

/**
 * Return the internal Session that is associated with this HttpRequest,
 * possibly creating a new one if necessary, or <code>null</code> if
 * there is no such session and we did not create one.
 *
 * @param request The HttpRequest we are processing
 * @param create Should we create a session if needed?
 *//*w w  w .j a v  a  2s.c  o  m*/
protected Session getSession(HttpRequest request, boolean create) {

    HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
    HttpSession hses = hreq.getSession(create);
    if (hses == null)
        return (null);
    Manager manager = context.getManager();
    if (manager == null)
        return (null);
    else {
        try {
            return (manager.findSession(hses.getId()));
        } catch (IOException e) {
            return (null);
        }
    }

}

From source file:com.cws.us.pws.controllers.CommonController.java

@RequestMapping(value = "/search/terms/{terms}page/{page}", method = RequestMethod.GET)
public final ModelAndView siteSearch(@PathVariable("terms") final String terms,
        @PathVariable("page") final int page) {
    final String methodName = CommonController.CNAME
            + "#siteSearch(@PathVariable(\"terms\") final String terms, @PathVariable(\"page\") final int page)";

    if (DEBUG) {/*from w w  w .  j  a va2 s .c  o  m*/
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("terms: {}", terms);
        DEBUGGER.debug("page: {}", page);
    }

    ModelAndView mView = new ModelAndView();

    final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
            .currentRequestAttributes();
    final HttpServletRequest hRequest = requestAttributes.getRequest();
    final HttpSession hSession = hRequest.getSession();
    final ISearchProcessor processor = new SearchProcessorImpl();

    if (DEBUG) {
        DEBUGGER.debug("ServletRequestAttributes: {}", requestAttributes);
        DEBUGGER.debug("HttpServletRequest: {}", hRequest);
        DEBUGGER.debug("HttpSession: {}", hSession);
        DEBUGGER.debug("Session ID: {}", hSession.getId());

        DEBUGGER.debug("Dumping session content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> sessionEnumeration = hSession.getAttributeNames();

        while (sessionEnumeration.hasMoreElements()) {
            String sessionElement = sessionEnumeration.nextElement();
            Object sessionValue = hSession.getAttribute(sessionElement);

            DEBUGGER.debug("Attribute: " + sessionElement + "; Value: " + sessionValue);
        }

        DEBUGGER.debug("Dumping request content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> requestEnumeration = hRequest.getAttributeNames();

        while (requestEnumeration.hasMoreElements()) {
            String requestElement = requestEnumeration.nextElement();
            Object requestValue = hRequest.getAttribute(requestElement);

            DEBUGGER.debug("Attribute: " + requestElement + "; Value: " + requestValue);
        }

        DEBUGGER.debug("Dumping request parameters:");
        @SuppressWarnings("unchecked")
        Enumeration<String> paramsEnumeration = hRequest.getParameterNames();

        while (paramsEnumeration.hasMoreElements()) {
            String requestElement = paramsEnumeration.nextElement();
            Object requestValue = hRequest.getParameter(requestElement);

            DEBUGGER.debug("Parameter: " + requestElement + "; Value: " + requestValue);
        }
    }

    try {
        SearchRequest request = new SearchRequest();
        request.setSearchType(SearchRequestType.SITE);
        request.setSearchTerms(terms);
        request.setStartRow(page);

        if (DEBUG) {
            DEBUGGER.debug("SearchRequest: {}", request);
        }

        SearchResponse response = processor.doSiteSearch(request);

        if (DEBUG) {
            DEBUGGER.debug("SearchResponse: {}", response);
        }

        if (response.getRequestStatus() == CoreServicesStatus.SUCCESS) {
            mView.addObject("pages", (int) Math.ceil(response.getEntryCount() * 1.0 / this.recordsPerPage));
            mView.addObject("page", page);
            mView.addObject("searchTerms", terms);
            mView.addObject("searchResults", response.getResults());
            mView.setViewName(this.appConfig.getSearchRequestPage());
        } else {
            mView.addObject(Constants.MESSAGE_RESPONSE, response.getResponse());
            mView.setViewName(this.appConfig.getSearchRequestPage());
        }

        mView = new ModelAndView(new RedirectView());
        mView.setViewName(this.appConfig.getRequestCompletePage());
    } catch (SearchRequestException srx) {
        ERROR_RECORDER.error(srx.getMessage(), srx);

        mView = new ModelAndView(new RedirectView());
        mView.setViewName(this.appConfig.getErrorResponsePage());
    }

    if (DEBUG) {
        DEBUGGER.debug("ModelAndView: {}", mView);
    }

    return mView;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String loadSearch(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|loadSearch|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }/*  w w w . j  a v  a 2s .c  o  m*/

    baseDBForm.resetForm();

    session.setAttribute(DisplayConstants.CURRENT_ACTION, DisplayConstants.SEARCH);
    session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);

    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|loadSearch|Success|Loading the Search Page||");
    return ForwardConstants.LOAD_SEARCH_SUCCESS;
}

From source file:com.cws.us.pws.controllers.CommonController.java

@RequestMapping(value = "/search", method = RequestMethod.POST)
public final ModelAndView siteSearch(@ModelAttribute("request") final SearchRequest request,
        final BindingResult bindResult) {
    final String methodName = CommonController.CNAME
            + "#sendMessage(@ModelAttribute(\"request\") final SearchRequest request, final BindingResult bindResult)";

    if (DEBUG) {//  ww w . j a  v a2s. c om
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("SearchRequest: {}", request);
        DEBUGGER.debug("BindingResult: {}", bindResult);
    }

    ModelAndView mView = new ModelAndView();

    final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
            .currentRequestAttributes();
    final HttpServletRequest hRequest = requestAttributes.getRequest();
    final HttpSession hSession = hRequest.getSession();
    final ISearchProcessor processor = new SearchProcessorImpl();

    if (DEBUG) {
        DEBUGGER.debug("ServletRequestAttributes: {}", requestAttributes);
        DEBUGGER.debug("HttpServletRequest: {}", hRequest);
        DEBUGGER.debug("HttpSession: {}", hSession);
        DEBUGGER.debug("Session ID: {}", hSession.getId());

        DEBUGGER.debug("Dumping session content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> sessionEnumeration = hSession.getAttributeNames();

        while (sessionEnumeration.hasMoreElements()) {
            String sessionElement = sessionEnumeration.nextElement();
            Object sessionValue = hSession.getAttribute(sessionElement);

            DEBUGGER.debug("Attribute: " + sessionElement + "; Value: " + sessionValue);
        }

        DEBUGGER.debug("Dumping request content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> requestEnumeration = hRequest.getAttributeNames();

        while (requestEnumeration.hasMoreElements()) {
            String requestElement = requestEnumeration.nextElement();
            Object requestValue = hRequest.getAttribute(requestElement);

            DEBUGGER.debug("Attribute: " + requestElement + "; Value: " + requestValue);
        }

        DEBUGGER.debug("Dumping request parameters:");
        @SuppressWarnings("unchecked")
        Enumeration<String> paramsEnumeration = hRequest.getParameterNames();

        while (paramsEnumeration.hasMoreElements()) {
            String requestElement = paramsEnumeration.nextElement();
            Object requestValue = hRequest.getParameter(requestElement);

            DEBUGGER.debug("Parameter: " + requestElement + "; Value: " + requestValue);
        }
    }

    // validate
    this.appConfig.getEmailValidator().validate(request, bindResult);

    if (bindResult.hasErrors()) {
        // errors occurred during validation
        ERROR_RECORDER.error("Form failed field validation");

        mView.addObject(Constants.ERROR_MESSAGE, this.appConfig.getMessageValidationFailed());
        mView.addObject("command", new SearchRequest());
        mView.setViewName(this.appConfig.getSearchRequestPage());

        if (DEBUG) {
            DEBUGGER.debug("ModelAndView: {}", mView);
        }

        return mView;
    }

    try {
        SearchResponse response = processor.doSiteSearch(request);

        if (DEBUG) {
            DEBUGGER.debug("SearchResponse: {}", response);
        }

        if (response.getRequestStatus() == CoreServicesStatus.SUCCESS) {
            mView.addObject("pages", (int) Math.ceil(response.getEntryCount() * 1.0 / this.recordsPerPage));
            mView.addObject("page", 1);
            mView.addObject("searchTerms", request.getSearchTerms());
            mView.addObject("searchResults", response.getResults());
            mView.setViewName(this.appConfig.getSearchRequestPage());
        } else {
            mView.addObject(Constants.MESSAGE_RESPONSE, response.getResponse());
            mView.setViewName(this.appConfig.getSearchRequestPage());
        }

        mView = new ModelAndView(new RedirectView());
        mView.setViewName(this.appConfig.getRequestCompletePage());
    } catch (SearchRequestException srx) {
        ERROR_RECORDER.error(srx.getMessage(), srx);

        mView = new ModelAndView(new RedirectView());
        mView.setViewName(this.appConfig.getErrorResponsePage());
    }

    if (DEBUG) {
        DEBUGGER.debug("ModelAndView: {}", mView);
    }

    return mView;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String read(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();
    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|read|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }//  ww  w .  ja  v a2  s.  c  om
    if (baseDBForm.getPrimaryId() == null || baseDBForm.getPrimaryId().equalsIgnoreCase("")) {
        addActionError("A record needs to be selected first to view details");
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + baseDBForm.getFormName() + "|read|Failure|No Primary Id for " + baseDBForm.getFormName()
                    + " object||");
        return ForwardConstants.READ_FAILURE;
    }
    try {
        UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession())
                .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER);
        baseDBForm.setRequest(request);
        baseDBForm.buildDisplayForm(userProvisioningManager);
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + baseDBForm.getFormName() + "|read|Failure|Error Reading the " + baseDBForm.getFormName()
                    + " object|" + "|" + cse.getMessage());
    }
    session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);
    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|read|Success|Success reading " + baseDBForm.getFormName()
                + " object|" + "|");

    return ForwardConstants.READ_SUCCESS;
}

From source file:fr.paris.lutece.plugins.directory.service.upload.DirectoryAsynchronousUploadHandler.java

/**
 * Add file item to the list of uploaded files
 * @param fileItem the file item/*  w  w  w.j a  v  a 2 s .  c o m*/
 * @param strIdEntry the id entry
 * @param session the session
 */
public void addFileItemToUploadedFile(FileItem fileItem, String strIdEntry, HttpSession session) {
    // This is the name that will be displayed in the form. We keep
    // the original name, but clean it to make it cross-platform.
    String strFileName = UploadUtil.cleanFileName(FileUploadService.getFileNameOnly(fileItem));

    // Check if this file has not already been uploaded
    List<FileItem> uploadedFiles = getFileItems(strIdEntry, session.getId());

    if ((uploadedFiles != null) && !uploadedFiles.isEmpty()) {
        Iterator<FileItem> iterUploadedFiles = uploadedFiles.iterator();
        boolean bNew = true;

        while (bNew && iterUploadedFiles.hasNext()) {
            FileItem uploadedFile = iterUploadedFiles.next();
            String strUploadedFileName = UploadUtil
                    .cleanFileName(FileUploadService.getFileNameOnly(uploadedFile));
            // If we find a file with the same name and the same
            // length, we consider that the current file has
            // already been uploaded
            bNew = !(strUploadedFileName.equals(strFileName) && (uploadedFile.getSize() == fileItem.getSize()));
        }

        if (!bNew) {
            // Delete the temporary file
            // file.delete(  );

            // TODO : Raise an error
        }
    }

    if (uploadedFiles != null) {
        uploadedFiles.add(fileItem);
    }
}

From source file:com.liferay.portal.util.HttpImpl.java

public String getCompleteURL(HttpServletRequest request) {
    StringBuffer sb = request.getRequestURL();

    if (sb == null) {
        sb = new StringBuffer();
    }/*from  ww  w .j a  va  2 s.  com*/

    if (request.getQueryString() != null) {
        sb.append(StringPool.QUESTION);
        sb.append(request.getQueryString());
    }

    String proxyPath = PortalUtil.getPathProxy();

    if (Validator.isNotNull(proxyPath)) {
        int x = sb.indexOf(Http.PROTOCOL_DELIMITER) + Http.PROTOCOL_DELIMITER.length();
        int y = sb.indexOf(StringPool.SLASH, x);

        sb.insert(y, proxyPath);
    }

    String completeURL = sb.toString();

    if (request.isRequestedSessionIdFromURL()) {
        HttpSession session = request.getSession();

        String sessionId = session.getId();

        completeURL = PortalUtil.getURLWithSessionId(completeURL, sessionId);
    }

    if (_log.isWarnEnabled()) {
        if (completeURL.contains("?&")) {
            _log.warn("Invalid url " + completeURL);
        }
    }

    return completeURL;
}

From source file:pivotal.au.se.gemfirexdweb.controller.AutoLoginController.java

@RequestMapping(value = "/autologin", method = RequestMethod.GET)
public String autologin(Model model, HttpSession session, HttpServletRequest request) throws Exception {
    logger.debug("Received request to auto login");
    ConnectionManager cm = ConnectionManager.getInstance();
    Connection conn;/*from  www  . ja  va  2 s  .c o m*/
    String username = null;
    String passwd = null;
    String url = null;

    try {
        username = fixRequestParam(request.getParameter("username"));
        passwd = fixRequestParam(request.getParameter("passwd"));
        url = fixRequestParam(request.getParameter("url"));

        logger.debug("username = " + username);
        logger.debug("passwd = " + passwd);
        logger.debug("url = " + url);

        if (username.trim().equals("")) {
            conn = AdminUtil.getNewConnection(url);
        } else {
            conn = AdminUtil.getNewConnection(url, username, passwd);
        }

        SQLFireJDBCConnection newConn = new SQLFireJDBCConnection(conn, url, new java.util.Date().toString(),
                username.trim().equals("") ? "APP" : username.toUpperCase());

        cm.addConnection(newConn, session.getId());

        session.setAttribute("user_key", session.getId());
        session.setAttribute("schema", username.trim().equals("") ? "APP" : username.toUpperCase());
        session.setAttribute("url", url);
        session.setAttribute("prefs", new UserPref());
        session.setAttribute("history", new LinkedList());

        Map<String, String> schemaMap = AdminUtil.getSchemaMap();

        // get schema count now
        schemaMap = QueryUtil.populateSchemaMap(conn, schemaMap,
                username.trim().equals("") ? "APP" : username.toUpperCase());

        session.setAttribute("schemaMap", schemaMap);

        // This will resolve to /WEB-INF/jsp/main.jsp
        return "main";
    } catch (Exception ex) {
        model.addAttribute("error", ex.getMessage());
        Login login = new Login();
        login.setUsername(username);
        login.setUrl(url);

        model.addAttribute("loginAttribute", login);
        // This will resolve to /WEB-INF/jsp/loginpage.jsp
        return "loginpage";
    }

}

From source file:cn.lhfei.fu.web.controller.SystemController.java

@RequestMapping(value = "/login", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
@Transactional// w  ww  .j  ava  2 s  . co  m
public @ResponseBody Map<String, Object> login(@RequestBody UserModel user, HttpSession session)
        throws Exception {
    UserSession userSession = null;

    String userId = user.getUserId();
    String passWord = user.getPassWord();

    if (StringUtils.isNotEmpty(userId) && StringUtils.isNotEmpty(passWord)) {
        User userEntity = identityService.login(userId, passWord);

        if (null != userEntity) { // check user name and password.
            user.setAliasName(userEntity.getAliasName());
            user.setBirthday(userEntity.getBirthday());
            user.setEmail(userEntity.getEmail());
            user.setGender(userEntity.getGender());
            user.setId(userEntity.getId());
            user.setPassWord(userEntity.getPassWord());
            user.setRoleId(userEntity.getRole().getRoleId());
            user.setUserId(userEntity.getUserId());
            user.setUserName(userEntity.getUserName());
            user.setUserType(userEntity.getUserType());

            // cached the current user login info.
            userSession = new UserSession(session.getId());
            userSession.setUser(user);
            session.setAttribute(USER_SESSION, userSession);

            // get current teaching period
            TeachingPeriods period = systemService.searchCurrentTeachingPeriods();
            session.setAttribute(CURRENT_ACADEMICYEAR_SEMESTER, period);
            //session.setAttribute(CURRENT_SEMESTER, period.getSemester());

            return JSONReturn.mapOK("0");

        } else {//userId and passWord not matched.
            return JSONReturn.mapError("\u7528\u6237\u540d\u548c\u5bc6\u7801\u4e0d\u5339\u914d!");
        }

    } else {// userId and passWord not entry.
        return JSONReturn.mapError("\u7528\u6237\u540d\u548c\u5bc6\u7801\u5fc5\u987b\u8f93\u5165!");
    }
}

From source file:com.redsqirl.auth.UserInfoBean.java

/**
 * login/*from  w ww.j a v a2  s. com*/
 * 
 * Method to validate permission of the user and call init.
 * 
 * @return String - success or failure
 * @author Igor.Souza
 */
public String login() {
    logger.warn("login");
    setMsnError(null);
    cancel = false;
    checkPassword = false;
    buildBackend = true;
    setAlreadySignedInOtherMachine(null);
    setAlreadySignedIn(null);
    String licenseKey = null;
    String licence = "";

    if (getUserName() == null || "".equals(getUserName())) {
        setMsnError(getMessageResources("login_error_user_required"));
        return "failure";
    }

    if (getPassword() == null || "".equals(getPassword())) {
        setMsnError(getMessageResources("login_error_password_required"));
        return "failure";
    }

    FacesContext fCtx = FacesContext.getCurrentInstance();
    ServletContext sc = (ServletContext) fCtx.getExternalContext().getContext();
    HttpSession session = (HttpSession) fCtx.getExternalContext().getSession(true);

    try {
        Connection conn = new Connection(hostname);
        conn.connect();

        if (conn.isAuthMethodAvailable(userName, "publickey")) {
            logger.debug("--> public key auth method supported by server");
        } else {
            logger.debug("--> public key auth method not supported by server");
        }
        if (conn.isAuthMethodAvailable(userName, "keyboard-interactive")) {
            logger.debug("--> keyboard interactive auth method supported by server");
        } else {
            logger.debug("--> keyboard interactive auth method not supported by server");
        }
        if (conn.isAuthMethodAvailable(userName, "password")) {
            logger.debug("--> password auth method supported by server");
        } else {
            logger.warn("--> password auth method not supported by server");
        }

        checkPassword = conn.authenticateWithPassword(userName, password);

        if (!checkPassword) {
            setMsnError("Authentication Error");
            setAlreadySignedInOtherMachine(null);

            logger.warn("Authentication Error");

            return "failure";
        }
        try {
            File licenseP = new File(WorkflowPrefManager.getPathSystemLicence());
            logger.warn("path licence " + WorkflowPrefManager.getPathSystemLicence());
            Properties props = new Properties();
            logger.warn(ProjectID.get());

            String[] value = ProjectID.get().trim().split("-");
            if (value != null && value.length > 1) {
                licenseKey = value[0].replaceAll("[0-9]", "") + value[value.length - 1];

                if (licenseP.exists()) {
                    props.load(new FileInputStream(licenseP));
                    logger.warn(props.toString());

                    licenseKey = licenseKey.replaceAll("[^A-Za-z0-9]", "").toLowerCase();
                    logger.warn(licenseKey);
                    licence = props.getProperty(licenseKey);
                } else {
                    setMsnError("Could not find license key");
                    logger.warn("Could not find license key");
                    invalidateSession();
                    return "failure";
                }

                if (licence == null || licence.isEmpty()) {
                    setMsnError("License key was empty");
                    logger.warn("License key was empty");
                    invalidateSession();
                    return "failure";
                }

                Decrypter decrypt = new Decrypter();
                decrypt.decrypt(licence);

                //setNumberCluster(decrypt.getNumberCluster());

                /*File file = new File(WorkflowPrefManager.getPathUsersFolder());
                int homes = 0;
                if(file.exists()){
                   homes = file.list().length;
                }*/

                Map<String, String> params = new HashMap<String, String>();

                //params.put(Decrypter.clusterNb, String.valueOf(homes));

                //params.put(Decrypter.mac, decrypt.getMACAddress());
                params.put(Decrypter.name, licenseKey);

                DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
                params.put(Decrypter.date, formatter.format(new Date()));

                if (!decrypt.validateExpiredKey(params)) {
                    setMsnError("License Key is expired");
                    logger.warn("License Key is expired");
                    invalidateSession();
                    return "failure";
                }

                boolean valid = decrypt.validateAllValuesSoft(params);

                if (!valid) {
                    setMsnError("License Key is Invalid");
                    logger.warn("License Key is Invalid");
                    invalidateSession();
                    return "failure";
                }

            } else {
                setMsnError("Project Version is Invalid");
                logger.warn("Project Version is Invalid");
                invalidateSession();
                return "failure";
            }

        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            setMsnError("Failed to get license");
            invalidateSession();
            return "failure";
        }

    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        invalidateSession();
        setMsnError("error - Please Contact Your Administrator");
        return "failure";
    }

    UsageRecordWriter usageRecordLog = new UsageRecordWriter(licence, userName);
    Map<String, UsageRecordWriter> sessionUsageRecordWriter = (Map<String, UsageRecordWriter>) sc
            .getAttribute("usageRecordLog");
    if (sessionUsageRecordWriter == null) {
        sessionUsageRecordWriter = new HashMap<String, UsageRecordWriter>();
    }
    sessionUsageRecordWriter.put(userName, usageRecordLog);
    sc.setAttribute("usageRecordLog", sessionUsageRecordWriter);

    @SuppressWarnings("unchecked")
    Map<String, HttpSession> sessionLoginMap = (Map<String, HttpSession>) sc.getAttribute("sessionLoginMap");

    HttpSession sessionLogin = sessionLoginMap.get(userName);
    if (sessionLogin != null) {

        logger.warn("validateSecondLogin sessionLogin");

        if (sessionLogin.getId().equals(session.getId())) {
            setAlreadySignedInOtherMachine(null);
            setAlreadySignedIn("twice");

            logger.warn("Already Authenticated twice");
            usageRecordLog().addError("ERROR LOGIN", "Already Authenticated twice");

            return "failure";
        } else if (forceSignIn.equalsIgnoreCase("T")) {
            //Invalidate the session
            invalidateSession(sessionLogin);
        } else {
            setAlreadySignedInOtherMachine("two");
            logger.warn("Already Authenticated two");
            usageRecordLog().addError("ERROR LOGIN", "Already Authenticated two");
            return "failure";
        }
    }

    logger.info("update progressbar");
    setValueProgressBar(5);

    logger.info("validateSecondLogin end");

    usageRecordLog().addSuccess("LOGIN");

    return init();
}