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

Rename CredentialType.Attributes to AttributeTypes

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