當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。