Commit 0da3c2ff authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Rename CredentialType.Attributes to AttributeTypes

parent da9fdf3d
...@@ -83,8 +83,8 @@ func (al *AttributeList) Map(conf *Configuration) map[AttributeTypeIdentifier]Tr ...@@ -83,8 +83,8 @@ func (al *AttributeList) Map(conf *Configuration) map[AttributeTypeIdentifier]Tr
ctid := al.CredentialType().Identifier() ctid := al.CredentialType().Identifier()
strings := al.Strings() strings := al.Strings()
ct := conf.CredentialTypes[ctid] ct := conf.CredentialTypes[ctid]
for i := range ct.Attributes { for i := range ct.AttributeTypes {
attrid := ct.Attributes[i].GetAttributeTypeIdentifier() attrid := ct.AttributeTypes[i].GetAttributeTypeIdentifier()
al.attrMap[attrid] = strings[i] al.attrMap[attrid] = strings[i]
} }
} }
...@@ -142,7 +142,7 @@ func (al *AttributeList) UntranslatedAttribute(identifier AttributeTypeIdentifie ...@@ -142,7 +142,7 @@ func (al *AttributeList) UntranslatedAttribute(identifier AttributeTypeIdentifie
if al.CredentialType().Identifier() != identifier.CredentialTypeIdentifier() { if al.CredentialType().Identifier() != identifier.CredentialTypeIdentifier() {
return nil return nil
} }
for i, desc := range al.CredentialType().Attributes { for i, desc := range al.CredentialType().AttributeTypes {
if desc.ID == string(identifier.Name()) { if desc.ID == string(identifier.Name()) {
return al.decode(i) return al.decode(i)
} }
...@@ -155,7 +155,7 @@ func (al *AttributeList) Attribute(identifier AttributeTypeIdentifier) Translate ...@@ -155,7 +155,7 @@ func (al *AttributeList) Attribute(identifier AttributeTypeIdentifier) Translate
if al.CredentialType().Identifier() != identifier.CredentialTypeIdentifier() { if al.CredentialType().Identifier() != identifier.CredentialTypeIdentifier() {
return nil return nil
} }
for i, desc := range al.CredentialType().Attributes { for i, desc := range al.CredentialType().AttributeTypes {
if desc.ID == string(identifier.Name()) { if desc.ID == string(identifier.Name()) {
return al.Strings()[i] return al.Strings()[i]
} }
......
...@@ -54,7 +54,7 @@ type CredentialType struct { ...@@ -54,7 +54,7 @@ type CredentialType struct {
SchemeManagerID string `xml:"SchemeManager"` SchemeManagerID string `xml:"SchemeManager"`
IsSingleton bool `xml:"ShouldBeSingleton"` IsSingleton bool `xml:"ShouldBeSingleton"`
Description TranslatedString Description TranslatedString
Attributes []*AttributeType `xml:"Attributes>Attribute" json:"-"` AttributeTypes []*AttributeType `xml:"Attributes>Attribute" json:"-"`
XMLVersion int `xml:"version,attr"` XMLVersion int `xml:"version,attr"`
XMLName xml.Name `xml:"IssueSpecification"` XMLName xml.Name `xml:"IssueSpecification"`
...@@ -91,7 +91,7 @@ func (ct *CredentialType) ContainsAttribute(ai AttributeTypeIdentifier) bool { ...@@ -91,7 +91,7 @@ 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
} }
for _, desc := range ct.Attributes { for _, desc := range ct.AttributeTypes {
if desc.ID == ai.Name() { if desc.ID == ai.Name() {
return true return true
} }
...@@ -105,7 +105,7 @@ func (ct CredentialType) IndexOf(ai AttributeTypeIdentifier) (int, error) { ...@@ -105,7 +105,7 @@ func (ct CredentialType) IndexOf(ai AttributeTypeIdentifier) (int, error) {
if ai.CredentialTypeIdentifier() != ct.Identifier() { if ai.CredentialTypeIdentifier() != ct.Identifier() {
return -1, errors.New("Wrong credential type") return -1, errors.New("Wrong credential type")
} }
for i, description := range ct.Attributes { for i, description := range ct.AttributeTypes {
if description.ID == ai.Name() { if description.ID == ai.Name() {
return i, nil return i, nil
} }
...@@ -118,7 +118,7 @@ func (ct CredentialType) AttributeType(ai AttributeTypeIdentifier) *AttributeTyp ...@@ -118,7 +118,7 @@ func (ct CredentialType) AttributeType(ai AttributeTypeIdentifier) *AttributeTyp
if i == -1 { if i == -1 {
return nil return nil
} }
return ct.Attributes[i] return ct.AttributeTypes[i]
} }
// TranslatedString is a map of translated strings. // TranslatedString is a map of translated strings.
......
...@@ -42,7 +42,7 @@ type Configuration struct { ...@@ -42,7 +42,7 @@ type Configuration struct {
SchemeManagers map[SchemeManagerIdentifier]*SchemeManager SchemeManagers map[SchemeManagerIdentifier]*SchemeManager
Issuers map[IssuerIdentifier]*Issuer Issuers map[IssuerIdentifier]*Issuer
CredentialTypes map[CredentialTypeIdentifier]*CredentialType CredentialTypes map[CredentialTypeIdentifier]*CredentialType
Attributes map[AttributeTypeIdentifier]*AttributeType AttributeTypes map[AttributeTypeIdentifier]*AttributeType
// Path to the irma_configuration folder that this instance represents // Path to the irma_configuration folder that this instance represents
Path string Path string
...@@ -119,7 +119,7 @@ func (conf *Configuration) clear() { ...@@ -119,7 +119,7 @@ func (conf *Configuration) clear() {
conf.SchemeManagers = make(map[SchemeManagerIdentifier]*SchemeManager) conf.SchemeManagers = make(map[SchemeManagerIdentifier]*SchemeManager)
conf.Issuers = make(map[IssuerIdentifier]*Issuer) conf.Issuers = make(map[IssuerIdentifier]*Issuer)
conf.CredentialTypes = make(map[CredentialTypeIdentifier]*CredentialType) conf.CredentialTypes = make(map[CredentialTypeIdentifier]*CredentialType)
conf.Attributes = make(map[AttributeTypeIdentifier]*AttributeType) conf.AttributeTypes = make(map[AttributeTypeIdentifier]*AttributeType)
conf.DisabledSchemeManagers = make(map[SchemeManagerIdentifier]*SchemeManagerError) conf.DisabledSchemeManagers = make(map[SchemeManagerIdentifier]*SchemeManagerError)
conf.kssPublicKeys = make(map[SchemeManagerIdentifier]map[int]*rsa.PublicKey) conf.kssPublicKeys = make(map[SchemeManagerIdentifier]map[int]*rsa.PublicKey)
conf.publicKeys = make(map[IssuerIdentifier]map[int]*gabi.PublicKey) conf.publicKeys = make(map[IssuerIdentifier]map[int]*gabi.PublicKey)
...@@ -458,12 +458,12 @@ func (conf *Configuration) parseCredentialsFolder(manager *SchemeManager, issuer ...@@ -458,12 +458,12 @@ func (conf *Configuration) parseCredentialsFolder(manager *SchemeManager, issuer
credid := cred.Identifier() credid := cred.Identifier()
conf.CredentialTypes[credid] = cred conf.CredentialTypes[credid] = cred
conf.addReverseHash(credid) conf.addReverseHash(credid)
for index, attr := range cred.Attributes { for index, attr := range cred.AttributeTypes {
attr.Index = index attr.Index = index
attr.SchemeManagerID = cred.SchemeManagerID attr.SchemeManagerID = cred.SchemeManagerID
attr.IssuerID = cred.IssuerID attr.IssuerID = cred.IssuerID
attr.CredentialTypeID = cred.ID attr.CredentialTypeID = cred.ID
conf.Attributes[attr.GetAttributeTypeIdentifier()] = attr conf.AttributeTypes[attr.GetAttributeTypeIdentifier()] = attr
} }
return nil return nil
}) })
...@@ -725,7 +725,7 @@ func (conf *Configuration) checkCredentialTypes(session SessionRequest, managers ...@@ -725,7 +725,7 @@ func (conf *Configuration) checkCredentialTypes(session SessionRequest, managers
} }
// For each of the attributes in the credentialtype, see if it is present; if so remove it from newAttrs // For each of the attributes in the credentialtype, see if it is present; if so remove it from newAttrs
// If not, check that it is optional; if not the credentialtype must be updated // If not, check that it is optional; if not the credentialtype must be updated
for _, attrtyp := range typ.Attributes { for _, attrtyp := range typ.AttributeTypes {
_, contains = newAttrs[attrtyp.ID] _, contains = newAttrs[attrtyp.ID]
if !contains && !attrtyp.IsOptional() { if !contains && !attrtyp.IsOptional() {
managers[credreq.CredentialTypeID.Root()] = struct{}{} managers[credreq.CredentialTypeID.Root()] = struct{}{}
...@@ -1076,11 +1076,11 @@ func (conf *Configuration) checkCredentialType(manager *SchemeManager, issuer *I ...@@ -1076,11 +1076,11 @@ func (conf *Configuration) checkCredentialType(manager *SchemeManager, issuer *I
func (conf *Configuration) checkAttributes(cred *CredentialType) error { func (conf *Configuration) checkAttributes(cred *CredentialType) error {
name := cred.Identifier().String() name := cred.Identifier().String()
indices := make(map[int]struct{}) indices := make(map[int]struct{})
count := len(cred.Attributes) count := len(cred.AttributeTypes)
if count == 0 { if count == 0 {
return errors.Errorf("Credenial type %s has no attributes", name) return errors.Errorf("Credenial type %s has no attributes", name)
} }
for i, attr := range cred.Attributes { for i, attr := range cred.AttributeTypes {
conf.checkTranslations(fmt.Sprintf("Attribute %s of credential type %s", attr.ID, cred.Identifier().String()), attr) conf.checkTranslations(fmt.Sprintf("Attribute %s of credential type %s", attr.ID, cred.Identifier().String()), attr)
index := i index := i
if attr.DisplayIndex != nil { if attr.DisplayIndex != nil {
......
...@@ -136,7 +136,7 @@ func TestParseIrmaConfiguration(t *testing.T) { ...@@ -136,7 +136,7 @@ func TestParseIrmaConfiguration(t *testing.T) {
require.Equal(t, require.Equal(t,
"studentID", "studentID",
conf.CredentialTypes[NewCredentialTypeIdentifier("irma-demo.RU.studentCard")].Attributes[2].ID, conf.CredentialTypes[NewCredentialTypeIdentifier("irma-demo.RU.studentCard")].AttributeTypes[2].ID,
"irma-demo.RU.studentCard.studentID has unexpected name") "irma-demo.RU.studentCard.studentID has unexpected name")
// Hash algorithm pseudocode: // Hash algorithm pseudocode:
......
...@@ -167,7 +167,7 @@ func (cr *CredentialRequest) Validate(conf *Configuration) error { ...@@ -167,7 +167,7 @@ func (cr *CredentialRequest) Validate(conf *Configuration) error {
// in the credential descriptor. // in the credential descriptor.
for crName := range cr.Attributes { for crName := range cr.Attributes {
found := false found := false
for _, ad := range credtype.Attributes { for _, ad := range credtype.AttributeTypes {
if ad.ID == crName { if ad.ID == crName {
found = true found = true
break break
...@@ -178,7 +178,7 @@ func (cr *CredentialRequest) Validate(conf *Configuration) error { ...@@ -178,7 +178,7 @@ func (cr *CredentialRequest) Validate(conf *Configuration) error {
} }
} }
for _, attrtype := range credtype.Attributes { for _, attrtype := range credtype.AttributeTypes {
if _, present := cr.Attributes[attrtype.ID]; !present && attrtype.Optional != "true" { if _, present := cr.Attributes[attrtype.ID]; !present && attrtype.Optional != "true" {
return errors.New("Required attribute not present in credential request") return errors.New("Required attribute not present in credential request")
} }
...@@ -204,9 +204,9 @@ func (cr *CredentialRequest) AttributeList(conf *Configuration, metadataVersion ...@@ -204,9 +204,9 @@ func (cr *CredentialRequest) AttributeList(conf *Configuration, metadataVersion
// Compute other attributes // Compute other attributes
credtype := conf.CredentialTypes[cr.CredentialTypeID] credtype := conf.CredentialTypes[cr.CredentialTypeID]
attrs := make([]*big.Int, len(credtype.Attributes)+1) attrs := make([]*big.Int, len(credtype.AttributeTypes)+1)
attrs[0] = meta.Int attrs[0] = meta.Int
for i, attrtype := range credtype.Attributes { for i, attrtype := range credtype.AttributeTypes {
attrs[i+1] = new(big.Int) attrs[i+1] = new(big.Int)
if str, present := cr.Attributes[attrtype.ID]; present { if str, present := cr.Attributes[attrtype.ID]; present {
// Set attribute to str << 1 + 1 // Set attribute to str << 1 + 1
......
...@@ -81,7 +81,7 @@ func (sm *SignedMessage) VerifyTimestamp(message string, conf *Configuration) er ...@@ -81,7 +81,7 @@ func (sm *SignedMessage) VerifyTimestamp(message string, conf *Configuration) er
if ct == nil { if ct == nil {
return errors.New("Cannot verify timestamp: signature contains attributes from unknown credential type") return errors.New("Cannot verify timestamp: signature contains attributes from unknown credential type")
} }
attrcount := len(ct.Attributes) + 2 // plus secret key and metadata attrcount := len(ct.AttributeTypes) + 2 // plus secret key and metadata
disclosed[i] = make([]*big.Int, attrcount) disclosed[i] = make([]*big.Int, attrcount)
for j := 0; j < attrcount; j++ { for j := 0; j < attrcount; j++ {
val, ok := proofd.ADisclosed[j] val, ok := proofd.ADisclosed[j]
......
...@@ -159,7 +159,7 @@ func (pl ProofList) DisclosedAttributes(configuration *Configuration, disjunctio ...@@ -159,7 +159,7 @@ func (pl ProofList) DisclosedAttributes(configuration *Configuration, disjunctio
p := "present" p := "present"
attrval = &p attrval = &p
} else { } else {
attrid = credtype.Attributes[k-2].GetAttributeTypeIdentifier() attrid = credtype.AttributeTypes[k-2].GetAttributeTypeIdentifier()
attrval = decodeAttribute(v, metadata.Version()) attrval = decodeAttribute(v, metadata.Version())
} }
attr = &DisclosedAttribute{ attr = &DisclosedAttribute{
......
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