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

Stop using identifiers

parent 8641506d
......@@ -54,34 +54,18 @@ type AttributeDescription struct {
}
// Identifier returns the identifier of the specified credential type.
func (cd *CredentialDescription) Identifier() *CredentialTypeIdentifier {
if cd.identifier == nil {
cd.identifier = NewCredentialTypeIdentifier(cd.SchemeManagerName + "." + cd.IssuerName + "." + cd.Name)
}
return cd.identifier
func (cd *CredentialDescription) Identifier() string {
return cd.SchemeManagerName + "." + cd.IssuerName + "." + cd.Name
}
// Identifier returns the identifier of the specified issuer description.
func (id *IssuerDescription) Identifier() *IssuerIdentifier {
if id.identifier == nil {
id.identifier = NewIssuerIdentifier(id.SchemeManagerName + "." + id.Name)
}
return id.identifier
func (id *IssuerDescription) Identifier() string {
return id.SchemeManagerName + "." + id.Name
}
// CurrentPublicKey returns the latest known public key of the issuer identified by this instance.
func (id *IssuerDescription) CurrentPublicKey() *gabi.PublicKey {
return id.Identifier().CurrentPublicKey()
}
// PublicKey returns the specified public key of the issuer identified by this instance.
func (id *IssuerDescription) PublicKey(index int) *gabi.PublicKey {
return id.Identifier().PublicKey(index)
}
// CurrentPublicKey returns the latest known public key of the issuer identified by this instance.
func (i *IssuerIdentifier) CurrentPublicKey() *gabi.PublicKey {
keys := MetaStore.publickeys[i.string]
keys := MetaStore.publickeys[id.Identifier()]
if keys == nil || len(keys) == 0 {
return nil
}
......@@ -89,8 +73,8 @@ func (i *IssuerIdentifier) CurrentPublicKey() *gabi.PublicKey {
}
// PublicKey returns the specified public key of the issuer identified by this instance.
func (i *IssuerIdentifier) PublicKey(index int) *gabi.PublicKey {
keys := MetaStore.publickeys[i.string]
func (id *IssuerDescription) PublicKey(index int) *gabi.PublicKey {
keys := MetaStore.publickeys[id.Identifier()]
if keys == nil || index >= len(keys) {
return nil
}
......
package irmago
// Contains identifiers for issuers, credential types, and attributes
// Thin wrapper about their string equivalents (e.g., "irma-demo.RU")
// in case of the "RU" issuer in the "irma-demo" domain
// Not sure if these are at all necessary. Avoid if possible, TODO: remove these?
import "strings"
// Base object for identifiers
type objectIdentifier struct {
string `json:"identifier"`
parts []string
}
// IssuerIdentifier identifies an issuer.
......@@ -47,10 +51,7 @@ func NewAttributeTypeIdentifier(identifier string) *AttributeTypeIdentifier {
}
func (o *objectIdentifier) split() []string {
if o.parts == nil {
o.parts = strings.Split(o.string, ".")
}
return o.parts
return strings.Split(o.string, ".")
}
// SchemeManagerName returns the name of the scheme maanger of the current credential type.
......
......@@ -52,17 +52,17 @@ func (store *ConfigurationStore) parseIssuerFolders(path string) error {
return err
}
if exists {
store.issuers[issuer.Identifier().string] = issuer
store.issuers[issuer.Identifier()] = issuer
if err = store.parseCredentialsFolder(dir + "/Issues/"); err != nil {
return err
}
return store.parseKeysFolder(issuer.Identifier(), dir+"/PublicKeys/")
return store.parseKeysFolder(issuer, dir+"/PublicKeys/")
}
return nil
})
}
func (store *ConfigurationStore) parseKeysFolder(issuer *IssuerIdentifier, path string) error {
func (store *ConfigurationStore) parseKeysFolder(issuer *IssuerDescription, path string) error {
for i := 0; ; i++ {
file := path + strconv.Itoa(i) + ".xml"
if _, err := os.Stat(file); err != nil {
......@@ -72,7 +72,7 @@ func (store *ConfigurationStore) parseKeysFolder(issuer *IssuerIdentifier, path
if err != nil {
return err
}
MetaStore.publickeys[issuer.string] = append(MetaStore.publickeys[issuer.string], pk)
MetaStore.publickeys[issuer.Identifier()] = append(MetaStore.publickeys[issuer.Identifier()], pk)
}
return nil
}
......@@ -85,7 +85,7 @@ func (store *ConfigurationStore) parseCredentialsFolder(path string) error {
return err
}
if exists {
store.credentials[cred.Identifier().string] = cred
store.credentials[cred.Identifier()] = cred
}
return nil
})
......
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