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


Java Authentication.isAuthenticated方法代码示例

本文整理汇总了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);
}
 
开发者ID:DIA-NZ,项目名称:webcurator,代码行数:38,代码来源:WCTForcePasswordChange.java

示例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;
}
 
开发者ID:enil,项目名称:gitlab-auth-plugin,代码行数:11,代码来源:GitLabAbstractACL.java


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