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


Java AuthenticationSuccessEvent类代码示例

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


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

示例1: onApplicationEvent

import org.springframework.security.event.authentication.AuthenticationSuccessEvent; //导入依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEvent event) {
  if (event instanceof AbstractAuthenticationFailureEvent) {
    onAuthenticationFailure((AbstractAuthenticationFailureEvent) event);
  }
  if (event instanceof AuthenticationSuccessEvent) {
    onAuthenticationSuccess((AuthenticationSuccessEvent) event);
  }
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:10,代码来源:AuthenticationEventListener.java

示例2: onAuthenticationSuccess

import org.springframework.security.event.authentication.AuthenticationSuccessEvent; //导入依赖的package包/类
protected void onAuthenticationSuccess(AuthenticationSuccessEvent event) {
  // on success - principal is a UserDetails
  UserDetails details = (UserDetails) event.getAuthentication().getPrincipal();
  String username = details.getUsername();
  if (!StringUtils.isBlank(username)) {
    Long orgId = organizationManager.getOrganization().getId();
    User user = userDao.findUserByOrganizationAndUsername(orgId, username);
    if (user != null) {
      user.setLoginFailureCount(0);
      userDao.persist(user);
    }
  }
}
 
开发者ID:vactowb,项目名称:jbehave-core,代码行数:14,代码来源:AuthenticationEventListener.java

示例3: testAuthenticationSuccessEventWithEverything

import org.springframework.security.event.authentication.AuthenticationSuccessEvent; //导入依赖的package包/类
public void testAuthenticationSuccessEventWithEverything() throws Exception {
    String userName = "bar";
    String ip = "1.2.3.4";
    String sessionId = "it tastes just like our regular coffee";
    
    HttpServletRequest request = createMock(HttpServletRequest.class);
    HttpSession session = createMock(HttpSession.class);
    expect(request.getRemoteAddr()).andReturn(ip);
    expect(request.getSession(false)).andReturn(session);
    expect(session.getId()).andReturn(sessionId);
    
    replay(request, session);
    WebAuthenticationDetails details = new WebAuthenticationDetails(request);
    verify(request, session);
    
    Authentication authentication = new TestingDetailsAuthenticationToken(userName, "cheesiness", new GrantedAuthority[0], details);
    AuthenticationSuccessEvent authEvent = new AuthenticationSuccessEvent(authentication);
    
    SecurityAuthenticationEventOnmsEventBuilder builder = new SecurityAuthenticationEventOnmsEventBuilder();
    builder.setEventProxy(m_eventProxy);
    builder.afterPropertiesSet();
    
    EventBuilder eventBuilder = new EventBuilder(SecurityAuthenticationEventOnmsEventBuilder.SUCCESS_UEI, "OpenNMS.WebUI");
    eventBuilder.addParam("user", userName);
    eventBuilder.addParam("ip", ip);
    
    m_eventProxy.send(EventEquals.eqEvent(eventBuilder.getEvent()));
    
    m_mocks.replayAll();
    builder.onApplicationEvent(authEvent);
    m_mocks.verifyAll();
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:33,代码来源:SecurityAuthenticationEventOnmsEventBuilderTest.java


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