Commit 324d9102 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Make CredentialRequest.CredentialTypeIdentifier not a pointer

parent 31ecb981
......@@ -48,8 +48,6 @@ func getSigningJwt(name string, id irma.AttributeTypeIdentifier) interface{} {
func getIssuanceRequest(defaultValidity bool) *irma.IssuanceRequest {
temp := irma.Timestamp(irma.FloorToEpochBoundary(time.Now().AddDate(1, 0, 0)))
var expiry *irma.Timestamp
credid1 := irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")
credid2 := irma.NewCredentialTypeIdentifier("irma-demo.MijnOverheid.root")
if !defaultValidity {
expiry = &temp
......@@ -59,7 +57,7 @@ func getIssuanceRequest(defaultValidity bool) *irma.IssuanceRequest {
Credentials: []*irma.CredentialRequest{
{
Validity: expiry,
CredentialTypeID: &credid1,
CredentialTypeID: irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard"),
Attributes: map[string]string{
"university": "Radboud",
"studentCardNumber": "31415927",
......@@ -68,7 +66,7 @@ func getIssuanceRequest(defaultValidity bool) *irma.IssuanceRequest {
},
}, {
Validity: expiry,
CredentialTypeID: &credid2,
CredentialTypeID: irma.NewCredentialTypeIdentifier("irma-demo.MijnOverheid.root"),
Attributes: map[string]string{
"BSN": "299792458",
},
......@@ -79,13 +77,12 @@ func getIssuanceRequest(defaultValidity bool) *irma.IssuanceRequest {
func getNameIssuanceRequest() *irma.IssuanceRequest {
expiry := irma.Timestamp(irma.NewMetadataAttribute(0).Expiry())
credid := irma.NewCredentialTypeIdentifier("irma-demo.MijnOverheid.fullName")
req := &irma.IssuanceRequest{
Credentials: []*irma.CredentialRequest{
{
Validity: &expiry,
CredentialTypeID: &credid,
CredentialTypeID: irma.NewCredentialTypeIdentifier("irma-demo.MijnOverheid.fullName"),
Attributes: map[string]string{
"firstnames": "Johan Pieter",
"firstname": "Johan",
......@@ -167,13 +164,12 @@ func sessionHelper(t *testing.T, jwtcontents interface{}, url string, client *ir
func keyshareSessions(t *testing.T, client *irmaclient.Client) {
id := irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID")
expiry := irma.Timestamp(irma.NewMetadataAttribute(0).Expiry())
credid := irma.NewCredentialTypeIdentifier("test.test.mijnirma")
jwt := getCombinedJwt("testip", id)
jwt.(*irma.IdentityProviderJwt).Request.Request.Credentials = append(
jwt.(*irma.IdentityProviderJwt).Request.Request.Credentials,
&irma.CredentialRequest{
Validity: &expiry,
CredentialTypeID: &credid,
CredentialTypeID: irma.NewCredentialTypeIdentifier("test.test.mijnirma"),
Attributes: map[string]string{"email": "testusername"},
},
)
......
......@@ -224,7 +224,7 @@ func (session *session) processSessionInfo() {
// Calculate singleton credentials to be removed
for _, credreq := range ir.Credentials {
preexistingCredentials := session.client.attrs(*credreq.CredentialTypeID)
preexistingCredentials := session.client.attrs(credreq.CredentialTypeID)
if len(preexistingCredentials) != 0 && preexistingCredentials[0].IsValid() && preexistingCredentials[0].CredentialType().IsSingleton {
ir.RemovalCredentialInfoList = append(ir.RemovalCredentialInfoList, preexistingCredentials[0].Info())
}
......
......@@ -713,7 +713,7 @@ func (conf *Configuration) checkCredentialTypes(session SessionRequest, managers
case *IssuanceRequest:
for _, credreq := range s.Credentials {
// First check if we have this credential type
typ, contains = conf.CredentialTypes[*credreq.CredentialTypeID]
typ, contains = conf.CredentialTypes[credreq.CredentialTypeID]
if !contains {
managers[credreq.CredentialTypeID.Root()] = struct{}{}
continue
......
......@@ -83,10 +83,10 @@ type IssuanceRequest struct {
// A CredentialRequest contains the attributes and metadata of a credential
// that will be issued in an IssuanceRequest.
type CredentialRequest struct {
Validity *Timestamp `json:"validity"`
KeyCounter int `json:"keyCounter"`
CredentialTypeID *CredentialTypeIdentifier `json:"credential"`
Attributes map[string]string `json:"attributes"`
Validity *Timestamp `json:"validity"`
KeyCounter int `json:"keyCounter"`
CredentialTypeID CredentialTypeIdentifier `json:"credential"`
Attributes map[string]string `json:"attributes"`
}
// ServerJwt contains standard JWT fields.
......@@ -160,7 +160,7 @@ func (cr *CredentialRequest) Info(conf *Configuration, metadataVersion byte) (*C
// the credential type is known, all required attributes are present and no unknown attributes
// are given.
func (cr *CredentialRequest) Validate(conf *Configuration) error {
credtype := conf.CredentialTypes[*cr.CredentialTypeID]
credtype := conf.CredentialTypes[cr.CredentialTypeID]
if credtype == nil {
return errors.New("Credential request of unknown credential type")
}
......@@ -205,7 +205,7 @@ func (cr *CredentialRequest) AttributeList(conf *Configuration, metadataVersion
}
// Compute other attributes
credtype := conf.CredentialTypes[*cr.CredentialTypeID]
credtype := conf.CredentialTypes[cr.CredentialTypeID]
attrs := make([]*big.Int, len(credtype.Attributes)+1)
attrs[0] = meta.Int
for i, attrtype := range credtype.Attributes {
......@@ -236,7 +236,7 @@ func (ir *IssuanceRequest) Identifiers() *IrmaIdentifierSet {
issuer := credreq.CredentialTypeID.IssuerIdentifier()
ir.Ids.SchemeManagers[issuer.SchemeManagerIdentifier()] = struct{}{}
ir.Ids.Issuers[issuer] = struct{}{}
ir.Ids.CredentialTypes[*credreq.CredentialTypeID] = struct{}{}
ir.Ids.CredentialTypes[credreq.CredentialTypeID] = struct{}{}
if ir.Ids.PublicKeys[issuer] == nil {
ir.Ids.PublicKeys[issuer] = []int{}
}
......
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