1 line
4.7 KiB
JSON
1 line
4.7 KiB
JSON
{"repo": "air846/ai-agent", "files": {"chat-backend/src/main/java/com/example/chat/common/config/SensitivePropertyValidator.java": {"ab39cf4e940c562a20f5580e8cb6244aae2b132f": {"t": 1785745699.2675278, "n": 1537, "h": "11f255f62ed0b369", "c": "package com.example.chat.common.config;\n\nimport com.example.chat.module.ai.config.AiProperties;\nimport jakarta.annotation.PostConstruct;\nimport org.springframework.beans.factory.annotation.Value;\nimport org.springframework.stereotype.Component;\nimport org.springframework.util.StringUtils;\n\nimport java.nio.charset.StandardCharsets;\n\n@Component\npublic class SensitivePropertyValidator {\n\n @Value(\"${spring.datasource.password:}\")\n private String databasePassword;\n\n @Value(\"${jwt.secret:}\")\n private String jwtSecret;\n\n @Value(\"${ai.providers.deepseek.api-key:}\")\n private String deepSeekApiKey;\n\n private final AiProperties aiProperties;\n\n public SensitivePropertyValidator(AiProperties aiProperties) {\n this.aiProperties = aiProperties;\n }\n\n @PostConstruct\n public void validate() {\n require(databasePassword, \"APP_DB_PASSWORD\");\n require(jwtSecret, \"JWT_SECRET\");\n if (jwtSecret.getBytes(StandardCharsets.UTF_8).length < 32) {\n throw new IllegalStateException(\"JWT_SECRET must contain at least 32 bytes\");\n }\n\n AiProperties.ProviderConfig deepSeekConfig = aiProperties.getProviderConfig(\"deepseek\");\n if (deepSeekConfig != null && deepSeekConfig.isEnabled()) {\n require(deepSeekApiKey, \"DEEPSEEK_API_KEY\");\n }\n }\n\n private void require(String value, String propertyName) {\n if (!StringUtils.hasText(value)) {\n throw new IllegalStateException(propertyName + \" must be configured\");\n }\n }\n}\n"}, "7da94f6599f72dec2de351bc6428aab3402b4032": {"t": 1785755752.3357913, "n": 1537, "h": "11f255f62ed0b369", "c": "package com.example.chat.common.config;\n\nimport com.example.chat.module.ai.config.AiProperties;\nimport jakarta.annotation.PostConstruct;\nimport org.springframework.beans.factory.annotation.Value;\nimport org.springframework.stereotype.Component;\nimport org.springframework.util.StringUtils;\n\nimport java.nio.charset.StandardCharsets;\n\n@Component\npublic class SensitivePropertyValidator {\n\n @Value(\"${spring.datasource.password:}\")\n private String databasePassword;\n\n @Value(\"${jwt.secret:}\")\n private String jwtSecret;\n\n @Value(\"${ai.providers.deepseek.api-key:}\")\n private String deepSeekApiKey;\n\n private final AiProperties aiProperties;\n\n public SensitivePropertyValidator(AiProperties aiProperties) {\n this.aiProperties = aiProperties;\n }\n\n @PostConstruct\n public void validate() {\n require(databasePassword, \"APP_DB_PASSWORD\");\n require(jwtSecret, \"JWT_SECRET\");\n if (jwtSecret.getBytes(StandardCharsets.UTF_8).length < 32) {\n throw new IllegalStateException(\"JWT_SECRET must contain at least 32 bytes\");\n }\n\n AiProperties.ProviderConfig deepSeekConfig = aiProperties.getProviderConfig(\"deepseek\");\n if (deepSeekConfig != null && deepSeekConfig.isEnabled()) {\n require(deepSeekApiKey, \"DEEPSEEK_API_KEY\");\n }\n }\n\n private void require(String value, String propertyName) {\n if (!StringUtils.hasText(value)) {\n throw new IllegalStateException(propertyName + \" must be configured\");\n }\n }\n}\n"}, "4d01c2c0ecd1f6c71ced347293df25dfe90a6533": {"t": 1785755753.765204, "n": 1071, "h": "2992718c75b4a950", "c": "package com.example.chat.common.config;\n\nimport jakarta.annotation.PostConstruct;\nimport org.springframework.beans.factory.annotation.Value;\nimport org.springframework.stereotype.Component;\nimport org.springframework.util.StringUtils;\n\n@Component\npublic class SensitivePropertyValidator {\n\n @Value(\"${spring.datasource.password:}\")\n private String databasePassword;\n\n @Value(\"${jwt.secret:}\")\n private String jwtSecret;\n\n @Value(\"${ai.providers.deepseek.api-key:}\")\n private String deepSeekApiKey;\n\n @PostConstruct\n public void validate() {\n require(databasePassword, \"APP_DB_PASSWORD\");\n require(jwtSecret, \"JWT_SECRET\");\n require(deepSeekApiKey, \"DEEPSEEK_API_KEY\");\n if (jwtSecret.length() < 32) {\n throw new IllegalStateException(\"JWT_SECRET must contain at least 32 characters\");\n }\n }\n\n private void require(String value, String propertyName) {\n if (!StringUtils.hasText(value)) {\n throw new IllegalStateException(propertyName + \" must be configured\");\n }\n }\n}\n"}}}} |