Commit 774e3097 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Renaming server configuration fields

parent 4f1f1235
...@@ -25,7 +25,7 @@ func StartIrmaClientServer(t *testing.T) { ...@@ -25,7 +25,7 @@ func StartIrmaClientServer(t *testing.T) {
require.NoError(t, irmarequestor.Initialize(&server.Configuration{ require.NoError(t, irmarequestor.Initialize(&server.Configuration{
Logger: logger, Logger: logger,
IrmaConfigurationPath: filepath.Join(testdata, "irma_configuration"), IrmaConfigurationPath: filepath.Join(testdata, "irma_configuration"),
PrivateKeysPath: filepath.Join(testdata, "privatekeys"), IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
})) }))
mux := http.NewServeMux() mux := http.NewServeMux()
......
...@@ -26,7 +26,7 @@ func StartIrmaServer() { ...@@ -26,7 +26,7 @@ func StartIrmaServer() {
Configuration: &server.Configuration{ Configuration: &server.Configuration{
Logger: logger, Logger: logger,
IrmaConfigurationPath: filepath.Join(testdata, "irma_configuration"), IrmaConfigurationPath: filepath.Join(testdata, "irma_configuration"),
PrivateKeysPath: filepath.Join(testdata, "privatekeys"), IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
}, },
Port: 48682, Port: 48682,
}) })
......
...@@ -14,12 +14,12 @@ var Logger *logrus.Logger = logrus.StandardLogger() ...@@ -14,12 +14,12 @@ var Logger *logrus.Logger = logrus.StandardLogger()
type Configuration struct { type Configuration struct {
IrmaConfigurationPath string IrmaConfigurationPath string
PrivateKeysPath string IssuerPrivateKeysPath string
Logger *logrus.Logger Logger *logrus.Logger `json:"-"`
PrivateKeys map[irma.IssuerIdentifier]*gabi.PrivateKey IssuerPrivateKeys map[irma.IssuerIdentifier]*gabi.PrivateKey `json:"-"`
IrmaConfiguration *irma.Configuration IrmaConfiguration *irma.Configuration `json:"-"`
} }
type SessionResult struct { type SessionResult struct {
......
...@@ -37,11 +37,11 @@ func Initialize(configuration *server.Configuration) error { ...@@ -37,11 +37,11 @@ func Initialize(configuration *server.Configuration) error {
} }
} }
if conf.PrivateKeys == nil { if conf.IssuerPrivateKeys == nil {
conf.PrivateKeys = make(map[irma.IssuerIdentifier]*gabi.PrivateKey) conf.IssuerPrivateKeys = make(map[irma.IssuerIdentifier]*gabi.PrivateKey)
} }
if conf.PrivateKeysPath != "" { if conf.IssuerPrivateKeysPath != "" {
files, err := ioutil.ReadDir(conf.PrivateKeysPath) files, err := ioutil.ReadDir(conf.IssuerPrivateKeysPath)
if err != nil { if err != nil {
return err return err
} }
...@@ -51,14 +51,14 @@ func Initialize(configuration *server.Configuration) error { ...@@ -51,14 +51,14 @@ func Initialize(configuration *server.Configuration) error {
if _, ok := conf.IrmaConfiguration.Issuers[issid]; !ok { if _, ok := conf.IrmaConfiguration.Issuers[issid]; !ok {
return errors.Errorf("Private key %s belongs to an unknown issuer", filename) return errors.Errorf("Private key %s belongs to an unknown issuer", filename)
} }
sk, err := gabi.NewPrivateKeyFromFile(filepath.Join(conf.PrivateKeysPath, filename)) sk, err := gabi.NewPrivateKeyFromFile(filepath.Join(conf.IssuerPrivateKeysPath, filename))
if err != nil { if err != nil {
return err return err
} }
conf.PrivateKeys[issid] = sk conf.IssuerPrivateKeys[issid] = sk
} }
} }
for issid, sk := range conf.PrivateKeys { for issid, sk := range conf.IssuerPrivateKeys {
pk, err := conf.IrmaConfiguration.PublicKey(issid, int(sk.Counter)) pk, err := conf.IrmaConfiguration.PublicKey(issid, int(sk.Counter))
if err != nil { if err != nil {
return err return err
......
...@@ -145,7 +145,7 @@ func (session *session) handlePostCommitments(commitments *gabi.IssueCommitmentM ...@@ -145,7 +145,7 @@ func (session *session) handlePostCommitments(commitments *gabi.IssueCommitmentM
for i, cred := range request.Credentials { for i, cred := range request.Credentials {
id := cred.CredentialTypeID.IssuerIdentifier() id := cred.CredentialTypeID.IssuerIdentifier()
pk, _ := conf.IrmaConfiguration.PublicKey(id, cred.KeyCounter) pk, _ := conf.IrmaConfiguration.PublicKey(id, cred.KeyCounter)
issuer := gabi.NewIssuer(conf.PrivateKeys[id], pk, one) issuer := gabi.NewIssuer(conf.IssuerPrivateKeys[id], pk, one)
proof := commitments.Proofs[i+discloseCount].(*gabi.ProofU) proof := commitments.Proofs[i+discloseCount].(*gabi.ProofU)
attributes, err := cred.AttributeList(conf.IrmaConfiguration, 0x03) attributes, err := cred.AttributeList(conf.IrmaConfiguration, 0x03)
if err != nil { if err != nil {
......
...@@ -41,7 +41,7 @@ func validateIssuanceRequest(request *irma.IssuanceRequest) error { ...@@ -41,7 +41,7 @@ func validateIssuanceRequest(request *irma.IssuanceRequest) error {
for _, cred := range request.Credentials { for _, cred := range request.Credentials {
// Check that we have the appropriate private key // Check that we have the appropriate private key
iss := cred.CredentialTypeID.IssuerIdentifier() iss := cred.CredentialTypeID.IssuerIdentifier()
privatekey, havekey := conf.PrivateKeys[iss] privatekey, havekey := conf.IssuerPrivateKeys[iss]
if !havekey { if !havekey {
return errors.Errorf("missing private key of issuer %s", iss.String()) return errors.Errorf("missing private key of issuer %s", iss.String())
} }
......
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