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


Java AuthenticationSuccessEvent.getAuthentication方法代码示例

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


在下文中一共展示了AuthenticationSuccessEvent.getAuthentication方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleAuthenticationSuccessEvent

import org.springframework.security.authentication.event.AuthenticationSuccessEvent; //导入方法依赖的package包/类
/**
 * Обрабатывает событие успешной аутентификации
 *
 * @param event событие
 */
private void handleAuthenticationSuccessEvent(AuthenticationSuccessEvent event) {
    if (LOG.isInfoEnabled()) {
        Authentication authentication = event.getAuthentication();

        String commonMessage = String.format(
                SUCCESS_TEMPLATE,
                DateUtil.formatDateTime(new Date(event.getTimestamp())),
                extractPrincipal(authentication),
                StringUtils.collectionToCommaDelimitedString(authentication.getAuthorities())
        );
        String detailsMessage = (authentication.getDetails() != null) ? OBJECT_HEX_PATTERN.matcher(authentication.getDetails().toString()).replaceAll("") : null;
        String resultMessage = StringUtils.hasText(detailsMessage) ? String.format(DETAILS_TEMPLATE, commonMessage, detailsMessage) : commonMessage;

        LOG.info(resultMessage);
    }
}
 
开发者ID:hflabs,项目名称:perecoder,代码行数:22,代码来源:AuthenticationEventListener.java

示例2: loginSuccess

import org.springframework.security.authentication.event.AuthenticationSuccessEvent; //导入方法依赖的package包/类
public void loginSuccess(AuthenticationSuccessEvent event) {
    Authentication authentication = event.getAuthentication();
    update(authentication.getPrincipal(), true);
}
 
开发者ID:maxdelo77,项目名称:replyit-master-3.2-final,代码行数:5,代码来源:AuthenticationResultHandler.java

示例3: onApplicationEvent

import org.springframework.security.authentication.event.AuthenticationSuccessEvent; //导入方法依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEvent event) {
    if(event instanceof AuthenticationSuccessEvent) {
        AuthenticationSuccessEvent successEvent =
                (AuthenticationSuccessEvent) event;
        final Authentication authentication = successEvent.getAuthentication();
        final OpenAMUserdetails details = (OpenAMUserdetails) authentication.getDetails();
        final String nickname = details.getUsername();

        Query query = new Query();
        query.addCriteria(Criteria.where("nickName").is(nickname));

        final String surname = details.getAttributeValue("sn");
        final String givenname = details.getAttributeValue("givenname");
        final String email = details.getAttributeValue("mail");

        Update update = new Update();
        update.set("email", email);
        update.set("givenName", givenname);
        update.set("surName", surname);
        update.set("lastLogin", new Date());
        try {
            update.set("gravatar", User.md5Hex(email));
        } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
            LOGGER.error("Failed while calculating gravatar hash!");
        }

        final User user = mongoTemplate.findAndModify(query, update, FindAndModifyOptions.options().upsert(true).returnNew(true), User.class);
        if (user != null) {
            LOGGER.debug("LoginEvent for user: " + user.toString());
        } else {
            LOGGER.debug("Upsert didn't return new user!");
        }
    }
}
 
开发者ID:jalieven,项目名称:sarcasmotron,代码行数:36,代码来源:LoginEventHandler.java

示例4: onApplicationEvent

import org.springframework.security.authentication.event.AuthenticationSuccessEvent; //导入方法依赖的package包/类
public void onApplicationEvent(ApplicationEvent event) {
		if (event instanceof AuthenticationSuccessEvent) { 
			try { 
				AuthenticationSuccessEvent success = (AuthenticationSuccessEvent) event; 
				Authentication auth = success.getAuthentication(); 
//				LOG.debug("LoginLog auth = " + auth.toString());

				Object principal = auth.getPrincipal();
				if (!(principal instanceof EgovUserDetails) ) {
					return;
				} 
				
				EgovUserDetails details = (EgovUserDetails) principal;
				LoginVO loginVO = (LoginVO) details.getEgovUserVO();

				String uniqId = "unknown";
				String ip = "";
				if( loginVO != null ) {
					uniqId = loginVO.getUniqId();
					ip = loginVO.getIp();
				}

				if( "127.0.0.1".equals(ip)) return;
				
				if (LOG.isDebugEnabled()) {
					LOG.debug("Execute login log!!");
				}
				
				LoginLogVO loginLogVO = new LoginLogVO();
				loginLogVO.setLoginId(uniqId);
				loginLogVO.setLoginIp(ip);
				loginLogVO.setLoginMthd("I"); // 로그인:I, 로그아웃:O
				loginLogVO.setErrOccrrAt("N");
				loginLogVO.setErrorCode("");
				loginLogService.logInsertLoginLog(loginLogVO);

			} catch(Exception Ex) {
				LOG.error("Error !! " + Ex.getMessage());
			}
		}
	}
 
开发者ID:aramsoft,项目名称:aramcomp,代码行数:42,代码来源:LoginLogListener.java


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