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


Java SecurityContextLogoutHandler类代码示例

本文整理汇总了Java中org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler的典型用法代码示例。如果您正苦于以下问题:Java SecurityContextLogoutHandler类的具体用法?Java SecurityContextLogoutHandler怎么用?Java SecurityContextLogoutHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SecurityContextLogoutHandler类属于org.springframework.security.web.authentication.logout包,在下文中一共展示了SecurityContextLogoutHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLoggedInUser

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
protected IUser getLoggedInUser() {
    if(this.loggedInUser != null) {
        return this.loggedInUser;
    }

    IUser user = null;
    try {
        final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        if(auth == null) {
            LOGGER.warn(() -> "Failed to determine loggedIn User!");

        } else {
            final String email = auth.getName(); // get logged in email
            user = serviceUser.findUserByEmail(email);
            if(user == null) {
                // Perhaps the user's email has been changed ..?
                // we need force them to be logged-out
                new SecurityContextLogoutHandler().setClearAuthentication(true);
                LOGGER.warn(() -> "Failed to determine loggedIn User!");
            }
        }
    } catch(final Exception e) {
        LOGGER.error(() -> e.getMessage(), e);
    }
    return user;
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:27,代码来源:ControllerAbstract.java

示例2: configure

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
/**
 * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configure(org.springframework.security.config.annotation.web.builders.HttpSecurity)
 */
@Override
protected void configure(HttpSecurity http) throws Exception {
	http.exceptionHandling()
			.authenticationEntryPoint(casEntryPoint())
			.and()
		.authorizeRequests()
			.antMatchers(ConstanteUtils.SECURITY_CONNECT_PATH+"/**").authenticated()
			.antMatchers("/**").permitAll()
			.antMatchers(ConstanteUtils.SECURITY_SWITCH_PATH).hasAuthority(NomenclatureUtils.DROIT_PROFIL_ADMIN)
			.antMatchers(ConstanteUtils.SECURITY_SWITCH_BACK_PATH).hasAuthority(SwitchUserFilter.ROLE_PREVIOUS_ADMINISTRATOR)
			.anyRequest().authenticated()
			.and()
		.addFilterBefore(singleSignOutFilter(), LogoutFilter.class)
		.addFilter(new LogoutFilter(casUrl + ConstanteUtils.SECURITY_LOGOUT_PATH, new SecurityContextLogoutHandler()))
		.addFilter(casAuthenticationFilter())
		.addFilterAfter(switchUserFilter(), FilterSecurityInterceptor.class)
		/* La protection Spring Security contre le Cross Scripting Request Forgery est désactivée, Vaadin implémente sa propre protection */
		.csrf().disable()
		.headers()
			/* Autorise l'affichage en iFrame */
			.frameOptions().disable()
			/* Supprime la gestion du cache du navigateur, pour corriger le bug IE de chargement des polices cf. http://stackoverflow.com/questions/7748140/font-face-eot-not-loading-over-https */
			.cacheControl().disable();
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:28,代码来源:SecurityConfig.java

示例3: logoutPage

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logoutPage(HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        new SecurityContextLogoutHandler().logout(request, response, auth);
    }
    return "redirect:/login?logout";//You can redirect wherever you want, but generally it's a good practice to show login screen again.
}
 
开发者ID:toeasy,项目名称:spring-boot-boilerplate,代码行数:9,代码来源:MainController.java

示例4: logoutPage

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@RequestMapping(value="/logout", method = RequestMethod.GET)
public String logoutPage (HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();

    if (auth != null) {
        new SecurityContextLogoutHandler().logout(request, response, auth);
    }

    return "redirect:/login?logout";
}
 
开发者ID:kplachkov,项目名称:KPBlog,代码行数:11,代码来源:UserController.java

示例5: MainResource

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@Inject
public MainResource(ApplicationContext applicationContext,
                    List<SocialNetwork> networks,
                    SecurityContextLogoutHandler securityContextLogoutHandler,
                    AccountRepository accountRepository,
                    EntityRepository entityRepository,
                    CommandMetadataRepository commandMetadataRepository,
                    EmoteMetadataRepository emoteMetadataRepository,
                    CapabilityRepository capabilityRepository,
                    WorldManager worldManager,
                    EntityService entityService,
                    Emote emote,
                    @Qualifier("worldExtent") int worldExtent) {

    this.WORLD_EXTENT = worldExtent;
    this.applicationContext = applicationContext;
    this.networks = networks;
    this.securityContextLogoutHandler = securityContextLogoutHandler;
    this.accountRepository = accountRepository;
    this.entityRepository = entityRepository;
    this.commandMetadataRepository = commandMetadataRepository;
    this.emoteMetadataRepository = emoteMetadataRepository;
    this.capabilityRepository = capabilityRepository;
    this.worldManager = worldManager;
    this.entityService = entityService;
    this.emote = emote;
}
 
开发者ID:scionaltera,项目名称:emergentmud,代码行数:28,代码来源:MainResource.java

示例6: configure

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@Override
public void configure(HttpSecurity http) throws Exception {
    http.logout()
        .permitAll()
        .logoutSuccessUrl("/logout.html")
        .logoutRequestMatcher(new AntPathRequestMatcher("/logout"));
    String logoutUrl = UriComponentsBuilder
            .fromUri(casSecurityProperties.getServer().getBaseUrl())
            .path(casSecurityProperties.getServer().getPaths().getLogout())
            .toUriString();
    LogoutFilter filter = new LogoutFilter(logoutUrl, new SecurityContextLogoutHandler());
    filter.setFilterProcessesUrl("/cas/logout");
    http.addFilterBefore(filter, LogoutFilter.class);
}
 
开发者ID:kakawait,项目名称:cas-security-spring-boot-starter,代码行数:15,代码来源:CasSecuritySpringBootSampleApplication.java

示例7: logout

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logout(HttpServletRequest request,
		HttpServletResponse response) {
	Authentication auth = SecurityContextHolder.getContext()
			.getAuthentication();

	if (auth != null) {
		new SecurityContextLogoutHandler().logout(request, response, auth);
		request.getSession().invalidate();
	}
	return "redirect:/";
}
 
开发者ID:ilagaba,项目名称:https-github.com-in28minutes-SpringMvcStepByStep,代码行数:13,代码来源:LogoutController.java

示例8: logout

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
/**
 * This method handles logout requests.
 * Toggle the handlers if you are RememberMe functionality is useless in your app.
 */
@RequestMapping(value="/admin/logout", method = RequestMethod.GET)
public String logout(HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null){
        new SecurityContextLogoutHandler().logout(request, response, auth);
        SecurityContextHolder.getContext().setAuthentication(null);
    }
    return "redirect:/admin/login";
}
 
