From 56ba7c456a3d904d75972edbe171f2b2b53e2ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E9=9B=A8=E8=90=BD?= Date: Wed, 14 Oct 2026 21:02:11 +0800 Subject: [PATCH] feat: add credential properties. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 秋雨落 --- .../h2l/api/profile/HyperZoneCredential.kt | 3 +- .../icu/h2l/api/util/IPropertiesHolder.kt | 43 +++++++++++++++++++ .../YggdrasilHyperZoneCredential.kt | 6 +++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 api/src/main/kotlin/icu/h2l/api/util/IPropertiesHolder.kt diff --git a/api/src/main/kotlin/icu/h2l/api/profile/HyperZoneCredential.kt b/api/src/main/kotlin/icu/h2l/api/profile/HyperZoneCredential.kt index c2f74a98..51794665 100644 --- a/api/src/main/kotlin/icu/h2l/api/profile/HyperZoneCredential.kt +++ b/api/src/main/kotlin/icu/h2l/api/profile/HyperZoneCredential.kt @@ -21,6 +21,7 @@ package icu.h2l.api.profile +import icu.h2l.api.util.IPropertiesHolder import java.util.* /** @@ -29,7 +30,7 @@ import java.util.* * 注意:凭证对象本身不直接携带 profileId 字段; * 是否已绑定、如何绑定到 Profile,都由各认证模块自己的实现负责。 */ -interface HyperZoneCredential { +interface HyperZoneCredential : IPropertiesHolder { /** * 认证渠道唯一标识,由子模块负责稳定定义。 */ diff --git a/api/src/main/kotlin/icu/h2l/api/util/IPropertiesHolder.kt b/api/src/main/kotlin/icu/h2l/api/util/IPropertiesHolder.kt new file mode 100644 index 00000000..b238810f --- /dev/null +++ b/api/src/main/kotlin/icu/h2l/api/util/IPropertiesHolder.kt @@ -0,0 +1,43 @@ +/* + * This file is part of HyperZoneLogin, licensed under the GNU Affero General Public License v3.0 or later. + * + * Copyright (C) ksqeib (庆灵) + * Copyright (C) contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +package icu.h2l.api.util + +interface IPropertiesHolder { + val properties: HashMap + get() = HashMap() + + fun getProperty(key: String): String { + return properties[key] as String + } + + fun setProperty(key: String, value: String) { + properties[key] = value + } + + fun hasProperty(key: String): Boolean { + return properties.containsKey(key) + } + + fun removeProperty(key: String) { + properties.remove(key) + } +} \ No newline at end of file diff --git a/auth-yggd/src/main/kotlin/icu/h2l/login/auth/online/credential/YggdrasilHyperZoneCredential.kt b/auth-yggd/src/main/kotlin/icu/h2l/login/auth/online/credential/YggdrasilHyperZoneCredential.kt index 9131e777..b7ab183a 100644 --- a/auth-yggd/src/main/kotlin/icu/h2l/login/auth/online/credential/YggdrasilHyperZoneCredential.kt +++ b/auth-yggd/src/main/kotlin/icu/h2l/login/auth/online/credential/YggdrasilHyperZoneCredential.kt @@ -36,6 +36,10 @@ class YggdrasilHyperZoneCredential( override val channelId: String = CHANNEL_ID override val credentialId: String = "$entryId:$authenticatedUUID" + init { + setProperty(YGGDRASIL_ENTRY_ID_PROPERTY, entryId.lowercase(Locale.getDefault())) + } + override fun getRegistrationName(): String = authenticatedName override fun getBoundProfileId(): UUID? { @@ -86,5 +90,7 @@ class YggdrasilHyperZoneCredential( companion object { private const val CHANNEL_ID = "yggdrasil" + + public const val YGGDRASIL_ENTRY_ID_PROPERTY = "yggdrasil-entry-id" } }