Revision a23c2a31
Added by Andreas Kohlbecker about 5 years ago
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/AccountStore.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.common; |
|
12 |
|
|
13 |
import java.io.File; |
|
14 |
import java.io.FileInputStream; |
|
15 |
import java.io.FileNotFoundException; |
|
16 |
import java.io.FileOutputStream; |
|
17 |
import java.io.IOException; |
|
18 |
import java.util.Properties; |
|
19 |
|
|
20 |
import org.apache.log4j.Logger; |
|
21 |
|
|
22 |
|
|
23 |
public class AccountStore { |
|
24 |
|
|
25 |
private static Logger logger = Logger.getLogger(AccountStore.class); |
|
26 |
|
|
27 |
public final static File accountsFile = new File(ConfigFileUtil.perUserCdmFolder() + File.separator + ".dbaccounts.properties"); |
|
28 |
|
|
29 |
public static String getAccountsFileName(){ |
|
30 |
try { |
|
31 |
return accountsFile.getCanonicalPath(); |
|
32 |
} catch (IOException e) { |
|
33 |
logger.warn(e); |
|
34 |
return "AN ERROR OCCURRED WHEN RETRIEVING THE FILE NAME"; |
|
35 |
} |
|
36 |
} |
|
37 |
|
|
38 |
public String getPassword(String dbms, String strServer, String userName){ |
|
39 |
String pwd = null; |
|
40 |
|
|
41 |
Properties accounts = loadAccounts(); |
|
42 |
String key = strServer+'.'+dbms+'.'+userName; |
|
43 |
pwd = accounts.getProperty(key); |
|
44 |
return pwd; |
|
45 |
} |
|
46 |
|
|
47 |
private Properties loadAccounts() { |
|
48 |
Properties accounts = new Properties(); |
|
49 |
try { |
|
50 |
accountsFile.createNewFile(); |
|
51 |
|
|
52 |
// this gives me errors. Properties object doesn't have a method |
|
53 |
// with this signature |
|
54 |
//FileReader in = new FileReader(accountsFile); |
|
55 |
//accounts.load(in); |
|
56 |
//in.close(); |
|
57 |
|
|
58 |
FileInputStream inStream = new FileInputStream(accountsFile); |
|
59 |
accounts.load(inStream); |
|
60 |
inStream.close(); |
|
61 |
|
|
62 |
} catch (IOException e) { |
|
63 |
logger.error(e); |
|
64 |
} |
|
65 |
return accounts; |
|
66 |
} |
|
67 |
|
|
68 |
public void setPassword(String dbms, String strServer, String userName, String pwd){ |
|
69 |
Properties accounts = loadAccounts(); |
|
70 |
String key = strServer+'.'+dbms+'.'+userName; |
|
71 |
accounts.setProperty(key, pwd); |
|
72 |
saveAccounts(accounts); |
|
73 |
} |
|
74 |
|
|
75 |
private void saveAccounts(Properties accounts) { |
|
76 |
//FileWriter out; |
|
77 |
FileOutputStream outStream; |
|
78 |
try { |
|
79 |
//out = new FileWriter(accountsFile); |
|
80 |
//accounts.store(out, ""); |
|
81 |
//out.close(); |
|
82 |
outStream = new FileOutputStream(accountsFile); |
|
83 |
accounts.store(outStream, ""); |
|
84 |
outStream.close(); |
|
85 |
} catch (FileNotFoundException e) { |
|
86 |
logger.error("File " + accountsFile.toString() + " not found", e); |
|
87 |
} catch (IOException e) { |
|
88 |
logger.error("Unable to write properties", e); |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
public void removePassword(String dbms, String strServer, String userName){ |
|
93 |
String key = strServer+'.'+dbms+'.'+userName; |
|
94 |
Properties accounts = loadAccounts(); |
|
95 |
accounts.remove(key); |
|
96 |
saveAccounts(accounts); |
|
97 |
} |
|
98 |
|
|
99 |
public static String readOrStorePassword(String dbms, String strServer, String userName, String pwd){ |
|
100 |
AccountStore accounts = new AccountStore(); |
|
101 |
boolean doStore = false; |
|
102 |
try { |
|
103 |
if (pwd == null){ |
|
104 |
pwd = accounts.getPassword(dbms, strServer, userName); |
|
105 |
if(pwd == null){ |
|
106 |
doStore = true; |
|
107 |
pwd = CdmUtils.readInputLine("Please insert password for user '" + CdmUtils.Nz(userName) + "': "); |
|
108 |
} else { |
|
109 |
logger.info("using stored password for user '" + CdmUtils.Nz(userName) + "'"); |
|
110 |
} |
|
111 |
} |
|
112 |
// on success store userName, pwd in property file |
|
113 |
if(doStore){ |
|
114 |
accounts.setPassword(dbms, strServer, userName, pwd); |
|
115 |
logger.info("password stored in " + AccountStore.getAccountsFileName()); |
|
116 |
} |
|
117 |
} catch (Exception e) { |
|
118 |
if(doStore){ |
|
119 |
accounts.removePassword(dbms, strServer, userName); |
|
120 |
logger.info("password removed from " + AccountStore.getAccountsFileName()); |
|
121 |
} |
|
122 |
logger.error(e); |
|
123 |
return null; |
|
124 |
} |
|
125 |
return pwd; |
|
126 |
} |
|
127 |
|
|
128 |
public static void main(String[] args) { |
|
129 |
AccountStore a = new AccountStore(); |
|
130 |
// BerlinModel - EditWp6 |
|
131 |
String dbms = "SQLServer"; |
|
132 |
String strServer = "BGBM111"; |
|
133 |
String userName = "webUser"; |
|
134 |
a.setPassword(dbms, strServer, userName, "psst"); |
|
135 |
logger.info(a.getPassword(dbms, strServer, userName)); |
|
136 |
a.removePassword(dbms, strServer, userName); |
|
137 |
logger.info(a.getPassword(dbms, strServer, userName)); |
|
138 |
|
|
139 |
} |
|
140 |
} |
cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/ConfigFileUtil.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.common; |
|
10 |
|
|
11 |
import java.io.BufferedWriter; |
|
12 |
import java.io.File; |
|
13 |
import java.io.FileInputStream; |
|
14 |
import java.io.FileNotFoundException; |
|
15 |
import java.io.IOException; |
|
16 |
import java.net.URL; |
|
17 |
import java.nio.file.Files; |
|
18 |
import java.util.Properties; |
|
19 |
|
|
20 |
import org.apache.log4j.Logger; |
|
21 |
import org.springframework.context.EnvironmentAware; |
|
22 |
import org.springframework.core.env.Environment; |
|
23 |
|
|
24 |
/** |
|
25 |
* |
|
26 |
* @author a.kohlbecker |
|
27 |
* @since May 8, 2017 |
|
28 |
* |
|
29 |
*/ |
|
30 |
public class ConfigFileUtil implements EnvironmentAware { |
|
31 |
|
|
32 |
private static final Logger logger = Logger.getLogger(ConfigFileUtil.class); |
|
33 |
|
|
34 |
private static String userHome = null; |
|
35 |
|
|
36 |
/** |
|
37 |
* The per user cdm folder name: ".cdmLibrary" |
|
38 |
*/ |
|
39 |
private static final String CDM_FOLDER_NAME = ".cdmLibrary"; |
|
40 |
|
|
41 |
/** |
|
42 |
* The per user cdm folder "~/.cdmLibrary" |
|
43 |
*/ |
|
44 |
private static File perUserCdmFolder = null; |
|
45 |
|
|
46 |
public static File perUserCdmFolder() { |
|
47 |
return perUserCdmFolder; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* suggested sub folder for web app related data and configurations. |
|
52 |
* Each webapp instance should use a dedicated subfolder or file |
|
53 |
* which is named by the data source bean id. |
|
54 |
*/ |
|
55 |
public static final String SUBFOLDER_WEBAPP = "remote-webapp"; |
|
56 |
|
|
57 |
static final String MUST_EXIST_FILE = "MUST-EXIST.txt"; |
|
58 |
|
|
59 |
//folder separator |
|
60 |
static String folderSeparator; |
|
61 |
|
|
62 |
protected Environment env; |
|
63 |
|
|
64 |
@Override |
|
65 |
public void setEnvironment(Environment environment) { |
|
66 |
this.env = environment; |
|
67 |
if(userHome == null){ |
|
68 |
ConfigFileUtil.userHome = env.getRequiredProperty("user.home"); |
|
69 |
ConfigFileUtil.perUserCdmFolder = new File(userHome + File.separator + CDM_FOLDER_NAME ); |
|
70 |
logger.info("user.home is set to " + ConfigFileUtil.userHome); |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
|
|
75 |
/** |
|
76 |
* @return |
|
77 |
*/ |
|
78 |
static public String getFolderSeperator(){ |
|
79 |
if (folderSeparator == null){ |
|
80 |
URL url = CdmUtils.class.getResource("/"+ MUST_EXIST_FILE); |
|
81 |
if ( url != null && ! urlIsJarOrBundle(url) ){ |
|
82 |
folderSeparator = File.separator; |
|
83 |
}else{ |
|
84 |
folderSeparator = "/"; |
|
85 |
} |
|
86 |
} |
|
87 |
return folderSeparator; |
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
/** |
|
92 |
* @param url |
|
93 |
* @return |
|
94 |
*/ |
|
95 |
static private boolean urlIsJarOrBundle(URL url){ |
|
96 |
return url.getProtocol().startsWith("jar") || url.getProtocol().startsWith("bundleresource"); |
|
97 |
} |
|
98 |
|
|
99 |
|
|
100 |
public static File getCdmHomeDir() { |
|
101 |
return new File(perUserCdmFolder + File.separator); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* Returns specified the sub folder of {@link #CDM_FOLDER_NAME}. |
|
106 |
* If the sub folder does not exist it will be created. |
|
107 |
* |
|
108 |
* @param subFolderName |
|
109 |
* @return the sub folder or null in case the folder did not exist ant the attempt to create it has failed. |
|
110 |
* |
|
111 |
* @see {@link #SUBFOLDER_WEBAPP} |
|
112 |
*/ |
|
113 |
public static File getCdmHomeSubDir(String subFolderName) { |
|
114 |
|
|
115 |
File parentFolder = getCdmHomeDir(); |
|
116 |
return ensureSubfolderExists(parentFolder, subFolderName); |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* Returns an instance specific folder folder in {@link #CDM_FOLDER_NAME}/<code>subFolderName</code> |
|
121 |
* Non existing folders will be created. |
|
122 |
* |
|
123 |
* @param subFolderName |
|
124 |
* The name of a subfolded. In most cases this will be {@link #SUBFOLDER_WEBAPP} |
|
125 |
* @param instanceName |
|
126 |
* The name of the application instance. The name should be related to the data source id. |
|
127 |
* @return the sub folder or null in case the folder did not exist ant the attempt to create it has failed. |
|
128 |
* |
|
129 |
* @see {@link #SUBFOLDER_WEBAPP} |
|
130 |
*/ |
|
131 |
public static File getCdmInstanceSubDir(String subFolderName, String instanceName) { |
|
132 |
|
|
133 |
File subfolder = ensureSubfolderExists(getCdmHomeDir(), subFolderName); |
|
134 |
return ensureSubfolderExists(subfolder, instanceName); |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* @param subFolderName |
|
139 |
* @param parentFolder |
|
140 |
* @return |
|
141 |
*/ |
|
142 |
private static File ensureSubfolderExists(File parentFolder, String subFolderName) { |
|
143 |
if (!parentFolder.exists()){ |
|
144 |
if (!parentFolder.mkdir()) { |
|
145 |
throw new RuntimeException("Parent folder could not be created: " + parentFolder.getAbsolutePath()); |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
File subfolder = new File(parentFolder, subFolderName); |
|
150 |
// if the directory does not exist, create it |
|
151 |
if (!subfolder.exists()) { |
|
152 |
if (!subfolder.mkdir()) { |
|
153 |
throw new RuntimeException("Subfolder could not be created: " + subfolder.getAbsolutePath()); |
|
154 |
} |
|
155 |
} |
|
156 |
return subfolder; |
|
157 |
} |
|
158 |
public static final String CDM_CONFIGFILE_OVERRIDE = "cdm.configfile.override."; |
|
159 |
|
|
160 |
private Properties props = null; |
|
161 |
|
|
162 |
private String defaultContent = ""; |
|
163 |
|
|
164 |
public ConfigFileUtil(){ |
|
165 |
|
|
166 |
} |
|
167 |
|
|
168 |
public ConfigFileUtil setDefaultContent(String content) { |
|
169 |
if(content != null){ |
|
170 |
defaultContent = content; |
|
171 |
} |
|
172 |
return this; |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* Per default the <code>propertiesSet</code> is loaded from a file located in |
|
177 |
* <code>~/.cdmLibrary/remote-webapp/{instanceName}/{propertiesSet}.properties</code>. |
|
178 |
* <p> |
|
179 |
* This behavior can be overwritten by setting the java System property |
|
180 |
* <code>cdm.configfile.override.{propertiesSet}</code> to an alternative file location. |
|
181 |
* This mechanism should only be used for unit and integration tests. |
|
182 |
* |
|
183 |
* @param instanceName the name of the cdm instance. This value can be retrieved from the |
|
184 |
* Spring environment with the key DataSourceConfigurer.CDM_DATA_SOURCE_ID ("") |
|
185 |
* @param propertiesSet |
|
186 |
* The base name of the properties file to be loaded. This name is extended with |
|
187 |
* ".properties" to form the actual filename |
|
188 |
* |
|
189 |
* @return |
|
190 |
* The file containing the properties |
|
191 |
*/ |
|
192 |
public File getPropertiesFile(String instanceName, String propertiesSet) { |
|
193 |
|
|
194 |
if(propertiesSet == null){ |
|
195 |
throw new NullPointerException(); |
|
196 |
} |
|
197 |
String override = System.getProperty(CDM_CONFIGFILE_OVERRIDE + propertiesSet); |
|
198 |
if(override != null){ |
|
199 |
return new File(override); |
|
200 |
} else { |
|
201 |
File configFolder = ConfigFileUtil.getCdmInstanceSubDir(ConfigFileUtil.SUBFOLDER_WEBAPP, instanceName); |
|
202 |
return new File(configFolder, propertiesSet + ".properties"); |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* Per default the <code>propertiesSet</code> is loaded from a file located in |
|
208 |
* <code>~/.cdmLibrary/remote-webapp/{instanceName}/{propertiesSet}.properties</code>. |
|
209 |
* <p> |
|
210 |
* This behavior can be overwritten by setting the java System property |
|
211 |
* <code>cdm.configfile.override.{propertiesSet}</code> to an alternative file location. |
|
212 |
* This mechanism should only be used for unit and integration tests. |
|
213 |
* |
|
214 |
* @param instanceName the name of the cdm instance. This value can be retrieved from the |
|
215 |
* Spring environment with the key DataSourceConfigurer.CDM_DATA_SOURCE_ID ("") |
|
216 |
* @param propertiesSet |
|
217 |
* The base name of the properties file to be loaded. This name is extended with |
|
218 |
* ".properties" to form the actual filename |
|
219 |
* |
|
220 |
* @return |
|
221 |
* The properties loaded from the file |
|
222 |
*/ |
|
223 |
public Properties getProperties(String instanceName, String propertiesName) throws IOException { |
|
224 |
|
|
225 |
if(instanceName == null){ |
|
226 |
throw new NullPointerException(); |
|
227 |
} |
|
228 |
if(props == null){ |
|
229 |
props = new Properties(); |
|
230 |
File uiPropertiesFile = getPropertiesFile(instanceName, propertiesName); |
|
231 |
if(!uiPropertiesFile.exists()){ |
|
232 |
BufferedWriter writer = Files.newBufferedWriter(uiPropertiesFile.toPath()); |
|
233 |
writer.write(defaultContent); |
|
234 |
writer.close(); |
|
235 |
} |
|
236 |
try { |
|
237 |
props.load(new FileInputStream(uiPropertiesFile)); |
|
238 |
} catch (FileNotFoundException e) { |
|
239 |
// must not happen since we checked before |
|
240 |
} |
|
241 |
|
|
242 |
} |
|
243 |
return props; |
|
244 |
} |
|
245 |
} |
cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/ConfigFileUtilTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.common; |
|
11 |
|
|
12 |
import static org.junit.Assert.assertNotNull; |
|
13 |
|
|
14 |
import java.io.File; |
|
15 |
import java.io.IOException; |
|
16 |
import java.io.InputStream; |
|
17 |
|
|
18 |
import org.junit.Assert; |
|
19 |
import org.junit.Ignore; |
|
20 |
import org.junit.Test; |
|
21 |
|
|
22 |
|
|
23 |
public class ConfigFileUtilTest { |
|
24 |
|
|
25 |
@Test |
|
26 |
public void testGetReadableResourceStream() { |
|
27 |
String resourceFileName = ConfigFileUtil.MUST_EXIST_FILE; |
|
28 |
try { |
|
29 |
InputStream inputStream = CdmUtils.getReadableResourceStream(resourceFileName); |
|
30 |
assertNotNull(inputStream); |
|
31 |
} catch (IOException e) { |
|
32 |
Assert.fail("IOException"); |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
@Test |
|
37 |
public void testGetFolderSeperator() { |
|
38 |
Assert.assertEquals(File.separator, ConfigFileUtil.getFolderSeperator()); |
|
39 |
} |
|
40 |
|
|
41 |
@Test |
|
42 |
@Ignore |
|
43 |
public void testGetHomeDir() { |
|
44 |
Assert.assertEquals("", ConfigFileUtil.getCdmHomeDir()); |
|
45 |
} |
|
46 |
|
|
47 |
|
|
48 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/TermMapping.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
import au.com.bytecode.opencsv.CSVReader; |
21 | 21 |
import eu.etaxonomy.cdm.common.CdmUtils; |
22 |
import eu.etaxonomy.cdm.common.ConfigFileUtil;
|
|
22 |
import eu.etaxonomy.cdm.config.ConfigFileUtil;
|
|
23 | 23 |
|
24 | 24 |
/** |
25 | 25 |
* @author a.mueller |
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/sdd/in/KeyActivator.java | ||
---|---|---|
12 | 12 |
import java.net.URISyntaxException; |
13 | 13 |
import java.net.URL; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
15 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
16 | 16 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
17 | 17 |
import eu.etaxonomy.cdm.database.DatabaseTypeEnum; |
18 | 18 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
cdmlib-io/src/test/java/eu/etaxonomy/cdm/test/functional/TestSource.java | ||
---|---|---|
11 | 11 |
import java.sql.ResultSet; |
12 | 12 |
import java.sql.SQLException; |
13 | 13 |
|
14 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
14 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
15 | 15 |
import eu.etaxonomy.cdm.io.common.Source; |
16 | 16 |
|
17 | 17 |
/** |
cdmlib-io/src/test/java/eu/etaxonomy/cdm/test/integration/TestCdmDbComparator.java | ||
---|---|---|
17 | 17 |
import org.springframework.transaction.TransactionStatus; |
18 | 18 |
|
19 | 19 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
20 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
20 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
21 | 21 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
22 | 22 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
23 | 23 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/init/TermLoader.java | ||
---|---|---|
23 | 23 |
import org.springframework.stereotype.Component; |
24 | 24 |
|
25 | 25 |
import au.com.bytecode.opencsv.CSVReader; |
26 |
import eu.etaxonomy.cdm.api.utility.config.ConfigFileUtil; |
|
26 | 27 |
import eu.etaxonomy.cdm.common.CdmUtils; |
27 |
import eu.etaxonomy.cdm.common.ConfigFileUtil; |
|
28 | 28 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
29 | 29 |
import eu.etaxonomy.cdm.model.term.OrderedTermBase; |
30 | 30 |
import eu.etaxonomy.cdm.model.term.OrderedTermVocabulary; |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationUtils.java | ||
---|---|---|
18 | 18 |
import org.apache.log4j.Logger; |
19 | 19 |
|
20 | 20 |
import eu.etaxonomy.cdm.common.CdmUtils; |
21 |
import eu.etaxonomy.cdm.common.ConfigFileUtil; |
|
22 | 21 |
import eu.etaxonomy.cdm.common.FileCopy; |
23 | 22 |
import eu.etaxonomy.cdm.config.CdmPersistentXMLSource; |
23 |
import eu.etaxonomy.cdm.config.ConfigFileUtil; |
|
24 | 24 |
|
25 | 25 |
public class CdmApplicationUtils { |
26 | 26 |
private static final Logger logger = Logger.getLogger(CdmApplicationUtils.class); |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/config/AccountStore.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.config; |
|
12 |
|
|
13 |
import java.io.File; |
|
14 |
import java.io.FileInputStream; |
|
15 |
import java.io.FileNotFoundException; |
|
16 |
import java.io.FileOutputStream; |
|
17 |
import java.io.IOException; |
|
18 |
import java.util.Properties; |
|
19 |
|
|
20 |
import org.apache.log4j.Logger; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
23 |
|
|
24 |
|
|
25 |
public class AccountStore { |
|
26 |
|
|
27 |
private static Logger logger = Logger.getLogger(AccountStore.class); |
|
28 |
|
|
29 |
public final static File accountsFile = new File(ConfigFileUtil.perUserCdmFolder() + File.separator + ".dbaccounts.properties"); |
|
30 |
|
|
31 |
public static String getAccountsFileName(){ |
|
32 |
try { |
|
33 |
return accountsFile.getCanonicalPath(); |
|
34 |
} catch (IOException e) { |
|
35 |
logger.warn(e); |
|
36 |
return "AN ERROR OCCURRED WHEN RETRIEVING THE FILE NAME"; |
|
37 |
} |
|
38 |
} |
|
39 |
|
|
40 |
public String getPassword(String dbms, String strServer, String userName){ |
|
41 |
String pwd = null; |
|
42 |
|
|
43 |
Properties accounts = loadAccounts(); |
|
44 |
String key = strServer+'.'+dbms+'.'+userName; |
|
45 |
pwd = accounts.getProperty(key); |
|
46 |
return pwd; |
|
47 |
} |
|
48 |
|
|
49 |
private Properties loadAccounts() { |
|
50 |
Properties accounts = new Properties(); |
|
51 |
try { |
|
52 |
accountsFile.createNewFile(); |
|
53 |
|
|
54 |
// this gives me errors. Properties object doesn't have a method |
|
55 |
// with this signature |
|
56 |
//FileReader in = new FileReader(accountsFile); |
|
57 |
//accounts.load(in); |
|
58 |
//in.close(); |
|
59 |
|
|
60 |
FileInputStream inStream = new FileInputStream(accountsFile); |
|
61 |
accounts.load(inStream); |
|
62 |
inStream.close(); |
|
63 |
|
|
64 |
} catch (IOException e) { |
|
65 |
logger.error(e); |
|
66 |
} |
|
67 |
return accounts; |
|
68 |
} |
|
69 |
|
|
70 |
public void setPassword(String dbms, String strServer, String userName, String pwd){ |
|
71 |
Properties accounts = loadAccounts(); |
|
72 |
String key = strServer+'.'+dbms+'.'+userName; |
|
73 |
accounts.setProperty(key, pwd); |
|
74 |
saveAccounts(accounts); |
|
75 |
} |
|
76 |
|
|
77 |
private void saveAccounts(Properties accounts) { |
|
78 |
//FileWriter out; |
|
79 |
FileOutputStream outStream; |
|
80 |
try { |
|
81 |
//out = new FileWriter(accountsFile); |
|
82 |
//accounts.store(out, ""); |
|
83 |
//out.close(); |
|
84 |
outStream = new FileOutputStream(accountsFile); |
|
85 |
accounts.store(outStream, ""); |
|
86 |
outStream.close(); |
|
87 |
} catch (FileNotFoundException e) { |
|
88 |
logger.error("File " + accountsFile.toString() + " not found", e); |
|
89 |
} catch (IOException e) { |
|
90 |
logger.error("Unable to write properties", e); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
public void removePassword(String dbms, String strServer, String userName){ |
|
95 |
String key = strServer+'.'+dbms+'.'+userName; |
|
96 |
Properties accounts = loadAccounts(); |
|
97 |
accounts.remove(key); |
|
98 |
saveAccounts(accounts); |
|
99 |
} |
|
100 |
|
|
101 |
public static String readOrStorePassword(String dbms, String strServer, String userName, String pwd){ |
|
102 |
AccountStore accounts = new AccountStore(); |
|
103 |
boolean doStore = false; |
|
104 |
try { |
|
105 |
if (pwd == null){ |
|
106 |
pwd = accounts.getPassword(dbms, strServer, userName); |
|
107 |
if(pwd == null){ |
|
108 |
doStore = true; |
|
109 |
pwd = CdmUtils.readInputLine("Please insert password for user '" + CdmUtils.Nz(userName) + "': "); |
|
110 |
} else { |
|
111 |
logger.info("using stored password for user '" + CdmUtils.Nz(userName) + "'"); |
|
112 |
} |
|
113 |
} |
|
114 |
// on success store userName, pwd in property file |
|
115 |
if(doStore){ |
|
116 |
accounts.setPassword(dbms, strServer, userName, pwd); |
|
117 |
logger.info("password stored in " + AccountStore.getAccountsFileName()); |
|
118 |
} |
|
119 |
} catch (Exception e) { |
|
120 |
if(doStore){ |
|
121 |
accounts.removePassword(dbms, strServer, userName); |
|
122 |
logger.info("password removed from " + AccountStore.getAccountsFileName()); |
|
123 |
} |
|
124 |
logger.error(e); |
|
125 |
return null; |
|
126 |
} |
|
127 |
return pwd; |
|
128 |
} |
|
129 |
|
|
130 |
public static void main(String[] args) { |
|
131 |
AccountStore a = new AccountStore(); |
|
132 |
// BerlinModel - EditWp6 |
|
133 |
String dbms = "SQLServer"; |
|
134 |
String strServer = "BGBM111"; |
|
135 |
String userName = "webUser"; |
|
136 |
a.setPassword(dbms, strServer, userName, "psst"); |
|
137 |
logger.info(a.getPassword(dbms, strServer, userName)); |
|
138 |
a.removePassword(dbms, strServer, userName); |
|
139 |
logger.info(a.getPassword(dbms, strServer, userName)); |
|
140 |
|
|
141 |
} |
|
142 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/config/ConfigFileUtil.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.config; |
|
10 |
|
|
11 |
import java.io.BufferedWriter; |
|
12 |
import java.io.File; |
|
13 |
import java.io.FileInputStream; |
|
14 |
import java.io.FileNotFoundException; |
|
15 |
import java.io.IOException; |
|
16 |
import java.net.URL; |
|
17 |
import java.nio.file.Files; |
|
18 |
import java.util.Properties; |
|
19 |
|
|
20 |
import org.apache.log4j.Logger; |
|
21 |
import org.springframework.context.EnvironmentAware; |
|
22 |
import org.springframework.core.env.Environment; |
|
23 |
|
|
24 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
28 |
* @author a.kohlbecker |
|
29 |
* @since May 8, 2017 |
|
30 |
* |
|
31 |
*/ |
|
32 |
public class ConfigFileUtil implements EnvironmentAware { |
|
33 |
|
|
34 |
private static final Logger logger = Logger.getLogger(ConfigFileUtil.class); |
|
35 |
|
|
36 |
private static String userHome = null; |
|
37 |
|
|
38 |
/** |
|
39 |
* The per user cdm folder name: ".cdmLibrary" |
|
40 |
*/ |
|
41 |
private static final String CDM_FOLDER_NAME = ".cdmLibrary"; |
|
42 |
|
|
43 |
/** |
|
44 |
* The per user cdm folder "~/.cdmLibrary" |
|
45 |
*/ |
|
46 |
private static File perUserCdmFolder = null; |
|
47 |
|
|
48 |
public static File perUserCdmFolder() { |
|
49 |
return perUserCdmFolder; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* suggested sub folder for web app related data and configurations. |
|
54 |
* Each webapp instance should use a dedicated subfolder or file |
|
55 |
* which is named by the data source bean id. |
|
56 |
*/ |
|
57 |
public static final String SUBFOLDER_WEBAPP = "remote-webapp"; |
|
58 |
|
|
59 |
static final String MUST_EXIST_FILE = "MUST-EXIST.txt"; |
|
60 |
|
|
61 |
|
|
62 |
protected Environment env; |
|
63 |
|
|
64 |
@Override |
|
65 |
public void setEnvironment(Environment environment) { |
|
66 |
this.env = environment; |
|
67 |
if(userHome == null){ |
|
68 |
ConfigFileUtil.userHome = env.getRequiredProperty("user.home"); |
|
69 |
ConfigFileUtil.perUserCdmFolder = new File(userHome + File.separator + CDM_FOLDER_NAME ); |
|
70 |
logger.info("user.home is set to " + ConfigFileUtil.userHome); |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
//folder separator |
|
75 |
static String folderSeparator; |
|
76 |
|
|
77 |
/** |
|
78 |
* @return |
|
79 |
*/ |
|
80 |
static public String getFolderSeperator(){ |
|
81 |
if (folderSeparator == null){ |
|
82 |
URL url = CdmUtils.class.getResource("/"+ MUST_EXIST_FILE); |
|
83 |
if ( url != null && ! urlIsJarOrBundle(url) ){ |
|
84 |
folderSeparator = File.separator; |
|
85 |
}else{ |
|
86 |
folderSeparator = "/"; |
|
87 |
} |
|
88 |
} |
|
89 |
return folderSeparator; |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
/** |
|
94 |
* @param url |
|
95 |
* @return |
|
96 |
*/ |
|
97 |
static private boolean urlIsJarOrBundle(URL url){ |
|
98 |
return url.getProtocol().startsWith("jar") || url.getProtocol().startsWith("bundleresource"); |
|
99 |
} |
|
100 |
|
|
101 |
|
|
102 |
public static File getCdmHomeDir() { |
|
103 |
return new File(perUserCdmFolder + File.separator); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Returns specified the sub folder of {@link #CDM_FOLDER_NAME}. |
|
108 |
* If the sub folder does not exist it will be created. |
|
109 |
* |
|
110 |
* @param subFolderName |
|
111 |
* @return the sub folder or null in case the folder did not exist ant the attempt to create it has failed. |
|
112 |
* |
|
113 |
* @see {@link #SUBFOLDER_WEBAPP} |
|
114 |
*/ |
|
115 |
public static File getCdmHomeSubDir(String subFolderName) { |
|
116 |
|
|
117 |
File parentFolder = getCdmHomeDir(); |
|
118 |
return ensureSubfolderExists(parentFolder, subFolderName); |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Returns an instance specific folder folder in {@link #CDM_FOLDER_NAME}/<code>subFolderName</code> |
|
123 |
* Non existing folders will be created. |
|
124 |
* |
|
125 |
* @param subFolderName |
|
126 |
* The name of a subfolded. In most cases this will be {@link #SUBFOLDER_WEBAPP} |
|
127 |
* @param instanceName |
|
128 |
* The name of the application instance. The name should be related to the data source id. |
|
129 |
* @return the sub folder or null in case the folder did not exist ant the attempt to create it has failed. |
|
130 |
* |
|
131 |
* @see {@link #SUBFOLDER_WEBAPP} |
|
132 |
*/ |
|
133 |
public static File getCdmInstanceSubDir(String subFolderName, String instanceName) { |
|
134 |
|
|
135 |
File subfolder = ensureSubfolderExists(getCdmHomeDir(), subFolderName); |
|
136 |
return ensureSubfolderExists(subfolder, instanceName); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* @param subFolderName |
|
141 |
* @param parentFolder |
|
142 |
* @return |
|
143 |
*/ |
|
144 |
private static File ensureSubfolderExists(File parentFolder, String subFolderName) { |
|
145 |
if (!parentFolder.exists()){ |
|
146 |
if (!parentFolder.mkdir()) { |
|
147 |
throw new RuntimeException("Parent folder could not be created: " + parentFolder.getAbsolutePath()); |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
File subfolder = new File(parentFolder, subFolderName); |
|
152 |
// if the directory does not exist, create it |
|
153 |
if (!subfolder.exists()) { |
|
154 |
if (!subfolder.mkdir()) { |
|
155 |
throw new RuntimeException("Subfolder could not be created: " + subfolder.getAbsolutePath()); |
|
156 |
} |
|
157 |
} |
|
158 |
return subfolder; |
|
159 |
} |
|
160 |
public static final String CDM_CONFIGFILE_OVERRIDE = "cdm.configfile.override."; |
|
161 |
|
|
162 |
private Properties props = null; |
|
163 |
|
|
164 |
private String defaultContent = ""; |
|
165 |
|
|
166 |
public ConfigFileUtil(){ |
|
167 |
|
|
168 |
} |
|
169 |
|
|
170 |
public ConfigFileUtil setDefaultContent(String content) { |
|
171 |
if(content != null){ |
|
172 |
defaultContent = content; |
|
173 |
} |
|
174 |
return this; |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Per default the <code>propertiesSet</code> is loaded from a file located in |
|
179 |
* <code>~/.cdmLibrary/remote-webapp/{instanceName}/{propertiesSet}.properties</code>. |
|
180 |
* <p> |
|
181 |
* This behavior can be overwritten by setting the java System property |
|
182 |
* <code>cdm.configfile.override.{propertiesSet}</code> to an alternative file location. |
|
183 |
* This mechanism should only be used for unit and integration tests. |
|
184 |
* |
|
185 |
* @param instanceName the name of the cdm instance. This value can be retrieved from the |
|
186 |
* Spring environment with the key DataSourceConfigurer.CDM_DATA_SOURCE_ID ("") |
|
187 |
* @param propertiesSet |
|
188 |
* The base name of the properties file to be loaded. This name is extended with |
|
189 |
* ".properties" to form the actual filename |
|
190 |
* |
|
191 |
* @return |
|
192 |
* The file containing the properties |
|
193 |
*/ |
|
194 |
public File getPropertiesFile(String instanceName, String propertiesSet) { |
|
195 |
|
|
196 |
if(propertiesSet == null){ |
|
197 |
throw new NullPointerException(); |
|
198 |
} |
|
199 |
String override = System.getProperty(CDM_CONFIGFILE_OVERRIDE + propertiesSet); |
|
200 |
if(override != null){ |
|
201 |
return new File(override); |
|
202 |
} else { |
|
203 |
File configFolder = ConfigFileUtil.getCdmInstanceSubDir(ConfigFileUtil.SUBFOLDER_WEBAPP, instanceName); |
|
204 |
return new File(configFolder, propertiesSet + ".properties"); |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* Per default the <code>propertiesSet</code> is loaded from a file located in |
|
210 |
* <code>~/.cdmLibrary/remote-webapp/{instanceName}/{propertiesSet}.properties</code>. |
|
211 |
* <p> |
|
212 |
* This behavior can be overwritten by setting the java System property |
|
213 |
* <code>cdm.configfile.override.{propertiesSet}</code> to an alternative file location. |
|
214 |
* This mechanism should only be used for unit and integration tests. |
|
215 |
* |
|
216 |
* @param instanceName the name of the cdm instance. This value can be retrieved from the |
|
217 |
* Spring environment with the key DataSourceConfigurer.CDM_DATA_SOURCE_ID ("") |
|
218 |
* @param propertiesSet |
|
219 |
* The base name of the properties file to be loaded. This name is extended with |
|
220 |
* ".properties" to form the actual filename |
|
221 |
* |
|
222 |
* @return |
|
223 |
* The properties loaded from the file |
|
224 |
*/ |
|
225 |
public Properties getProperties(String instanceName, String propertiesName) throws IOException { |
|
226 |
|
|
227 |
if(instanceName == null){ |
|
228 |
throw new NullPointerException(); |
|
229 |
} |
|
230 |
if(props == null){ |
|
231 |
props = new Properties(); |
|
232 |
File uiPropertiesFile = getPropertiesFile(instanceName, propertiesName); |
|
233 |
if(!uiPropertiesFile.exists()){ |
|
234 |
BufferedWriter writer = Files.newBufferedWriter(uiPropertiesFile.toPath()); |
|
235 |
writer.write(defaultContent); |
|
236 |
writer.close(); |
|
237 |
} |
|
238 |
try { |
|
239 |
props.load(new FileInputStream(uiPropertiesFile)); |
|
240 |
} catch (FileNotFoundException e) { |
|
241 |
// must not happen since we checked before |
|
242 |
} |
|
243 |
|
|
244 |
} |
|
245 |
return props; |
|
246 |
} |
|
247 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/DataSourceBeanLoader.java | ||
---|---|---|
8 | 8 |
import org.springframework.core.io.FileSystemResource; |
9 | 9 |
import org.springframework.stereotype.Component; |
10 | 10 |
|
11 |
import eu.etaxonomy.cdm.common.ConfigFileUtil;
|
|
11 |
import eu.etaxonomy.cdm.config.ConfigFileUtil;
|
|
12 | 12 |
|
13 | 13 |
@Component |
14 | 14 |
public class DataSourceBeanLoader { |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v31_33/TermVocabularyRepresentationUpdater.java | ||
---|---|---|
17 | 17 |
|
18 | 18 |
import au.com.bytecode.opencsv.CSVReader; |
19 | 19 |
import eu.etaxonomy.cdm.common.CdmUtils; |
20 |
import eu.etaxonomy.cdm.common.ConfigFileUtil; |
|
21 | 20 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
21 |
import eu.etaxonomy.cdm.config.ConfigFileUtil; |
|
22 | 22 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
23 | 23 |
import eu.etaxonomy.cdm.database.update.CaseType; |
24 | 24 |
import eu.etaxonomy.cdm.database.update.SchemaUpdateResult; |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/config/ConfigFileUtilTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.config; |
|
11 |
|
|
12 |
import static org.junit.Assert.assertNotNull; |
|
13 |
|
|
14 |
import java.io.File; |
|
15 |
import java.io.IOException; |
|
16 |
import java.io.InputStream; |
|
17 |
|
|
18 |
import org.junit.Assert; |
|
19 |
import org.junit.Ignore; |
|
20 |
import org.junit.Test; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
23 |
|
|
24 |
|
|
25 |
public class ConfigFileUtilTest { |
|
26 |
|
|
27 |
@Test |
|
28 |
public void testGetReadableResourceStream() { |
|
29 |
String resourceFileName = ConfigFileUtil.MUST_EXIST_FILE; |
|
30 |
try { |
|
31 |
InputStream inputStream = CdmUtils.getReadableResourceStream(resourceFileName); |
|
32 |
assertNotNull(inputStream); |
|
33 |
} catch (IOException e) { |
|
34 |
Assert.fail("IOException"); |
|
35 |
} |
|
36 |
} |
|
37 |
|
|
38 |
@Test |
|
39 |
public void testGetFolderSeperator() { |
|
40 |
Assert.assertEquals(File.separator, ConfigFileUtil.getFolderSeperator()); |
|
41 |
} |
|
42 |
|
|
43 |
@Test |
|
44 |
@Ignore |
|
45 |
public void testGetHomeDir() { |
|
46 |
Assert.assertEquals("", ConfigFileUtil.getCdmHomeDir()); |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
} |
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/database/update/CdmUpdaterTest.java | ||
---|---|---|
19 | 19 |
import org.junit.Ignore; |
20 | 20 |
import org.junit.Test; |
21 | 21 |
|
22 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
22 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
23 | 23 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
24 | 24 |
import eu.etaxonomy.cdm.database.DatabaseTypeEnum; |
25 | 25 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
cdmlib-print/src/main/java/eu/etaxonomy/cdm/print/out/PublishOutputModuleBase.java | ||
---|---|---|
25 | 25 |
import org.apache.log4j.Logger; |
26 | 26 |
import org.jdom.Document; |
27 | 27 |
|
28 |
import eu.etaxonomy.cdm.common.ConfigFileUtil; |
|
29 | 28 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
29 |
import eu.etaxonomy.cdm.config.ConfigFileUtil; |
|
30 | 30 |
|
31 | 31 |
/** |
32 | 32 |
* This abstract implementation of the {@link IPublishOutputModule} contains |
cdmlib-print/src/main/java/eu/etaxonomy/cdm/print/out/mediawiki/Cdm2MediawikiExporter.java | ||
---|---|---|
24 | 24 |
import org.jdom.output.XMLOutputter; |
25 | 25 |
import org.jdom.xpath.XPath; |
26 | 26 |
|
27 |
import eu.etaxonomy.cdm.common.ConfigFileUtil; |
|
28 | 27 |
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor; |
28 |
import eu.etaxonomy.cdm.config.ConfigFileUtil; |
|
29 | 29 |
import eu.etaxonomy.cdm.print.IXMLEntityFactory; |
30 | 30 |
import eu.etaxonomy.cdm.print.PublishConfigurator; |
31 | 31 |
import eu.etaxonomy.cdm.print.Publisher; |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/opt/config/DataSourceConfigurer.java | ||
---|---|---|
40 | 40 |
import com.mchange.v2.c3p0.ComboPooledDataSource; |
41 | 41 |
|
42 | 42 |
import eu.etaxonomy.cdm.api.config.CdmConfigurationKeys; |
43 |
import eu.etaxonomy.cdm.common.ConfigFileUtil;
|
|
43 |
import eu.etaxonomy.cdm.config.ConfigFileUtil;
|
|
44 | 44 |
import eu.etaxonomy.cdm.database.WrappedCdmDataSource; |
45 | 45 |
import eu.etaxonomy.cdm.database.update.CdmUpdater; |
46 | 46 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData; |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/opt/config/EhCacheDiskStoreConfiguration.java | ||
---|---|---|
15 | 15 |
import org.springframework.context.annotation.Bean; |
16 | 16 |
import org.springframework.context.annotation.Configuration; |
17 | 17 |
|
18 |
import eu.etaxonomy.cdm.common.ConfigFileUtil;
|
|
18 |
import eu.etaxonomy.cdm.config.ConfigFileUtil;
|
|
19 | 19 |
import net.sf.ehcache.config.DiskStoreConfiguration; |
20 | 20 |
|
21 | 21 |
/** |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/config/AbstractWebApplicationConfigurer.java | ||
---|---|---|
21 | 21 |
import org.springframework.core.env.ConfigurableEnvironment; |
22 | 22 |
import org.springframework.web.context.WebApplicationContext; |
23 | 23 |
|
24 |
import eu.etaxonomy.cdm.common.ConfigFileUtil;
|
|
24 |
import eu.etaxonomy.cdm.config.ConfigFileUtil;
|
|
25 | 25 |
|
26 | 26 |
/** |
27 | 27 |
* @author a.kohlbecker |
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/config/MultiWebSecurityConfiguration.java | ||
---|---|---|
25 | 25 |
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
26 | 26 |
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
27 | 27 |
|
28 |
import eu.etaxonomy.cdm.common.ConfigFileUtil;
|
|
28 |
import eu.etaxonomy.cdm.config.ConfigFileUtil;
|
|
29 | 29 |
|
30 | 30 |
/** |
31 | 31 |
* |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/config/ApplicationConfiguration.java | ||
---|---|---|
18 | 18 |
import org.springframework.core.env.Environment; |
19 | 19 |
import org.springframework.stereotype.Component; |
20 | 20 |
|
21 |
import eu.etaxonomy.cdm.common.ConfigFileUtil;
|
|
21 |
import eu.etaxonomy.cdm.config.ConfigFileUtil;
|
|
22 | 22 |
|
23 | 23 |
/** |
24 | 24 |
* @author a.kohlbecker |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/scripts/FixMultipleTextDataInImageGalleries.java | ||
---|---|---|
18 | 18 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
19 | 19 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
20 | 20 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
21 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
21 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
22 | 22 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
23 | 23 |
import eu.etaxonomy.cdm.database.DataSourceNotFoundException; |
24 | 24 |
import eu.etaxonomy.cdm.database.DatabaseTypeEnum; |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/example/ApplicationExample.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
12 | 12 |
import eu.etaxonomy.cdm.api.application.ICdmRepository; |
13 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
13 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
14 | 14 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
15 | 15 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
16 | 16 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/Datasource.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
29 | 29 |
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; |
30 | 30 |
import eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO; |
31 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
31 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
32 | 32 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
33 | 33 |
import eu.etaxonomy.cdm.database.CdmPersistentDataSource; |
34 | 34 |
import eu.etaxonomy.cdm.database.DataSourceNotFoundException; |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/TestModelUpdate.java | ||
---|---|---|
12 | 12 |
import org.apache.log4j.Logger; |
13 | 13 |
|
14 | 14 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
15 |
import eu.etaxonomy.cdm.common.AccountStore; |
|
16 | 15 |
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor; |
16 |
import eu.etaxonomy.cdm.config.AccountStore; |
|
17 | 17 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
18 | 18 |
import eu.etaxonomy.cdm.database.DatabaseTypeEnum; |
19 | 19 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/TestValidationManager.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
12 | 12 |
import eu.etaxonomy.cdm.api.validation.ValidationManager; |
13 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
13 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
14 | 14 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
15 | 15 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
16 | 16 |
import eu.etaxonomy.cdm.model.reference.Reference; |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/integration/TestTaxonServices.java | ||
---|---|---|
13 | 13 |
import org.springframework.transaction.TransactionStatus; |
14 | 14 |
|
15 | 15 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
16 |
import eu.etaxonomy.cdm.common.AccountStore;
|
|
16 |
import eu.etaxonomy.cdm.config.AccountStore;
|
|
17 | 17 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
18 | 18 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
19 | 19 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
Also available in: Unified diff
ref #8189 moving ConfigFileUtil and AccountStore to cdmlib-persistence:eu.etaxonomy.cdm.config