{"record":{"id":"5515b116ff11aee6","repo":"apereo/cas","slug":"not-found-in-backing-file","errorCode":null,"errorMessage":" not found in backing file.","messagePattern":" not found in backing file\\.","errorType":"exception","errorClass":"AccountNotFoundException","httpStatus":null,"severity":"error","filePath":"support/cas-server-support-generic/src/main/java/org/apereo/cas/adaptors/generic/FileAuthenticationHandler.java","lineNumber":61,"sourceCode":"    public FileAuthenticationHandler(final String name,\n                                     final PrincipalFactory principalFactory,\n                                     final Resource fileName, final String separator) {\n        super(name, principalFactory, null);\n        this.fileName = fileName;\n        this.separator = separator;\n    }\n\n    @Override\n    protected AuthenticationHandlerExecutionResult authenticateUsernamePasswordInternal(final UsernamePasswordCredential transformedCredential,\n                                                                                        final String originalPassword) throws Throwable {\n        try {\n            if (this.fileName == null) {\n                throw new FileNotFoundException(\"Filename does not exist\");\n            }\n            val username = transformedCredential.getUsername();\n            val passwordOnRecord = getPasswordOnRecord(username);\n            if (StringUtils.isBlank(passwordOnRecord)) {\n                throw new AccountNotFoundException(username + \" not found in backing file.\");\n            }\n            if (matches(originalPassword, passwordOnRecord)) {\n                val principal = this.principalFactory.createPrincipal(username);\n                return createHandlerResult(transformedCredential, principal, new ArrayList<>());\n            }\n        } catch (final IOException e) {\n            throw new PreventedException(e);\n        }\n        throw new FailedLoginException();\n    }\n\n    /**\n     * Gets the password on record.\n     *\n     * @param username the username\n     * @return the password on record\n     * @throws IOException Signals that an I/O exception has occurred.\n     */","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-generic/src/main/java/org/apereo/cas/adaptors/generic/FileAuthenticationHandler.java#L43-L79","documentation":"FileAuthenticationHandler authenticates users against a plaintext file of username:password entries. It throws AccountNotFoundException with '<username> not found in backing file.' when getPasswordOnRecord(username) returns blank, i.e. no entry (or an empty password field) exists for that user in the configured file.","triggerScenarios":"authenticateUsernamePasswordInternal called with a credential whose transformed username has no matching line in this.fileName, or whose file entry has a blank password.","commonSituations":"Typo in username at login; user missing from the password file; file format deviation (wrong separator) so parsing yields a blank password; pointing at a stale/partial copy of the backing file; comment/whitespace lines confusing parsers.","solutions":["Verify the username exists as a line in the configured file (check exact spelling and case after any transformation)","Confirm the entry has a non-empty password field in the expected format (username:password)","Check cas.authn.accept.users / file resource config points to the current file and it is readable","If users are transient, switch to a handler backed by a database/LDAP instead of a static file"],"exampleFix":"// before (backing file)\njdoe:\n// after\njdoe:{plain}password123","handlingStrategy":"validation","validationCode":"// before authentication, ensure the user entry exists in the file\nboolean known = Files.lines(Path.of(fileName))\n    .anyMatch(line -> line.startsWith(username + \":\") && line.length() > username.length() + 1);","typeGuard":null,"tryCatchPattern":"try {\n    return handler.authenticate(credential);\n} catch (AccountNotFoundException e) {\n    // treat as unknown user; return generic invalid-credentials response\n}","preventionTips":["Keep the backing file format strictly username:password one per line","Provision users to the file automatically as part of account creation","Verify file path config points at the live, readable copy"],"tags":["authentication","file","user-not-found","account-lookup"],"backgroundTag":"user-not-found","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}