mirror of
https://github.com/hpd840321/craftlabs-authorization-sdk.git
synced 2026-06-09 10:00:30 +08:00
feat(sdk): AuthConfigs, JSON Schema, examples, and release checksum CI
Add craftlabs-auth-config.schema.json, Java AuthConfigs model with tests, example configs aligned to BP-10, C/Java/auth-config documentation, native header notes, RELEASING guide, and workflow to verify SDK artifact checksums on release tags. Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"provider": "bitanswer",
|
||||
"scenario": "floating",
|
||||
"bitanswer": {
|
||||
"url": "https://cloud.bitanswer.example/e3",
|
||||
"loginMode": "REMOTE"
|
||||
},
|
||||
"features": {
|
||||
"face": { "bitanswerFeatureId": 301 }
|
||||
},
|
||||
"floating": {
|
||||
"projectId": "migrant-flow-prj-2026-001",
|
||||
"projectName": "某市流动人口人像核验",
|
||||
"contractRef": "PO-2026-8848"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"provider": "bitanswer",
|
||||
"scenario": "school",
|
||||
"bitanswer": {
|
||||
"url": "https://cloud.bitanswer.example/e3",
|
||||
"loginMode": "AUTO",
|
||||
"sn": ""
|
||||
},
|
||||
"features": {
|
||||
"face": { "bitanswerFeatureId": 201 },
|
||||
"expression": { "bitanswerFeatureId": 202 }
|
||||
},
|
||||
"school": {
|
||||
"edgeDeviceId": "classroom-gate-01",
|
||||
"tenantId": "school-district-demo"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"provider": "selfhosted",
|
||||
"scenario": "school",
|
||||
"selfhosted": {
|
||||
"baseUrl": "https://license.internal.example/api/v1",
|
||||
"tenantKey": "district-west"
|
||||
},
|
||||
"features": {
|
||||
"face": {},
|
||||
"expression": {}
|
||||
},
|
||||
"school": {
|
||||
"edgeDeviceId": "gate-02"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"provider": "bitanswer",
|
||||
"scenario": "wharf",
|
||||
"bitanswer": {
|
||||
"url": "bit://license.example.com:8273",
|
||||
"loginMode": "AUTO",
|
||||
"rootPath": "/var/lib/craftlabs/bitanswer"
|
||||
},
|
||||
"features": {
|
||||
"container_number_detect": { "bitanswerFeatureId": 101 },
|
||||
"container_number_recognize": { "bitanswerFeatureId": 102 },
|
||||
"iso_detect": { "bitanswerFeatureId": 103 },
|
||||
"iso_recognize": { "bitanswerFeatureId": 104 }
|
||||
},
|
||||
"wharf": {
|
||||
"topology": "group",
|
||||
"groupServiceUrl": "bit://license.example.com:8273",
|
||||
"notes": "边设备集中连集团服务;特征项与控制台产品一致后替换 id。"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
import cn.craftlabs.auth.AuthProvider;
|
||||
import cn.craftlabs.auth.AuthResult;
|
||||
import cn.craftlabs.auth.bitanswer.BitAnswerProvider;
|
||||
import cn.craftlabs.auth.config.AuthConfig;
|
||||
import cn.craftlabs.auth.config.AuthConfigException;
|
||||
import cn.craftlabs.auth.config.AuthConfigs;
|
||||
|
||||
/**
|
||||
* 演示:通过 {@link BitAnswerProvider} 完成初始化与许可校验。
|
||||
* 演示:校验 {@code config_json} 后初始化并完成许可校验。
|
||||
*
|
||||
* <p>编译时需将 {@code craftlabs-auth-core} 与 Jackson 置于 classpath(与 Maven 模块依赖一致)。
|
||||
*
|
||||
* <p>版权所有 © 广州创飞人工智能技术有限公司
|
||||
*
|
||||
@@ -11,8 +16,30 @@ import cn.craftlabs.auth.bitanswer.BitAnswerProvider;
|
||||
*/
|
||||
public class ExampleApp {
|
||||
public static void main(String[] args) {
|
||||
String json =
|
||||
"""
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"provider": "bitanswer",
|
||||
"scenario": "school",
|
||||
"bitanswer": { "url": "https://example.invalid/bitanswer", "loginMode": "AUTO" },
|
||||
"features": {
|
||||
"face": { "bitanswerFeatureId": 201 },
|
||||
"expression": { "bitanswerFeatureId": 202 }
|
||||
},
|
||||
"school": { "edgeDeviceId": "demo-edge-01", "tenantId": "demo-tenant" }
|
||||
}
|
||||
""";
|
||||
try {
|
||||
AuthConfig cfg = AuthConfigs.parse(json);
|
||||
System.out.println("scenario=" + cfg.scenario() + ", face id=" + cfg.bitanswerFeatureId("face"));
|
||||
} catch (AuthConfigException e) {
|
||||
System.err.println("config invalid: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try (AuthProvider p = new BitAnswerProvider()) {
|
||||
AuthResult r = p.initialize("{}");
|
||||
AuthResult r = p.initialize(json);
|
||||
System.out.println("init: " + r.isSuccess() + " " + r.getMessage());
|
||||
r = p.checkLicense();
|
||||
System.out.println("check: " + r.isSuccess() + " " + r.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user