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
e03aeafc
Commit
e03aeafc
authored
Sep 27, 2017
by
Sietse Ringers
Browse files
Fix empty Manager.CredentialList() after Init()
parent
be6b9198
Changes
4
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
e03aeafc
...
...
@@ -44,16 +44,50 @@ type MetadataAttribute struct {
// AttributeList contains attributes, excluding the secret key,
// providing convenient access to the metadata attribute.
type
AttributeList
struct
{
*
MetadataAttribute
`json:"-"`
Ints
[]
*
big
.
Int
strings
[]
string
*
MetadataAttribute
`json:"-"`
info
*
Credential
}
func
(
al
*
AttributeList
)
MarshalJSON
()
([]
byte
,
error
)
{
return
json
.
Marshal
(
al
.
Ints
)
}
func
(
al
*
AttributeList
)
UnmarshalJSON
(
bytes
[]
byte
)
error
{
ints
:=
[]
*
big
.
Int
{}
if
err
:=
json
.
Unmarshal
(
bytes
,
&
ints
);
err
!=
nil
{
return
err
}
*
al
=
*
NewAttributeListFromInts
(
ints
)
return
nil
}
// NewAttributeListFromInts initializes a new AttributeList from a list of bigints.
func
NewAttributeListFromInts
(
ints
[]
*
big
.
Int
)
*
AttributeList
{
meta
:=
MetadataFromInt
(
ints
[
0
])
credtype
:=
meta
.
CredentialType
()
issid
:=
credtype
.
IssuerIdentifier
()
attrs
:=
make
([]
TranslatedString
,
len
(
credtype
.
Attributes
))
for
i
:=
range
credtype
.
Attributes
{
val
:=
string
(
ints
[
i
+
1
]
.
Bytes
())
attrs
[
i
]
=
TranslatedString
(
map
[
string
]
string
{
"en"
:
val
,
"nl"
:
val
})
}
return
&
AttributeList
{
Ints
:
ints
,
MetadataAttribute
:
MetadataFromInt
(
ints
[
0
]),
MetadataAttribute
:
meta
,
info
:
&
Credential
{
ID
:
credtype
.
Identifier
()
.
String
(),
SignedOn
:
Timestamp
(
meta
.
SigningDate
()),
Expires
:
Timestamp
(
meta
.
Expiry
()),
Type
:
credtype
,
Issuer
:
MetaStore
.
Issuers
[
issid
],
SchemeManager
:
MetaStore
.
SchemeManagers
[
issid
.
SchemeManagerIdentifier
()],
Attributes
:
attrs
,
Logo
:
""
,
// TODO
},
}
}
...
...
credential.go
View file @
e03aeafc
...
...
@@ -11,8 +11,6 @@ import (
type
credential
struct
{
*
gabi
.
Credential
*
MetadataAttribute
info
*
Credential
}
// A Credential contains all information of an IRMA credential.
...
...
@@ -32,31 +30,11 @@ type CredentialList []*Credential
func
newCredential
(
gabicred
*
gabi
.
Credential
)
(
cred
*
credential
)
{
meta
:=
MetadataFromInt
(
gabicred
.
Attributes
[
1
])
credtype
:=
meta
.
CredentialType
()
issid
:=
credtype
.
IssuerIdentifier
()
attrs
:=
make
([]
TranslatedString
,
len
(
credtype
.
Attributes
))
for
i
:=
range
credtype
.
Attributes
{
val
:=
string
(
gabicred
.
Attributes
[
i
+
2
]
.
Bytes
())
attrs
[
i
]
=
TranslatedString
(
map
[
string
]
string
{
"en"
:
val
,
"nl"
:
val
})
}
cred
=
&
credential
{
Credential
:
gabicred
,
MetadataAttribute
:
meta
,
info
:
&
Credential
{
ID
:
credtype
.
Identifier
()
.
String
(),
SignedOn
:
Timestamp
(
meta
.
SigningDate
()),
Expires
:
Timestamp
(
meta
.
Expiry
()),
Type
:
credtype
,
Issuer
:
MetaStore
.
Issuers
[
issid
],
SchemeManager
:
MetaStore
.
SchemeManagers
[
issid
.
SchemeManagerIdentifier
()],
Attributes
:
attrs
,
Logo
:
""
,
// TODO
},
}
cred
.
Pk
=
MetaStore
.
PublicKey
(
issid
,
cred
.
KeyCounter
())
cred
.
Pk
=
MetaStore
.
PublicKey
(
meta
.
CredentialType
()
.
IssuerIdentifier
(),
cred
.
KeyCounter
())
return
}
...
...
irmago_test.go
View file @
e03aeafc
...
...
@@ -68,6 +68,8 @@ func verifyStoreIsUnmarshaled(t *testing.T) {
assert
.
NotNil
(
t
,
cred
,
"Credential should exist"
)
assert
.
NotNil
(
t
,
cred
.
Attributes
[
0
],
"Metadata attribute of irma-demo.RU.studentCard should not be nil"
)
assert
.
NotEmpty
(
t
,
Manager
.
CredentialList
())
assert
.
True
(
t
,
cred
.
Signature
.
Verify
(
cred
.
PublicKey
(),
cred
.
Attributes
),
"Credential should be valid"
,
...
...
manager.go
View file @
e03aeafc
...
...
@@ -36,11 +36,13 @@ func newCredentialManager() *CredentialManager {
// CredentialList returns a list of information of all contained credentials.
func
(
cm
*
CredentialManager
)
CredentialList
()
CredentialList
{
list
:=
CredentialList
([]
*
Credential
{})
for
_
,
credlist
:=
range
cm
.
credentials
{
for
_
,
cred
:=
range
credlist
{
list
=
append
(
list
,
cred
.
info
)
for
_
,
attrlistlist
:=
range
cm
.
attributes
{
for
_
,
attrlist
:=
range
attrlistlist
{
list
=
append
(
list
,
attrlist
.
info
)
}
}
sort
.
Sort
(
list
)
return
list
}
...
...
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