Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
496920ce
Commit
496920ce
authored
Feb 04, 2018
by
Sietse Ringers
Browse files
Add new KeyshareRegistrationIncomplete message to session handler interface
parent
f81d74b1
Changes
4
Hide whitespace changes
Inline
Side-by-side
irmaclient/keyshare.go
View file @
496920ce
...
...
@@ -25,6 +25,7 @@ type keyshareSessionHandler interface {
KeyshareDone
(
message
interface
{})
KeyshareCancelled
()
KeyshareBlocked
(
manager
irma
.
SchemeManagerIdentifier
,
duration
int
)
KeyshareRegistrationIncomplete
(
manager
irma
.
SchemeManagerIdentifier
)
// In errors the manager may be nil, as not all keyshare errors have a clearly associated scheme manager
KeyshareError
(
manager
*
irma
.
SchemeManagerIdentifier
,
err
error
)
KeysharePin
()
...
...
@@ -193,7 +194,7 @@ func startKeyshareSession(
authstatus
:=
&
keyshareAuthorization
{}
err
:=
transport
.
Post
(
"users/isAuthorized"
,
authstatus
,
""
)
if
err
!=
nil
{
ks
.
sessionHandler
.
KeyshareError
(
&
managerID
,
err
)
ks
.
fail
(
managerID
,
err
)
return
}
switch
authstatus
.
Status
{
...
...
@@ -214,6 +215,28 @@ func startKeyshareSession(
}
}
func
(
ks
*
keyshareSession
)
fail
(
manager
irma
.
SchemeManagerIdentifier
,
err
error
)
{
serr
,
ok
:=
err
.
(
*
irma
.
SessionError
)
if
ok
{
if
serr
.
ApiError
!=
nil
&&
len
(
serr
.
ApiError
.
ErrorName
)
>
0
{
switch
serr
.
ApiError
.
ErrorName
{
case
"USER_NOT_REGISTERED"
:
ks
.
sessionHandler
.
KeyshareRegistrationIncomplete
(
manager
)
case
"USER_BLOCKED"
:
duration
,
err
:=
strconv
.
Atoi
(
serr
.
ApiError
.
Message
)
if
err
!=
nil
{
// Not really clear what to do with duration, but should never happen anyway
duration
=
-
1
}
ks
.
sessionHandler
.
KeyshareBlocked
(
manager
,
duration
)
default
:
ks
.
sessionHandler
.
KeyshareError
(
&
manager
,
err
)
}
}
}
else
{
ks
.
sessionHandler
.
KeyshareError
(
&
manager
,
err
)
}
}
// Ask for a pin, repeatedly if necessary, and either continue the keyshare protocol
// with authorization, or stop the keyshare protocol and inform of failure.
func
(
ks
*
keyshareSession
)
VerifyPin
(
attempts
int
)
{
...
...
irmaclient/manual_session_test.go
View file @
496920ce
...
...
@@ -90,3 +90,6 @@ func (sh *ManualSessionHandler) Failure(irmaAction irma.Action, err *irma.Sessio
func
(
sh
*
ManualSessionHandler
)
KeyshareBlocked
(
manager
irma
.
SchemeManagerIdentifier
,
duration
int
)
{
sh
.
Failure
(
irma
.
ActionUnknown
,
&
irma
.
SessionError
{
ErrorType
:
irma
.
ErrorKeyshareBlocked
})
}
func
(
sh
*
ManualSessionHandler
)
KeyshareRegistrationIncomplete
(
manager
irma
.
SchemeManagerIdentifier
)
{
sh
.
c
<-
&
irma
.
SessionError
{
Err
:
errors
.
New
(
"KeyshareRegistrationIncomplete"
)}
}
irmaclient/session.go
View file @
496920ce
...
...
@@ -34,6 +34,7 @@ type Handler interface {
MissingKeyshareEnrollment
(
manager
irma
.
SchemeManagerIdentifier
)
KeyshareBlocked
(
manager
irma
.
SchemeManagerIdentifier
,
duration
int
)
KeyshareRegistrationIncomplete
(
manager
irma
.
SchemeManagerIdentifier
)
RequestIssuancePermission
(
request
irma
.
IssuanceRequest
,
ServerName
string
,
callback
PermissionHandler
)
RequestVerificationPermission
(
request
irma
.
DisclosureRequest
,
ServerName
string
,
callback
PermissionHandler
)
...
...
@@ -87,6 +88,10 @@ type manualSession struct {
session
}
func
(
session
*
session
)
KeyshareRegistrationIncomplete
(
manager
irma
.
SchemeManagerIdentifier
)
{
session
.
Handler
.
KeyshareRegistrationIncomplete
(
manager
)
}
// We implement the handler for the keyshare protocol
var
_
keyshareSessionHandler
=
(
*
interactiveSession
)(
nil
)
var
_
keyshareSessionHandler
=
(
*
manualSession
)(
nil
)
...
...
irmaclient/session_test.go
View file @
496920ce
...
...
@@ -19,8 +19,12 @@ type TestHandler struct {
client
*
Client
}
func
(
th
TestHandler
)
KeyshareRegistrationIncomplete
(
manager
irma
.
SchemeManagerIdentifier
)
{
th
.
Failure
(
irma
.
ActionUnknown
,
&
irma
.
SessionError
{
Err
:
errors
.
New
(
"KeyshareRegistrationIncomplete"
)})
}
func
(
th
TestHandler
)
KeyshareBlocked
(
manager
irma
.
SchemeManagerIdentifier
,
duration
int
)
{
th
.
Failure
(
irma
.
ActionUnknown
,
&
irma
.
SessionError
{
Err
orType
:
irma
.
Error
KeyshareBlocked
})
th
.
Failure
(
irma
.
ActionUnknown
,
&
irma
.
SessionError
{
Err
:
errors
.
New
(
"
KeyshareBlocked
"
)
})
}
func
(
th
TestHandler
)
MissingKeyshareEnrollment
(
manager
irma
.
SchemeManagerIdentifier
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment