Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
11cf952d
Commit
11cf952d
authored
Jul 28, 2017
by
Sietse Ringers
Browse files
Add server request types
parent
b8f0ad25
Changes
2
Hide whitespace changes
Inline
Side-by-side
protocol/protocol_test.go
View file @
11cf952d
...
...
@@ -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"
)))
}
protocol/requests.go
View file @
11cf952d
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"`
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment