当前位置: 首页>>代码示例>>Java>>正文


Java UsernamePasswordAuthenticationToken.isAuthenticated方法代码示例

本文整理汇总了Java中org.springframework.security.authentication.UsernamePasswordAuthenticationToken.isAuthenticated方法的典型用法代码示例。如果您正苦于以下问题:Java UsernamePasswordAuthenticationToken.isAuthenticated方法的具体用法?Java UsernamePasswordAuthenticationToken.isAuthenticated怎么用?Java UsernamePasswordAuthenticationToken.isAuthenticated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.authentication.UsernamePasswordAuthenticationToken的用法示例。


在下文中一共展示了UsernamePasswordAuthenticationToken.isAuthenticated方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: signInUser

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //导入方法依赖的package包/类
public String signInUser(){

        boolean registered = userService.createUser(username, password);

        if(registered){

            UserDetails userDetails = userDetailsService.loadUserByUsername(username);
            UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
                    userDetails,
                    password,
                    userDetails.getAuthorities());

            authenticationManager.authenticate(token);

            if (token.isAuthenticated()) {
                SecurityContextHolder.getContext().setAuthentication(token);
            }

            return "/index.jsf";
        } else {
            return "/signin.jsf?error=true";
        }
    }
 
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:24,代码来源:SignInController.java

示例2: autoLogin

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //导入方法依赖的package包/类
@Override
public void autoLogin(String username, String password) {
    boolean isLogin = false;
    UserDetails userDetails = userDetailsService.loadUserByUsername(username);
    UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());

    authenticationManager.authenticate(usernamePasswordAuthenticationToken);

    if (usernamePasswordAuthenticationToken.isAuthenticated()) {
        SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
        isLogin = true;
    }

}
 
开发者ID:kuylim,项目名称:spring-boot-security-vaadin,代码行数:15,代码来源:SecurityImpl.java

示例3: autologin

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void autologin(final String username, final String password) {
    UserDetails userDetails = userDetailsService.loadUserByUsername(username);
    UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());

    authenticationManager.authenticate(usernamePasswordAuthenticationToken);

    if (usernamePasswordAuthenticationToken.isAuthenticated()) {
        SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
        logger.debug(String.format("Auto login %s successfully!", username));
    }
}
 
开发者ID:maugern,项目名称:QRcode-factory,代码行数:14,代码来源:SecurityServiceImpl.java

示例4: autologin

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; //导入方法依赖的package包/类
@Override
public void autologin(String username, String password) {
    UserDetails userDetails = userDetailsService.loadUserByUsername(username);
    UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());

    authenticationManager.authenticate(usernamePasswordAuthenticationToken);

    if (usernamePasswordAuthenticationToken.isAuthenticated()) {
        SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
        logger.debug(String.format("Auto login %s successfully!", username));
    }
}
 
开发者ID:bndynet,项目名称:web-framework-for-java,代码行数:13,代码来源:SecurityServiceImpl.java


注:本文中的org.springframework.security.authentication.UsernamePasswordAuthenticationToken.isAuthenticated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。