File tree Expand file tree Collapse file tree 3 files changed +28
-11
lines changed
commonMain/kotlin/spp.protocol/platform/auth
kotlin/spp/protocol/marshall Expand file tree Collapse file tree 3 files changed +28
-11
lines changed Original file line number Diff line number Diff line change 1717 */
1818package spp.protocol.platform.auth
1919
20- enum class DeveloperRole (var roleName : String , var nativeRole : Boolean ) {
21- ROLE_MANAGER (" role_manager" , true ),
22- ROLE_USER (" role_user" , true ),
23- USER (" *" , false );
20+ import kotlinx.serialization.Serializable
2421
22+ @Serializable
23+ data class DeveloperRole (val roleName : String , val nativeRole : Boolean ) {
2524 companion object {
25+ val ROLE_MANAGER = DeveloperRole (" role_manager" , true )
26+ val ROLE_USER = DeveloperRole (" role_user" , true )
27+
2628 fun fromString (roleName : String ): DeveloperRole {
27- val nativeRole = values().find { it.name.lowercase() == roleName.lowercase() }
28- return if (nativeRole != null ) {
29- nativeRole
29+ return if (roleName.equals(" role_manager" , true )) {
30+ ROLE_MANAGER
31+ } else if (roleName.equals(" role_user" , true )) {
32+ ROLE_USER
3033 } else {
31- val user = USER
32- user.roleName = roleName.toLowerCase().replace(' ' , ' _' ).trim()
33- user
34+ DeveloperRole (roleName.toLowerCase().replace(' ' , ' _' ).trim(), false )
3435 }
3536 }
3637 }
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import spp.protocol.instrument.event.LiveInstrumentRemoved
3939import spp.protocol.instrument.event.LiveLogHit
4040import spp.protocol.instrument.variable.LiveVariable
4141import spp.protocol.platform.auth.DataRedaction
42+ import spp.protocol.platform.auth.DeveloperRole
4243import spp.protocol.platform.auth.RedactionType
4344import spp.protocol.platform.developer.SelfInfo
4445import spp.protocol.platform.general.Service
@@ -424,4 +425,17 @@ object ProtocolMarshaller {
424425 value.getString(" replacement" )
425426 )
426427 }
428+
429+ @JvmStatic
430+ fun serializeDeveloperRole (value : DeveloperRole ): JsonObject {
431+ return JsonObject (Json .encode(value))
432+ }
433+
434+ @JvmStatic
435+ fun deserializeDeveloperRole (value : JsonObject ): DeveloperRole {
436+ return DeveloperRole (
437+ value.getString(" roleName" ),
438+ value.getBoolean(" nativeRole" )
439+ )
440+ }
427441}
Original file line number Diff line number Diff line change @@ -29,4 +29,6 @@ spp.protocol.platform.status.ActiveInstance.deserializer=spp.protocol.marshall.P
2929spp.protocol.instrument.event.LiveInstrumentRemoved.serializer =spp.protocol.marshall.ProtocolMarshaller# serializeLiveInstrumentRemoved
3030spp.protocol.instrument.event.LiveInstrumentRemoved.deserializer =spp.protocol.marshall.ProtocolMarshaller# deserializeLiveInstrumentRemoved
3131spp.protocol.instrument.event.LiveBreakpointHit.serializer =spp.protocol.marshall.ProtocolMarshaller# serializeLiveBreakpointHit
32- spp.protocol.instrument.event.LiveBreakpointHit.deserializer =spp.protocol.marshall.ProtocolMarshaller# deserializeLiveBreakpointHit
32+ spp.protocol.instrument.event.LiveBreakpointHit.deserializer =spp.protocol.marshall.ProtocolMarshaller# deserializeLiveBreakpointHit
33+ spp.protocol.platform.auth.DeveloperRole.serializer =spp.protocol.marshall.ProtocolMarshaller# serializeDeveloperRole
34+ spp.protocol.platform.auth.DeveloperRole.deserializer =spp.protocol.marshall.ProtocolMarshaller# deserializeDeveloperRole
You can’t perform that action at this time.
0 commit comments