Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Fix: app crash unsatisfiable request #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions irmagobridge/session_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,14 @@ func (sh *SessionHandler) Cancelled() {
sendAction(action)
}

func (sh *SessionHandler) UnsatisfiableRequest(request irma.SessionRequest,
serverName irma.TranslatedString, missing irmaclient.MissingAttributes) {
logDebug("Handling UnsatisfiableRequest")
action := &OutgoingAction{
"type": "IrmaSession.UnsatisfiableRequest",
"sessionId": sh.sessionID,
"serverName": serverName,
"missingDisclosures": missing,
"disclosuresLabels": request.Disclosure().Labels,
}

sendAction(action)
}

func CheckContainsCredentialIdentifiers(request *irma.DisclosureRequest) *irma.SessionError {
func checkContainsCredentialIdentifiers(request *irma.DisclosureRequest) *irma.SessionError {
for _, discon := range request.Disclose {
for _, con := range discon {
for _, attrReq := range con {
if attrReq.Type.IsCredential() {
return &irma.SessionError{
ErrorType: irma.ErrorInvalidRequest,
Err: errors.New("Request should only contain AttributeIdentifiers"),
Err: errors.New("Request should only contain AttributeTypeIdentifiers"),
}
}
}
Expand All @@ -109,13 +95,32 @@ func CheckContainsCredentialIdentifiers(request *irma.DisclosureRequest) *irma.S
return nil
}

func (sh *SessionHandler) UnsatisfiableRequest(request irma.SessionRequest,
serverName irma.TranslatedString, missing irmaclient.MissingAttributes) {
logDebug("Handling UnsatisfiableRequest")
err := checkContainsCredentialIdentifiers(request.Disclosure())
if err != nil {
sh.Failure(err)
return
}
action := &OutgoingAction{
"type": "IrmaSession.UnsatisfiableRequest",
"sessionId": sh.sessionID,
"serverName": serverName,
"missingDisclosures": missing,
"disclosuresLabels": request.Disclosure().Labels,
}

sendAction(action)
}

func (sh *SessionHandler) RequestIssuancePermission(request *irma.IssuanceRequest, candidates [][][]*irma.AttributeIdentifier, serverName irma.TranslatedString, ph irmaclient.PermissionHandler) {
logDebug("Handling RequestIssuancePermission")
disclose := request.Disclose
if disclose == nil {
disclose = irma.AttributeConDisCon{}
}
err := CheckContainsCredentialIdentifiers(request.Disclosure())
err := checkContainsCredentialIdentifiers(request.Disclosure())
if err != nil {
sh.Failure(err)
return
Expand All @@ -136,7 +141,7 @@ func (sh *SessionHandler) RequestIssuancePermission(request *irma.IssuanceReques

func (sh *SessionHandler) RequestVerificationPermission(request *irma.DisclosureRequest, candidates [][][]*irma.AttributeIdentifier, serverName irma.TranslatedString, ph irmaclient.PermissionHandler) {
logDebug("Handling RequestVerificationPermission")
err := CheckContainsCredentialIdentifiers(request)
err := checkContainsCredentialIdentifiers(request)
if err != nil {
sh.Failure(err)
return
Expand All @@ -156,7 +161,7 @@ func (sh *SessionHandler) RequestVerificationPermission(request *irma.Disclosure

func (sh *SessionHandler) RequestSignaturePermission(request *irma.SignatureRequest, candidates [][][]*irma.AttributeIdentifier, serverName irma.TranslatedString, ph irmaclient.PermissionHandler) {
logDebug("Handling RequestSignaturePermission")
err := CheckContainsCredentialIdentifiers(request.Disclosure())
err := checkContainsCredentialIdentifiers(request.Disclosure())
if err != nil {
sh.Failure(err)
return
Expand Down