Example usage for javax.servlet.http HttpSession setAttribute

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

Introduction

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

Prototype

public void setAttribute(String name, Object value);

Source Link

Document

Binds an object to this session, using the name specified.

Usage

From source file:com.digitalizat.control.TaclController.java

@RequestMapping(value = "doLogin")
public @ResponseBody User doLogin(@RequestParam(value = "user", required = true) String user,
        @RequestParam(value = "pwd", required = true) String pwd, HttpServletRequest request) throws Exception {
    System.out.println("HomeController: Passing through...");

    User usuarioALogar = aclManager.getUser(user);

    MessageDigest mda = MessageDigest.getInstance("SHA-512");
    byte[] digesta = mda.digest(pwd.getBytes());
    if (!usuarioALogar.getPassword().equals(toHexadecimal(digesta))) {
        throw new Exception("La contrasenya no es correcta");
    }/*  www.  jav a 2  s. c o m*/

    HttpSession sesion = request.getSession();

    sesion.setAttribute("logged", true);
    sesion.setAttribute("user", usuarioALogar);
    sesion.setAttribute("acronimo", usuarioALogar.getEmail());

    return usuarioALogar;
}

From source file:com.tsg.cms.HomeController.java

@RequestMapping(value = { "/", "/home" }, method = RequestMethod.GET)
public String displayHomePage(Model model, HttpSession session) {

    String homePage = staticPageDao.getHomePageLink();
    if (homePage == null) {
        session.setAttribute("page", "blog");
        session.setAttribute("js_page", "blog.js");
        return "home";

    } else {/*from w w  w.  j a  v  a 2s.com*/

        return "redirect:/pagelink/" + homePage;
    }

}

From source file:com.virtusa.akura.staff.controller.StaffDetailsLoadController.java

/**
 * Get the search staff id and set it to admin details to view the search staff details.
 *
 * @param request - HttpServletRequest/*from w  w w.  jav a  2  s .c o  m*/
 * @param session - HttpSession
 * @param model - ModelMap
 * @return view of student details
 */
@RequestMapping(value = LOAD_STAFF_DETAILS)
public String loadData(HttpServletRequest request, HttpSession session, ModelMap model) {

    if (request.getParameter(STAFF_ID) != null) {
        int staffId = Integer.parseInt(request.getParameter(STAFF_ID));
        session.setAttribute(STAFF_ID, staffId);
    }

    return REDIRECT_VIEW_STAFF_MEMBER_DETAILS;
}

From source file:architecture.ee.web.community.struts2.action.SocialConnectAction.java

public String getAuthorizationUrl() throws NotFoundException {
    SocialNetwork socialNetworkToUse = getSocialNetwork();
    if (socialNetworkToUse.getSocialServiceProvider().getMedia() == Media.TUMBLR) {
        Token requestToken = socialNetworkToUse.getSocialServiceProvider().getOAuthService().getRequestToken();
        HttpSession session = request.getSession(true);
        session.setAttribute(OAUTH_SECRET_KEY, requestToken.getSecret());
        return socialNetworkToUse.getSocialServiceProvider().getOAuthService()
                .getAuthorizationUrl(requestToken);
    } else {//w w  w . ja  va2s  .  com
        return socialNetworkToUse.getAuthorizationUrl();
    }
}

From source file:br.edu.ifrn.pdscfyp.Controller.MainController.java

@RequestMapping(value = "/logon", method = RequestMethod.POST)
public String logon(HttpSession session, @RequestParam("login") String login,
        @RequestParam("senha") String senha) {

    Usuario u = Usuario.login(login, senha);
    session.setAttribute("usuarioLogado", u);

    if (u != null) {
        return "redirect:mapa";
    } else {/* w  ww  . j a v a2s.c o  m*/
        session.setAttribute("jaPassou", true);
        session.setAttribute("falhaLogin", "algumacoisa");
        return "redirect:index";
    }
}

From source file:com.sourcesense.alfresco.opensso.AlfrescoFacade.java

protected void populateSession(HttpSession httpSess, User user) {
    httpSess.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user);
    httpSess.setAttribute(LoginBean.LOGIN_EXTERNAL_AUTH, Boolean.TRUE);
}

From source file:csjobs.security.AuthenticationSuccessHandler.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws ServletException, IOException {

    System.out.println("Insidees");
    //User user = (User) authentication.getPrincipal();

    /* RequestCache requestCache = new HttpSessionRequestCache();
     SavedRequest savedRequest = requestCache.getRequest( request, response );
     if( savedRequest != null )//from   w w w .j  a  v  a2 s  .c o m
     {
     super.onAuthenticationSuccess( request, response, authentication );
     return;
     }*/
    HttpSession session = request.getSession(true);

    String email = authentication.getName();
    User user = userDao.getUser(email);
    session.setAttribute("authenticatedUser", user);
    if (user.isAdmin()) {
        response.sendRedirect("admin.html");
    } else if (user.isReviewer()) {
        response.sendRedirect("reviewer.html");
    }

    else {

        response.sendRedirect("applicant.html");
    }
}

From source file:mx.com.quadrum.contratos.controller.service.user.ClientesController.java

@ResponseBody
@RequestMapping(value = "/aceptoErrores", method = RequestMethod.POST)
public String aceptoErrores(Model model, HttpSession session) {
    session.setAttribute("error", false);
    session.setAttribute("errores", null);
    return "";
}

From source file:org.katzorke.cage.CageController.java

@RequestMapping("/cage/gcaptcha")
public void gcaptcha(HttpSession session, HttpServletResponse response) throws IOException {
    CaptchaToken captchaToken = new CaptchaToken(gcage.getTokenGenerator().next());
    session.setAttribute("gcageToken", captchaToken);
    OutputStream os = response.getOutputStream();
    try {//from www  .j a  v  a 2s.c o m
        gcage.draw(captchaToken.token, os);
    } finally {
        os.close();
    }
}

From source file:org.katzorke.cage.CageController.java

@RequestMapping("/cage/ycaptcha")
public void ycaptcha(HttpSession session, HttpServletResponse response) throws IOException {
    CaptchaToken captchaToken = new CaptchaToken(ycage.getTokenGenerator().next());
    session.setAttribute("ycageToken", captchaToken);
    OutputStream os = response.getOutputStream();
    try {//  ww w  .  j a va2  s .c  om
        ycage.draw(captchaToken.token, os);
    } finally {
        os.close();
    }
}