判断是否登录
User user = (User) SecurityUtils.getSubject().getPrincipal();
if (user != null) {
flag = true;
}
登出
Subject subject = SecurityUtils.getSubject();
subject.logout();
登陆
UsernamePasswordToken token = new UsernamePasswordToken(username, password, true, getIpAddress(request));
login(token);