Skip to content

Commit

Permalink
Move encryptor configuration file to the data directory config folder
Browse files Browse the repository at this point in the history
  • Loading branch information
josegar74 authored and fxprunayre committed May 5, 2021
1 parent c56ed42 commit 0d9bb9b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ web/src/main/webapp/WEB-INF/data/config/schema_plugins/dublin-core
web/src/main/webapp/WEB-INF/data/config/schema_plugins/iso19*
web/src/main/webapp/WEB-INF/data/config/schema_plugins/schemaplugin-uri-catalog.xml
web/src/main/webapp/WEB-INF/data/config/schemaplugin-uri-catalog.xml
web/src/main/webapp/WEB-INF/data/config/encryptor.properties
web/src/main/webapp/WEB-INF/data/data/backup
web/src/main/webapp/WEB-INF/data/data/metadata_data
web/src/main/webapp/WEB-INF/data/data/metadata_subversion
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/fao/geonet/constants/Geonet.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public static final class File {
public static final String UPDATE_FIXED_INFO = "update-fixed-info.xsl";
public static final String UPDATE_FIXED_INFO_SUBTEMPLATE = "update-fixed-info-subtemplate.xsl";
public static final String UPDATE_CHILD_FROM_PARENT_INFO = "update-child-from-parent-info.xsl";
public static final String ENCRYPTOR_DIR = "encryptor";
public static final String EXTRACT_UUID = "extract-uuid.xsl";
public static final String EXTRACT_TITLES = "extract-titles.xsl";
public static final String EXTRACT_DEFAULT_LANGUAGE = "extract-default-language.xsl";
Expand All @@ -119,7 +118,9 @@ public static final class File {
public static final String METADATA_BRIEF = "metadata-brief.xsl";
public static final String METADATA_BASEBLANK = "blanks/metadata-schema00";
public static final String METADATA_BLANK = "blanks/metadata-schema";
public static final String ENCRYPTOR_CONFIGURATION = "encryptor.properties";
public static final int METADATA_MAX_BLANKS = 20;

}

public static final class SchemaPath {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,27 +444,25 @@ private void initDataDirectory() throws IOException {
}
}

Path encryptorFolder = configDir.resolve(Geonet.File.ENCRYPTOR_DIR);
if (!Files.exists(encryptorFolder)) {
Log.info(Geonet.DATA_DIRECTORY, " - Copying encryptor directory...");
try {
final Path srcEncryptorDir = getDefaultDataDir(webappDir).resolve("config").resolve(Geonet.File.ENCRYPTOR_DIR);
final Path destDir = this.configDir.resolve(Geonet.File.ENCRYPTOR_DIR);
// Copy encryptor dir if doesn't exist
if (!Files.exists(destDir)) {
IO.copyDirectoryOrFile(srcEncryptorDir, destDir, true);
}

} catch (IOException e) {
Log.info(
Geonet.DATA_DIRECTORY,
" - Error copying encryptor config directory: "
+ e.getMessage());
throw e;
Log.info(Geonet.DATA_DIRECTORY, " - Copying encryptor.properties file...");
try {
final Path srcEncryptorFile = getDefaultDataDir(webappDir).resolve("config").resolve(Geonet.File.ENCRYPTOR_CONFIGURATION);
final Path destEncryptorFile = this.configDir.resolve("encryptor.properties");
// Copy encryptor.properties if doesn't exist
if (!Files.exists(destEncryptorFile)) {
IO.copyDirectoryOrFile(srcEncryptorFile, destEncryptorFile, true);
}

} catch (IOException e) {
Log.info(
Geonet.DATA_DIRECTORY,
" - Error copying encryptor.propeties file: "
+ e.getMessage());
throw e;
}


final Path locDir = webappDir.resolve("loc");
if (!Files.exists(locDir)) {
Files.createDirectories(locDir);
Expand Down
22 changes: 22 additions & 0 deletions web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,28 @@
<overwrite>true</overwrite>
</configuration>
</execution>
<execution>
<id>copy-encryptor-config-to-source</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<escapeString>\</escapeString>
<includeEmptyDirs>false</includeEmptyDirs>
<outputDirectory>${basedir}/src/main/webapp/WEB-INF/data/config</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/webResources/WEB-INF/data/config</directory>
<filtering>true</filtering>
<includes>
<include>encryptor.properties</include>
</includes>
</resource>
</resources>
<overwrite>false</overwrite>
</configuration>
</execution>
</executions>
</plugin>

Expand Down
3 changes: 1 addition & 2 deletions web/src/main/java/org/fao/geonet/EncryptorInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ private int encryptDatabaseValuesStringId(StandardPBEStringEncryptor previousEnc
*/
private PropertiesConfiguration getEncryptorPropertiesFile(GeonetworkDataDirectory dataDirectory)
throws Exception {
Path securityPropsPath = dataDirectory.getConfigDir().resolve("encryptor")
.resolve("encryptor.properties");
Path securityPropsPath = dataDirectory.getConfigDir().resolve(Geonet.File.ENCRYPTOR_CONFIGURATION);

// Create the file if doesn't exists
if (!Files.exists(securityPropsPath)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Password encripter configuration
# Password encryptor configuration
encryptor.algorithm = PBEWithMD5AndDES
encryptor.password =

0 comments on commit 0d9bb9b

Please sign in to comment.