Commit 850fa020 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Add CredentialInfoList to issuance requests

parent f4122790
......@@ -29,7 +29,7 @@ type CredentialInfo struct {
Expires Timestamp // Unix timestamp
Attributes []TranslatedString // Human-readable rendered attributes
Logo string // Path to logo on storage
Hash string // SHA256 hash over the attributes
Hash string // SHA256 hash over the attributes
}
// A CredentialInfoList is a list of credentials (implements sort.Interface).
......@@ -53,9 +53,13 @@ func NewCredentialInfo(ints []*big.Int, store *ConfigurationStore) *CredentialIn
if !exists {
path = ""
}
id := credtype.Identifier()
issid := id.IssuerIdentifier()
return &CredentialInfo{
CredentialTypeID: credtype.Identifier().String(),
CredentialTypeID: id.String(),
Name: id.Name(),
IssuerID: issid.Name(),
SchemeManagerID: issid.SchemeManagerIdentifier().String(),
SignedOn: Timestamp(meta.SigningDate()),
Expires: Timestamp(meta.Expiry()),
Attributes: attrs,
......
......@@ -98,6 +98,8 @@ const (
ErrorApi = ErrorType("api")
// Server returned unexpected or malformed response
ErrorServerResponse = ErrorType("serverResponse")
// Credential type not present in our ConfigurationStore
ErrorUnknownCredentialType = ErrorType("unknownCredentialType")
)
func (e *SessionError) Error() string {
......
......@@ -47,8 +47,9 @@ type SignatureRequest struct {
// optionally also asking for certain attributes to be simultaneously disclosed.
type IssuanceRequest struct {
SessionRequest
Credentials []*CredentialRequest `json:"credentials"`
Disclose AttributeDisjunctionList `json:"disclose"`
Credentials []*CredentialRequest `json:"credentials"`
Disclose AttributeDisjunctionList `json:"disclose"`
CredentialInfoList CredentialInfoList `json:",omitempty"`
state *issuanceState
}
......@@ -110,6 +111,14 @@ type issuanceState struct {
builders []*gabi.CredentialBuilder
}
func (cr *CredentialRequest) Info(store *ConfigurationStore) (*CredentialInfo, error) {
list, err := cr.AttributeList(store)
if err != nil {
return nil, err
}
return NewCredentialInfo(list.Ints, store), nil
}
// AttributeList returns the list of attributes from this credential request.
func (cr *CredentialRequest) AttributeList(store *ConfigurationStore) (*AttributeList, error) {
meta := NewMetadataAttribute()
......
......@@ -157,9 +157,16 @@ func (session *session) start() {
session.irmaSession.SetContext(session.info.Context)
session.irmaSession.SetNonce(session.info.Nonce)
if session.Action == ActionIssuing {
ir := session.irmaSession.(*IssuanceRequest)
// Store which public keys the server will use
for _, credreq := range session.irmaSession.(*IssuanceRequest).Credentials {
for _, credreq := range ir.Credentials {
credreq.KeyCounter = session.info.Keys[credreq.CredentialTypeID.IssuerIdentifier()]
info, err := credreq.Info(session.credManager.ConfigurationStore)
if err != nil {
session.fail(&SessionError{ErrorType: ErrorUnknownCredentialType, Err: err})
return
}
ir.CredentialInfoList = append(ir.CredentialInfoList, info)
}
}
......
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