Commit 11cf952d authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Add server request types

parent b8f0ad25
......@@ -49,3 +49,33 @@ func TestAttributeDisjunctionMarshaling(t *testing.T) {
disjunction.selected = &disjunction.Attributes[0]
require.True(t, disjunction.Satisfied())
}
func TestServiceProviderRequest(t *testing.T) {
var sprequest ServiceProviderRequest
var spjson = `{
"sprequest": {
"validity": 60,
"timeout": 60,
"request": {
"content": [
{
"label": "ID",
"attributes": ["irma-demo.RU.studentCard.studentID"]
}
]
}
}
}`
require.NoError(t, json.Unmarshal([]byte(spjson), &sprequest))
require.NotNil(t, sprequest.Request.Request.Content)
require.NotEmpty(t, sprequest.Request.Request.Content)
require.NotNil(t, sprequest.Request.Request.Content[0])
require.NotEmpty(t, sprequest.Request.Request.Content[0])
require.NotNil(t, sprequest.Request.Request.Content[0].Attributes)
require.NotEmpty(t, sprequest.Request.Request.Content[0].Attributes)
require.Equal(t, sprequest.Request.Request.Content[0].Attributes[0].Name(), "studentID")
require.NotNil(t, sprequest.Request.Request.Content.Find(irmago.NewAttributeIdentifier("irma-demo.RU.studentCard.studentID")))
}
package protocol
import "math/big"
import (
"math/big"
"time"
"fmt"
"strconv"
"github.com/credentials/irmago"
)
type Timestamp time.Time
func (t *Timestamp) MarshalJSON() ([]byte, error) {
ts := time.Time(*t).Unix()
stamp := fmt.Sprint(ts)
return []byte(stamp), nil
}
func (t *Timestamp) UnmarshalJSON(b []byte) error {
ts, err := strconv.Atoi(string(b))
if err != nil {
return err
}
*t = Timestamp(time.Unix(int64(ts), 0))
return nil
}
type SessionRequest struct {
Context *big.Int
Nonce *big.Int
Context *big.Int `json:"nonce"`
Nonce *big.Int `json:"context"`
}
type DisclosureRequest struct {
SessionRequest
content *AttributeDisjunctionList
Content AttributeDisjunctionList `json:"content"`
}
type SignatureRequest struct {
DisclosureRequest
Message string `json:"message"`
MessageType string `json:"messageType"`
}
type CredentialRequest struct {
Validity Timestamp
KeyCounter int
Credential irmago.CredentialTypeIdentifier
Attributes map[string]string
}
type ServerRequest struct {
ServerName string `json:"iss"`
IssuedAt Timestamp `json:"iat"`
Type string `json:"subject"`
}
type IssuanceRequest struct {
SessionRequest
Credentials []CredentialRequest `json:"credentials"`
Discose []*AttributeDisjunctionList `json:"disclose"`
}
type ServiceProviderRequest struct {
ServerRequest
Request struct {
Request DisclosureRequest `json:"request"`
} `json:"sprequest"`
}
type SignatureServerRequest struct {
ServerRequest
Request struct {
Request SignatureRequest `json:"request"`
} `json:"sigrequest"`
}
type IdentityProviderRequest struct {
ServerRequest
Request struct {
Request IssuanceRequest `json:"request"`
} `json:"iprequest"`
}
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