相关疑难解决方法(0)

如何在spring security authenticated登录中获取用户输入的用户名和密码值

我在我的应用程序中使用Spring MVC,登录通过spring security进行身份验证.我的类中有以下两种方法UserServiceImpl.java,public UserDetails loadUserByUsername(String userName)抛出UsernameNotFoundException,DataAccessException {

        ApplicationTO applicationTO = null;
        try
            {
                applicationTO = applicationService.getApplicationTO(adminDomainName);
            }
        catch (ApplicationPropertyException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        UserTO userTO = getUserTO(applicationTO.getApplicationId(), userName);
        if (userTO == null)
            {
                throw new UsernameNotFoundException("user not found");
            }
        httpSession.setAttribute("userTO", userTO);
        return buildUserFromUserEntity(userTO);
    }


User buildUserFromUserEntity(UserTO userTO)
            {
                String username = userTO.getUsername();
                String password = userTO.getPassword();
                int userId = userTO.getUserId();
                int applicationId = userTO.getApplicationId();
                boolean enabled = userTO.isEnabled();
                boolean accountNonExpired = true;
                boolean …
Run Code Online (Sandbox Code Playgroud)

java security spring spring-mvc spring-security

2
推荐指数
1
解决办法
5352
查看次数

标签 统计

java ×1

security ×1

spring ×1

spring-mvc ×1

spring-security ×1