-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWrappedKeyEntity.java
More file actions
49 lines (39 loc) · 1.31 KB
/
WrappedKeyEntity.java
File metadata and controls
49 lines (39 loc) · 1.31 KB
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
package ftn.security.minikms.entity;
import ftn.security.minikms.enumeration.KeyOperation;
import ftn.security.minikms.enumeration.KeyType;
import jakarta.persistence.*;
import jakarta.persistence.Id;
import lombok.Data;
import java.time.Instant;
import java.util.List;
import java.util.UUID;
@Data
@Entity
public class WrappedKeyEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, updatable = false)
private UUID logicalKey;
private String alias;
private Integer version;
@Enumerated(EnumType.STRING)
private KeyType keyType;
@Lob
private byte[] wrappedKey;
@ElementCollection(fetch = FetchType.EAGER)
@Enumerated(EnumType.STRING)
private List<KeyOperation> allowedOperations;
private Instant createdAt;
public static WrappedKeyEntity of(UUID logicalKey, String alias, Integer version, KeyType keyType, byte[] wrappedKey, List<KeyOperation> allowedOperations) {
var entity = new WrappedKeyEntity();
entity.logicalKey = logicalKey;
entity.alias = alias;
entity.version = version;
entity.keyType = keyType;
entity.wrappedKey = wrappedKey;
entity.allowedOperations = allowedOperations;
entity.createdAt = Instant.now();
return entity;
}
}