开发者ID:realxujiang,项目名称:itweet-boot,代码行数:14,代码来源:LoginController.java

示例9: loginOut

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@GetMapping("/logout")
public String loginOut(HttpServletRequest request, HttpServletResponse response){
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null){
        new SecurityContextLogoutHandler().logout(request, response, auth);
    }
    return "redirect:/login";
}
 
开发者ID:ronger-x,项目名称:player,代码行数:9,代码来源:LoginController.java

示例10: logout

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@RequestMapping(value = "/userlogout", method = GET)
public String logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        new SecurityContextLogoutHandler().logout(request, response, auth);
    }
    URL url = new URL(request.getRequestURL().toString());
    String urlStr = url.getProtocol() + "://" + url.getAuthority();
    return "redirect:" + ssoServiceUrl + "/logout.do?redirect=" + urlStr + "&clientId=" + clientId;
}
 
开发者ID:bijukunjummen,项目名称:oauth-uaa-sample,代码行数:11,代码来源:SampleController.java

示例11: logout

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@RequestMapping(value = "/secure/logout", method = RequestMethod.GET)
public String logout(HttpServletRequest request,
		HttpServletResponse response) {
	Authentication auth = SecurityContextHolder.getContext()
			.getAuthentication();

	if (auth != null) {
		new SecurityContextLogoutHandler().logout(request, response, auth);
		request.getSession().invalidate();
	}
	return "redirect:/secure/welcome";
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Spring-5.0,代码行数:13,代码来源:LogoutController.java

示例12: logoutPage

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@RequestMapping(value="/logout", method = RequestMethod.GET)
public String logoutPage (HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null){    
        new SecurityContextLogoutHandler().logout(request, response, auth);
    }
    return "redirect:/login?logout";
}
 
开发者ID:ruyangit,项目名称:angit,代码行数:9,代码来源:LoginController.java

示例13: logoutPage

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@RequestMapping(value="/logout", method = RequestMethod.GET)
public String logoutPage(HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();

    if(auth != null) {
        new SecurityContextLogoutHandler().logout(request, response, auth);
    }

    return "redirect:/login?logout";
}
 
开发者ID:kostovhg,项目名称:SoftUni,代码行数:11,代码来源:UserController.java

示例14: logoutPage

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
@GetMapping("/logout")
public String logoutPage (HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null){
        new SecurityContextLogoutHandler().logout(request, response, auth);
    }
    Cookie[] cookies = request.getCookies();
    for(int i = 0,len = cookies.length; i < len; i++) {
        Cookie cookie = new Cookie(cookies[i].getName(),null);
        cookie.setMaxAge(0);
        cookie.setPath("/");
        response.addCookie(cookie);
    }
    return "redirect:/";
}
 
开发者ID:hulvyou,项目名称:spring-cloud-template,代码行数:16,代码来源:LoginController.java

示例15: casLogoutFilter

import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; //导入依赖的package包/类
/**
 * Request single point exit filter
 */
@Bean
public LogoutFilter casLogoutFilter() {
    LogoutFilter logoutFilter = new LogoutFilter(
            casServerLogout,
            new SecurityContextLogoutHandler());
    logoutFilter.setFilterProcessesUrl("/logout");
    return logoutFilter;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:12,代码来源:CasConfig.java


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