Skip to content
GitLab
Menu
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
24f32567
Commit
24f32567
authored
Jun 08, 2018
by
David Venhoek
Browse files
Changed pinchange interface to better meet requirements from mobile app.
parent
1ea7670b
Changes
3
Show whitespace changes
Inline
Side-by-side
irmaclient/client.go
View file @
24f32567
...
@@ -83,6 +83,7 @@ type KeyshareHandler interface {
...
@@ -83,6 +83,7 @@ type KeyshareHandler interface {
type
ChangepinHandler
interface
{
type
ChangepinHandler
interface
{
ChangepinFailure
(
manager
irma
.
SchemeManagerIdentifier
,
err
error
)
ChangepinFailure
(
manager
irma
.
SchemeManagerIdentifier
,
err
error
)
ChangepinSuccess
(
manager
irma
.
SchemeManagerIdentifier
)
ChangepinSuccess
(
manager
irma
.
SchemeManagerIdentifier
)
ChangepinIncorrect
(
manager
irma
.
SchemeManagerIdentifier
)
}
}
// ClientHandler informs the user that the configuration or the list of attributes
// ClientHandler informs the user that the configuration or the list of attributes
...
@@ -689,6 +690,16 @@ func (client *Client) unenrolledSchemeManagers() []irma.SchemeManagerIdentifier
...
@@ -689,6 +690,16 @@ func (client *Client) unenrolledSchemeManagers() []irma.SchemeManagerIdentifier
return
list
return
list
}
}
func
(
client
*
Client
)
EnrolledSchemeManagers
()
[]
irma
.
SchemeManagerIdentifier
{
list
:=
[]
irma
.
SchemeManagerIdentifier
{}
for
name
,
manager
:=
range
client
.
Configuration
.
SchemeManagers
{
if
_
,
contains
:=
client
.
keyshareServers
[
name
];
manager
.
Distributed
()
&&
contains
{
list
=
append
(
list
,
manager
.
Identifier
())
}
}
return
list
}
// KeyshareEnroll attempts to enroll at the keyshare server of the specified scheme manager.
// KeyshareEnroll attempts to enroll at the keyshare server of the specified scheme manager.
func
(
client
*
Client
)
KeyshareEnroll
(
manager
irma
.
SchemeManagerIdentifier
,
email
*
string
,
pin
string
,
lang
string
)
{
func
(
client
*
Client
)
KeyshareEnroll
(
manager
irma
.
SchemeManagerIdentifier
,
email
*
string
,
pin
string
,
lang
string
)
{
go
func
()
{
go
func
()
{
...
@@ -749,8 +760,6 @@ func (client *Client) KeyshareChangepin(manager irma.SchemeManagerIdentifier, ol
...
@@ -749,8 +760,6 @@ func (client *Client) KeyshareChangepin(manager irma.SchemeManagerIdentifier, ol
err
:=
client
.
keyshareChangepinWorker
(
manager
,
oldpin
,
newpin
)
err
:=
client
.
keyshareChangepinWorker
(
manager
,
oldpin
,
newpin
)
if
err
!=
nil
{
if
err
!=
nil
{
client
.
handler
.
ChangepinFailure
(
manager
,
err
)
client
.
handler
.
ChangepinFailure
(
manager
,
err
)
}
else
{
client
.
handler
.
ChangepinSuccess
(
manager
)
}
}
}()
}()
}
}
...
@@ -762,7 +771,7 @@ func (client *Client) keyshareChangepinWorker(managerID irma.SchemeManagerIdenti
...
@@ -762,7 +771,7 @@ func (client *Client) keyshareChangepinWorker(managerID irma.SchemeManagerIdenti
}
}
transport
:=
irma
.
NewHTTPTransport
(
kss
.
URL
)
transport
:=
irma
.
NewHTTPTransport
(
kss
.
URL
)
message
:=
keyshare
Pinc
hange
{
message
:=
keyshare
C
hange
pin
{
Username
:
kss
.
Username
,
Username
:
kss
.
Username
,
Oldpin
:
kss
.
HashedPin
(
oldpin
),
Oldpin
:
kss
.
HashedPin
(
oldpin
),
Newpin
:
kss
.
HashedPin
(
newpin
),
Newpin
:
kss
.
HashedPin
(
newpin
),
...
@@ -773,9 +782,13 @@ func (client *Client) keyshareChangepinWorker(managerID irma.SchemeManagerIdenti
...
@@ -773,9 +782,13 @@ func (client *Client) keyshareChangepinWorker(managerID irma.SchemeManagerIdenti
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
res
.
Status
!=
kssPinSuccess
{
if
res
.
Status
!=
kssPinSuccess
{
return
errors
.
New
(
"Pin change rejected"
)
client
.
handler
.
ChangepinIncorrect
(
managerID
)
}
else
{
client
.
handler
.
ChangepinSuccess
(
managerID
)
}
}
return
nil
return
nil
}
}
...
...
irmaclient/irmaclient_test.go
View file @
24f32567
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"math/big"
"math/big"
"os"
"os"
"testing"
"testing"
"errors"
"github.com/mhe/gabi"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago"
...
@@ -54,6 +55,14 @@ func (i *TestClientHandler) ChangepinFailure(manager irma.SchemeManagerIdentifie
...
@@ -54,6 +55,14 @@ func (i *TestClientHandler) ChangepinFailure(manager irma.SchemeManagerIdentifie
i
.
t
.
Fatal
(
err
)
i
.
t
.
Fatal
(
err
)
}
}
}
}
func
(
i
*
TestClientHandler
)
ChangepinIncorrect
(
manager
irma
.
SchemeManagerIdentifier
)
{
err
:=
errors
.
New
(
"incorrect pin"
)
select
{
case
i
.
c
<-
err
:
//nop
default
:
i
.
t
.
Fatal
(
err
)
}
}
func
parseStorage
(
t
*
testing
.
T
)
*
Client
{
func
parseStorage
(
t
*
testing
.
T
)
*
Client
{
require
.
NoError
(
t
,
fs
.
CopyDirectory
(
"../testdata/teststorage"
,
"../testdata/storage/test"
))
require
.
NoError
(
t
,
fs
.
CopyDirectory
(
"../testdata/teststorage"
,
"../testdata/storage/test"
))
...
...
irmaclient/keyshare.go
View file @
24f32567
...
@@ -62,7 +62,7 @@ type keyshareEnrollment struct {
...
@@ -62,7 +62,7 @@ type keyshareEnrollment struct {
Language
string
`json:"language"`
Language
string
`json:"language"`
}
}
type
keyshare
Pinc
hange
struct
{
type
keyshare
C
hange
pin
struct
{
Username
string
`json:"id"`
Username
string
`json:"id"`
Oldpin
string
`json:"oldpin"`
Oldpin
string
`json:"oldpin"`
Newpin
string
`json:"newpin"`
Newpin
string
`json:"newpin"`
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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