Example usage for org.springframework.security.core.context SecurityContextHolder clearContext

List of usage examples for org.springframework.security.core.context SecurityContextHolder clearContext

Introduction

In this page you can find the example usage for org.springframework.security.core.context SecurityContextHolder clearContext.

Prototype

public static void clearContext() 

Source Link

Document

Explicitly clears the context value from the current thread.

Usage

From source file:org.vaadin.spring.samples.mvp.ui.component.listener.LogoutLinkListener.java

@Override
public void buttonClick(ClickEvent event) {
    SecurityContextHolder.clearContext();
    HasComponents parent = event.getComponent().getParent();
    String contextPath = VaadinServlet.getCurrent().getServletContext().getContextPath();
    String urlMapping = env.getProperty("vaadin.servlet.urlMapping");
    String uiPath = urlMapping.substring(0, urlMapping.length() - 2);
    String location = contextPath.concat(uiPath);
    parent.getUI().getPage().setLocation(location);
}

From source file:org.zaizi.sensefy.auth.IndexController.java

@RequestMapping("/logout")
public void logout() {
    SecurityContextHolder.clearContext();
}

From source file:example.company.MethodLevelSecurityTests.java

@Before
public void setUp() {
    SecurityContextHolder.clearContext();
}

From source file:com.application.utils.RequestHolderApplicationServlet.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    SecurityContextHolder.setContext(SecurityContextHolder.createEmptyContext());

    RequestHolder.setRequest(request);/* w w  w.  ja  v a2s .c  om*/

    super.service(request, response);

    // We remove the request from the thread local, there's no reason to keep it once the work is done
    RequestHolder.clean();

    SecurityContextHolder.clearContext();
}

From source file:org.opentides.util.SecurityUtilTest.java

@Before
public void init() {
    SecurityContextHolder.clearContext();
}

From source file:org.vader.common.cxf.SpringSecurityUsernameTokenValidator.java

@Override
protected void verifyPlaintextPassword(UsernameToken usernameToken, RequestData data)
        throws WSSecurityException {
    SecurityContextHolder.clearContext();

    final String login = usernameToken.getName();
    final String password = usernameToken.getPassword();
    if (StringUtils.isBlank(login) || StringUtils.isBlank(password)) {
        throw new WSSecurityException(
                String.format("Auth failed for login=[%s], password=[%s]", login, password));
    }//  w w  w. j  a  v a  2  s. c o  m

    try {
        final Authentication authentication = authenticationManager
                .authenticate(new UsernamePasswordAuthenticationToken(login, password));

        SecurityContextHolder.getContext().setAuthentication(authentication);
    } catch (AuthenticationException e) {
        throw new WSSecurityException(
                String.format("Auth failed for login=[%s], password=[%s]", login, password), e);
    }
}

From source file:com.cfs.backingbean.AutenticacaoBacking.java

public String deslogar() {
    SecurityContextHolder.clearContext();
    FacesContext.getCurrentInstance().getExternalContext().invalidateSession();

    return "/login.xhtml?faces-redirect=true";
}

From source file:org.jasig.springframework.security.portlet.authentication.PortletAuthenticationProcessingFilterTest.java

@After
@Before
public void clearContext() {
    SecurityContextHolder.clearContext();
}

From source file:com.epam.ta.reportportal.ws.BaseMvcTest.java

@After
public void teardown() {
    SecurityContextHolder.clearContext();
}

From source file:hsa.awp.admingui.AbstractSecurityTest.java

@After
public void clear() {
    SecurityContextHolder.clearContext();
}