Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix certificate renewal periodicals to parse both Duration and Period #20056

Merged
merged 8 commits into from
Aug 9, 2024

Conversation

moesterheld
Copy link
Contributor

Description

Certificate renewal periodicals were currently parsing Durations for calculating a 10% time buffer for renewal.
This did not work for TemporalAmounts stored as e.g. PxM which can only be parsed using java.time.Period.

This PR introduces the ThreeTen-Extra library which will also be needed for replacing org.joda.time in the near future.
The TemporalAmount is parsed by PeriodDuration and for Durations, the 10% time buffer is applied. For Periods, a 23-hour buffer is applied in general as 1 day is the smallest unit a Period can represent.

/nocl

Motivation and Context

fixes errors during cert renewal checks

How Has This Been Tested?

added unit tests

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Copy link
Contributor

@todvora todvora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you! Just one question around the json serialization.

@@ -34,4 +40,26 @@ public static Mode create(String value) {
return Mode.valueOf(value.toUpperCase(Locale.ROOT));
}
}

public @NotNull Duration parsedCertificateLifetime() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also ignore this in json serialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ignored in serialization since it isn't a getter method anyway, so no need for the annotation imho

@moesterheld moesterheld merged commit fbefdcc into master Aug 9, 2024
6 checks passed
@moesterheld moesterheld deleted the fix/period-parsing branch August 9, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants