class LoginFilter(url: String, authManager: AuthenticationManager) : AbstractAuthenticationProcessingFilter(AntPathRequestMatcher(url)) { init { authenticationManager = authManager } override fun attemptAuthentication(request: HttpServletRequest?, response: HttpServletResponse?): Authentication { val userCredentials: UserCredentials = jacksonObjectMapper() .readValue(request!!.inputStream) // this part throws exception return authenticationManager.authenticate( UsernamePasswordAuthenticationToken( userCredentials.userName, userCredentials.password, emptyList() ) ) } // ... }