{"record":{"id":"fbc88e1203dea09e","repo":"apereo/cas","slug":"username-not-found-in-backing-map","errorCode":null,"errorMessage":"${username} not found in backing map.","messagePattern":"(.+?) not found in backing map\\.","errorType":"exception","errorClass":"AccountNotFoundException","httpStatus":null,"severity":"error","filePath":"core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/AcceptUsersAuthenticationHandler.java","lineNumber":67,"sourceCode":"                                            final PrincipalFactory principalFactory, final Integer order,\n                                            final Map<String, String> users) {\n        super(name, principalFactory, order);\n        this.users = users;\n    }\n\n    @Override\n    protected AuthenticationHandlerExecutionResult authenticateUsernamePasswordInternal(\n        final UsernamePasswordCredential credential,\n        @Nullable final String originalPassword) throws Throwable {\n\n        if (this.users == null || this.users.isEmpty()) {\n            throw new FailedLoginException(\"No user can be accepted because none is defined\");\n        }\n        val username = credential.getUsername();\n        val cachedPassword = this.users.get(username);\n        if (cachedPassword == null) {\n            LOGGER.debug(\"[{}] was not found in the map.\", username);\n            throw new AccountNotFoundException(username + \" not found in backing map.\");\n        }\n        if (!Strings.CS.equals(credential.toPassword(), cachedPassword)) {\n            throw new FailedLoginException();\n        }\n        val strategy = getPasswordPolicyHandlingStrategy();\n        if (strategy != null && StringUtils.isNotBlank(username)) {\n            LOGGER.debug(\"Attempting to examine and handle password policy via [{}]\", strategy.getClass().getSimpleName());\n            val principal = this.principalFactory.createPrincipal(username);\n            val messageList = strategy.handle(principal, getPasswordPolicyConfiguration());\n            return createHandlerResult(credential, principal, messageList);\n        }\n        throw new FailedLoginException(\"Unable to authenticate \" + credential.getId());\n    }\n}\n","sourceCodeStart":49,"sourceCodeEnd":82,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/AcceptUsersAuthenticationHandler.java#L49-L82","documentation":"AcceptUsersAuthenticationHandler throws AccountNotFoundException when the submitted username is not a key in its configured users map. Unlike a password failure, this reports that the account does not exist in the static backing map at all.","triggerScenarios":"authenticateUsernamePasswordInternal is called with a username absent from the users map loaded from cas.authn.accept.users (or the bean's map), e.g. typo in username, case-sensitive mismatch, or user never provisioned in the property.","commonSituations":"End users typing usernames not present in the static list; case sensitivity differences (map keys are exact); environments where the static user list is out of date versus the real user directory.","solutions":["Add the user to cas.authn.accept.users in the form username::password","Check exact spelling and case of the submitted username","If users should come from a directory, migrate from the static handler to LDAP/JDBC authentication"],"exampleFix":"// before\ncas.authn.accept.users=casuser::Mellon  # user 'alice' not listed\n// after\ncas.authn.accept.users=casuser::Mellon|alice::alicePassword","handlingStrategy":"validation","validationCode":"// before submitting credentials\nboolean known = casProperties.getAuthn().getAccept().getUsers().keySet().stream()\n    .anyMatch(u -> u.equals(submittedUsername));\nif (!known) { throw new IllegalArgumentException(\"Username not provisioned in accept-users map\"); }","typeGuard":null,"tryCatchPattern":"try {\n    handlerResult = acceptUsersHandler.authenticate(credential, service);\n} catch (AccountNotFoundException e) {\n    LOGGER.warn(\"Unknown user [{}] for static handler\", credential.getUsername());\n}","preventionTips":["Provision every expected user in cas.authn.accept.users with exact spelling and case","Remember map lookup is case-sensitive","Migrate to LDAP/JDBC if the user set is dynamic"],"tags":["java","authentication","user-not-found"],"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"}