Example usage for org.apache.shiro.mgt AbstractRememberMeManager rememberIdentity

List of usage examples for org.apache.shiro.mgt AbstractRememberMeManager rememberIdentity

Introduction

In this page you can find the example usage for org.apache.shiro.mgt AbstractRememberMeManager rememberIdentity.

Prototype

public void rememberIdentity(Subject subject, AuthenticationToken token, AuthenticationInfo authcInfo) 

Source Link

Document

Remembers a subject-unique identity for retrieval later.

Usage

From source file:com.github.dactiv.fear.user.web.AccountController.java

License:Apache License

/**
 * ?//  w w  w. ja  v a2s  .  c  o  m
 *
 * @param entity              Map
 * @param redirectAttributes spring mvc ??
 *
 * @return ? json
 *
 * @throws IOException
 */
@RequestMapping("update-profile")
public String updateProfile(@RequestParam Map<String, Object> entity, RedirectAttributes redirectAttributes)
        throws IOException {
    // ?? shiro subject ?
    Subject subject = SecurityUtils.getSubject();
    Map<String, Object> user = Casts.cast(subject.getPrincipal());
    // ???
    user.putAll(entity);
    // ??
    Apis.invoke("accountService", "saveUser", user, null);

    DefaultSecurityManager securityManager = (DefaultSecurityManager) SecurityUtils.getSecurityManager();
    // ?????
    AbstractRememberMeManager rmm = (AbstractRememberMeManager) securityManager.getRememberMeManager();
    rmm.rememberIdentity(subject, null,
            new SimpleAuthenticationInfo(subject.getPrincipals(), user.get("password")));

    // ? subjectDao, ???
    securityManager.getSubjectDAO().save(subject);

    redirectAttributes.addFlashAttribute("message", "??.");

    return "redirect:/account/user-profile";
}