[PD1] Fixed stuff. Unmarshal still returns map[string]interface{}, need to fix

This commit is contained in:
Afonso Franco 2024-04-19 11:55:16 +01:00
parent c131aa2aea
commit 39a0e5c01f
Signed by: afonso
SSH key fingerprint: SHA256:aiLbdlPwXKJS5wMnghdtod0SPy8imZjlVvCyUX9DJNk
6 changed files with 127 additions and 96 deletions

View file

@ -9,17 +9,29 @@ import (
func clientHandler(connection networking.Connection[protocol.Packet], dataStore DataStore) {
defer connection.Conn.Close()
_ = dataStore
//Get certificate sent by user
clientCert := connection.GetPeerCertificate()
oidValueMap := cryptoUtils.ExtractAllOIDValues(clientCert)
fmt.Println(oidValueMap)
//Get the OID values
oidMap := cryptoUtils.ExtractAllOIDValues(clientCert)
//Get the UID of this user
UID := oidMap["2.5.4.65"]
if UID=="" {
panic("User certificate does not specify it's PSEUDONYM")
}
for {
pac := connection.Receive()
var pac protocol.Packet
connection.Receive(&pac)
switch pac.Flag {
case protocol.ReqUserCertPkt:
//userCertPacket := dataStore.GetUserCertificate(uid)
//connection.Send(userCertPacket)
fmt.Printf("Type of pac.Body: %T\n", pac.Body)
UserCertPacket, ok := (pac.Body).(protocol.RequestUserCertPacket)
if !ok {
panic("Could not cast packet to it's type")
}
userCertPacket := dataStore.GetUserCertificate(UserCertPacket.UID)
connection.Send(userCertPacket)
case protocol.ReqAllMsgPkt:
fmt.Println("ReqAllMsg")
case protocol.ReqMsgPkt: