forked from ThalesGroup/kmip-go
-
Notifications
You must be signed in to change notification settings - Fork 2
/
op_activate.go
48 lines (36 loc) · 1.31 KB
/
op_activate.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
package kmip
import (
"context"
)
// 3.1 Unique Identifier
// The Unique Identifier is generated by the key management system to uniquely identify a Managed Object. It is only REQUIRED to be unique within
// the identifier space managed by a single key management system, however this identifier SHOULD be globally unique in order to allow for a key
// management domain export of such objects. This attribute SHALL be assigned by the key management system at creation or registration time, and
// then SHALL NOT be changed or deleted before the object is destroyed.
// Object Encoding - Unique Identifier: Text String
// 4.19 Activate
// Table 210
type ActivateRequestPayload struct {
UniqueIdentifier string // Required: No
}
// Table 211
type ActivateResponsePayload struct {
UniqueIdentifier string // Required: Yes
}
type ActivateHandler struct {
Activate func(ctx context.Context, payload *ActivateRequestPayload) (*ActivateResponsePayload, error)
}
func (h *ActivateHandler) HandleItem(ctx context.Context, req *Request) (*ResponseBatchItem, error) {
var payload ActivateRequestPayload
err := req.DecodePayload(&payload)
if err != nil {
return nil, err
}
respPayload, err := h.Activate(ctx, &payload)
if err != nil {
return nil, err
}
return &ResponseBatchItem{
ResponsePayload: respPayload,
}, nil
}