1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 18:15:42 +01:00

reworked loading, checking and storing interims.

This commit is contained in:
Sascha L. Teichmann 2022-08-02 17:01:48 +02:00
parent 892a0b941b
commit ef829131e1
2 changed files with 88 additions and 75 deletions

View file

@ -16,6 +16,7 @@ import (
"os"
"runtime"
"sync"
"time"
"github.com/BurntSushi/toml"
"github.com/ProtonMail/gopenpgp/v2/crypto"
@ -85,6 +86,16 @@ type config struct {
keyErr error
}
// TooOldForInterims returns a function that tells if a given
// time is too old for the configured interims interval.
func (c *config) TooOldForInterims() func(time.Time) bool {
if c.InterimYears <= 0 {
return func(time.Time) bool { return false }
}
from := time.Now().AddDate(-c.InterimYears, 0, 0)
return func(t time.Time) bool { return t.Before(from) }
}
// serviceDocument tells if we should generate a service document for a
// given provider.
func (p *provider) serviceDocument(c *config) bool {