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

Rename AttributeIdentifier -> AttributeTypeIdentifier

parent b2f2c486
......@@ -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 AttributeTypeIdentifier) bool {
if ai.CredentialTypeIdentifier().String() != ct.Identifier().String() {
return false
}
......
......@@ -19,8 +19,8 @@ type CredentialTypeIdentifier struct {
objectIdentifier
}
// AttributeIdentifier identifies an attribute. For example "irma-demo.RU.studentCard.studentID".
type AttributeIdentifier struct {
// AttributeTypeIdentifier identifies an attribute. For example "irma-demo.RU.studentCard.studentID".
type AttributeTypeIdentifier 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)}
// NewAttributeTypeIdentifier converts the specified identifier to a AttributeTypeIdentifier.
func NewAttributeTypeIdentifier(id string) AttributeTypeIdentifier {
return AttributeTypeIdentifier{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 AttributeTypeIdentifier) CredentialTypeIdentifier() CredentialTypeIdentifier {
return NewCredentialTypeIdentifier(id.Parent())
}
......@@ -10,10 +10,10 @@ import (
// AttributeDisjunction ...
type AttributeDisjunction struct {
Label string
Attributes []irmago.AttributeIdentifier
Values map[irmago.AttributeIdentifier]string
Attributes []irmago.AttributeTypeIdentifier
Values map[irmago.AttributeTypeIdentifier]string
selected *irmago.AttributeIdentifier
selected *irmago.AttributeTypeIdentifier
}
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.AttributeTypeIdentifier) *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.AttributeTypeIdentifier `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.AttributeTypeIdentifier]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.AttributeTypeIdentifier]string)
}
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.
......@@ -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.NewAttributeTypeIdentifier(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.NewAttributeTypeIdentifier(str))
}
default:
return errors.New("could not parse attribute disjunction: element 'attributes' was incorrect")
......
......@@ -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.NewAttributeTypeIdentifier("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.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