org.springframework.security.authentication.RememberMeAuthenticationToken Java Examples

The following examples show how to use org.springframework.security.authentication.RememberMeAuthenticationToken. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HomeController.java    From Spring with Apache License 2.0 5 votes vote down vote up
private boolean rememberMeCheck() {
	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	if (auth != null) {
		return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
	} else {
		return false;
	}
}
 
Example #2
Source File: HomeController.java    From Spring with Apache License 2.0 5 votes vote down vote up
private boolean rememberMeCheck() {
	Authentication auth=SecurityContextHolder.getContext().getAuthentication();
	if(auth!=null){
		return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
	}
	else
	return false;
}
 
Example #3
Source File: HomeController.java    From Spring with Apache License 2.0 5 votes vote down vote up
private boolean rememberMeCheck() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
    } else
        return false;
}
 
Example #4
Source File: HomeController.java    From Spring with Apache License 2.0 5 votes vote down vote up
private boolean rememberMeCheck() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
    } else
        return false;
}
 
Example #5
Source File: HomeController.java    From Spring with Apache License 2.0 5 votes vote down vote up
private boolean rememberMeCheck() {
	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	if (auth != null) {
		return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
	} else {
		return false;
	}
}
 
Example #6
Source File: HomeController.java    From Spring with Apache License 2.0 5 votes vote down vote up
private boolean rememberMeCheck() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
    } else
        return false;
}
 
Example #7
Source File: HomeController.java    From Spring with Apache License 2.0 5 votes vote down vote up
private boolean rememberMeCheck() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
    } else
        return false;
}
 
Example #8
Source File: HomeController.java    From Spring with Apache License 2.0 5 votes vote down vote up
private boolean rememberMeCheck() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
    } else
        return false;
}
 
Example #9
Source File: IndexController.java    From spring-boot-cookbook with Apache License 2.0 5 votes vote down vote up
/**
 * 判断用户是否从Remember Me Cookie自动登录
 *
 * @return
 */
private boolean isRememberMeAuthenticated() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication == null) {
        return false;
    }
    return RememberMeAuthenticationToken.class.isAssignableFrom(authentication.getClass());
}
 
Example #10
Source File: FlowableCookieFilter.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
    if (!skipAuthenticationCheck(request)) {
        RemoteToken token = getValidToken(request);
        if (token != null) {
            try {
                FlowableAppUser appUser = userCache.get(token.getUserId());
                if (!validateRequiredPriviliges(request, response, appUser)) {
                    redirectOrSendNotPermitted(request, response, appUser.getUserObject().getId());
                    return; // no need to execute any other filters
                }
                SecurityContextHolder.getContext().setAuthentication(new RememberMeAuthenticationToken(token.getId(),
                    appUser, appUser.getAuthorities()));

            } catch (Exception e) {
                LOGGER.trace("Could not set necessary threadlocals for token", e);
                redirectOrSendNotPermitted(request, response, token.getUserId());
            }
            if (filterCallback != null) {
                filterCallback.onValidTokenFound(request, response, token);
            }
        } else {
            redirectOrSendNotPermitted(request, response, null);
            return; // no need to execute any other filters
        }
    }

    try {
        filterChain.doFilter(request, response);
    } finally {
        if (filterCallback != null) {
            filterCallback.onFilterCleanup(request, response);
        }
    }
}
 
Example #11
Source File: SecurityUtils.java    From zhcet-web with Apache License 2.0 4 votes vote down vote up
public static boolean isRememberMe(Authentication authentication) {
    return authentication != null && authentication.getClass().isAssignableFrom(RememberMeAuthenticationToken.class);
}
 
Example #12
Source File: AuthenticatedVoter.java    From lemon with Apache License 2.0 4 votes vote down vote up
public boolean isRemembered(Authentication authentication, String attribute) {
    return IS_REMEMBERED.equals(attribute)
            && RememberMeAuthenticationToken.class
                    .isAssignableFrom(authentication.getClass());
}
 
Example #13
Source File: KeycloakLogoutHandlerTest.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Test
public void testLogoutRememberMeAuthentication() throws Exception {
    Authentication authentication = new RememberMeAuthenticationToken(UUID.randomUUID().toString(), UUID.randomUUID().toString(), authorities);
    keycloakLogoutHandler.logout(request, response, authentication);
    verifyZeroInteractions(session);
}