Skip to content

Commit cf17248

Browse files
committed
Reregister AuthCheckFilter exclusion when certificates change
The AdminConsole restarts when the certificates change, clearing previously registered AuthCheckFilter exclusions
1 parent 576ba07 commit cf17248

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/java/org/jivesoftware/openfire/plugin/rest/RESTServicePlugin.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
import org.jivesoftware.admin.AuthCheckFilter;
2020
import org.jivesoftware.openfire.container.Plugin;
2121
import org.jivesoftware.openfire.container.PluginManager;
22+
import org.jivesoftware.openfire.keystore.CertificateStore;
2223
import org.jivesoftware.openfire.plugin.rest.service.JerseyWrapper;
2324
import org.jivesoftware.openfire.stats.StatisticsManager;
25+
import org.jivesoftware.util.CertificateEventListener;
26+
import org.jivesoftware.util.CertificateManager;
2427
import org.jivesoftware.util.JiveGlobals;
2528
import org.jivesoftware.util.PropertyEventDispatcher;
2629
import org.jivesoftware.util.PropertyEventListener;
@@ -32,7 +35,7 @@
3235
/**
3336
* The Class RESTServicePlugin.
3437
*/
35-
public class RESTServicePlugin implements Plugin, PropertyEventListener {
38+
public class RESTServicePlugin implements Plugin, PropertyEventListener, CertificateEventListener {
3639

3740
private static final String CUSTOM_AUTH_FILTER_PROPERTY_NAME = "plugin.restapi.customAuthFilter";
3841
public static final String SERVICE_LOGGING_ENABLED = "plugin.restapi.serviceLoggingEnabled";
@@ -99,6 +102,9 @@ public void initializePlugin(PluginManager manager, File pluginDirectory) {
99102
// Listen to system property events
100103
PropertyEventDispatcher.addListener(this);
101104

105+
// Re-register the URL exclusion if the admin console restarts (e.g. on certificate change)
106+
CertificateManager.addListener(this);
107+
102108
// Exclude this servlet from requering the user to login
103109
AuthCheckFilter.addExclude(JerseyWrapper.SERVLET_URL);
104110
}
@@ -118,6 +124,17 @@ public void destroyPlugin() {
118124
AuthCheckFilter.removeExclude(JerseyWrapper.SERVLET_URL);
119125
// Stop listening to system property events
120126
PropertyEventDispatcher.removeListener(this);
127+
CertificateManager.removeListener(this);
128+
}
129+
130+
/**
131+
* Re-registers the URL exclusion with the admin console's AuthCheckFilter after a certificate
132+
* store change, which triggers an admin console restart that would otherwise clear plugin-
133+
* registered excludes.
134+
*/
135+
@Override
136+
public void storeContentChanged(CertificateStore store) {
137+
AuthCheckFilter.addExclude(JerseyWrapper.SERVLET_URL);
121138
}
122139

123140
/**

0 commit comments

Comments
 (0)