本文整理汇总了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;
}
示例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();
}
示例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.
}
示例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";
}
示例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;
}
示例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";
}
示例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";
}
示例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;
}
示例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";
}
示例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";
}
示例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";
}
示例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:/";
}
示例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;
}