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

Rename Credential struct to CredentialInfo

parent ab6d50e9
......@@ -47,7 +47,7 @@ type AttributeList struct {
*MetadataAttribute `json:"-"`
Ints []*big.Int
strings []string
info *Credential
info *CredentialInfo
}
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() *CredentialInfo {
if al.info == nil {
al.info = NewCredential(al.Ints)
al.info = NewCredentialInfo(al.Ints)
}
return al.info
}
......
......@@ -15,8 +15,8 @@ type credential struct {
*MetadataAttribute
}
// A Credential contains all information of an IRMA credential.
type Credential struct {
// CredentialInfo contains all information of an IRMA credential.
type CredentialInfo 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 CredentialInfoList is a list of credentials (implements sort.Interface).
type CredentialInfoList []*CredentialInfo
func NewCredential(ints []*big.Int) *Credential {
func NewCredentialInfo(ints []*big.Int) *CredentialInfo {
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 &CredentialInfo{
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 CredentialInfoList) Len() int {
return len(cl)
}
// Swap implements sort.Interface.
func (cl CredentialList) Swap(i, j int) {
func (cl CredentialInfoList) 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 CredentialInfoList) 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
}
......@@ -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.CredentialInfoList())
assert.True(t,
cred.Signature.Verify(cred.PublicKey(), cred.Attributes),
......
......@@ -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{})
// CredentialInfoList returns a list of information of all contained credentials.
func (cm *CredentialManager) CredentialInfoList() CredentialInfoList {
list := CredentialInfoList([]*CredentialInfo{})
for _, attrlistlist := range cm.attributes {
for _, attrlist := range attrlistlist {
......
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