{"record":{"id":"882435d121ccc295","repo":"dromara/Sa-Token","slug":"http-digest-username-password","errorCode":null,"errorMessage":"全局 Http Digest 认证参数配置错误，格式应如：username:password","messagePattern":"全局 Http Digest 认证参数配置错误，格式应如：username:password","errorType":"validation","errorClass":"SaTokenException","httpStatus":null,"severity":"error","filePath":"sa-token-core/src/main/java/cn/dev33/satoken/httpauth/digest/SaHttpDigestTemplate.java","lineNumber":266,"sourceCode":"     * @param username 用户名\n     * @param password 密码\n     * @param realm 领域\n     */\n    public void check(String username, String password, String realm) {\n        check(new SaHttpDigestModel(username, password, realm));\n    }\n\n    /**\n     * 校验：根据全局配置参数，校验不通过抛出异常\n     */\n    public void check() {\n        String httpDigest = SaManager.getConfig().getHttpDigest();\n        if(SaFoxUtil.isEmpty(httpDigest)){\n            throw new SaTokenException(\"未配置全局 Http Digest 认证参数\");\n        }\n        String[] arr = httpDigest.split(\":\");\n        if(arr.length != 2){\n            throw new SaTokenException(\"全局 Http Digest 认证参数配置错误，格式应如：username:password\");\n        }\n        check(arr[0], arr[1]);\n    }\n\n\n\n    // ----------------- 过期方法 -----------------\n\n    /**\n     * 根据注解 ( @SaCheckHttpDigest ) 鉴权\n     *\n     * @param at 注解对象\n     */\n    @Deprecated\n    public void checkByAnnotation(SaCheckHttpDigest at) {\n\n        // 如果配置了 value，则以 value 优先\n        String value = at.value();","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-core/src/main/java/cn/dev33/satoken/httpauth/digest/SaHttpDigestTemplate.java#L248-L284","documentation":"SaTokenException thrown by SaHttpDigestTemplate.check() when the global 'httpDigest' config string does not split on ':' into exactly two parts. The config must be strictly 'username:password' — the implementation uses httpDigest.split(\":\") and requires arr.length == 2, so any extra or missing colon is rejected before authentication runs.","triggerScenarios":"Setting sa-token.http-digest to a value with zero colons (e.g. 'admin123') or two-plus colons (e.g. 'admin:pass:extra', or a password that itself contains ':' such as 'admin:p@ss:word'), then invoking the no-arg check().","commonSituations":"Password containing a colon makes the split produce 3 parts; typo like 'admin password' with a space instead of colon; copy-pasting a URL like 'http://...' into the value; trailing colon 'admin:'.","solutions":["Ensure the value is exactly one username, one colon, one password: sa-token.http-digest=admin:123456","If the password must contain a colon, do not use the global config — use @SaCheckHttpDigest(username=..., password=...) or call check(username, password) programmatically where both are separate strings","Double-check for typos, trailing colons, or accidental extra segments in the YAML/properties value"],"exampleFix":"# before\nsa-token:\n  http-digest: admin:p@ss:word   # password contains ':' -> arr.length==3 -> exception\n\n# after\nsa-token:\n  http-digest: admin:p@ssword    # colon-free password\n# or bypass global config:\n@SaCheckHttpDigest(username=\"admin\", password=\"p@ss:word\")","handlingStrategy":"validation","validationCode":"String httpDigest = SaManager.getConfig().getHttpDigest();\nboolean valid = httpDigest != null && httpDigest.split(\":\").length == 2;\nif (!valid) { /* reject config at startup */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the http-digest value strictly 'username:password' with exactly one colon","If the password contains ':', use per-annotation username/password attributes instead of global config","Validate security config format in a startup health check"],"tags":["http-digest","configuration","validation","sa-token"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}