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


Java LogoutHandler类代码示例

本文整理汇总了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));
}
 
开发者ID:shiver-me-timbers,项目名称:smt-spring-security-parent,代码行数:18,代码来源:JwtLogoutHandlerAdderTest.java

示例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);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:29,代码来源:CommunoteLogoutFilter.java

示例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);
}
 
开发者ID:skarpushin,项目名称:summerb,代码行数:25,代码来源:RestLogoutFilter.java

示例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()]));
        }
    });
}
 
开发者ID:shiver-me-timbers,项目名称:smt-spring-security-parent,代码行数:13,代码来源:JwtLogoutHandlerAdder.java

示例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);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:18,代码来源:ApiLogoutFilter.java

示例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);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:10,代码来源:LogoutService.java

示例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);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:18,代码来源:LogoutService.java

示例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);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:41,代码来源:AccessFilter.java

示例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();
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:13,代码来源:LogoutPage.java

示例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);
}
 
开发者ID:motech,项目名称:motech,代码行数:11,代码来源:SecurityRuleBuilder.java

示例11: logoutHandler

import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
@Bean
public LogoutHandler logoutHandler() {
    return new SecurityContextLogoutHandler();
}
 
开发者ID:helloworldtang,项目名称:sns-todo,代码行数:5,代码来源:FormLoginSecurityConfig.java

示例12: getObject

import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
public Collection<LogoutHandler> getObject() throws Exception {
	return logoutHandlers;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:4,代码来源:LogoutHandlerFactory.java

示例13: setApplicationContext

import org.springframework.security.web.authentication.logout.LogoutHandler; //导入依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	logoutHandlers=applicationContext.getBeansOfType(LogoutHandler.class).values();
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:4,代码来源:LogoutHandlerFactory.java

示例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()});
}
 
开发者ID:lhartikk,项目名称:spring-tsers-auth,代码行数:7,代码来源:WebSecurityConfig.java

示例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


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