下面列出了怎么用org.springframework.security.authentication.RememberMeAuthenticationToken的API类实例代码及写法,或者点击链接到github查看源代码。
private boolean rememberMeCheck() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
} else {
return false;
}
}
private boolean rememberMeCheck() {
Authentication auth=SecurityContextHolder.getContext().getAuthentication();
if(auth!=null){
return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
}
else
return false;
}
private boolean rememberMeCheck() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
} else
return false;
}
private boolean rememberMeCheck() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
} else
return false;
}
private boolean rememberMeCheck() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
} else {
return false;
}
}
private boolean rememberMeCheck() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
} else
return false;
}
private boolean rememberMeCheck() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
} else
return false;
}
private boolean rememberMeCheck() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
return (auth instanceof AnonymousAuthenticationToken || auth instanceof RememberMeAuthenticationToken);
} else
return false;
}
/**
* 判断用户是否从Remember Me Cookie自动登录
*
* @return
*/
private boolean isRememberMeAuthenticated() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return false;
}
return RememberMeAuthenticationToken.class.isAssignableFrom(authentication.getClass());
}
@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);
}
}
}
public static boolean isRememberMe(Authentication authentication) {
return authentication != null && authentication.getClass().isAssignableFrom(RememberMeAuthenticationToken.class);
}
public boolean isRemembered(Authentication authentication, String attribute) {
return IS_REMEMBERED.equals(attribute)
&& RememberMeAuthenticationToken.class
.isAssignableFrom(authentication.getClass());
}
@Test
public void testLogoutRememberMeAuthentication() throws Exception {
Authentication authentication = new RememberMeAuthenticationToken(UUID.randomUUID().toString(), UUID.randomUUID().toString(), authorities);
keycloakLogoutHandler.logout(request, response, authentication);
verifyZeroInteractions(session);
}