本文整理汇总了Java中org.springframework.security.web.authentication.logout.LogoutHandler类的典型用法代码示例。如果您正苦于以下问题:Java LogoutHandler类的具体用法?Java LogoutHandler怎么用?Java LogoutHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LogoutHandler类属于org.springframework.security.web.authentication.logout包,在下文中一共展示了LogoutHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Can_add_a_logout_handler
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void Can_add_a_logout_handler() {
final LogoutFilter filter = mock(LogoutFilter.class);
final CaptureHandlers handlers = new CaptureHandlers();
// Given
willAnswer(handlers).given(mutator).update(eq(filter), eq("handlers"), eq(List.class), any(Updater.class));
// When
logoutHandlerAdder.modify(filter);
// Then
assertThat(handlers, contains((LogoutHandler) logoutHandler));
}
示例2: CommunoteLogoutFilter
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
/**
* Instantiates a new logout filter.
*
* @param logoutSuccessUrl
* the logout success url
* @param handlers
* the handlers
*/
public CommunoteLogoutFilter(final String logoutSuccessUrl, LogoutHandler[] handlers) {
super(new SimpleUrlLogoutSuccessHandler() {
{
setDefaultTargetUrl(logoutSuccessUrl);
setRedirectStrategy(new DefaultRedirectStrategy() {
@Override
public void sendRedirect(HttpServletRequest request,
HttpServletResponse response, String url) throws java.io.IOException {
if (url.startsWith("http://") || url.startsWith("https://")) {
throw new IllegalArgumentException(
"could not add client id to this uri: '" + url + "'");
}
// reset session values
SessionHandler.instance().resetOverriddenCurrentUserLocale(request);
ControllerHelper.sendInternalRedirect(request, response, url);
};
});
}
}, handlers);
}
示例3: doFilter
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
if (requiresLogout(request, response)) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (logger.isDebugEnabled()) {
logger.debug("Logging out user '" + auth + "' and transferring to logout destination");
}
for (LogoutHandler handler : handlers) {
handler.logout(request, response, auth);
}
response.setStatus(200);
jsonResponseHelper.writeResponseBody("Logged out", response);
return;
}
chain.doFilter(request, response);
}
示例4: modify
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void modify(final LogoutFilter filter) {
mutator.update(filter, "handlers", List.class, new Updater<List>() {
@Override
public List update(List oldHandlers) {
final List<LogoutHandler> handlers = new ArrayList<>(oldHandlers);
handlers.add(0, logoutHandler);
return asList(handlers.toArray(new LogoutHandler[handlers.size()]));
}
});
}
示例5: ApiLogoutFilter
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
/**
* Instantiates a new api logout filter.
*
* @param handlers
* the handlers
*/
public ApiLogoutFilter(LogoutHandler[] handlers) {
super(new SimpleUrlLogoutSuccessHandler() {
@Override
protected void handle(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
response.getWriter().write(
"{\"message\":\"User logged out successfully.\",\"status\":\"OK\"}");
super.handle(request, response, authentication);
}
}, handlers);
}
示例6: execute
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@Override
public void execute(ArtifactoryRestRequest request, RestResponse response) {
try {
Map<String, LogoutHandler> logoutHandlers = ContextHelper.get().beansForType(LogoutHandler.class);
tryToLogoutFromProviders(request, response, logoutHandlers);
}catch (Exception e){
log.debug("failed to perform session logout" , e);
}
}
示例7: tryToLogoutFromProviders
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
/**
* iterate security providers and try to logout
*
* @param artifactoryRequest - encapsulate data related to request
* @param artifactoryResponse - encapsulate data require for response
* @param logoutHandlers - map of logout handlers
*/
private void tryToLogoutFromProviders(ArtifactoryRestRequest artifactoryRequest,
RestResponse artifactoryResponse, Map<String, LogoutHandler> logoutHandlers) {
HttpServletRequest servletRequest = artifactoryRequest.getServletRequest();
HttpServletResponse servletResponse = artifactoryResponse.getServletResponse();
Authentication authentication = AuthenticationHelper.getAuthentication();
// logout from all providers
for (LogoutHandler logoutHandler : logoutHandlers.values()) {
logoutHandler.logout(servletRequest, servletResponse, authentication);
}
}
示例8: doFilterInternal
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
private void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws IOException, ServletException {
final String servletPath = RequestUtils.getServletPathFromRequest(request);
// add no cache header to web app request
RequestUtils.addNoCacheToWebAppRequest(servletPath, response);
String method = request.getMethod();
if ((servletPath == null || "/".equals(servletPath) || servletPath.length() == 0) &&
"get".equalsIgnoreCase(method)) {
//We were called with an empty path - redirect to the app main page
response.sendRedirect(HttpUtils.ANGULAR_WEBAPP + "/");
return;
}
//Reuse the authentication if it exists
Authentication authentication = RequestUtils.getAuthentication(request);
boolean isAuthenticated = authentication != null && authentication.isAuthenticated();
// Make sure this is called only once
boolean reAuthRequired = reAuthenticationRequired(request, authentication);
if (reAuthRequired) {
/**
* A re-authentication is required but we might still have data that needs to be invalidated (like the
* Wicket session)
*/
Map<String, LogoutHandler> logoutHandlers = ContextHelper.get().beansForType(LogoutHandler.class);
for (LogoutHandler logoutHandler : logoutHandlers.values()) {
logoutHandler.logout(request, response, authentication);
}
}
boolean authenticationRequired = !isAuthenticated || reAuthRequired;
SecurityContext securityContext = SecurityContextHolder.getContext();
if (authenticationRequired) {
if (authFilter.acceptFilter(request)) {
authenticateAndExecute(request, response, chain, securityContext);
} else {
useAnonymousIfPossible(request, response, chain, securityContext);
}
} else {
log.debug("Using authentication {} from Http session.", authentication);
useAuthentication(request, response, chain, authentication, securityContext);
}
}
示例9: init
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@Override
protected void init() {
HttpServletRequest servletRequest = WicketUtils.getHttpServletRequest();
HttpServletResponse servletResponse = WicketUtils.getHttpServletResponse();
Authentication authentication = AuthenticationHelper.getAuthentication();
Map<String, LogoutHandler> logoutHandlers = ContextHelper.get().beansForType(LogoutHandler.class);
for (LogoutHandler logoutHandler : logoutHandlers.values()) {
logoutHandler.logout(servletRequest, servletResponse, authentication);
}
super.init();
}
示例10: addLogoutFilter
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
private void addLogoutFilter(List<Filter> filters, MotechURLSecurityRule securityRule) {
if (securityRule.isRest()) {
return;
}
LogoutHandler springLogoutHandler = new SecurityContextLogoutHandler();
LogoutFilter logoutFilter = new LogoutFilter("/module/server/login", motechLogoutHandler, springLogoutHandler);
logoutFilter.setFilterProcessesUrl("/module/server/j_spring_security_logout");
filters.add(logoutFilter);
}
示例11: logoutHandler
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@Bean
public LogoutHandler logoutHandler() {
return new SecurityContextLogoutHandler();
}
示例12: getObject
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
public Collection<LogoutHandler> getObject() throws Exception {
return logoutHandlers;
}
示例13: setApplicationContext
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
logoutHandlers=applicationContext.getBeansOfType(LogoutHandler.class).values();
}
示例14: samlLogoutFilter
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@Bean
public SAMLLogoutFilter samlLogoutFilter() {
return new SAMLLogoutFilter(successLogoutHandler(),
new LogoutHandler[]{logoutHandler()},
new LogoutHandler[]{logoutHandler()});
}
示例15: samlLogoutFilter
import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@Bean
public SAMLLogoutFilter samlLogoutFilter() {
return new SAMLLogoutFilter(successLogoutHandler(),
new LogoutHandler[]{logoutHandler()},
new LogoutHandler[]{logoutHandler()});
}
开发者ID:choonchernlim,项目名称:spring-security-adfs-saml2,代码行数:7,代码来源:SAMLWebSecurityConfigurerAdapter.java