Rev 22627 | Blame | Compare with Previous | Last modification | View Log | RSS feed
/****/package in.shop2020.inventory.controllers;import in.shop2020.serving.auth.InventoryAuthorizingRealm;import in.shop2020.thrift.clients.HelperClient;import in.shop2020.utils.HelperService.Client;import javax.servlet.http.Cookie;import org.apache.shiro.SecurityUtils;import org.apache.shiro.crypto.hash.Sha256Hash;import org.apache.struts2.convention.annotation.Result;import org.apache.thrift.TException;/*** @author mandeep* This class manages all the login related updates for a user.*/@Result(name="loginPage", location="/login.html")public class LoginController extends BaseController {/****/private static final long serialVersionUID = 1L;private String password;public String updatePassword() throws TException{Client helperClient = new HelperClient().getClient();helperClient.updatePasswordForAgent(SecurityUtils.getSubject().getPrincipal().toString(), new Sha256Hash(password).toHex());addActionMessage("Password changed successfully!");// Dummy call to reload agentsInventoryAuthorizingRealm.getAgent(-1);return INDEX;}public String logout(){log.info("Logging out!");SecurityUtils.getSubject().logout();Cookie[] cookies = request.getCookies();for (Cookie cookie : cookies) {cookie.setMaxAge(0);cookie.setValue(null);cookie.setPath("/inventory");response.addCookie(cookie);}return "loginPage";}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public static void main(String[] args) {System.out.println(new Sha256Hash("neeraj@123").toHex());}}