2727
2828public class SaltService implements IService {
2929 private static final Logger LOGGER = LoggerFactory .getLogger (SaltService .class );
30+ private static final Duration [] SALT_ROTATION_AGE_THRESHOLDS = new Duration []{
31+ Duration .ofDays (30 ),
32+ Duration .ofDays (60 ),
33+ Duration .ofDays (90 ),
34+ Duration .ofDays (120 ),
35+ Duration .ofDays (150 ),
36+ Duration .ofDays (180 ),
37+ Duration .ofDays (210 ),
38+ Duration .ofDays (240 ),
39+ Duration .ofDays (270 ),
40+ Duration .ofDays (300 ),
41+ Duration .ofDays (330 ),
42+ Duration .ofDays (360 ),
43+ Duration .ofDays (390 )
44+ };
3045
3146 private final AdminAuthMiddleware auth ;
3247 private final WriteLock writeLock ;
3348 private final SaltStoreWriter storageManager ;
3449 private final RotatingSaltProvider saltProvider ;
3550 private final SaltRotation saltRotation ;
36- private final Duration [] defaultSaltRotationAgeThresholds ;
51+
3752
3853 public SaltService (AdminAuthMiddleware auth ,
3954 WriteLock writeLock ,
@@ -45,7 +60,6 @@ public SaltService(AdminAuthMiddleware auth,
4560 this .storageManager = storageManager ;
4661 this .saltProvider = saltProvider ;
4762 this .saltRotation = saltRotation ;
48- this .defaultSaltRotationAgeThresholds = generateThresholds (30 , 390 , 30 );
4963 }
5064
5165 @ Override
@@ -122,9 +136,9 @@ private void handleSaltRotate(RoutingContext rc) {
122136 ageThresholds = RequestUtil .getDurations (rc , "min_ages_in_seconds" );
123137 if (ageThresholds == null ) return ;
124138 } else {
125- ageThresholds = defaultSaltRotationAgeThresholds ;
139+ ageThresholds = SALT_ROTATION_AGE_THRESHOLDS ;
126140 }
127-
141+ LOGGER . info ( "Salt rotation age thresholds: {}" , Arrays . toString ( ageThresholds ));
128142
129143 final TargetDate targetDate =
130144 RequestUtil .getDate (rc , "target_date" , DateTimeFormatter .ISO_LOCAL_DATE )
@@ -157,14 +171,6 @@ private void handleSaltRotate(RoutingContext rc) {
157171 }
158172 }
159173
160- private Duration [] generateThresholds (int minAge , int maxAge , int interval ) {
161- List <Duration > thresholds = new ArrayList <>();
162- for (int i = minAge ; i <= maxAge ; i += interval ) {
163- thresholds .add (Duration .ofDays (i ));
164- }
165- return thresholds .toArray (new Duration [0 ]);
166- }
167-
168174 private JsonObject toJson (RotatingSaltProvider .SaltSnapshot snapshot ) {
169175 JsonObject jo = new JsonObject ();
170176 jo .put ("effective" , snapshot .getEffective ().toEpochMilli ());
0 commit comments