类org.springframework.security.authentication.event.AbstractAuthenticationFailureEvent源码实例Demo

下面列出了怎么用org.springframework.security.authentication.event.AbstractAuthenticationFailureEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: airsonic-advanced   文件: GlobalSecurityConfig.java
@EventListener
public void loginFailureListener(AbstractAuthenticationFailureEvent event) {
    if (event.getSource() instanceof AbstractAuthenticationToken) {
        AbstractAuthenticationToken token = (AbstractAuthenticationToken) event.getSource();
        Object details = token.getDetails();
        if (details instanceof WebAuthenticationDetails) {
            LOG.info("Login failed from [{}]", ((WebAuthenticationDetails) details).getRemoteAddress());
        }
    }
}
 
源代码2 项目: smaker   文件: AuthenticationFailureEvenHandler.java
/**
 * Handle an application event.
 *
 * @param event the event to respond to
 */
@Override
public void onApplicationEvent(AbstractAuthenticationFailureEvent event) {
	AuthenticationException authenticationException = event.getException();
	Authentication authentication = (Authentication) event.getSource();

	handle(authenticationException, authentication);
}
 
源代码3 项目: airsonic   文件: LoginFailureListener.java
@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (event instanceof AbstractAuthenticationFailureEvent) {
        if (event.getSource() instanceof AbstractAuthenticationToken) {
            AbstractAuthenticationToken token = (AbstractAuthenticationToken) event.getSource();
            Object details = token.getDetails();
            if (details instanceof WebAuthenticationDetails) {
                LOG.info("Login failed from [" + ((WebAuthenticationDetails) details).getRemoteAddress() + "]");
            }
        }
    }

}
 
源代码4 项目: dhis2-core   文件: AuthenticationListener.java
@EventListener
public void handleAuthenticationFailure( AbstractAuthenticationFailureEvent event )
{
    Authentication auth = event.getAuthentication();

    if ( TwoFactorWebAuthenticationDetails.class.isAssignableFrom( auth.getDetails().getClass() ) )
    {
        TwoFactorWebAuthenticationDetails authDetails =
            ( TwoFactorWebAuthenticationDetails ) auth.getDetails();

        log.info( String.format( "Login attempt failed for remote IP: %s", authDetails.getIp() ) );
    }

    securityService.registerFailedLogin( auth.getName() );
}
 
源代码5 项目: dhis2-core   文件: AuthenticationLoggerListener.java
public void onApplicationEvent( AbstractAuthenticationEvent event )
{
    if ( log.isWarnEnabled() )
    {
        final StringBuilder builder = new StringBuilder();
        builder.append( "Authentication event " );
        builder.append( ClassUtils.getShortName( event.getClass() ) );
        builder.append( ": " );
        builder.append( event.getAuthentication().getName() );

        Object details = event.getAuthentication().getDetails();

        if ( ForwardedIpAwareWebAuthenticationDetails.class.isAssignableFrom( details.getClass() ) )
        {
            ForwardedIpAwareWebAuthenticationDetails authDetails = (ForwardedIpAwareWebAuthenticationDetails) details;
            String ip = authDetails.getIp();

            builder.append( "; ip: " );
            builder.append( ip );

            String sessionId = authDetails.getSessionId();
            if ( sessionId != null )
            {
                HashCode hash = Hashing.sha256().newHasher().putString( sessionId, Charsets.UTF_8 ).hash();
                builder.append( " sessionId: " );
                builder.append( hash.toString() );
            }

        }

        if ( event instanceof AbstractAuthenticationFailureEvent )
        {
            builder.append( "; exception: " );
            builder.append( ((AbstractAuthenticationFailureEvent) event).getException().getMessage() );
        }

        log.warn( builder.toString() );
    }
}
 
@Override
public void onApplicationEvent(AbstractAuthenticationFailureEvent event) {
    log.info("User Oauth2 login Failed, " + event.getException().getMessage());
}
 
@Override
public void onApplicationEvent(AbstractAuthenticationFailureEvent e) {
  GraviteeAuthenticationDetails auth = (GraviteeAuthenticationDetails)  e.getAuthentication().getDetails();
  LOGGER.warn("Authentication failed event for: " + e.getAuthentication().getPrincipal() + " - IP: " + auth.getRemoteAddress());
}
 
 类方法
 同包方法