Search in sources :

Example 1 with AuthenticationCredentialsNotFoundEvent

use of org.springframework.security.access.event.AuthenticationCredentialsNotFoundEvent in project spring-boot by spring-projects.

the class AuthorizationAuditListenerTests method testAuthenticationCredentialsNotFound.

@Test
public void testAuthenticationCredentialsNotFound() {
    AuditApplicationEvent event = handleAuthorizationEvent(new AuthenticationCredentialsNotFoundEvent(this, Collections.<ConfigAttribute>singletonList(new SecurityConfig("USER")), new AuthenticationCredentialsNotFoundException("Bad user")));
    assertThat(event.getAuditEvent().getType()).isEqualTo(AuthenticationAuditListener.AUTHENTICATION_FAILURE);
}
Also used : AuthenticationCredentialsNotFoundEvent(org.springframework.security.access.event.AuthenticationCredentialsNotFoundEvent) AuthenticationCredentialsNotFoundException(org.springframework.security.authentication.AuthenticationCredentialsNotFoundException) ConfigAttribute(org.springframework.security.access.ConfigAttribute) SecurityConfig(org.springframework.security.access.SecurityConfig) AuditApplicationEvent(org.springframework.boot.actuate.audit.listener.AuditApplicationEvent) Test(org.junit.Test)

Example 2 with AuthenticationCredentialsNotFoundEvent

use of org.springframework.security.access.event.AuthenticationCredentialsNotFoundEvent in project spring-security by spring-projects.

the class AbstractSecurityInterceptor method credentialsNotFound.

/**
	 * Helper method which generates an exception containing the passed reason, and
	 * publishes an event to the application context.
	 * <p>
	 * Always throws an exception.
	 *
	 * @param reason to be provided in the exception detail
	 * @param secureObject that was being called
	 * @param configAttribs that were defined for the secureObject
	 */
private void credentialsNotFound(String reason, Object secureObject, Collection<ConfigAttribute> configAttribs) {
    AuthenticationCredentialsNotFoundException exception = new AuthenticationCredentialsNotFoundException(reason);
    AuthenticationCredentialsNotFoundEvent event = new AuthenticationCredentialsNotFoundEvent(secureObject, configAttribs, exception);
    publishEvent(event);
    throw exception;
}
Also used : AuthenticationCredentialsNotFoundException(org.springframework.security.authentication.AuthenticationCredentialsNotFoundException) AuthenticationCredentialsNotFoundEvent(org.springframework.security.access.event.AuthenticationCredentialsNotFoundEvent)

Aggregations

AuthenticationCredentialsNotFoundEvent (org.springframework.security.access.event.AuthenticationCredentialsNotFoundEvent)2 AuthenticationCredentialsNotFoundException (org.springframework.security.authentication.AuthenticationCredentialsNotFoundException)2 Test (org.junit.Test)1 AuditApplicationEvent (org.springframework.boot.actuate.audit.listener.AuditApplicationEvent)1 ConfigAttribute (org.springframework.security.access.ConfigAttribute)1 SecurityConfig (org.springframework.security.access.SecurityConfig)1