{"record":{"id":"fa5c8c9e6463d0ee","repo":"dromara/Sa-Token","slug":"username-password-fa5c8c","errorCode":null,"errorMessage":"注解参数配置错误，格式应如：username:password","messagePattern":"注解参数配置错误，格式应如：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":288,"sourceCode":"\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();\n        if(SaFoxUtil.isNotEmpty(value)){\n            String[] arr = value.split(\":\");\n            if(arr.length != 2){\n                throw new SaTokenException(\"注解参数配置错误，格式应如：username:password\");\n            }\n            check(arr[0], arr[1]);\n            return;\n        }\n\n        // 如果配置了 username，则分别获取参数\n        String username = at.username();\n        if(SaFoxUtil.isNotEmpty(username)){\n            check(username, at.password(), at.realm());\n            return;\n        }\n\n        // 都没有配置，则根据全局配置参数进行校验\n        check();\n    }\n\n}\n","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-core/src/main/java/cn/dev33/satoken/httpauth/digest/SaHttpDigestTemplate.java#L270-L306","documentation":"SaTokenException thrown by the deprecated checkByAnnotation(SaCheckHttpDigest) when the annotation's value() attribute is non-empty but does not split on ':' into exactly two parts. The value attribute must be strictly 'username:password'; anything else is a compile-time-style configuration mistake caught at runtime.","triggerScenarios":"Annotating a method/class with @SaCheckHttpDigest(\"someValue\") where someValue has no colon or more than one colon. The value branch runs first (value takes priority over username/password attributes), so split(\":\").length != 2 throws immediately.","commonSituations":"Writing @SaCheckHttpDigest(\"admin password\") with a space; a password containing ':' supplied via value; misunderstanding that value must be 'user:pass' and instead putting a realm or role name there; upgrading from versions where the attribute semantics differed.","solutions":["Fix the annotation value to 'username:password' format, e.g. @SaCheckHttpDigest(\"admin:123456\")","If the password contains a colon, use the named attributes instead: @SaCheckHttpDigest(username=\"admin\", password=\"p@ss:word\") — the username branch does not split on ':'","Prefer the non-deprecated API path (current interceptor handles the annotation directly); verify against your sa-token version's docs"],"exampleFix":"// before\n@SaCheckHttpDigest(\"admin\")   // no colon -> split length 1 -> exception\n\n// after\n@SaCheckHttpDigest(\"admin:123456\")\n// or\n@SaCheckHttpDigest(username=\"admin\", password=\"123456\")","handlingStrategy":"validation","validationCode":"@SaCheckHttpDigest(\"admin:123456\") // value must contain exactly one ':'\n// programmatic check of an annotation before use:\nString[] parts = at.value().split(\":\");\nif (parts.length != 2) { /* reject */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write annotation values as 'username:password' with exactly one colon","Use named attributes (username=, password=) when credentials contain special characters","Cover annotation config with a startup smoke test that hits one protected endpoint"],"tags":["http-digest","annotation","configuration","sa-token"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}