Hi everyone,
I wanted to ask about the best way to add encryption settings to the SQL
Server extension for geoserver 2.16 (on a windows 2012 server using
tomcat). I was able to unpack the JAR file, modify the java file, however,
I seem to be having compiling issues on windows command prompt. What is
considered best practice for customizing extensions?
Here is the modified java file:
package org.geotools.data.sqlserver;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.geotools.data.DataAccessFactory;
import org.geotools.jdbc.JDBCDataStore;
import org.geotools.jdbc.JDBCDataStoreFactory;
import org.geotools.jdbc.SQLDialect;
public class SQLServerDataStoreFactory
extends JDBCDataStoreFactory
{
public static final DataAccessFactory.Param DBTYPE = new
DataAccessFactory.Param("dbtype", String.class, "Type", true, "sqlserver",
Collections.singletonMap("level", "program"));
public static final DataAccessFactory.Param INTSEC = new
DataAccessFactory.Param("Integrated Security", Boolean.class, "Login as
current windows user account. Works only in windows. Ignores user and
password settings.", false, Boolean.FALSE);
public static final DataAccessFactory.Param NATIVE_PAGING = new
DataAccessFactory.Param("Use Native Paging", Boolean.class, "Use native
paging for sql queries. For some sets of data, native paging can have a
performance impact.", false, Boolean.TRUE);
public static final DataAccessFactory.Param GEOMETRY_METADATA_TABLE = new
DataAccessFactory.Param("Geometry metadata table", String.class, "The
optional table containing geometry metadata (geometry type and srid). Can
be expressed as 'schema.name' or just 'name'", false);
public static final DataAccessFactory.Param NATIVE_SERIALIZATION = new
DataAccessFactory.Param("Use native geometry serialization", Boolean.class,
"Use native SQL Server serialization, or WKB serialization.", false,
Boolean.FALSE);
public static final DataAccessFactory.Param FORCE_SPATIAL_INDEX = new
DataAccessFactory.Param("Force spatial index usage via hints",
Boolean.class, "When enabled, spatial filters will be accompained by a WITH
INDEX sql hint forcing the usage of the spatial index.", false,
Boolean.FALSE);
public static final DataAccessFactory.Param TABLE_HINTS = new
DataAccessFactory.Param("Table hints", String.class, "These table hints
will be added to every select query.", false, "");
public static final DataAccessFactory.Param ENCRYPT = new
DataAccessFactory.Param(
"Encryption",
String.class,
"This will enforce TLS encryption in the sql server
connection.",
true,
"");
public static final DataAccessFactory.Param PORT = new
DataAccessFactory.Param("port", Integer.class, "Port", false);
public static final DataAccessFactory.Param INSTANCE = new
DataAccessFactory.Param("instance", String.class, "Instance Name", false);
protected SQLDialect createSQLDialect(JDBCDataStore dataStore) { return
new SQLServerDialect(dataStore); }
protected String getDatabaseID() { return (String)DBTYPE.sample; }
public String getDescription() { return "Microsoft SQL Server"; }
protected String getDriverClassName() { return
"com.microsoft.sqlserver.jdbc.SQLServerDriver"; }
protected String getValidationQuery() { return "select 1"; }
protected void setupParameters(Map parameters) {
super.setupParameters(parameters);
parameters.put(PORT.key, PORT);
parameters.put(DBTYPE.key, DBTYPE);
parameters.put(INTSEC.key, INTSEC);
parameters.put(NATIVE_PAGING.key, NATIVE_PAGING);
parameters.put(NATIVE_SERIALIZATION.key, NATIVE_SERIALIZATION);
parameters.put(GEOMETRY_METADATA_TABLE.key, GEOMETRY_METADATA_TABLE);
parameters.put(FORCE_SPATIAL_INDEX.key, FORCE_SPATIAL_INDEX);
parameters.put(TABLE_HINTS.key, TABLE_HINTS);
parameters.put(INSTANCE.key, INSTANCE);
parameters.put(ENCRYPT.key, ENCRYPT);
}
protected String getJDBCUrl(Map params) throws IOException {
String host = (String)HOST.lookUp(params);
Integer port = (Integer)PORT.lookUp(params);
String db = (String)DATABASE.lookUp(params);
String instance = (String)INSTANCE.lookUp(params);
String url = "jdbc:" + getDatabaseID() + "://" + host;
if (port != null) {
url = url + ":" + port;
} else if (instance != null) {
url = url + "\\" + instance;
}
if (db != null) {
url = url + "/" + db;
}
Boolean EncryptBool = (Boolean) ENCRYPT.lookUp(params);
Boolean intsec = (Boolean)INTSEC.lookUp(params);
if (db != null)
{
url = url.substring(0, url.lastIndexOf("/")) + ((db != null) ?
(";DatabaseName=" + db) : "");
}
if (intsec != null && intsec.booleanValue()) {
url = url + ";integratedSecurity=true";
}
if (EncryptBool != null && EncryptBool.booleanValue()) {
url = url + ";encrypt=true;trustServerCertificate=false;";
}
return url;
}
public boolean canProcess(Map params) {
if (!super.canProcess(params)) {
return false;
}
Integer port = null;
String instance = null;
try {
port = (Integer)PORT.lookUp(params);
instance = (String)INSTANCE.lookUp(params);
} catch (IOException iOException) {}
return (port != null || instance != null);
}
protected JDBCDataStore createDataStoreInternal(JDBCDataStore dataStore,
Map params) throws IOException {
SQLServerDialect dialect = (SQLServerDialect)dataStore.getSQLDialect();
String metadataTable = (String)GEOMETRY_METADATA_TABLE.lookUp(params);
dialect.setGeometryMetadataTable(metadataTable);
Boolean useNativePaging = (Boolean)NATIVE_PAGING.lookUp(params);
dialect.setUseOffSetLimit(Boolean.valueOf((useNativePaging == null ||
Boolean.TRUE.equals(useNativePaging))));
Boolean useNativeSerialization =
(Boolean)NATIVE_SERIALIZATION.lookUp(params);
if (useNativeSerialization != null) {
dialect.setUseNativeSerialization(useNativeSerialization);
}
Boolean forceSpatialIndexes =
(Boolean)FORCE_SPATIAL_INDEX.lookUp(params);
if (forceSpatialIndexes != null) {
dialect.setForceSpatialIndexes(forceSpatialIndexes.booleanValue());
}
String tableHints = (String)TABLE_HINTS.lookUp(params);
if (tableHints != null) {
dialect.setTableHints(tableHints);
}
return dataStore;
}
}
**************END OF JAVA***************
Here is the error log for recompiling:
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:6:
error: cannot find symbol
/* */ import org.geotools.data.DataAccessFactory;
^
symbol: class DataAccessFactory
location: package org.geotools.data
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:7:
error: package org.geotools.jdbc does not exist
/* */ import org.geotools.jdbc.JDBCDataStore;
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:8:
error: package org.geotools.jdbc does not exist
/* */ import org.geotools.jdbc.JDBCDataStoreFactory;
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:9:
error: package org.geotools.jdbc does not exist
/* */ import org.geotools.jdbc.SQLDialect;
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:32:
error: cannot find symbol
/* */ extends JDBCDataStoreFactory
^
symbol: class JDBCDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:34:
error: package DataAccessFactory does not exist
/* 34 */ public static final DataAccessFactory.Param DBTYPE = new
DataAccessFactory.Param("dbtype", String.class, "Type", true, "sqlserver",
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:47:
error: package DataAccessFactory does not exist
/* 47 */ public static final DataAccessFactory.Param INTSEC = new
DataAccessFactory.Param("Integrated Security", Boolean.class, "Login as
current windows user account. Works only in windows. Ignores user and
password settings.", false, Boolean.FALSE);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:56:
error: package DataAccessFactory does not exist
/* 56 */ public static final DataAccessFactory.Param NATIVE_PAGING = new
DataAccessFactory.Param("Use Native Paging", Boolean.class, "Use native
paging for sql queries. For some sets of data, native paging can have a
performance impact.", false, Boolean.TRUE);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:65:
error: package DataAccessFactory does not exist
/* 65 */ public static final DataAccessFactory.Param
GEOMETRY_METADATA_TABLE = new DataAccessFactory.Param("Geometry metadata
table", String.class, "The optional table containing geometry metadata
(geometry type and srid). Can be expressed as 'schema.name' or just
'name'", false);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:73:
error: package DataAccessFactory does not exist
/* 73 */ public static final DataAccessFactory.Param
NATIVE_SERIALIZATION = new DataAccessFactory.Param("Use native geometry
serialization", Boolean.class, "Use native SQL Server serialization, or WKB
serialization.", false, Boolean.FALSE);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:82:
error: package DataAccessFactory does not exist
/* 82 */ public static final DataAccessFactory.Param FORCE_SPATIAL_INDEX
= new DataAccessFactory.Param("Force spatial index usage via hints",
Boolean.class, "When enabled, spatial filters will be accompained by a WITH
INDEX sql hint forcing the usage of the spatial index.", false,
Boolean.FALSE);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:91:
error: package DataAccessFactory does not exist
/* 91 */ public static final DataAccessFactory.Param TABLE_HINTS = new
DataAccessFactory.Param("Table hints", String.class, "These table hints
will be added to every select query.", false, "");
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:96:
error: package DataAccessFactory does not exist
/* */ public static final DataAccessFactory.Param ENCRYPT = new
DataAccessFactory.Param(
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:105:
error: package DataAccessFactory does not exist
/* 100 */ public static final DataAccessFactory.Param PORT = new
DataAccessFactory.Param("port", Integer.class, "Port", false);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:108:
error: package DataAccessFactory does not exist
/* 103 */ public static final DataAccessFactory.Param INSTANCE = new
DataAccessFactory.Param("instance", String.class, "Instance Name", false);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:113:
error: cannot find symbol
/* 108 */ protected SQLDialect createSQLDialect(JDBCDataStore dataStore)
{ return new SQLServerDialect(dataStore); }
^
symbol: class JDBCDataStore
location: class SQLServerDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:113:
error: cannot find symbol
/* 108 */ protected SQLDialect createSQLDialect(JDBCDataStore dataStore)
{ return new SQLServerDialect(dataStore); }
^
symbol: class SQLDialect
location: class SQLServerDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:211:
error: cannot find symbol
/* */ protected JDBCDataStore createDataStoreInternal(JDBCDataStore
dataStore, Map params) throws IOException {
^
symbol: class JDBCDataStore
location: class SQLServerDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:211:
error: cannot find symbol
/* */ protected JDBCDataStore createDataStoreInternal(JDBCDataStore
dataStore, Map params) throws IOException {
^
symbol: class JDBCDataStore
location: class SQLServerDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:34:
error: package DataAccessFactory does not exist
/* 34 */ public static final DataAccessFactory.Param DBTYPE = new
DataAccessFactory.Param("dbtype", String.class, "Type", true, "sqlserver",
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:47:
error: package DataAccessFactory does not exist
/* 47 */ public static final DataAccessFactory.Param INTSEC = new
DataAccessFactory.Param("Integrated Security", Boolean.class, "Login as
current windows user account. Works only in windows. Ignores user and
password settings.", false, Boolean.FALSE);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:56:
error: package DataAccessFactory does not exist
/* 56 */ public static final DataAccessFactory.Param NATIVE_PAGING = new
DataAccessFactory.Param("Use Native Paging", Boolean.class, "Use native
paging for sql queries. For some sets of data, native paging can have a
performance impact.", false, Boolean.TRUE);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:65:
error: package DataAccessFactory does not exist
/* 65 */ public static final DataAccessFactory.Param
GEOMETRY_METADATA_TABLE = new DataAccessFactory.Param("Geometry metadata
table", String.class, "The optional table containing geometry metadata
(geometry type and srid). Can be expressed as 'schema.name' or just
'name'", false);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:73:
error: package DataAccessFactory does not exist
/* 73 */ public static final DataAccessFactory.Param
NATIVE_SERIALIZATION = new DataAccessFactory.Param("Use native geometry
serialization", Boolean.class, "Use native SQL Server serialization, or WKB
serialization.", false, Boolean.FALSE);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:82:
error: package DataAccessFactory does not exist
/* 82 */ public static final DataAccessFactory.Param FORCE_SPATIAL_INDEX
= new DataAccessFactory.Param("Force spatial index usage via hints",
Boolean.class, "When enabled, spatial filters will be accompained by a WITH
INDEX sql hint forcing the usage of the spatial index.", false,
Boolean.FALSE);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:91:
error: package DataAccessFactory does not exist
/* 91 */ public static final DataAccessFactory.Param TABLE_HINTS = new
DataAccessFactory.Param("Table hints", String.class, "These table hints
will be added to every select query.", false, "");
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:96:
error: package DataAccessFactory does not exist
/* */ public static final DataAccessFactory.Param ENCRYPT = new
DataAccessFactory.Param(
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:105:
error: package DataAccessFactory does not exist
/* 100 */ public static final DataAccessFactory.Param PORT = new
DataAccessFactory.Param("port", Integer.class, "Port", false);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:108:
error: package DataAccessFactory does not exist
/* 103 */ public static final DataAccessFactory.Param INSTANCE = new
DataAccessFactory.Param("instance", String.class, "Instance Name", false);
^
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:139:
error: cannot find symbol
/* 134 */ super.setupParameters(parameters);
^
symbol: variable super
location: class SQLServerDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:156:
error: cannot find symbol
/* 150 */ String host = (String)HOST.lookUp(params);
^
symbol: variable HOST
location: class SQLServerDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:158:
error: cannot find symbol
/* 152 */ String db = (String)DATABASE.lookUp(params);
^
symbol: variable DATABASE
location: class SQLServerDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:193:
error: cannot find symbol
/* 183 */ if (!super.canProcess(params)) {
^
symbol: variable super
location: class SQLServerDataStoreFactory
C:\Users\dcolombini\Downloads\geoserver-2.16.0-sqlserver-plugin\gt-jdbc-sqlserver-22.0.zip.src\org\geotools\data\sqlserver\SQLServerDataStoreFactory.java:216:
error: cannot access BasicSQLDialect
/* 206 */ dialect.setGeometryMetadataTable(metadataTable);
^
class file for org.geotools.jdbc.BasicSQLDialect not found
34 errors
Thank you for any assistance,
*David Colombini*
Environmental Data Specialist
...........................................................................
*AKRF, INC.*
*Environmental, Planning, and Engineering Consultants*
440 Park Ave South , 7th Floor | New York , NY 10016
P) 646.388.9595 (x1595)
www.akrf.com
_______________________________________________
Geoserver-users mailing list
Please make sure you read the following two resources before posting to this
list:
- Earning your support instead of buying it, but Ian Turton:
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines:
http://geoserver.org/comm/userlist-guidelines.html
If you want to request a feature or an improvement, also see this:
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users