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
b39704b8
Commit
b39704b8
authored
Jul 27, 2018
by
Sietse Ringers
Browse files
Add new map to irma.Configuration for attribute types
Co-authored-by:
Confiks
<
confiks@scriptbase.org
>
parent
6ad21f06
Changes
4
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
b39704b8
...
...
@@ -104,7 +104,7 @@ func (al *AttributeList) Map(conf *Configuration) map[AttributeTypeIdentifier]Tr
strings
:=
al
.
Strings
()
ct
:=
conf
.
CredentialTypes
[
ctid
]
for
i
:=
range
ct
.
Attributes
{
attrid
:=
ct
.
Attributes
[
i
]
.
GetAttributeTypeIdentifier
(
ctid
)
attrid
:=
ct
.
Attributes
[
i
]
.
GetAttributeTypeIdentifier
()
al
.
attrMap
[
attrid
]
=
strings
[
i
]
}
}
...
...
@@ -166,7 +166,7 @@ func (al *AttributeList) UntranslatedAttribute(identifier AttributeTypeIdentifie
return
nil
}
// Attribute returns the content of the specified attribute, or
""
if not present in this attribute list.
// Attribute returns the content of the specified attribute, or
nil
if not present in this attribute list.
func
(
al
*
AttributeList
)
Attribute
(
identifier
AttributeTypeIdentifier
)
TranslatedString
{
if
al
.
CredentialType
()
.
Identifier
()
!=
identifier
.
CredentialTypeIdentifier
()
{
return
nil
...
...
descriptions.go
View file @
b39704b8
...
...
@@ -55,9 +55,9 @@ type CredentialType struct {
SchemeManagerID
string
`xml:"SchemeManager"`
IsSingleton
bool
`xml:"ShouldBeSingleton"`
Description
TranslatedString
Attributes
[]
AttributeType
`xml:"Attributes>Attribute"`
XMLVersion
int
`xml:"version,attr"`
XMLName
xml
.
Name
`xml:"IssueSpecification"`
Attributes
[]
*
AttributeType
`xml:"Attributes>Attribute"
json:"-"
`
XMLVersion
int
`xml:"version,attr"`
XMLName
xml
.
Name
`xml:"IssueSpecification"`
Valid
bool
`xml:"-"`
}
...
...
@@ -66,13 +66,20 @@ type CredentialType struct {
type
AttributeType
struct
{
ID
string
`xml:"id,attr"`
Optional
string
`xml:"optional,attr" json:",omitempty"`
Index
*
int
`xml:"index,attr" json:",omitempty"`
Name
TranslatedString
Description
TranslatedString
Index
int
`xml:"-"`
DisplayIndex
*
int
`xml:"displayIndex,attr" json:",omitempty"`
// Taken from containing CredentialType
CredentialTypeID
string
`xml:"-"`
IssuerID
string
`xml:"-"`
SchemeManagerID
string
`xml:"-"`
}
func
(
ad
AttributeType
)
GetAttributeTypeIdentifier
(
cred
CredentialTypeIdentifier
)
AttributeTypeIdentifier
{
return
NewAttributeTypeIdentifier
(
cred
.
S
t
rin
g
()
+
"."
+
ad
.
ID
)
func
(
ad
AttributeType
)
GetAttributeTypeIdentifier
()
AttributeTypeIdentifier
{
return
NewAttributeTypeIdentifier
(
fmt
.
S
p
rin
tf
(
"%s.%s.%s.%s"
,
ad
.
SchemeManagerID
,
ad
.
IssuerID
,
ad
.
CredentialTypeID
,
ad
.
ID
)
)
}
func
(
ad
AttributeType
)
IsOptional
()
bool
{
...
...
@@ -112,7 +119,7 @@ func (ct CredentialType) AttributeType(ai AttributeTypeIdentifier) *AttributeTyp
if
i
==
-
1
{
return
nil
}
return
&
ct
.
Attributes
[
i
]
return
ct
.
Attributes
[
i
]
}
// TranslatedString is a map of translated strings.
...
...
irmaconfig.go
View file @
b39704b8
...
...
@@ -40,6 +40,7 @@ type Configuration struct {
SchemeManagers
map
[
SchemeManagerIdentifier
]
*
SchemeManager
Issuers
map
[
IssuerIdentifier
]
*
Issuer
CredentialTypes
map
[
CredentialTypeIdentifier
]
*
CredentialType
Attributes
map
[
AttributeTypeIdentifier
]
*
AttributeType
// Path to the irma_configuration folder that this instance represents
Path
string
...
...
@@ -115,6 +116,7 @@ func (conf *Configuration) clear() {
conf
.
SchemeManagers
=
make
(
map
[
SchemeManagerIdentifier
]
*
SchemeManager
)
conf
.
Issuers
=
make
(
map
[
IssuerIdentifier
]
*
Issuer
)
conf
.
CredentialTypes
=
make
(
map
[
CredentialTypeIdentifier
]
*
CredentialType
)
conf
.
Attributes
=
make
(
map
[
AttributeTypeIdentifier
]
*
AttributeType
)
conf
.
DisabledSchemeManagers
=
make
(
map
[
SchemeManagerIdentifier
]
*
SchemeManagerError
)
conf
.
publicKeys
=
make
(
map
[
IssuerIdentifier
]
map
[
int
]
*
gabi
.
PublicKey
)
conf
.
reverseHashes
=
make
(
map
[
string
]
CredentialTypeIdentifier
)
...
...
@@ -429,6 +431,13 @@ func (conf *Configuration) parseCredentialsFolder(manager *SchemeManager, issuer
credid
:=
cred
.
Identifier
()
conf
.
CredentialTypes
[
credid
]
=
cred
conf
.
addReverseHash
(
credid
)
for
index
,
attr
:=
range
cred
.
Attributes
{
attr
.
Index
=
index
attr
.
SchemeManagerID
=
cred
.
SchemeManagerID
attr
.
IssuerID
=
cred
.
IssuerID
attr
.
CredentialTypeID
=
cred
.
ID
conf
.
Attributes
[
attr
.
GetAttributeTypeIdentifier
()]
=
attr
}
return
nil
})
if
!
foundcred
{
...
...
@@ -1047,16 +1056,16 @@ func (conf *Configuration) checkAttributes(cred *CredentialType) error {
for
i
,
attr
:=
range
cred
.
Attributes
{
conf
.
checkTranslations
(
fmt
.
Sprintf
(
"Attribute %s of credential type %s"
,
attr
.
ID
,
cred
.
Identifier
()
.
String
()),
attr
)
index
:=
i
if
attr
.
Index
!=
nil
{
index
=
*
attr
.
Index
if
attr
.
Display
Index
!=
nil
{
index
=
*
attr
.
Display
Index
}
if
index
>=
count
{
conf
.
Warnings
=
append
(
conf
.
Warnings
,
fmt
.
Sprintf
(
"Credential type %s has invalid attribute
i
ndex at attribute %d"
,
name
,
i
))
conf
.
Warnings
=
append
(
conf
.
Warnings
,
fmt
.
Sprintf
(
"Credential type %s has invalid attribute
displayI
ndex at attribute %d"
,
name
,
i
))
}
indices
[
index
]
=
struct
{}{}
}
if
len
(
indices
)
!=
count
{
conf
.
Warnings
=
append
(
conf
.
Warnings
,
fmt
.
Sprintf
(
"Credential type %s has invalid attribute ordering, check the
i
ndex
-
tags"
,
name
))
conf
.
Warnings
=
append
(
conf
.
Warnings
,
fmt
.
Sprintf
(
"Credential type %s has invalid attribute ordering, check the
displayI
ndex
tags"
,
name
))
}
return
nil
}
...
...
verify.go
View file @
b39704b8
...
...
@@ -162,7 +162,7 @@ func NewDisclosedCredentialFromADisclosed(aDisclosed map[int]*big.Int, configura
continue
}
id
:=
cred
.
Attributes
[
k
-
2
]
.
GetAttributeTypeIdentifier
(
cred
.
Identifier
()
)
id
:=
cred
.
Attributes
[
k
-
2
]
.
GetAttributeTypeIdentifier
()
attributeValue
:=
decodeAttribute
(
v
,
metadata
.
Version
())
rawAttributes
[
id
]
=
attributeValue
attributes
[
id
]
=
translateAttribute
(
attributeValue
)
...
...
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