Search in sources :

Example 11 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class OneTimePasswordController method genhotp.

@RequestMapping(value = { "gen/hotp" })
public ModelAndView genhotp() {
    UserInfo userInfo = WebContext.getUserInfo();
    byte[] byteSharedSecret = OtpSecret.generate(otpKeyUriFormat.getCrypto());
    String sharedSecret = Base32Utils.encode(byteSharedSecret);
    sharedSecret = passwordReciprocal.encode(sharedSecret);
    userInfo.setSharedSecret(sharedSecret);
    userInfo.setSharedCounter("0");
    userInfoService.updateSharedSecret(userInfo);
    WebContext.setUserInfo(userInfo);
    return WebContext.redirect("/safe/otp/hotp");
}
Also used : UserInfo(org.maxkey.entity.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class OneTimePasswordController method gencounterbased.

@RequestMapping(value = { "gen/counterbased" })
public ModelAndView gencounterbased() {
    UserInfo userInfo = WebContext.getUserInfo();
    byte[] byteSharedSecret = OtpSecret.generate(otpKeyUriFormat.getCrypto());
    String sharedSecret = Base32Utils.encode(byteSharedSecret);
    sharedSecret = passwordReciprocal.encode(sharedSecret);
    userInfo.setSharedSecret(sharedSecret);
    userInfo.setSharedCounter("0");
    userInfoService.updateSharedSecret(userInfo);
    WebContext.setUserInfo(userInfo);
    return WebContext.redirect("/safe/otp/counterbased");
}
Also used : UserInfo(org.maxkey.entity.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class ProfileController method forwardBasic.

@RequestMapping(value = { "/myProfile" })
public ModelAndView forwardBasic() {
    ModelAndView modelAndView = new ModelAndView("profile/myProfile");
    UserInfo userInfo = userInfoService.findByUsername(WebContext.getUserInfo().getUsername());
    userInfo.transPictureBase64();
    // HashMap<String,Object>extraAttributeMap=new HashMap<String,Object>();
    // extraAttributeMap=(HashMap<String,Object>)JsonUtils.json2Object(userInfo.getExtraAttribute(),extraAttributeMap);
    // modelAndView.addObject("extraAttributeMap", extraAttributeMap);
    // _logger.info("extraAttributeMap : "+extraAttributeMap);
    // 
    modelAndView.addObject("model", userInfo);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) UserInfo(org.maxkey.entity.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class RegisterController method registeron.

// 直接注册
@RequestMapping(value = { "/registeron" })
@ResponseBody
public Message registeron(UserInfo userInfo, @RequestParam String emailMobile) throws ServletException, IOException {
    if (StringUtils.isEmpty(emailMobile)) {
        return new Message(WebContext.getI18nValue("register.emailMobile.error"), "1");
    }
    if (StringUtils.isValidEmail(emailMobile)) {
        userInfo.setEmail(emailMobile);
    }
    if (StringUtils.isValidMobileNo(emailMobile)) {
        userInfo.setMobile(emailMobile);
    }
    if (!(StringUtils.isValidEmail(emailMobile) || StringUtils.isValidMobileNo(emailMobile))) {
        return new Message(WebContext.getI18nValue("register.emailMobile.error"), "1");
    }
    UserInfo temp = userInfoService.findByEmailMobile(emailMobile);
    if (temp != null) {
        return new Message(WebContext.getI18nValue("register.emailMobile.exist"), "1");
    }
    temp = userInfoService.findByUsername(userInfo.getUsername());
    if (temp != null) {
        return new Message(WebContext.getI18nValue("register.user.error"), "1");
    }
    // default InstId
    if (StringUtils.isEmpty(userInfo.getInstId())) {
        userInfo.setInstId("1");
    }
    userInfo.setStatus(ConstsStatus.ACTIVE);
    if (userInfoService.insert(userInfo)) {
        return new Message(WebContext.getI18nValue("login.text.register.success"), "0");
    }
    return new Message(WebContext.getI18nValue("login.text.register.error"), "1");
}
Also used : Message(org.maxkey.web.message.Message) UserInfo(org.maxkey.entity.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with UserInfo

use of org.maxkey.entity.UserInfo in project MaxKey by dromara.

the class SafeController method changeInitPassword.

@RequestMapping(value = "/changeInitPassword")
public ModelAndView changeInitPassword(@RequestParam(value = "oldPassword", required = false) String oldPassword, @RequestParam(value = "newPassword", required = false) String newPassword, @RequestParam(value = "confirmPassword", required = false) String confirmPassword) {
    ModelAndView modelAndView = new ModelAndView("passwordInitial");
    if (newPassword == null || newPassword.equals("")) {
    } else if (userInfoService.changePassword(oldPassword, newPassword, confirmPassword, ConstsPasswordSetType.PASSWORD_NORMAL)) {
        WebContext.getSession().setAttribute(WebConstants.CURRENT_USER_PASSWORD_SET_TYPE, ConstsPasswordSetType.PASSWORD_NORMAL);
        return WebContext.redirect("/index");
    }
    Object errorMessage = WebContext.getAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT);
    modelAndView.addObject("errorMessage", errorMessage == null ? "" : errorMessage);
    UserInfo userInfo = WebContext.getUserInfo();
    modelAndView.addObject("model", userInfo);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) UserInfo(org.maxkey.entity.UserInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

UserInfo (org.maxkey.entity.UserInfo)85 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)42 ModelAndView (org.springframework.web.servlet.ModelAndView)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)15 Message (org.maxkey.web.message.Message)8 Date (java.util.Date)7 HashMap (java.util.HashMap)7 Operation (io.swagger.v3.oas.annotations.Operation)6 ConstsOperateMessage (org.maxkey.constants.ConstsOperateMessage)6 Accounts (org.maxkey.entity.Accounts)6 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)6 SigninPrincipal (org.maxkey.authn.SigninPrincipal)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ServiceResponseBuilder (org.maxkey.authz.cas.endpoint.response.ServiceResponseBuilder)4 AbstractAuthorizeAdapter (org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter)4 SynchroRelated (org.maxkey.entity.SynchroRelated)4 NamingException (javax.naming.NamingException)3 ProxyServiceResponseBuilder (org.maxkey.authz.cas.endpoint.response.ProxyServiceResponseBuilder)3 Ticket (org.maxkey.authz.cas.endpoint.ticket.Ticket)3 Apps (org.maxkey.entity.apps.Apps)3