<commit_before>package com.forsrc.springmvc.restful.login.controller;


import com.forsrc.constant.KeyConstants;
import com.forsrc.constant.MyToken;
import com.forsrc.exception.NoSuchUserException;
import com.forsrc.exception.PasswordNotMatchException;
import com.forsrc.pojo.User;
import com.forsrc.springmvc.restful.login.service.LoginService;
import com.forsrc.springmvc.restful.login.validator.LoginValidator;
import com.forsrc.utils.MessageUtils;
import com.forsrc.utils.MyAesUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping(value = "/v1.0")
public class LoginController {

    @Autowired
    @Resource(name = "loginService")
    private LoginService loginService;

    @Autowired
    @Resource(name = "messageSource")
    protected MessageSource messageSource;

    private final String VERSION_V_1_0 = "v1.0";

    @RequestMapping(value = {"/login/getLoginToken"}, method = RequestMethod.POST)
    @ResponseBody
    public ModelAndView list(HttpServletRequest request,
                             HttpServletResponse response) {

        MyToken token = new MyToken();
        Map<String, String> message = new HashMap<String, String>();

        try {
            message.put("loginToken", MyAesUtils.encrypt(token.getAesKey(), token.getLoginToken()));
        } catch (MyAesUtils.AesException e) {
            throw new ArithmeticException(e.getMessage());
        }
        message.put("loginTokenTime", String.valueOf(token.getLoginTokenTime()));
        message.put("ai", token.getAesKey().getIv());
        message.put("ak", token.getAesKey().getKey());

        HttpSession session = request.getSession();
        session.setAttribute(KeyConstants.TOKEN.getKey(), token);
<commit_msg>[REF] refactoring<commit_after>package com.forsrc.springmvc.restful.login.controller;


import com.forsrc.constant.KeyConstants;
import com.forsrc.constant.MyToken;
import com.forsrc.exception.NoSuchUserException;
import com.forsrc.exception.PasswordNotMatchException;
import com.forsrc.pojo.User;
import com.forsrc.springmvc.restful.login.service.LoginService;
import com.forsrc.springmvc.restful.login.validator.LoginValidator;
import com.forsrc.utils.MessageUtils;
import com.forsrc.utils.MyAesUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping(value = "/v1.0")
public class LoginController {

    @Autowired
    @Resource(name = "loginService")
    private LoginService loginService;

    @Autowired
    @Resource(name = "messageSource")
    protected MessageSource messageSource;

    private final String VERSION_V_1_0 = "v1.0";

    @RequestMapping(value = {"/login/getLoginToken"}, method = RequestMethod.POST)
    @ResponseBody
    public ModelAndView getLoginToken(HttpServletRequest request,
                             HttpServletResponse response) {

        MyToken token = new MyToken();
        Map<String, String> message = new HashMap<String, String>();

        try {
            message.put("loginToken", MyAesUtils.encrypt(token.getAesKey(), token.getLoginToken()));
        } catch (MyAesUtils.AesException e) {
            throw new ArithmeticException(e.getMessage());
        }
        message.put("loginTokenTime", String.valueOf(token.getLoginTokenTime()));
        message.put("ai", token.getAesKey().getIv());
        message.put("ak", token.getAesKey().getKey());

        HttpSession session = request.getSession();
        session.setAttribute(KeyConstants.TOKEN.getKey(), token);

{'fraction_non_alphanumeric': 0.11052520565281586, 'fraction_numerical': 0.0025311115798354778, 'mean_word_length': 4.565727699530516, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2500760', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1322, 'n_words': 227}