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
ff930a82
Commit
ff930a82
authored
Oct 03, 2019
by
Sietse Ringers
Browse files
feat: asynchronously populate nonrevocation caches on irmaclient startup
parent
07ab5695
Changes
1
Hide whitespace changes
Inline
Side-by-side
irmaclient/client.go
View file @
ff930a82
...
...
@@ -130,7 +130,7 @@ func New(
return
nil
,
err
}
c
m
:=
&
Client
{
c
lient
:=
&
Client
{
credentialsCache
:
make
(
map
[
irma
.
CredentialTypeIdentifier
]
map
[
int
]
*
credential
),
keyshareServers
:
make
(
map
[
irma
.
SchemeManagerIdentifier
]
*
keyshareServer
),
attributes
:
make
(
map
[
irma
.
CredentialTypeIdentifier
][]
*
irma
.
AttributeList
),
...
...
@@ -138,57 +138,78 @@ func New(
handler
:
handler
,
}
c
m
.
Configuration
,
err
=
irma
.
NewConfigurationFromAssets
(
filepath
.
Join
(
storagePath
,
"irma_configuration"
),
irmaConfigurationPath
)
c
lient
.
Configuration
,
err
=
irma
.
NewConfigurationFromAssets
(
filepath
.
Join
(
storagePath
,
"irma_configuration"
),
irmaConfigurationPath
)
if
err
!=
nil
{
return
nil
,
err
}
schemeMgrErr
:=
c
m
.
Configuration
.
ParseOrRestoreFolder
()
schemeMgrErr
:=
c
lient
.
Configuration
.
ParseOrRestoreFolder
()
// If schemMgrErr is of type SchemeManagerError, we continue and
// return it at the end; otherwise bail out now
_
,
isSchemeMgrErr
:=
schemeMgrErr
.
(
*
irma
.
SchemeManagerError
)
if
schemeMgrErr
!=
nil
&&
!
isSchemeMgrErr
{
return
nil
,
schemeMgrErr
}
c
m
.
Configuration
.
RevocationPath
=
filepath
.
Join
(
storagePath
,
"revocation"
)
if
err
=
fs
.
EnsureDirectoryExists
(
c
m
.
Configuration
.
RevocationPath
);
err
!=
nil
{
c
lient
.
Configuration
.
RevocationPath
=
filepath
.
Join
(
storagePath
,
"revocation"
)
if
err
=
fs
.
EnsureDirectoryExists
(
c
lient
.
Configuration
.
RevocationPath
);
err
!=
nil
{
return
nil
,
err
}
// Ensure storage path exists, and populate it with necessary files
c
m
.
storage
=
storage
{
storagePath
:
storagePath
,
Configuration
:
c
m
.
Configuration
}
if
err
=
c
m
.
storage
.
EnsureStorageExists
();
err
!=
nil
{
c
lient
.
storage
=
storage
{
storagePath
:
storagePath
,
Configuration
:
c
lient
.
Configuration
}
if
err
=
c
lient
.
storage
.
EnsureStorageExists
();
err
!=
nil
{
return
nil
,
err
}
// Legacy storage does not need ensuring existence
cm
.
fileStorage
=
fileStorage
{
storagePath
:
storagePath
,
Configuration
:
cm
.
Configuration
}
if
c
m
.
Preferences
,
err
=
c
m
.
storage
.
LoadPreferences
();
err
!=
nil
{
if
c
lient
.
Preferences
,
err
=
c
lient
.
storage
.
LoadPreferences
();
err
!=
nil
{
return
nil
,
err
}
c
m
.
applyPreferences
()
c
lient
.
applyPreferences
()
// Perform new update functions from clientUpdates, if any
if
err
=
c
m
.
update
();
err
!=
nil
{
if
err
=
c
lient
.
update
();
err
!=
nil
{
return
nil
,
err
}
// Load our stuff
if
c
m
.
secretkey
,
err
=
c
m
.
storage
.
LoadSecretKey
();
err
!=
nil
{
if
c
lient
.
secretkey
,
err
=
c
lient
.
storage
.
LoadSecretKey
();
err
!=
nil
{
return
nil
,
err
}
if
c
m
.
attributes
,
err
=
c
m
.
storage
.
LoadAttributes
();
err
!=
nil
{
if
c
lient
.
attributes
,
err
=
c
lient
.
storage
.
LoadAttributes
();
err
!=
nil
{
return
nil
,
err
}
if
c
m
.
keyshareServers
,
err
=
c
m
.
storage
.
LoadKeyshareServers
();
err
!=
nil
{
if
c
lient
.
keyshareServers
,
err
=
c
lient
.
storage
.
LoadKeyshareServers
();
err
!=
nil
{
return
nil
,
err
}
if
len
(
c
m
.
UnenrolledSchemeManagers
())
>
1
{
if
len
(
c
lient
.
UnenrolledSchemeManagers
())
>
1
{
return
nil
,
errors
.
New
(
"Too many keyshare servers"
)
}
return
cm
,
schemeMgrErr
reportErr
:=
func
(
err
error
)
{
irma
.
Logger
.
Error
(
err
)
raven
.
CaptureError
(
err
,
nil
)
return
}
defer
func
()
{
var
cred
*
credential
var
err
error
for
credid
,
attrsets
:=
range
client
.
attributes
{
for
i
:=
range
attrsets
{
if
cred
,
err
=
client
.
credential
(
credid
,
i
);
err
!=
nil
{
reportErr
(
err
)
}
if
err
=
cred
.
PrepareNonrevCache
();
err
!=
nil
{
reportErr
(
err
)
}
}
}
}()
return
client
,
schemeMgrErr
}
func
(
client
*
Client
)
Close
()
error
{
...
...
Write
Preview
Markdown
is supported
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