Commit aa45e3ee authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Rename AttributeIdentifier -> AttributeTypeIdentifier

parent b2f2c486
...@@ -47,7 +47,7 @@ type CredentialType struct { ...@@ -47,7 +47,7 @@ type CredentialType struct {
// ContainsAttribute tests whether the specified attribute is contained in this // ContainsAttribute tests whether the specified attribute is contained in this
// credentialtype. // credentialtype.
func (ct *CredentialType) ContainsAttribute(ai AttributeIdentifier) bool { func (ct *CredentialType) ContainsAttribute(ai AttributeTypeIdentifier) bool {
if ai.CredentialTypeIdentifier().String() != ct.Identifier().String() { if ai.CredentialTypeIdentifier().String() != ct.Identifier().String() {
return false return false
} }
......
...@@ -19,8 +19,8 @@ type CredentialTypeIdentifier struct { ...@@ -19,8 +19,8 @@ type CredentialTypeIdentifier struct {
objectIdentifier objectIdentifier
} }
// AttributeIdentifier identifies an attribute. For example "irma-demo.RU.studentCard.studentID". // AttributeTypeIdentifier identifies an attribute. For example "irma-demo.RU.studentCard.studentID".
type AttributeIdentifier struct { type AttributeTypeIdentifier struct {
objectIdentifier objectIdentifier
} }
...@@ -53,9 +53,9 @@ func NewCredentialTypeIdentifier(id string) CredentialTypeIdentifier { ...@@ -53,9 +53,9 @@ func NewCredentialTypeIdentifier(id string) CredentialTypeIdentifier {
return CredentialTypeIdentifier{objectIdentifier(id)} return CredentialTypeIdentifier{objectIdentifier(id)}
} }
// NewAttributeIdentifier converts the specified identifier to a AttributeIdentifier. // NewAttributeTypeIdentifier converts the specified identifier to a AttributeTypeIdentifier.
func NewAttributeIdentifier(id string) AttributeIdentifier { func NewAttributeTypeIdentifier(id string) AttributeTypeIdentifier {
return AttributeIdentifier{objectIdentifier(id)} return AttributeTypeIdentifier{objectIdentifier(id)}
} }
// SchemeManagerIdentifier returns the scheme manager identifer of the issuer. // SchemeManagerIdentifier returns the scheme manager identifer of the issuer.
...@@ -69,6 +69,6 @@ func (id CredentialTypeIdentifier) IssuerIdentifier() IssuerIdentifier { ...@@ -69,6 +69,6 @@ func (id CredentialTypeIdentifier) IssuerIdentifier() IssuerIdentifier {
} }
// CredentialTypeIdentifier returns the CredentialTypeIdentifier of the attribute identifier. // CredentialTypeIdentifier returns the CredentialTypeIdentifier of the attribute identifier.
func (id AttributeIdentifier) CredentialTypeIdentifier() CredentialTypeIdentifier { func (id AttributeTypeIdentifier) CredentialTypeIdentifier() CredentialTypeIdentifier {
return NewCredentialTypeIdentifier(id.Parent()) return NewCredentialTypeIdentifier(id.Parent())
} }
...@@ -10,10 +10,10 @@ import ( ...@@ -10,10 +10,10 @@ import (
// AttributeDisjunction ... // AttributeDisjunction ...
type AttributeDisjunction struct { type AttributeDisjunction struct {
Label string Label string
Attributes []irmago.AttributeIdentifier Attributes []irmago.AttributeTypeIdentifier
Values map[irmago.AttributeIdentifier]string Values map[irmago.AttributeTypeIdentifier]string
selected *irmago.AttributeIdentifier selected *irmago.AttributeTypeIdentifier
} }
type AttributeDisjunctionList []*AttributeDisjunction type AttributeDisjunctionList []*AttributeDisjunction
...@@ -60,7 +60,7 @@ func (dl AttributeDisjunctionList) Satisfied() bool { ...@@ -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. // 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.AttributeTypeIdentifier) *AttributeDisjunction {
for _, disjunction := range dl { for _, disjunction := range dl {
for _, attr := range disjunction.Attributes { for _, attr := range disjunction.Attributes {
if attr == ai { if attr == ai {
...@@ -75,7 +75,7 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) { ...@@ -75,7 +75,7 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) {
if !disjunction.HasValues() { if !disjunction.HasValues() {
temp := struct { temp := struct {
Label string `json:"label"` Label string `json:"label"`
Attributes []irmago.AttributeIdentifier `json:"attributes"` Attributes []irmago.AttributeTypeIdentifier `json:"attributes"`
}{ }{
Label: disjunction.Label, Label: disjunction.Label,
Attributes: disjunction.Attributes, Attributes: disjunction.Attributes,
...@@ -84,7 +84,7 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) { ...@@ -84,7 +84,7 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) {
} else { } else {
temp := struct { temp := struct {
Label string `json:"label"` Label string `json:"label"`
Attributes map[irmago.AttributeIdentifier]string `json:"attributes"` Attributes map[irmago.AttributeTypeIdentifier]string `json:"attributes"`
}{ }{
Label: disjunction.Label, Label: disjunction.Label,
Attributes: disjunction.Values, Attributes: disjunction.Values,
...@@ -95,10 +95,10 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) { ...@@ -95,10 +95,10 @@ func (disjunction *AttributeDisjunction) MarshalJSON() ([]byte, error) {
func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error { func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
if disjunction.Values == nil { if disjunction.Values == nil {
disjunction.Values = make(map[irmago.AttributeIdentifier]string) disjunction.Values = make(map[irmago.AttributeTypeIdentifier]string)
} }
if disjunction.Attributes == nil { if disjunction.Attributes == nil {
disjunction.Attributes = make([]irmago.AttributeIdentifier, 0, 3) disjunction.Attributes = make([]irmago.AttributeTypeIdentifier, 0, 3)
} }
// We don't know if the json element "attributes" is a list, or a map. // 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 { ...@@ -119,7 +119,7 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
}{} }{}
json.Unmarshal(bytes, &temp) json.Unmarshal(bytes, &temp)
for str, value := range temp.Attributes { for str, value := range temp.Attributes {
id := irmago.NewAttributeIdentifier(str) id := irmago.NewAttributeTypeIdentifier(str)
disjunction.Attributes = append(disjunction.Attributes, id) disjunction.Attributes = append(disjunction.Attributes, id)
disjunction.Values[id] = value disjunction.Values[id] = value
} }
...@@ -130,7 +130,7 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error { ...@@ -130,7 +130,7 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
}{} }{}
json.Unmarshal(bytes, &temp) json.Unmarshal(bytes, &temp)
for _, str := range temp.Attributes { for _, str := range temp.Attributes {
disjunction.Attributes = append(disjunction.Attributes, irmago.NewAttributeIdentifier(str)) disjunction.Attributes = append(disjunction.Attributes, irmago.NewAttributeTypeIdentifier(str))
} }
default: default:
return errors.New("could not parse attribute disjunction: element 'attributes' was incorrect") return errors.New("could not parse attribute disjunction: element 'attributes' was incorrect")
......
...@@ -16,7 +16,7 @@ func TestAttributeDisjunctionMarshaling(t *testing.T) { ...@@ -16,7 +16,7 @@ func TestAttributeDisjunctionMarshaling(t *testing.T) {
var _ json.Unmarshaler = &disjunction var _ json.Unmarshaler = &disjunction
var _ json.Marshaler = &disjunction var _ json.Marshaler = &disjunction
id := irmago.NewAttributeIdentifier("MijnOverheid.ageLower.over18") id := irmago.NewAttributeTypeIdentifier("MijnOverheid.ageLower.over18")
attrsjson := ` attrsjson := `
{ {
...@@ -90,5 +90,5 @@ func TestServiceProviderRequest(t *testing.T) { ...@@ -90,5 +90,5 @@ func TestServiceProviderRequest(t *testing.T) {
require.NotEmpty(t, sprequest.Request.Request.Content[0].Attributes) require.NotEmpty(t, sprequest.Request.Request.Content[0].Attributes)
require.Equal(t, sprequest.Request.Request.Content[0].Attributes[0].Name(), "studentID") 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.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID")))
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment