diff --git a/api/src/main/kotlin/icu/h2l/api/util/IPropertiesHolder.kt b/api/src/main/kotlin/icu/h2l/api/util/IPropertiesHolder.kt index b238810f..589f1f04 100644 --- a/api/src/main/kotlin/icu/h2l/api/util/IPropertiesHolder.kt +++ b/api/src/main/kotlin/icu/h2l/api/util/IPropertiesHolder.kt @@ -22,11 +22,10 @@ package icu.h2l.api.util interface IPropertiesHolder { - val properties: HashMap - get() = HashMap() + val properties: MutableMap - fun getProperty(key: String): String { - return properties[key] as String + fun getProperty(key: String): String? { + return properties[key] } fun setProperty(key: String, value: String) { @@ -40,4 +39,4 @@ interface IPropertiesHolder { fun removeProperty(key: String) { properties.remove(key) } -} \ No newline at end of file +} diff --git a/api/src/main/kotlin/icu/h2l/api/util/PropertiesHolder.kt b/api/src/main/kotlin/icu/h2l/api/util/PropertiesHolder.kt new file mode 100644 index 00000000..61136f92 --- /dev/null +++ b/api/src/main/kotlin/icu/h2l/api/util/PropertiesHolder.kt @@ -0,0 +1,28 @@ +/* + * 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 + +import java.util.concurrent.ConcurrentHashMap + +class PropertiesHolder : IPropertiesHolder { + override val properties: MutableMap = ConcurrentHashMap() +} diff --git a/subplugin/auth-floodgate/src/main/kotlin/icu/h2l/login/auth/floodgate/credential/FloodgateHyperZoneCredential.kt b/subplugin/auth-floodgate/src/main/kotlin/icu/h2l/login/auth/floodgate/credential/FloodgateHyperZoneCredential.kt index b2540494..af9bb386 100644 --- a/subplugin/auth-floodgate/src/main/kotlin/icu/h2l/login/auth/floodgate/credential/FloodgateHyperZoneCredential.kt +++ b/subplugin/auth-floodgate/src/main/kotlin/icu/h2l/login/auth/floodgate/credential/FloodgateHyperZoneCredential.kt @@ -22,6 +22,8 @@ package icu.h2l.login.auth.floodgate.credential import icu.h2l.api.profile.HyperZoneCredential +import icu.h2l.api.util.IPropertiesHolder +import icu.h2l.api.util.PropertiesHolder import icu.h2l.login.auth.floodgate.db.FloodgateAuthRepository import java.util.* @@ -32,7 +34,7 @@ class FloodgateHyperZoneCredential( private val xuid: Long, private val suggestedProfileCreateUuid: UUID?, private val knownUserUUID: UUID? = null, -) : HyperZoneCredential { +) : HyperZoneCredential, IPropertiesHolder by PropertiesHolder() { override val channelId: String = CHANNEL_ID override val credentialId: String = trustedUuid.toString() diff --git a/subplugin/auth-offline/src/main/kotlin/icu/h2l/login/auth/offline/service/OfflineHyperZoneCredential.kt b/subplugin/auth-offline/src/main/kotlin/icu/h2l/login/auth/offline/service/OfflineHyperZoneCredential.kt index 90e7c398..fc6ec260 100644 --- a/subplugin/auth-offline/src/main/kotlin/icu/h2l/login/auth/offline/service/OfflineHyperZoneCredential.kt +++ b/subplugin/auth-offline/src/main/kotlin/icu/h2l/login/auth/offline/service/OfflineHyperZoneCredential.kt @@ -22,6 +22,8 @@ package icu.h2l.login.auth.offline.service import icu.h2l.api.profile.HyperZoneCredential +import icu.h2l.api.util.IPropertiesHolder +import icu.h2l.api.util.PropertiesHolder import icu.h2l.login.auth.offline.db.OfflineAuthRepository import icu.h2l.login.auth.offline.util.ExtraUuidUtils import java.util.* @@ -34,7 +36,7 @@ class OfflineHyperZoneCredential( private val knownUserUUID: UUID? = null, private val pendingRegistrationId: UUID? = null, private val passProfileCreateUuid: Boolean = false, -) : HyperZoneCredential { +) : HyperZoneCredential, IPropertiesHolder by PropertiesHolder() { override val channelId: String = CHANNEL_ID override val credentialId: String = pendingRegistrationId?.toString() ?: normalizedName diff --git a/subplugin/auth-yggd/src/main/kotlin/icu/h2l/login/auth/online/credential/YggdrasilHyperZoneCredential.kt b/subplugin/auth-yggd/src/main/kotlin/icu/h2l/login/auth/online/credential/YggdrasilHyperZoneCredential.kt index e484c248..b33a34f1 100644 --- a/subplugin/auth-yggd/src/main/kotlin/icu/h2l/login/auth/online/credential/YggdrasilHyperZoneCredential.kt +++ b/subplugin/auth-yggd/src/main/kotlin/icu/h2l/login/auth/online/credential/YggdrasilHyperZoneCredential.kt @@ -22,6 +22,8 @@ package icu.h2l.login.auth.online.credential import icu.h2l.api.profile.HyperZoneCredential +import icu.h2l.api.util.IPropertiesHolder +import icu.h2l.api.util.PropertiesHolder import icu.h2l.login.auth.online.db.EntryDatabaseHelper import java.util.* @@ -32,12 +34,12 @@ class YggdrasilHyperZoneCredential( private val authenticatedUUID: UUID, private val suggestedProfileCreateUuid: UUID?, private val knownUserUUID: UUID? = null, -) : HyperZoneCredential { +) : HyperZoneCredential, IPropertiesHolder by PropertiesHolder() { override val channelId: String = CHANNEL_ID override val credentialId: String = "$entryId:$authenticatedUUID" init { - setProperty(YGGDRASIL_ENTRY_ID_PROPERTY, entryId.lowercase(Locale.getDefault())) + setProperty(YGGDRASIL_ENTRY_ID_PROPERTY, entryId) } override fun getRegistrationName(): String = authenticatedName diff --git a/velocity/src/test/kotlin/icu/h2l/login/profile/UserBindingCodeServiceTest.kt b/velocity/src/test/kotlin/icu/h2l/login/profile/UserBindingCodeServiceTest.kt index 8cc4d1ea..d2c64d22 100644 --- a/velocity/src/test/kotlin/icu/h2l/login/profile/UserBindingCodeServiceTest.kt +++ b/velocity/src/test/kotlin/icu/h2l/login/profile/UserBindingCodeServiceTest.kt @@ -28,6 +28,8 @@ import icu.h2l.api.player.ClientLoginIdentity import icu.h2l.api.player.HyperZonePlayer import icu.h2l.api.profile.HyperZoneCredential import icu.h2l.api.profile.HyperZoneUserService +import icu.h2l.api.util.IPropertiesHolder +import icu.h2l.api.util.PropertiesHolder import icu.h2l.login.database.helper.BindingCodeStore import icu.h2l.login.manager.LoginManager import io.mockk.mockk @@ -262,7 +264,7 @@ class UserBindingCodeServiceTest { override fun getAttachedGameProfile() = error("not used") } - private class FakeCredential : HyperZoneCredential { + private class FakeCredential : HyperZoneCredential, IPropertiesHolder by PropertiesHolder() { override val channelId: String = "test" override val credentialId: String = "cred" diff --git a/velocity/src/test/kotlin/icu/h2l/login/profile/UserUnbindServiceTest.kt b/velocity/src/test/kotlin/icu/h2l/login/profile/UserUnbindServiceTest.kt index d8ba2a87..5088fd30 100644 --- a/velocity/src/test/kotlin/icu/h2l/login/profile/UserUnbindServiceTest.kt +++ b/velocity/src/test/kotlin/icu/h2l/login/profile/UserUnbindServiceTest.kt @@ -28,6 +28,8 @@ import icu.h2l.api.player.ClientLoginIdentity import icu.h2l.api.player.HyperZonePlayer import icu.h2l.api.profile.HyperZoneCredential import icu.h2l.api.profile.HyperZoneUserService +import icu.h2l.api.util.IPropertiesHolder +import icu.h2l.api.util.PropertiesHolder import icu.h2l.login.message.MessageService import io.mockk.every import io.mockk.mockk @@ -100,7 +102,7 @@ class UserUnbindServiceTest { private class FakeCredential( private val unsupported: Boolean = false, - ) : HyperZoneCredential { + ) : HyperZoneCredential, IPropertiesHolder by PropertiesHolder() { override val channelId: String = "test" override val credentialId: String = "credential" var unboundUserUUID: UUID? = null