Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
irmago
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
IRMA
Github mirrors
irmago
Commits
2f634b01
Commit
2f634b01
authored
Oct 31, 2019
by
Ivar Derksen
Committed by
David Venhoek
Nov 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat: replace cred when refreshing non-singleton credential
parent
69e1f404
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
3 deletions
+42
-3
attributes.go
attributes.go
+16
-0
internal/sessiontest/session_test.go
internal/sessiontest/session_test.go
+14
-0
irmaclient/client.go
irmaclient/client.go
+12
-3
No files found.
attributes.go
View file @
2f634b01
...
...
@@ -63,6 +63,22 @@ func (al *AttributeList) Info() *CredentialInfo {
return
al
.
info
}
// EqualsExceptMetadata checks whether two AttributeLists have the same attribute values.
// The attribute containing the metadata information is skipped in this check.
func
(
al
*
AttributeList
)
EqualsExceptMetadata
(
ol
*
AttributeList
)
bool
{
if
len
(
al
.
Ints
)
!=
len
(
ol
.
Ints
)
{
return
false
}
// Check whether value of all attributes, except for metadata attribute, is equal
for
i
:=
1
;
i
<
len
(
al
.
Ints
);
i
++
{
if
al
.
Ints
[
i
]
.
Cmp
(
ol
.
Ints
[
i
])
!=
0
{
return
false
}
}
return
true
}
func
(
al
*
AttributeList
)
Hash
()
string
{
if
al
.
h
==
""
{
bytes
:=
[]
byte
{}
...
...
internal/sessiontest/session_test.go
View file @
2f634b01
...
...
@@ -96,6 +96,20 @@ func TestIssuanceOptionalSetAttributes(t *testing.T) {
sessionHelper
(
t
,
req
,
"issue"
,
nil
)
}
func
TestIssuanceSameAttributesNotSingleton
(
t
*
testing
.
T
)
{
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
prevLen
:=
len
(
client
.
CredentialInfoList
())
req
:=
getIssuanceRequest
(
true
)
sessionHelper
(
t
,
req
,
"issue"
,
client
)
req
=
getIssuanceRequest
(
false
)
sessionHelper
(
t
,
req
,
"issue"
,
client
)
require
.
Equal
(
t
,
prevLen
+
1
,
len
(
client
.
CredentialInfoList
()))
}
func
TestLargeAttribute
(
t
*
testing
.
T
)
{
client
,
_
:=
parseStorage
(
t
)
defer
test
.
ClearTestStorage
(
t
)
...
...
irmaclient/client.go
View file @
2f634b01
...
...
@@ -217,9 +217,18 @@ func (client *Client) addCredential(cred *credential, storeAttributes bool) (err
}
// If this is a singleton credential type, ensure we have at most one by removing any previous instance
if
!
id
.
Empty
()
&&
cred
.
CredentialType
()
.
IsSingleton
{
// If a credential already exists with exactly the same attribute values (except metadata), delete the previous credential
if
!
id
.
Empty
()
{
if
cred
.
CredentialType
()
.
IsSingleton
{
for
len
(
client
.
attrs
(
id
))
!=
0
{
client
.
remove
(
id
,
0
,
false
)
_
=
client
.
remove
(
id
,
0
,
false
)
}
}
for
i
:=
len
(
client
.
attrs
(
id
))
-
1
;
i
>=
0
;
i
--
{
// Go backwards through array because remove manipulates it
if
client
.
attrs
(
id
)[
i
]
.
EqualsExceptMetadata
(
cred
.
AttributeList
())
{
_
=
client
.
remove
(
id
,
i
,
false
)
}
}
}
...
...
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