Add Session.purgeDirectoryCache()

pull/140/head
Richard Körber 2023-04-29 15:15:41 +02:00
parent d0c2aafaf1
commit 18e56c9d4f
No known key found for this signature in database
GPG Key ID: AAB9FD19C78AA3E0
2 changed files with 19 additions and 0 deletions

View File

@ -311,6 +311,18 @@ public class Session {
return resourceMap.get() != null;
}
/**
* Purges the directory cache. Makes sure that a fresh copy of the directory will be
* read from the CA on the next time the directory is accessed.
*
* @since 3.0.0
*/
public void purgeDirectoryCache() {
setDirectoryLastModified(null);
setDirectoryExpires(null);
resourceMap.set(null);
}
/**
* Reads the provider's directory, then rebuild the resource map. The resource map
* is unchanged if the {@link AcmeProvider} returns that the directory has not been

View File

@ -97,6 +97,13 @@ public class SessionTest {
assertThat(session.getDirectoryLastModified()).isEqualTo(now);
session.setDirectoryLastModified(null);
assertThat(session.getDirectoryLastModified()).isNull();
session.setDirectoryExpires(now);
session.setDirectoryLastModified(now);
session.purgeDirectoryCache();
assertThat(session.getDirectoryExpires()).isNull();
assertThat(session.getDirectoryLastModified()).isNull();
assertThat(session.hasDirectory()).isFalse();
}
/**