11package com .uid2 .admin .salt ;
22
3- import com .uid2 .admin .AdminConst ;
43import com .uid2 .shared .model .SaltEntry ;
54import com .uid2 .shared .secret .IKeyGenerator ;
65
7- import com .uid2 .shared .store .salt .ISaltProvider ;
86import com .uid2 .shared .store .salt .ISaltProvider .ISaltSnapshot ;
97import com .uid2 .shared .store .salt .RotatingSaltProvider .SaltSnapshot ;
10- import io .vertx .core .json .JsonObject ;
118import lombok .Getter ;
129import org .slf4j .Logger ;
1310import org .slf4j .LoggerFactory ;
@@ -22,18 +19,10 @@ public class SaltRotation {
2219 private static final double MAX_SALT_PERCENTAGE = 0.8 ;
2320
2421 private final IKeyGenerator keyGenerator ;
25- private final boolean isRefreshFromEnabled ;
26- private final boolean isCustomAgeThresholdEnabled ;
2722 private static final Logger LOGGER = LoggerFactory .getLogger (SaltRotation .class );
2823
29- public SaltRotation (JsonObject config , IKeyGenerator keyGenerator ) {
24+ public SaltRotation (IKeyGenerator keyGenerator ) {
3025 this .keyGenerator = keyGenerator ;
31- this .isRefreshFromEnabled = config .getBoolean (AdminConst .ENABLE_SALT_ROTATION_REFRESH_FROM , false );
32- this .isCustomAgeThresholdEnabled = config .getBoolean (AdminConst .ENABLE_SALT_ROTATION_CUSTOM_AGE_THRESHOLDS , false );
33- }
34-
35- public boolean isCustomAgeThresholdEnabled () {
36- return this .isCustomAgeThresholdEnabled ;
3726 }
3827
3928 public Result rotateSalts (
@@ -97,7 +86,6 @@ public Result rotateSaltsZero(
9786 return Result .fromSnapshot (nextSnapshot );
9887 }
9988
100-
10189 private static int getNumSaltsToRotate (SaltEntry [] preRotationSalts , double fraction ) {
10290 return (int ) Math .ceil (preRotationSalts .length * fraction );
10391 }
@@ -107,11 +95,7 @@ private Set<SaltEntry> findRefreshableSalts(SaltEntry[] preRotationSalts, Target
10795 }
10896
10997 private boolean isRefreshable (TargetDate targetDate , SaltEntry salt ) {
110- if (this .isRefreshFromEnabled ) {
111- return Instant .ofEpochMilli (salt .refreshFrom ()).truncatedTo (ChronoUnit .DAYS ).equals (targetDate .asInstant ());
112- }
113-
114- return true ;
98+ return Instant .ofEpochMilli (salt .refreshFrom ()).truncatedTo (ChronoUnit .DAYS ).equals (targetDate .asInstant ());
11599 }
116100
117101 private SaltEntry [] rotateSalts (SaltEntry [] oldSalts , List <SaltEntry > saltsToRotate , TargetDate targetDate ) throws Exception {
@@ -163,7 +147,7 @@ private List<SaltEntry> pickSaltsToRotate(
163147 TargetDate targetDate ,
164148 Duration [] minAges ,
165149 int numSaltsToRotate ) {
166- var maxSaltsPerAge = this . isRefreshFromEnabled ? (int ) (numSaltsToRotate * MAX_SALT_PERCENTAGE ) : numSaltsToRotate ;
150+ var maxSaltsPerAge = (int ) (numSaltsToRotate * MAX_SALT_PERCENTAGE );
167151
168152 var thresholds = Arrays .stream (minAges )
169153 .map (minAge -> targetDate .asInstant ().minusSeconds (minAge .getSeconds ()))
0 commit comments