Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
e7c3289a
Commit
e7c3289a
authored
Jun 04, 2017
by
Sietse Ringers
Browse files
Bless gorename
parent
50a45763
Changes
3
Hide whitespace changes
Inline
Side-by-side
descriptions.go
View file @
e7c3289a
...
...
@@ -6,8 +6,8 @@ import (
"github.com/mhe/gabi"
)
// SchemeManager
Description
describes a scheme manager.
type
SchemeManager
Description
struct
{
// SchemeManager describes a scheme manager.
type
SchemeManager
struct
{
Name
string
`xml:"Id"`
URL
string
`xml:"Contact"`
HRName
string
`xml:"Name"`
...
...
@@ -19,8 +19,8 @@ type SchemeManagerDescription struct {
XMLName
xml
.
Name
`xml:"SchemeManager"`
}
// Issuer
Description
describes an issuer.
type
Issuer
Description
struct
{
// Issuer describes an issuer.
type
Issuer
struct
{
HRName
string
`xml:"Name"`
HRShortName
string
`xml:"ShortName"`
Name
string
`xml:"ID"`
...
...
@@ -32,8 +32,8 @@ type IssuerDescription struct {
identifier
*
IssuerIdentifier
}
// Credential
Description
is a description of a credential type, specifying (a.o.) its name, issuer, and attributes.
type
Credential
Description
struct
{
// Credential
Type
is a description of a credential type, specifying (a.o.) its name, issuer, and attributes.
type
Credential
Type
struct
{
HRName
string
`xml:"Name"`
HRShortName
string
`xml:"ShortName"`
IssuerName
string
`xml:"IssuerID"`
...
...
@@ -54,18 +54,18 @@ type AttributeDescription struct {
}
// Identifier returns the identifier of the specified credential type.
func
(
cd
*
Credential
Description
)
Identifier
()
string
{
func
(
cd
*
Credential
Type
)
Identifier
()
string
{
return
cd
.
SchemeManagerName
+
"."
+
cd
.
IssuerName
+
"."
+
cd
.
Name
}
// Identifier returns the identifier of the specified issuer description.
func
(
id
*
Issuer
Description
)
Identifier
()
string
{
func
(
id
*
Issuer
)
Identifier
()
string
{
return
id
.
SchemeManagerName
+
"."
+
id
.
Name
}
// CurrentPublicKey returns the latest known public key of the issuer identified by this instance.
func
(
id
*
Issuer
Description
)
CurrentPublicKey
()
*
gabi
.
PublicKey
{
keys
:=
MetaStore
.
p
ublic
k
eys
[
id
.
Identifier
()]
func
(
id
*
Issuer
)
CurrentPublicKey
()
*
gabi
.
PublicKey
{
keys
:=
MetaStore
.
P
ublic
K
eys
[
id
.
Identifier
()]
if
keys
==
nil
||
len
(
keys
)
==
0
{
return
nil
}
...
...
@@ -73,8 +73,8 @@ func (id *IssuerDescription) CurrentPublicKey() *gabi.PublicKey {
}
// PublicKey returns the specified public key of the issuer identified by this instance.
func
(
id
*
Issuer
Description
)
PublicKey
(
index
int
)
*
gabi
.
PublicKey
{
keys
:=
MetaStore
.
p
ublic
k
eys
[
id
.
Identifier
()]
func
(
id
*
Issuer
)
PublicKey
(
index
int
)
*
gabi
.
PublicKey
{
keys
:=
MetaStore
.
P
ublic
K
eys
[
id
.
Identifier
()]
if
keys
==
nil
||
index
>=
len
(
keys
)
{
return
nil
}
...
...
irmago_test.go
View file @
e7c3289a
...
...
@@ -12,14 +12,14 @@ func TestParseStore(t *testing.T) {
t
.
Fatal
(
err
)
}
assert
.
NotNil
(
t
,
MetaStore
.
i
ssuers
[
"irma-demo.RU"
]
.
CurrentPublicKey
()
.
N
,
"irma-demo.RU public key has no modulus"
)
assert
.
Equal
(
t
,
MetaStore
.
m
anagers
[
"irma-demo"
]
.
HRName
,
"Irma Demo"
,
"irma-demo scheme manager has unexpected name"
)
assert
.
NotNil
(
t
,
MetaStore
.
I
ssuers
[
"irma-demo.RU"
]
.
CurrentPublicKey
()
.
N
,
"irma-demo.RU public key has no modulus"
)
assert
.
Equal
(
t
,
MetaStore
.
SchemeM
anagers
[
"irma-demo"
]
.
HRName
,
"Irma Demo"
,
"irma-demo scheme manager has unexpected name"
)
assert
.
Equal
(
t
,
"Radboud Universiteit Nijmegen"
,
MetaStore
.
i
ssuers
[
"irma-demo.RU"
]
.
HRName
,
MetaStore
.
I
ssuers
[
"irma-demo.RU"
]
.
HRName
,
"irma-demo.RU issuer has unexpected name"
)
assert
.
Equal
(
t
,
"Student Card"
,
MetaStore
.
c
redentials
[
"irma-demo.RU.studentCard"
]
.
HRShortName
,
MetaStore
.
C
redentials
[
"irma-demo.RU.studentCard"
]
.
HRShortName
,
"irma-demo.RU.studentCard has unexpected name"
)
}
store.go
View file @
e7c3289a
...
...
@@ -12,32 +12,32 @@ import (
// MetaStore is the global instance of ConfigurationStore
var
MetaStore
=
ConfigurationStore
{
make
(
map
[
string
]
*
SchemeManager
Description
),
make
(
map
[
string
]
*
Issuer
Description
),
make
(
map
[
string
]
*
Credential
Description
),
make
(
map
[
string
]
*
SchemeManager
),
make
(
map
[
string
]
*
Issuer
),
make
(
map
[
string
]
*
Credential
Type
),
make
(
map
[
string
][]
*
gabi
.
PublicKey
),
}
// ConfigurationStore keeps track of scheme managers, issuers, credential types and public keys.
// Use the global MetaStore instance.
type
ConfigurationStore
struct
{
m
anagers
map
[
string
]
*
SchemeManager
Description
i
ssuers
map
[
string
]
*
Issuer
Description
c
redentials
map
[
string
]
*
Credential
Description
p
ublic
k
eys
map
[
string
][]
*
gabi
.
PublicKey
SchemeM
anagers
map
[
string
]
*
SchemeManager
I
ssuers
map
[
string
]
*
Issuer
C
redentials
map
[
string
]
*
Credential
Type
P
ublic
K
eys
map
[
string
][]
*
gabi
.
PublicKey
}
// ParseFolder populates the current store by parsing the specified irma_configuration folder,
// listing the containing scheme managers, issuers, credential types and public keys.
func
(
store
*
ConfigurationStore
)
ParseFolder
(
path
string
)
error
{
return
iterateSubfolders
(
path
,
func
(
dir
string
)
error
{
manager
:=
&
SchemeManager
Description
{}
manager
:=
&
SchemeManager
{}
exists
,
err
:=
pathToDescription
(
dir
+
"/description.xml"
,
manager
)
if
err
!=
nil
{
return
err
}
if
exists
{
MetaStore
.
m
anagers
[
manager
.
Name
]
=
manager
MetaStore
.
SchemeM
anagers
[
manager
.
Name
]
=
manager
return
store
.
parseIssuerFolders
(
dir
)
}
return
nil
...
...
@@ -46,13 +46,13 @@ func (store *ConfigurationStore) ParseFolder(path string) error {
func
(
store
*
ConfigurationStore
)
parseIssuerFolders
(
path
string
)
error
{
return
iterateSubfolders
(
path
,
func
(
dir
string
)
error
{
issuer
:=
&
Issuer
Description
{}
issuer
:=
&
Issuer
{}
exists
,
err
:=
pathToDescription
(
dir
+
"/description.xml"
,
issuer
)
if
err
!=
nil
{
return
err
}
if
exists
{
store
.
i
ssuers
[
issuer
.
Identifier
()]
=
issuer
store
.
I
ssuers
[
issuer
.
Identifier
()]
=
issuer
if
err
=
store
.
parseCredentialsFolder
(
dir
+
"/Issues/"
);
err
!=
nil
{
return
err
}
...
...
@@ -62,7 +62,7 @@ func (store *ConfigurationStore) parseIssuerFolders(path string) error {
})
}
func
(
store
*
ConfigurationStore
)
parseKeysFolder
(
issuer
*
Issuer
Description
,
path
string
)
error
{
func
(
store
*
ConfigurationStore
)
parseKeysFolder
(
issuer
*
Issuer
,
path
string
)
error
{
for
i
:=
0
;
;
i
++
{
file
:=
path
+
strconv
.
Itoa
(
i
)
+
".xml"
if
_
,
err
:=
os
.
Stat
(
file
);
err
!=
nil
{
...
...
@@ -72,20 +72,20 @@ func (store *ConfigurationStore) parseKeysFolder(issuer *IssuerDescription, path
if
err
!=
nil
{
return
err
}
MetaStore
.
p
ublic
k
eys
[
issuer
.
Identifier
()]
=
append
(
MetaStore
.
p
ublic
k
eys
[
issuer
.
Identifier
()],
pk
)
MetaStore
.
P
ublic
K
eys
[
issuer
.
Identifier
()]
=
append
(
MetaStore
.
P
ublic
K
eys
[
issuer
.
Identifier
()],
pk
)
}
return
nil
}
func
(
store
*
ConfigurationStore
)
parseCredentialsFolder
(
path
string
)
error
{
return
iterateSubfolders
(
path
,
func
(
dir
string
)
error
{
cred
:=
&
Credential
Description
{}
cred
:=
&
Credential
Type
{}
exists
,
err
:=
pathToDescription
(
dir
+
"/description.xml"
,
cred
)
if
err
!=
nil
{
return
err
}
if
exists
{
store
.
c
redentials
[
cred
.
Identifier
()]
=
cred
store
.
C
redentials
[
cred
.
Identifier
()]
=
cred
}
return
nil
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment