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
aa45e3ee
Commit
aa45e3ee
authored
Jul 28, 2017
by
Sietse Ringers
Browse files
Rename AttributeIdentifier -> AttributeTypeIdentifier
parent
b2f2c486
Changes
4
Hide whitespace changes
Inline
Side-by-side
descriptions.go
View file @
aa45e3ee
...
...
@@ -47,7 +47,7 @@ type CredentialType struct {
// ContainsAttribute tests whether the specified attribute is contained in this
// credentialtype.
func
(
ct
*
CredentialType
)
ContainsAttribute
(
ai
AttributeIdentifier
)
bool
{
func
(
ct
*
CredentialType
)
ContainsAttribute
(
ai
Attribute
Type
Identifier
)
bool
{
if
ai
.
CredentialTypeIdentifier
()
.
String
()
!=
ct
.
Identifier
()
.
String
()
{
return
false
}
...
...
identifiers.go
View file @
aa45e3ee
...
...
@@ -19,8 +19,8 @@ type CredentialTypeIdentifier struct {
objectIdentifier
}
// AttributeIdentifier identifies an attribute. For example "irma-demo.RU.studentCard.studentID".
type
AttributeIdentifier
struct
{
// Attribute
Type
Identifier identifies an attribute. For example "irma-demo.RU.studentCard.studentID".
type
Attribute
Type
Identifier
struct
{
objectIdentifier
}
...
...
@@ -53,9 +53,9 @@ func NewCredentialTypeIdentifier(id string) CredentialTypeIdentifier {
return
CredentialTypeIdentifier
{
objectIdentifier
(
id
)}
}
// NewAttributeIdentifier converts the specified identifier to a AttributeIdentifier.
func
NewAttributeIdentifier
(
id
string
)
AttributeIdentifier
{
return
AttributeIdentifier
{
objectIdentifier
(
id
)}
// NewAttribute
Type
Identifier converts the specified identifier to a Attribute
Type
Identifier.
func
NewAttribute
Type
Identifier
(
id
string
)
Attribute
Type
Identifier
{
return
Attribute
Type
Identifier
{
objectIdentifier
(
id
)}
}
// SchemeManagerIdentifier returns the scheme manager identifer of the issuer.
...
...
@@ -69,6 +69,6 @@ func (id CredentialTypeIdentifier) IssuerIdentifier() IssuerIdentifier {
}
// CredentialTypeIdentifier returns the CredentialTypeIdentifier of the attribute identifier.
func
(
id
AttributeIdentifier
)
CredentialTypeIdentifier
()
CredentialTypeIdentifier
{
func
(
id
Attribute
Type
Identifier
)
CredentialTypeIdentifier
()
CredentialTypeIdentifier
{
return
NewCredentialTypeIdentifier
(
id
.
Parent
())
}
protocol/attributes.go
View file @
aa45e3ee
...
...
@@ -10,10 +10,10 @@ import (
// AttributeDisjunction ...
type
AttributeDisjunction
struct
{
Label
string
Attributes
[]
irmago
.
AttributeIdentifier
Values
map
[
irmago
.
AttributeIdentifier
]
string
Attributes
[]
irmago
.
Attribute
Type
Identifier
Values
map
[
irmago
.
Attribute
Type
Identifier
]
string
selected
*
irmago
.
AttributeIdentifier
selected
*
irmago
.
Attribute
Type
Identifier
}
type
AttributeDisjunctionList
[]
*
AttributeDisjunction
...
...
@@ -60,7 +60,7 @@ func (dl AttributeDisjunctionList) Satisfied() bool {
}
// Find searches for and returns the disjunction that contains the specified attribute identifier, or nil if not found.
func
(
dl
AttributeDisjunctionList
)
Find
(
ai
irmago
.
AttributeIdentifier
)
*
AttributeDisjunction
{
func
(
dl
AttributeDisjunctionList
)
Find
(
ai
irmago
.
Attribute
Type
Identifier
)
*
AttributeDisjunction
{
for
_
,
disjunction
:=
range
dl
{
for
_
,
attr
:=
range
disjunction
.
Attributes
{
if
attr
==
ai
{
...
...
@@ -75,7 +75,7 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) {
if
!
disjunction
.
HasValues
()
{
temp
:=
struct
{
Label
string
`json:"label"`
Attributes
[]
irmago
.
AttributeIdentifier
`json:"attributes"`
Attributes
[]
irmago
.
Attribute
Type
Identifier
`json:"attributes"`
}{
Label
:
disjunction
.
Label
,
Attributes
:
disjunction
.
Attributes
,
...
...
@@ -84,7 +84,7 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) {
}
else
{
temp
:=
struct
{
Label
string
`json:"label"`
Attributes
map
[
irmago
.
AttributeIdentifier
]
string
`json:"attributes"`
Attributes
map
[
irmago
.
Attribute
Type
Identifier
]
string
`json:"attributes"`
}{
Label
:
disjunction
.
Label
,
Attributes
:
disjunction
.
Values
,
...
...
@@ -95,10 +95,10 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) {
func
(
disjunction
*
AttributeDisjunction
)
UnmarshalJSON
(
bytes
[]
byte
)
error
{
if
disjunction
.
Values
==
nil
{
disjunction
.
Values
=
make
(
map
[
irmago
.
AttributeIdentifier
]
string
)
disjunction
.
Values
=
make
(
map
[
irmago
.
Attribute
Type
Identifier
]
string
)
}
if
disjunction
.
Attributes
==
nil
{
disjunction
.
Attributes
=
make
([]
irmago
.
AttributeIdentifier
,
0
,
3
)
disjunction
.
Attributes
=
make
([]
irmago
.
Attribute
Type
Identifier
,
0
,
3
)
}
// We don't know if the json element "attributes" is a list, or a map.
...
...
@@ -119,7 +119,7 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
}{}
json
.
Unmarshal
(
bytes
,
&
temp
)
for
str
,
value
:=
range
temp
.
Attributes
{
id
:=
irmago
.
NewAttributeIdentifier
(
str
)
id
:=
irmago
.
NewAttribute
Type
Identifier
(
str
)
disjunction
.
Attributes
=
append
(
disjunction
.
Attributes
,
id
)
disjunction
.
Values
[
id
]
=
value
}
...
...
@@ -130,7 +130,7 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
}{}
json
.
Unmarshal
(
bytes
,
&
temp
)
for
_
,
str
:=
range
temp
.
Attributes
{
disjunction
.
Attributes
=
append
(
disjunction
.
Attributes
,
irmago
.
NewAttributeIdentifier
(
str
))
disjunction
.
Attributes
=
append
(
disjunction
.
Attributes
,
irmago
.
NewAttribute
Type
Identifier
(
str
))
}
default
:
return
errors
.
New
(
"could not parse attribute disjunction: element 'attributes' was incorrect"
)
...
...
protocol/protocol_test.go
View file @
aa45e3ee
...
...
@@ -16,7 +16,7 @@ func TestAttributeDisjunctionMarshaling(t *testing.T) {
var
_
json
.
Unmarshaler
=
&
disjunction
var
_
json
.
Marshaler
=
&
disjunction
id
:=
irmago
.
NewAttributeIdentifier
(
"MijnOverheid.ageLower.over18"
)
id
:=
irmago
.
NewAttribute
Type
Identifier
(
"MijnOverheid.ageLower.over18"
)
attrsjson
:=
`
{
...
...
@@ -90,5 +90,5 @@ func TestServiceProviderRequest(t *testing.T) {
require
.
NotEmpty
(
t
,
sprequest
.
Request
.
Request
.
Content
[
0
]
.
Attributes
)
require
.
Equal
(
t
,
sprequest
.
Request
.
Request
.
Content
[
0
]
.
Attributes
[
0
]
.
Name
(),
"studentID"
)
require
.
NotNil
(
t
,
sprequest
.
Request
.
Request
.
Content
.
Find
(
irmago
.
NewAttributeIdentifier
(
"irma-demo.RU.studentCard.studentID"
)))
require
.
NotNil
(
t
,
sprequest
.
Request
.
Request
.
Content
.
Find
(
irmago
.
NewAttribute
Type
Identifier
(
"irma-demo.RU.studentCard.studentID"
)))
}
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