Skip to content

Commit 04f03f4

Browse files
committed
Updated formatting
1 parent 1fa7072 commit 04f03f4

File tree

3 files changed

+21
-30
lines changed

3 files changed

+21
-30
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ public final class IdentityRequest {
55
public final UserIdentity userIdentity;
66
public final TokenGeneratePolicy tokenGeneratePolicy;
77

8-
public IdentityRequest(
9-
PublisherIdentity publisherIdentity,
10-
UserIdentity userIdentity,
11-
TokenGeneratePolicy tokenGeneratePolicy)
12-
{
8+
public IdentityRequest(PublisherIdentity publisherIdentity,
9+
UserIdentity userIdentity,
10+
TokenGeneratePolicy tokenGeneratePolicy) {
1311
this.publisherIdentity = publisherIdentity;
1412
this.userIdentity = userIdentity;
1513
this.tokenGeneratePolicy = tokenGeneratePolicy;

src/main/java/com/uid2/operator/vertx/UIDOperatorVerticle.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public class UIDOperatorVerticle extends AbstractVerticle{
5757

5858
private static final int DEFAULT_MASTER_KEYSET_ID = 1;
5959
private static final int DEFAULT_KEYSET_ID = 99999;
60-
private static DateTimeFormatter APIDateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneId.of("UTC"));
60+
private static final DateTimeFormatter API_DATE_TIME_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneId.of("UTC"));
61+
6162
private final HealthComponent healthComponent = HealthManager.instance.registerComponent("http-server");
6263
private final JsonObject config;
6364
private final AuthMiddleware auth;
@@ -75,8 +76,7 @@ public class UIDOperatorVerticle extends AbstractVerticle{
7576
private Handler<RoutingContext> disableHandler = null;
7677
private final boolean phoneSupport;
7778
private final int tcfVendorId;
78-
79-
private IStatsCollectorQueue _statsCollectorQueue;
79+
private final IStatsCollectorQueue _statsCollectorQueue;
8080

8181
public UIDOperatorVerticle(JsonObject config,
8282
IClientKeyProvider clientKeyProvider,
@@ -99,7 +99,6 @@ public UIDOperatorVerticle(JsonObject config,
9999
this.v2PayloadHandler = new V2PayloadHandler(keyStore, config.getBoolean("enable_v2_encryption", true), this.identityScope);
100100
this.phoneSupport = config.getBoolean("enable_phone_support", true);
101101
this.tcfVendorId = config.getInteger("tcf_vendor_id", 21);
102-
103102
this._statsCollectorQueue = statsCollectorQueue;
104103
}
105104

@@ -303,10 +302,10 @@ public void handleKeysSharing(RoutingContext rc) {
303302
}
304303

305304
private List<EncryptionKey> getEncryptionKeys() {
306-
final List<EncryptionKey> keyStore = this.keyStore.getSnapshot().getActiveKeySet()
307-
.stream().filter(k -> k.getSiteId() != Const.Data.RefreshKeySiteId)
305+
return this.keyStore.getSnapshot().getActiveKeySet()
306+
.stream()
307+
.filter(k -> k.getSiteId() != Const.Data.RefreshKeySiteId)
308308
.collect(Collectors.toList());
309-
return keyStore;
310309
}
311310

312311
private void handleHealthCheck(RoutingContext rc) {
@@ -667,7 +666,7 @@ private void handleBucketsV1(RoutingContext rc) {
667666
o.put("bucket_id", e.getHashedId());
668667
Instant lastUpdated = Instant.ofEpochMilli(e.getLastUpdated());
669668

670-
o.put("last_updated", APIDateTimeFormatter.format(lastUpdated));
669+
o.put("last_updated", API_DATE_TIME_FORMATTER.format(lastUpdated));
671670
resp.add(o);
672671
}
673672
ResponseUtil.Success(rc, resp);
@@ -698,7 +697,7 @@ private void handleBucketsV2(RoutingContext rc) {
698697
o.put("bucket_id", e.getHashedId());
699698
Instant lastUpdated = Instant.ofEpochMilli(e.getLastUpdated());
700699

701-
o.put("last_updated", APIDateTimeFormatter.format(lastUpdated));
700+
o.put("last_updated", API_DATE_TIME_FORMATTER.format(lastUpdated));
702701
resp.add(o);
703702
}
704703
ResponseUtil.SuccessV2(rc, resp);
@@ -1058,9 +1057,7 @@ private void handleIdentityMapBatch(RoutingContext rc) {
10581057

10591058
final Instant now = Instant.now();
10601059
final JsonArray mapped = new JsonArray();
1061-
final int count = inputList.length;
1062-
for (int i = 0; i < count; ++i) {
1063-
final InputUtil.InputVal input = inputList[i];
1060+
for (final InputUtil.InputVal input : inputList) {
10641061
if (input != null && input.isValid()) {
10651062
final MappedIdentity mappedIdentity = this.idService.map(input.toUserIdentity(this.identityScope, 0, now), now);
10661063
final JsonObject resp = new JsonObject();
@@ -1245,8 +1242,7 @@ private JsonObject toJsonV1(IdentityTokens t) {
12451242

12461243
private JsonArray toJson(List<EncryptionKey> keys, ClientKey clientKey, IKeysAclSnapshot acls) {
12471244
final JsonArray a = new JsonArray();
1248-
for (int i = 0; i < keys.size(); ++i) {
1249-
final EncryptionKey k = keys.get(i);
1245+
for (final EncryptionKey k : keys) {
12501246
if (!acls.canClientAccessKey(clientKey, k)) {
12511247
continue;
12521248
}
@@ -1295,7 +1291,7 @@ public static class ResponseStatus {
12951291
public static String InsufficientUserConsent = "insufficient_user_consent";
12961292
}
12971293

1298-
public static enum UserConsentStatus {
1294+
public enum UserConsentStatus {
12991295
SUFFICIENT,
13001296
INSUFFICIENT,
13011297
INVALID,

src/main/java/com/uid2/operator/vertx/V2PayloadHandler.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
public class V2PayloadHandler {
2424
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(V2PayloadHandler.class);
2525

26-
private IKeyStore keyStore;
27-
28-
private Boolean enableEncryption;
29-
30-
private IdentityScope identityScope;
26+
private final IKeyStore keyStore;
27+
private final Boolean enableEncryption;
28+
private final IdentityScope identityScope;
3129

3230
public V2PayloadHandler(IKeyStore keyStore, Boolean enableEncryption, IdentityScope identityScope) {
3331
this.keyStore = keyStore;
@@ -144,13 +142,13 @@ public void handleTokenRefresh(RoutingContext rc, Handler<RoutingContext> apiHan
144142
rc.response().putHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
145143
// Encrypt whole payload using key shared with client.
146144
byte[] encryptedResp = AesGcm.encrypt(
147-
respJson.encode().getBytes(StandardCharsets.UTF_8),
148-
request.encryptionKey);
145+
respJson.encode().getBytes(StandardCharsets.UTF_8),
146+
request.encryptionKey);
149147
rc.response().end(Utils.toBase64String(encryptedResp));
150148
}
151149
else {
152150
rc.response().putHeader(HttpHeaders.CONTENT_TYPE, "application/json")
153-
.end(respJson.encode());
151+
.end(respJson.encode());
154152
}
155153
}
156154
catch (Exception ex){
@@ -167,7 +165,7 @@ private void passThrough(RoutingContext rc, Handler<RoutingContext> apiHandler)
167165
}
168166
JsonObject respJson = (JsonObject) rc.data().get("response");
169167
rc.response().putHeader(HttpHeaders.CONTENT_TYPE, "application/json")
170-
.end(respJson.encode());
168+
.end(respJson.encode());
171169
}
172170

173171
private void writeResponse(RoutingContext rc, byte[] nonce, JsonObject resp, byte[] keyBytes) {
@@ -195,4 +193,3 @@ private void handleResponse(RoutingContext rc, V2RequestUtil.V2Request request)
195193
}
196194
}
197195
}
198-

0 commit comments

Comments
 (0)