-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRotatingKeyAclProvider.java
More file actions
59 lines (47 loc) · 1.73 KB
/
RotatingKeyAclProvider.java
File metadata and controls
59 lines (47 loc) · 1.73 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
50
51
52
53
54
55
56
57
58
59
package com.uid2.shared.store.reader;
import com.uid2.shared.auth.AclSnapshot;
import com.uid2.shared.auth.EncryptionKeyAcl;
import com.uid2.shared.cloud.ICloudStorage;
import com.uid2.shared.store.CloudPath;
import com.uid2.shared.store.IKeyAclProvider;
import com.uid2.shared.store.ScopedStoreReader;
import com.uid2.shared.store.parser.KeyAclParser;
import com.uid2.shared.store.scope.StoreScope;
import io.vertx.core.json.JsonObject;
import java.time.Instant;
import java.util.Map;
public class RotatingKeyAclProvider implements IKeyAclProvider, StoreReader<Map<Integer, EncryptionKeyAcl>> {
private final ScopedStoreReader<AclSnapshot> reader;
public RotatingKeyAclProvider(ICloudStorage fileStreamProvider, StoreScope scope) {
this.reader = new ScopedStoreReader<>(fileStreamProvider, scope, new KeyAclParser(), "key acls");
}
public CloudPath getMetadataPath() { return reader.getMetadataPath(); }
@Override
public JsonObject getMetadata() throws Exception {
return reader.getMetadata();
}
@Override
public long getVersion(JsonObject metadata) {
return metadata.getLong("version");
}
@Override
public long loadContent(JsonObject metadata) throws Exception {
return reader.loadContent(metadata, "keys_acl");
}
@Override
public Map<Integer, EncryptionKeyAcl> getAll() {
return reader.getSnapshot().getAllAcls();
}
@Override
public void loadContent() throws Exception {
this.loadContent(this.getMetadata());
}
@Override
public AclSnapshot getSnapshot(Instant asOf) {
return reader.getSnapshot();
}
@Override
public AclSnapshot getSnapshot() {
return this.getSnapshot(Instant.now());
}
}