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


Java Authentication.getDetails方法代码示例

本文整理汇总了Java中org.acegisecurity.Authentication.getDetails方法的典型用法代码示例。如果您正苦于以下问题:Java Authentication.getDetails方法的具体用法?Java Authentication.getDetails怎么用?Java Authentication.getDetails使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.acegisecurity.Authentication的用法示例。


在下文中一共展示了Authentication.getDetails方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getRemoteUserObject

import org.acegisecurity.Authentication; //导入方法依赖的package包/类
/**
 * obtains the fully populated User object and its relationship to
 * Roles and privileges.
 * @return a fully populated wct User object, null is returned if no object found
 */
public static User getRemoteUserObject() {
	if(user!=null) {
		return user;
	}
    Authentication auth =  SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        return (User)auth.getDetails();
    }
    return null;
}
 
开发者ID:DIA-NZ,项目名称:webcurator,代码行数:16,代码来源:AuthUtil.java

示例3: sessionDestroyed

import org.acegisecurity.Authentication; //导入方法依赖的package包/类
public void sessionDestroyed(HttpSessionEvent event) {
    // Log the logout to the console.
       log.info("Detected Logout Event");
       
	// Get the Spring Application Context.
	WebApplicationContext ctx = ApplicationContextFactory.getWebApplicationContext();
       
	// We need to get the authentication context out of the 
       // event, as it doesn't necessarily exist through the
       // standard Acegi tools.
       String remoteUser = null;
       Authentication auth = null;        
       SecurityContext acegiCtx = (SecurityContext) event.getSession().getAttribute("ACEGI_SECURITY_CONTEXT");
       if( acegiCtx != null) {
           auth = acegiCtx.getAuthentication();
           if (auth != null) {
               remoteUser = auth.getName();
           }
       }
               
       if (remoteUser == null) {
           remoteUser = "[UNKNOWN]";
       }
	
	// Actions to perform on logout.
	lockManager = (LockManager) ctx.getBean("lockManager");
	lockManager.releaseLocksForOwner(remoteUser);
	
       if (auth != null) {
           Object blob = auth.getDetails();
           if (blob instanceof User) {
               User user = (User) auth.getDetails();
               Auditor auditor = (Auditor) ctx.getBean(Constants.BEAN_AUDITOR);
               auditor.audit(user, User.class.getName(), user.getOid(), Auditor.ACTION_LOGOUT, "User " + remoteUser + " has logged out.");        
           }
       
       
           SecurityContextHolder.clearContext();
           
           // logout for duration
           String sessionId = event.getSession().getId();
           LogonDurationDAO logonDurationDAO = (LogonDurationDAO) ctx.getBean(Constants.BEAN_LOGON_DURATION_DAO);
           logonDurationDAO.setLoggedOut(sessionId, new Date());
       }
               
       // Log the logout to the console.
       log.info("Detected Logout Event for: " + remoteUser);
}
 
开发者ID:DIA-NZ,项目名称:webcurator,代码行数:49,代码来源:AcegiLogoutListener.java

示例4: processFormSubmission

import org.acegisecurity.Authentication; //导入方法依赖的package包/类
@Override
protected ModelAndView processFormSubmission(HttpServletRequest req,
		HttpServletResponse resp, Object comm, BindException exc)
		throws Exception {
	
	ReportEmailCommand com = (ReportEmailCommand) comm;
	ModelAndView mav = new ModelAndView();
	
	if(com.getActionCmd().equals(ACTION_EMAIL)){
	
		OperationalReport operationalReport = (OperationalReport) req.getSession().getAttribute("operationalReport");

		// Get user's email address 
		// ...user
        String remoteUser = null;
        Authentication auth = null;        
        SecurityContext acegiCtx = (SecurityContext) req.getSession().getAttribute("ACEGI_SECURITY_CONTEXT");
        if( acegiCtx != null) {
            auth = acegiCtx.getAuthentication();
            if (auth != null) {
                remoteUser = auth.getName();
            }
        }
        // ...email address
        User user = (User) auth.getDetails();
        String userEmailAddress = user.getEmail(); 
				
        // Build attachment content
		String dataAttachment = operationalReport.getRendering(com.getFormat());
		
		// E-mail
		Mailable email = new Mailable();
		email.setRecipients(com.getRecipient());
		email.setSender(userEmailAddress);
		email.setSubject(com.getSubject());
		email.setMessage(com.getMessage());
		mailServer.send(email, 
				"report" + FileFactory.getFileExtension(com.getFormat()),
				FileFactory.getMIMEType(com.getFormat()),
				dataAttachment );
		
		log.debug("email sent:");
		log.debug("  from:" + userEmailAddress);
		log.debug("  format=" + com.getFormat());
		log.debug("  to=" + com.getRecipient());
		log.debug("  subject=" + com.getSubject());
		log.debug("  msg=" + com.getMessage());
	
		mav.setViewName("reporting-preview");
		
	} else {
		log.error("Did not get send request: " + com.getActionCmd());
		mav.setViewName("reporting-preview");
	}
	
	return mav;
			
}
 
开发者ID:DIA-NZ,项目名称:webcurator,代码行数:59,代码来源:ReportEmailController.java


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