本文整理汇总了Java中org.acegisecurity.Authentication.isAuthenticated方法的典型用法代码示例。如果您正苦于以下问题:Java Authentication.isAuthenticated方法的具体用法?Java Authentication.isAuthenticated怎么用?Java Authentication.isAuthenticated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.acegisecurity.Authentication
的用法示例。
在下文中一共展示了Authentication.isAuthenticated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFilter
import org.acegisecurity.Authentication; //导入方法依赖的package包/类
/** @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) */
public void doFilter(ServletRequest aRequest, ServletResponse aResponse, FilterChain aChain) throws IOException, ServletException {
if (log.isDebugEnabled()) {
log.debug("Checking forced password change action.");
}
if (!(aRequest instanceof HttpServletRequest)) {
throw new ServletException("Can only process HttpServletRequest");
}
if (!(aResponse instanceof HttpServletResponse)) {
throw new ServletException("Can only process HttpServletResponse");
}
HttpServletRequest httpRequest = (HttpServletRequest) aRequest;
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
if (auth.isAuthenticated()) {
User authUser = (User)auth.getDetails();
if (authUser != null) {
if (authUser.isForcePasswordChange() == true && authUser.isExternalAuth() == false) {
RequestDispatcher reqDisp = httpRequest.getRequestDispatcher("/"+Constants.CNTRL_RESET_PWD);
reqDisp.forward(aRequest, aResponse);
auditor.audit(User.class.getName(),authUser.getOid(),Auditor.ACTION_FORCE_PWD_CHANGE,"User has been forced to change password");
}
}
}
else {
throw new AccessControlException("The user is not authenticated correctly.");
}
}
aChain.doFilter(aRequest, aResponse);
}
示例2: isLoggedIn
import org.acegisecurity.Authentication; //导入方法依赖的package包/类
/**
* Checks if the user is logged in and if the principal is a
* GitLabUserDetails object.
*
* @param auth the authentication object
* @return true if logged in and the principal object is a GitLabUserDetails object
*/
protected boolean isLoggedIn(Authentication auth) {
return auth.isAuthenticated() && auth.getPrincipal() instanceof GitLabUserDetails;
}