本文整理匯總了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;
}