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
fc3f518f
Commit
fc3f518f
authored
Feb 09, 2018
by
Sietse Ringers
Browse files
Autocopy irma_configuration out of assets when outdated
parent
6c565cad
Changes
4
Hide whitespace changes
Inline
Side-by-side
irmaclient/updates.go
View file @
fc3f518f
...
...
@@ -34,19 +34,7 @@ var clientUpdates = []func(client *Client) error{
// Adding scheme manager index, signature and public key
// Check the signatures of all scheme managers, if any is not ok,
// copy the entire irma_configuration folder from assets
func
(
client
*
Client
)
error
{
conf
:=
client
.
Configuration
if
len
(
conf
.
DisabledSchemeManagers
)
>
0
{
return
conf
.
CopyFromAssets
(
true
)
}
for
manager
:=
range
conf
.
SchemeManagers
{
valid
,
err
:=
conf
.
VerifySignature
(
manager
)
if
err
!=
nil
||
!
valid
{
return
conf
.
CopyFromAssets
(
true
)
}
}
return
nil
},
nil
,
// made irrelevant by irma_configuration-autocopying
// Rename config -> preferences
func
(
client
*
Client
)
(
err
error
)
{
...
...
@@ -69,9 +57,7 @@ var clientUpdates = []func(client *Client) error{
},
// Copy new irma_configuration out of assets
func
(
client
*
Client
)
(
err
error
)
{
return
client
.
Configuration
.
CopyFromAssets
(
true
)
},
nil
,
// made irrelevant by irma_configuration-autocopying
// For each keyshare server, include in its struct the identifier of its scheme manager
func
(
client
*
Client
)
(
err
error
)
{
...
...
@@ -98,10 +84,10 @@ func (client *Client) update() error {
// Perform all new updates
for
i
:=
len
(
client
.
updates
);
i
<
len
(
clientUpdates
);
i
++
{
if
clientUpdates
[
i
]
==
nil
{
continue
err
=
nil
if
clientUpdates
[
i
]
!=
nil
{
err
=
clientUpdates
[
i
](
client
)
}
err
=
clientUpdates
[
i
](
client
)
u
:=
update
{
When
:
irma
.
Timestamp
(
time
.
Now
()),
Number
:
i
,
...
...
irmaconfig.go
View file @
fc3f518f
...
...
@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"strconv"
"time"
"crypto/sha256"
...
...
@@ -91,7 +92,11 @@ func NewConfiguration(path string, assets string) (conf *Configuration, err erro
if
err
=
fs
.
EnsureDirectoryExists
(
conf
.
Path
);
err
!=
nil
{
return
nil
,
err
}
if
conf
.
assets
!=
""
&&
fs
.
Empty
(
conf
.
Path
)
{
isUpToDate
,
err
:=
conf
.
isUpToDate
()
if
err
!=
nil
{
return
nil
,
err
}
if
conf
.
assets
!=
""
&&
!
isUpToDate
{
if
err
=
conf
.
CopyFromAssets
(
false
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -379,6 +384,42 @@ func (conf *Configuration) Contains(cred CredentialTypeIdentifier) bool {
conf
.
CredentialTypes
[
cred
]
!=
nil
}
func
(
conf
*
Configuration
)
readTimestamp
(
path
string
)
(
timestamp
*
time
.
Time
,
exists
bool
,
err
error
)
{
filename
:=
filepath
.
Join
(
path
,
"timestamp"
)
exists
,
err
=
fs
.
PathExists
(
filename
)
if
err
!=
nil
||
!
exists
{
return
}
bts
,
err
:=
ioutil
.
ReadFile
(
filename
)
if
err
!=
nil
{
return
}
i
,
err
:=
strconv
.
ParseInt
(
string
(
bts
),
10
,
64
)
if
err
!=
nil
{
return
}
t
:=
time
.
Unix
(
i
,
0
)
return
&
t
,
true
,
nil
}
func
(
conf
*
Configuration
)
isUpToDate
()
(
bool
,
error
)
{
if
conf
.
assets
==
""
{
return
true
,
nil
}
var
err
error
newTime
,
exists
,
err
:=
conf
.
readTimestamp
(
conf
.
assets
)
if
err
!=
nil
{
return
false
,
err
}
if
!
exists
{
return
false
,
errors
.
New
(
"Timestamp in assets irma_configuration not found"
)
}
// conf.Path does not need to have a timestamp. If it does not, it is outdated
oldTime
,
exists
,
err
:=
conf
.
readTimestamp
(
conf
.
Path
)
return
exists
&&
!
newTime
.
After
(
*
oldTime
),
err
}
// CopyFromAssets recursively copies the directory tree from the assets folder
// into the directory of this Configuration.
func
(
conf
*
Configuration
)
CopyFromAssets
(
parse
bool
)
error
{
...
...
testdata/irma_configuration/timestamp
0 → 100644
View file @
fc3f518f
1518279833
\ No newline at end of file
testdata/irma_configuration_invalid/timestamp
0 → 100644
View file @
fc3f518f
1518279833
\ No newline at end of file
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