requests.go 2.11 KB
Newer Older
1
2
package protocol

Sietse Ringers's avatar
Sietse Ringers committed
3
import (
4
	"time"
Sietse Ringers's avatar
Sietse Ringers committed
5
6
7
8

	"github.com/credentials/irmago"
)

9
type ServerJwt struct {
10
11
12
	ServerName string            `json:"iss"`
	IssuedAt   *irmago.Timestamp `json:"iat"`
	Type       string            `json:"sub"`
Sietse Ringers's avatar
Sietse Ringers committed
13
14
}

15
type ServiceProviderRequest struct {
16
	Request irmago.DisclosureRequest `json:"request"`
Sietse Ringers's avatar
Sietse Ringers committed
17
18
}

19
type SignatureServerRequest struct {
20
	Request irmago.SignatureRequest `json:"request"`
21
22
}

23
type IdentityProviderRequest struct {
24
	Request irmago.IssuanceRequest `json:"request"`
25
26
27
28
29
30
31
32
33
}

type ServiceProviderJwt struct {
	ServerJwt
	Request ServiceProviderRequest `json:"sprequest"`
}

type SignatureServerJwt struct {
	ServerJwt
34
	Request SignatureServerRequest `json:"absrequest"`
35
36
37
38
39
}

type IdentityProviderJwt struct {
	ServerJwt
	Request IdentityProviderRequest `json:"iprequest"`
40
41
}

42
43
func NewServiceProviderJwt(servername string, dr irmago.DisclosureRequest) *ServiceProviderJwt {
	now := irmago.Timestamp(time.Now())
44
45
	return &ServiceProviderJwt{
		ServerJwt: ServerJwt{
46
47
48
49
			ServerName: servername,
			IssuedAt:   &now,
			Type:       "verification_request",
		},
50
		Request: ServiceProviderRequest{Request: dr},
51
	}
Sietse Ringers's avatar
Sietse Ringers committed
52
53
}

54
55
func NewSignatureServerJwt(servername string, sr irmago.SignatureRequest) *SignatureServerJwt {
	now := irmago.Timestamp(time.Now())
56
57
58
59
60
61
	return &SignatureServerJwt{
		ServerJwt: ServerJwt{
			ServerName: servername,
			IssuedAt:   &now,
			Type:       "signature_request",
		},
Sietse Ringers's avatar
Sietse Ringers committed
62
		Request: SignatureServerRequest{Request: sr},
63
64
65
	}
}

66
67
func NewIdentityProviderJwt(servername string, ir irmago.IssuanceRequest) *IdentityProviderJwt {
	now := irmago.Timestamp(time.Now())
Sietse Ringers's avatar
Sietse Ringers committed
68
69
70
71
72
73
74
75
76
77
	return &IdentityProviderJwt{
		ServerJwt: ServerJwt{
			ServerName: servername,
			IssuedAt:   &now,
			Type:       "signature_request",
		},
		Request: IdentityProviderRequest{Request: ir},
	}
}

78
func (spr *ServiceProviderJwt) DisjunctionList() irmago.AttributeDisjunctionList {
79
80
81
	return spr.Request.Request.Content
}

82
func (ssr *SignatureServerJwt) DisjunctionList() irmago.AttributeDisjunctionList {
83
84
85
	return ssr.Request.Request.Content
}

86
func (ipr *IdentityProviderJwt) DisjunctionList() irmago.AttributeDisjunctionList {
87
88
	return ipr.Request.Request.Disclose
}