Spring Security SAML - Cannot catch UserNameNotFound Exception

359 views Asked by At

I've throw UserNameNotFound Exception in my SAMLUserDetailsService. But it still call my AuthenticationSuccessHandler when user is not in DB.

Do you have any idea on this issue? This is a part of my loadUserBySAML method

            String userName = nameValue.trim();
            AppUser domainUser = userRepository.findByAppUserNm(userName);

            if (domainUser == null) {
                logger.info("User is null");

                throw new UsernameNotFoundException("User is not in the DB");

            } else {
                boolean enabled = true;
                boolean accountNonExpired = true;
                boolean credentialsNonExpired = true;
                boolean accountNonLocked = true;

                return new User(domainUser.getAppUserNm(), domainUser.getAppUserPwdTxt().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired,
                        accountNonLocked, getAuthorities(userName));
            }
0

There are 0 answers