Skip to content

Commit fa99a38

Browse files
committed
clean up
1 parent 9198423 commit fa99a38

2 files changed

Lines changed: 8 additions & 28 deletions

File tree

conf/default-config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@
3737
"optout_inmem_cache": false,
3838
"enclave_platform": null,
3939
"failure_shutdown_wait_hours": 120,
40-
"keyset_key_shutdown_hours": 2,
4140
"sharing_token_expiry_seconds": 2592000,
4241
"operator_type": "public",
4342
"enable_remote_config": true,
4443
"uid_instance_id_prefix": "local-operator"
45-
}
44+
}

src/main/java/com/uid2/operator/model/KeyManager.java

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,16 @@
1313
import java.util.Comparator;
1414
import java.util.List;
1515
import java.util.Map;
16-
import java.util.function.Consumer;
1716
import java.util.stream.Collectors;
1817

1918
public class KeyManager {
2019
private static final Logger LOGGER = LoggerFactory.getLogger(UIDOperatorVerticle.class);
2120
private final IKeysetKeyStore keysetKeyStore;
2221
private final RotatingKeysetProvider keysetProvider;
23-
private final Consumer<Boolean> keyAvailabilityHandler;
2422

2523
public KeyManager(IKeysetKeyStore keysetKeyStore, RotatingKeysetProvider keysetProvider) {
26-
this(keysetKeyStore, keysetProvider, null);
27-
}
28-
29-
public KeyManager(IKeysetKeyStore keysetKeyStore, RotatingKeysetProvider keysetProvider,
30-
Consumer<Boolean> keyAvailabilityHandler) {
3124
this.keysetKeyStore = keysetKeyStore;
3225
this.keysetProvider = keysetProvider;
33-
this.keyAvailabilityHandler = keyAvailabilityHandler;
3426
}
3527

3628
public KeyManagerSnapshot getKeyManagerSnapshot(int siteId) {
@@ -44,11 +36,9 @@ public KeyManagerSnapshot getKeyManagerSnapshot(int siteId) {
4436

4537
public KeysetKey getActiveKeyBySiteIdWithFallback(int siteId, int fallbackSiteId, Instant asOf) {
4638
KeysetKey key = getActiveKeyBySiteId(siteId, asOf);
47-
if (key == null)
48-
key = getActiveKeyBySiteId(fallbackSiteId, asOf);
39+
if (key == null) key = getActiveKeyBySiteId(fallbackSiteId, asOf);
4940
if (key == null) {
50-
throw new NoActiveKeyException(String
51-
.format("Cannot get active key in default keyset with SITE ID %d or %d.", siteId, fallbackSiteId));
41+
throw new NoActiveKeyException(String.format("Cannot get active key in default keyset with SITE ID %d or %d.", siteId, fallbackSiteId));
5242
}
5343
return key;
5444
}
@@ -61,8 +51,7 @@ private Keyset getDefaultKeysetBySiteId(int siteId) {
6151
}
6252

6353
if (keysets.size() > 1) {
64-
throw new IllegalArgumentException(
65-
String.format("Multiple default keysets are enabled with SITE ID %d.", siteId));
54+
throw new IllegalArgumentException(String.format("Multiple default keysets are enabled with SITE ID %d.", siteId));
6655
}
6756

6857
return keysets.get(0);
@@ -87,12 +76,12 @@ public KeysetKey getKey(int keyId) {
8776
return this.keysetKeyStore.getSnapshot().getKey(keyId);
8877
}
8978

79+
9080
public List<KeysetKey> getKeysForSharingOrDsps() {
9181
Map<Integer, Keyset> keysetMap = this.keysetProvider.getSnapshot().getAllKeysets();
9282
List<KeysetKey> keys = keysetKeyStore.getSnapshot().getAllKeysetKeys();
9383
return keys
94-
.stream()
95-
.filter(k -> keysetMap.containsKey(k.getKeysetId()) && k.getKeysetId() != Const.Data.RefreshKeysetId)
84+
.stream().filter(k -> keysetMap.containsKey(k.getKeysetId()) && k.getKeysetId() != Const.Data.RefreshKeysetId)
9685
.sorted(Comparator.comparing(KeysetKey::getId)).collect(Collectors.toList());
9786
}
9887

@@ -118,12 +107,8 @@ public KeysetKey getMasterKey() {
118107
public KeysetKey getMasterKey(Instant asOf) {
119108
KeysetKey key = this.keysetKeyStore.getSnapshot().getActiveKey(Const.Data.MasterKeysetId, asOf);
120109
if (key == null) {
121-
throw new NoActiveKeyException(
122-
String.format("Cannot get a master key with keyset ID %d.", Const.Data.MasterKeysetId));
110+
throw new NoActiveKeyException(String.format("Cannot get a master key with keyset ID %d.", Const.Data.MasterKeysetId));
123111
}
124-
// Reset shutdown timer on successful key retrieval
125-
if (keyAvailabilityHandler != null)
126-
keyAvailabilityHandler.accept(true);
127112
return key;
128113
}
129114

@@ -134,12 +119,8 @@ public KeysetKey getRefreshKey() {
134119
public KeysetKey getRefreshKey(Instant asOf) {
135120
KeysetKey key = this.keysetKeyStore.getSnapshot().getActiveKey(Const.Data.RefreshKeysetId, asOf);
136121
if (key == null) {
137-
throw new NoActiveKeyException(
138-
String.format("Cannot get a refresh key with keyset ID %d.", Const.Data.RefreshKeysetId));
122+
throw new NoActiveKeyException(String.format("Cannot get a refresh key with keyset ID %d.", Const.Data.RefreshKeysetId));
139123
}
140-
// Reset shutdown timer on successful key retrieval
141-
if (keyAvailabilityHandler != null)
142-
keyAvailabilityHandler.accept(true);
143124
return key;
144125
}
145126

0 commit comments

Comments
 (0)