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
658c3375
Commit
658c3375
authored
Jul 26, 2018
by
Sietse Ringers
Browse files
Make CredentialInfo.Attributes a map
Co-authored-by:
Confiks
<
confiks@scriptbase.org
>
parent
bde25dff
Changes
2
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
658c3375
...
...
@@ -65,6 +65,7 @@ type AttributeList struct {
*
MetadataAttribute
`json:"-"`
Ints
[]
*
big
.
Int
strings
[]
TranslatedString
attrMap
map
[
AttributeTypeIdentifier
]
TranslatedString
info
*
CredentialInfo
h
string
}
...
...
@@ -96,6 +97,20 @@ func (al *AttributeList) Hash() string {
return
al
.
h
}
func
(
al
*
AttributeList
)
Map
(
conf
*
Configuration
)
map
[
AttributeTypeIdentifier
]
TranslatedString
{
if
al
.
attrMap
==
nil
{
al
.
attrMap
=
make
(
map
[
AttributeTypeIdentifier
]
TranslatedString
)
ctid
:=
al
.
CredentialType
()
.
Identifier
()
strings
:=
al
.
Strings
()
ct
:=
conf
.
CredentialTypes
[
ctid
]
for
i
:=
range
ct
.
Attributes
{
attrid
:=
ct
.
Attributes
[
i
]
.
GetAttributeTypeIdentifier
(
ctid
)
al
.
attrMap
[
attrid
]
=
strings
[
i
]
}
}
return
al
.
attrMap
}
// Strings converts the current instance to human-readable strings.
func
(
al
*
AttributeList
)
Strings
()
[]
TranslatedString
{
if
al
.
strings
==
nil
{
...
...
credinfo.go
View file @
658c3375
...
...
@@ -8,16 +8,16 @@ import (
// CredentialInfo contains all information of an IRMA credential.
type
CredentialInfo
struct
{
ID
string
// e.g., "studentCard"
CredentialTypeID
CredentialTypeIdentifier
// e.g., "irma-demo.RU.studentCard"
IssuerID
IssuerIdentifier
// e.g., "irma-demo.RU"
SchemeManagerID
SchemeManagerIdentifier
// e.g., "irma-demo"
Index
int
// This is the Index-th credential instance of this type
SignedOn
Timestamp
// Unix timestamp
Expires
Timestamp
// Unix timestamp
Attributes
[
]
TranslatedString
// Human-readable rendered attributes
Logo
string
// Path to logo on storage
Hash
string
// SHA256 hash over the attributes
ID
string
// e.g., "studentCard"
CredentialTypeID
CredentialTypeIdentifier
// e.g., "irma-demo.RU.studentCard"
IssuerID
IssuerIdentifier
// e.g., "irma-demo.RU"
SchemeManagerID
SchemeManagerIdentifier
// e.g., "irma-demo"
Index
int
// This is the Index-th credential instance of this type
SignedOn
Timestamp
// Unix timestamp
Expires
Timestamp
// Unix timestamp
Attributes
map
[
AttributeTypeIdentifier
]
TranslatedString
// Human-readable rendered attributes
Logo
string
// Path to logo on storage
Hash
string
// SHA256 hash over the attributes
}
// A CredentialInfoList is a list of credentials (implements sort.Interface).
...
...
@@ -40,7 +40,7 @@ func NewCredentialInfo(ints []*big.Int, conf *Configuration) *CredentialInfo {
SchemeManagerID
:
issid
.
SchemeManagerIdentifier
(),
SignedOn
:
Timestamp
(
meta
.
SigningDate
()),
Expires
:
Timestamp
(
meta
.
Expiry
()),
Attributes
:
attrs
.
Strings
(
),
Attributes
:
attrs
.
Map
(
conf
),
Logo
:
credtype
.
Logo
(
conf
),
Hash
:
attrs
.
Hash
(),
}
...
...
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