private void postLoginFailedEvent()

in src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java [1497:1528]


    private void postLoginFailedEvent(
            final HttpServletRequest request, final AuthenticationInfo authInfo, Exception reason) {
        // The reason for the failure may be useful to downstream subscribers.
        FAILURE_REASON_CODES reasonCode = FailureCodesMapper.getFailureReason(authInfo, reason);
        // if reason code is unknowm, it is problem some non-login related failure, so don't send the event
        if (reasonCode != FAILURE_REASON_CODES.UNKNOWN) {
            final Map<String, Object> properties = new HashMap<>();
            if (authInfo.getUser() != null) {
                properties.put(SlingConstants.PROPERTY_USERID, authInfo.getUser());
            }
            if (authInfo.getAuthType() != null) {
                properties.put(AuthenticationInfo.AUTH_TYPE, authInfo.getAuthType());
            }
            properties.put("reason_code", reasonCode.name());

            // allow extensions to supply additional properties
            final List<JakartaLoginEventDecorator> localList = this.jakartaLoginEventDecorators;
            for (final JakartaLoginEventDecorator decorator : localList) {
                decorator.decorateLoginFailedEvent(request, authInfo, properties);
            }
            final List<LoginEventDecorator> localListDep = this.loginEventDecorators;
            for (final LoginEventDecorator decorator : localListDep) {
                decorator.decorateLoginFailedEvent(
                        JakartaToJavaxRequestWrapper.toJavaxRequest(request), authInfo, properties);
            }

            EventAdmin localEA = this.eventAdmin;
            if (localEA != null) {
                localEA.postEvent(new Event(AuthConstants.TOPIC_LOGIN_FAILED, properties));
            }
        }
    }