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
faf6a34e
Commit
faf6a34e
authored
Sep 28, 2017
by
Sietse Ringers
Browse files
Rename Credential struct to CredentialInfo
parent
ab6d50e9
Changes
4
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
faf6a34e
...
...
@@ -47,7 +47,7 @@ type AttributeList struct {
*
MetadataAttribute
`json:"-"`
Ints
[]
*
big
.
Int
strings
[]
string
info
*
Credential
info
*
Credential
Info
}
func
(
al
*
AttributeList
)
MarshalJSON
()
([]
byte
,
error
)
{
...
...
@@ -80,9 +80,9 @@ func NewAttributeListFromInts(ints []*big.Int) (*AttributeList, error) {
},
nil
}
func
(
al
*
AttributeList
)
Info
()
*
Credential
{
func
(
al
*
AttributeList
)
Info
()
*
Credential
Info
{
if
al
.
info
==
nil
{
al
.
info
=
NewCredential
(
al
.
Ints
)
al
.
info
=
NewCredential
Info
(
al
.
Ints
)
}
return
al
.
info
}
...
...
credential.go
View file @
faf6a34e
...
...
@@ -15,8 +15,8 @@ type credential struct {
*
MetadataAttribute
}
//
A
Credential contains all information of an IRMA credential.
type
Credential
struct
{
// Credential
Info
contains all information of an IRMA credential.
type
Credential
Info
struct
{
ID
string
// e.g., "irma-demo.RU.studentCard"
SignedOn
Timestamp
// Unix timestamp
Expires
Timestamp
// Unix timestamp
...
...
@@ -27,10 +27,10 @@ type Credential struct {
Logo
string
// Path to logo on storage
}
// A CredentialList is a list of credentials (implements sort.Interface).
type
CredentialList
[]
*
Credential
// A Credential
Info
List is a list of credentials (implements sort.Interface).
type
Credential
Info
List
[]
*
Credential
Info
func
NewCredential
(
ints
[]
*
big
.
Int
)
*
Credential
{
func
NewCredential
Info
(
ints
[]
*
big
.
Int
)
*
Credential
Info
{
meta
:=
MetadataFromInt
(
ints
[
0
])
credtype
:=
meta
.
CredentialType
()
issid
:=
credtype
.
IssuerIdentifier
()
...
...
@@ -41,7 +41,7 @@ func NewCredential(ints []*big.Int) *Credential {
attrs
[
i
]
=
TranslatedString
(
map
[
string
]
string
{
"en"
:
val
,
"nl"
:
val
})
}
return
&
Credential
{
return
&
Credential
Info
{
ID
:
credtype
.
Identifier
()
.
String
(),
SignedOn
:
Timestamp
(
meta
.
SigningDate
()),
Expires
:
Timestamp
(
meta
.
Expiry
()),
...
...
@@ -64,17 +64,17 @@ func newCredential(gabicred *gabi.Credential) (cred *credential) {
}
// Len implements sort.Interface.
func
(
cl
CredentialList
)
Len
()
int
{
func
(
cl
Credential
Info
List
)
Len
()
int
{
return
len
(
cl
)
}
// Swap implements sort.Interface.
func
(
cl
CredentialList
)
Swap
(
i
,
j
int
)
{
func
(
cl
Credential
Info
List
)
Swap
(
i
,
j
int
)
{
cl
[
i
],
cl
[
j
]
=
cl
[
j
],
cl
[
i
]
}
// Less implements sort.Interface.
func
(
cl
CredentialList
)
Less
(
i
,
j
int
)
bool
{
func
(
cl
Credential
Info
List
)
Less
(
i
,
j
int
)
bool
{
// TODO Decide on sorting, and if it depends on a TranslatedString, allow language choosing
return
strings
.
Compare
(
cl
[
i
]
.
Type
.
Name
[
"en"
],
cl
[
j
]
.
Type
.
Name
[
"en"
])
>
0
}
irmago_test.go
View file @
faf6a34e
...
...
@@ -68,7 +68,7 @@ func verifyManagerIsUnmarshaled(t *testing.T) {
assert
.
NotNil
(
t
,
cred
,
"Credential should exist"
)
assert
.
NotNil
(
t
,
cred
.
Attributes
[
0
],
"Metadata attribute of irma-demo.RU.studentCard should not be nil"
)
assert
.
NotEmpty
(
t
,
Manager
.
CredentialList
())
assert
.
NotEmpty
(
t
,
Manager
.
Credential
Info
List
())
assert
.
True
(
t
,
cred
.
Signature
.
Verify
(
cred
.
PublicKey
(),
cred
.
Attributes
),
...
...
manager.go
View file @
faf6a34e
...
...
@@ -33,9 +33,9 @@ func newCredentialManager() *CredentialManager {
}
}
// CredentialList returns a list of information of all contained credentials.
func
(
cm
*
CredentialManager
)
CredentialList
()
CredentialList
{
list
:=
CredentialList
([]
*
Credential
{})
// Credential
Info
List returns a list of information of all contained credentials.
func
(
cm
*
CredentialManager
)
Credential
Info
List
()
Credential
Info
List
{
list
:=
Credential
Info
List
([]
*
Credential
Info
{})
for
_
,
attrlistlist
:=
range
cm
.
attributes
{
for
_
,
attrlist
:=
range
attrlistlist
{
...
...
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