Commit 3245f121 authored by Kevin Michael Smith's avatar Kevin Michael Smith Committed by Kevin Smith
Browse files

Move JDBCConfig's XStream whitelist to a persister initializer

parent 61a161d4
package org.geoserver.jdbcconfig.internal;
import org.geoserver.config.util.XStreamPersister;
import org.geoserver.config.util.XStreamPersisterInitializer;
public class JDBCConfigXStreamPersisterInitializer implements
XStreamPersisterInitializer {
@Override
public void init(XStreamPersister persister) {
persister.getXStream().allowTypes(new String[] {
"org.geoserver.wfs.WFSInfo.Version",
"org.geoserver.wfs.WFSInfo$Version",
"org.geoserver.wms.WatermarkInfoImpl",
"org.geoserver.wfs.GMLInfoImpl"
});
}
}
......@@ -26,12 +26,7 @@ public class XStreamInfoSerialBinding {
public XStreamInfoSerialBinding(final XStreamPersisterFactory xspf) {
this.xstreamPersister = xspf.createXMLPersister();
this.xstreamPersister.setLoggingLevel(Level.WARNING);
this.xstreamPersister.getXStream().allowTypes(new String[] {
"org.geoserver.wfs.WFSInfo.Version",
"org.geoserver.wfs.WFSInfo$Version",
"org.geoserver.wms.WatermarkInfoImpl",
"org.geoserver.wfs.GMLInfoImpl"
});
//new JDBCConfigXStreamPersisterInitializer().init(this.xstreamPersister);
}
public <T extends Info> T entryToObject(InputStream in, Class<T> target) {
......
......@@ -60,5 +60,6 @@
</bean>
<bean id="JDBCCacheProvider" class="org.geoserver.jdbcconfig.internal.JDBCCacheProvider"/>
<bean id="JDBCConfigXStreamPersisterInitializer" class="org.geoserver.jdbcconfig.internal.JDBCConfigXStreamPersisterInitializer"/>
</beans>
......@@ -16,17 +16,19 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletContext;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.geoserver.catalog.impl.CatalogImpl;
import org.geoserver.config.util.XStreamPersisterFactory;
import org.geoserver.config.util.XStreamPersisterInitializer;
import org.geoserver.jdbcconfig.internal.ConfigDatabase;
import org.geoserver.jdbcconfig.internal.DbMappings;
import org.geoserver.jdbcconfig.internal.Dialect;
import org.geoserver.jdbcconfig.internal.JDBCConfigXStreamPersisterInitializer;
import org.geoserver.jdbcconfig.internal.Util;
import org.geoserver.jdbcconfig.internal.XStreamInfoSerialBinding;
import org.geoserver.platform.GeoServerExtensionsHelper;
......@@ -211,11 +213,13 @@ public class JDBCConfigTestSupport {
// just to avoid hundreds of warnings in the logs about extension lookups with no app
// context set
appContext = createNiceMock(WebApplicationContext.class);
GeoServerExtensionsHelper.init(appContext);
configureAppContext(appContext);
replay(appContext);
GeoServerExtensionsHelper.init(appContext);
GeoServerExtensionsHelper.singleton("JDBCConfigXStreamPersisterInitializer", new JDBCConfigXStreamPersisterInitializer(), XStreamPersisterInitializer.class);
// final File testDbDir = new File("target", "jdbcconfig");
// FileUtils.deleteDirectory(testDbDir);
// testDbDir.mkdirs();
......@@ -238,10 +242,13 @@ public class JDBCConfigTestSupport {
}
protected void configureAppContext(WebApplicationContext appContext) {
expect(appContext.containsBean("JDBCConfigXStreamPersisterInitializer")).andStubReturn(true);
expect(appContext.getBeansOfType((Class) anyObject()))
.andReturn(Collections.EMPTY_MAP).anyTimes();
expect(appContext.getBeanNamesForType((Class) anyObject()))
.andReturn(new String[] {}).anyTimes();
ServletContext servletContext = createNiceMock(ServletContext.class);
replay(servletContext);
......@@ -259,6 +266,7 @@ public class JDBCConfigTestSupport {
dataSource.close();
}
}
GeoServerExtensionsHelper.clear();
}
public GeoServerResourceLoader getResourceLoader() {
......
......@@ -19,9 +19,12 @@ import org.geoserver.config.ServiceInfo;
import org.geoserver.config.impl.GeoServerImpl;
import org.geoserver.config.impl.ServiceInfoImpl;
import org.geoserver.config.impl.SettingsInfoImpl;
import org.geoserver.config.util.XStreamPersisterInitializer;
import org.geoserver.jdbcconfig.JDBCConfigTestSupport;
import org.geoserver.jdbcconfig.catalog.JDBCCatalogFacade;
import org.geoserver.jdbcconfig.internal.ConfigDatabase;
import org.geoserver.jdbcconfig.internal.JDBCConfigXStreamPersisterInitializer;
import org.geoserver.platform.GeoServerExtensionsHelper;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment