forked from ThalesGroup/kmip-go
-
Notifications
You must be signed in to change notification settings - Fork 2
/
op_query.go
67 lines (55 loc) · 1.9 KB
/
op_query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package kmip
import (
"context"
"github.com/Seagate/kmip-go/kmip14"
)
// 6.1.37 Query
// Table 259
type QueryRequestPayload struct {
QueryFunction []kmip14.QueryFunction
}
type CapabilityInformation struct {
StreamingCapability bool // Required: No
AsynchronousCapability bool // Required: No
AttestationCapability bool // Required: No
BatchUndoCapability bool // Required: No
BatchContinueCapability bool // Required: No
UnwrapMode kmip14.UnwrapMode // Required: No
DestroyAction kmip14.DestroyAction // Required: No
ShreddingAlgorithm kmip14.ShreddingAlgorithm // Required: No
RNGMode kmip14.RNGMode // Required: No
}
// Table 260
type QueryResponsePayload struct {
Operation []kmip14.Operation
ObjectType []kmip14.ObjectType
VendorIdentification string
ServerInformation string
ApplicationNamespace string
ExtensionInformation string
AttestationType kmip14.AttestationType
RNGParameters string
ProfileInformation []kmip14.ProfileName
ValidationInformation []kmip14.ValidationAuthorityType
CapabilityInformation CapabilityInformation
ClientRegistrationMethod kmip14.ClientRegistrationMethod
DefaultsInformation string
ProtectionStorageMasks string
}
type QueryHandler struct {
Query func(ctx context.Context, payload *QueryRequestPayload) (*QueryResponsePayload, error)
}
func (h *QueryHandler) HandleItem(ctx context.Context, req *Request) (*ResponseBatchItem, error) {
var payload QueryRequestPayload
err := req.DecodePayload(&payload)
if err != nil {
return nil, err
}
respPayload, err := h.Query(ctx, &payload)
if err != nil {
return nil, err
}
return &ResponseBatchItem{
ResponsePayload: respPayload,
}, nil
}