Revision 4589
Added by daigle over 15 years ago
PropertyService.java | ||
---|---|---|
60 | 60 |
|
61 | 61 |
private static final String MAIN_CONFIG_NAME = "metacat.properties"; |
62 | 62 |
private static final String ORG_CONFIG_NAME = "org.properties"; |
63 |
private static final String LDAP_CONFIG_NAME = "ldap.properties";
|
|
63 |
private static final String AUTH_CONFIG_NAME = "auth.properties";
|
|
64 | 64 |
|
65 | 65 |
private static boolean bypassAlreadyChecked = false; |
66 | 66 |
|
... | ... | |
79 | 79 |
private static String orgMetaDataFilePath = null; |
80 | 80 |
private static PropertiesMetaData orgMetaData = null; |
81 | 81 |
|
82 |
private static String ldapBackupPropertiesFilePath = null;
|
|
83 |
private static SortedProperties ldapBackupProperties = null;
|
|
82 |
private static String authBackupPropertiesFilePath = null;
|
|
83 |
private static SortedProperties authBackupProperties = null;
|
|
84 | 84 |
|
85 |
private static String ldapMetaDataFilePath = null;
|
|
86 |
private static PropertiesMetaData ldapMetaData = null;
|
|
85 |
private static String authMetaDataFilePath = null;
|
|
86 |
private static PropertiesMetaData authMetaData = null;
|
|
87 | 87 |
|
88 | 88 |
|
89 | 89 |
private static Logger logMetacat = Logger.getLogger(PropertyService.class); |
... | ... | |
162 | 162 |
} |
163 | 163 |
|
164 | 164 |
|
165 |
// ldapMetaData holds configuration information about organization level
|
|
165 |
// authMetaData holds configuration information about organization level
|
|
166 | 166 |
// properties. This is primarily used to display input fields on |
167 |
// the ldap configuration page. The information is retrieved
|
|
168 |
// from an xml metadata file dedicated just to ldap properties.
|
|
169 |
ldapMetaDataFilePath = configDir + FileUtil.getFS() + LDAP_CONFIG_NAME + ".metadata.xml";
|
|
170 |
if (ldapMetaData == null) {
|
|
171 |
ldapMetaData = new PropertiesMetaData(ldapMetaDataFilePath);
|
|
167 |
// the auth configuration page. The information is retrieved
|
|
168 |
// from an xml metadata file dedicated just to auth properties.
|
|
169 |
authMetaDataFilePath = configDir + FileUtil.getFS() + AUTH_CONFIG_NAME + ".metadata.xml";
|
|
170 |
if (authMetaData == null) {
|
|
171 |
authMetaData = new PropertiesMetaData(authMetaDataFilePath);
|
|
172 | 172 |
} |
173 | 173 |
} catch (TransformerException te) { |
174 | 174 |
throw new GeneralPropertyException(te.getMessage()); |
... | ... | |
198 | 198 |
orgBackupProperties.load(); |
199 | 199 |
} |
200 | 200 |
|
201 |
// The ldapBackupProperties hold properties that were backed up the
|
|
202 |
// last time the LDAP was configured. On disk, the file will
|
|
201 |
// The authBackupProperties hold properties that were backed up the
|
|
202 |
// last time the auth was configured. On disk, the file will
|
|
203 | 203 |
// look like a smaller version of metacat.properties. It is stored |
204 | 204 |
// in the data storage directory outside the application directories. |
205 |
ldapBackupPropertiesFilePath = backupDirPath + FileUtil.getFS() + LDAP_CONFIG_NAME + ".backup";
|
|
206 |
if (ldapBackupProperties == null) {
|
|
207 |
ldapBackupProperties =
|
|
208 |
new SortedProperties(ldapBackupPropertiesFilePath);
|
|
209 |
ldapBackupProperties.load();
|
|
205 |
authBackupPropertiesFilePath = backupDirPath + FileUtil.getFS() + AUTH_CONFIG_NAME + ".backup";
|
|
206 |
if (authBackupProperties == null) {
|
|
207 |
authBackupProperties =
|
|
208 |
new SortedProperties(authBackupPropertiesFilePath);
|
|
209 |
authBackupProperties.load();
|
|
210 | 210 |
} |
211 | 211 |
|
212 | 212 |
} |
... | ... | |
318 | 318 |
} |
319 | 319 |
|
320 | 320 |
/** |
321 |
* Get the LDAP backup properties file. These are configurable
|
|
321 |
* Get the auth backup properties file. These are configurable
|
|
322 | 322 |
* properties that are stored outside the metacat install directories so |
323 | 323 |
* the user does not need to re-enter all the configuration information |
324 | 324 |
* every time they do an upgrade. |
325 | 325 |
* |
326 | 326 |
* @return a SortedProperties object with the backup properties |
327 | 327 |
*/ |
328 |
public static SortedProperties getLDAPBackupProperties() {
|
|
329 |
return ldapBackupProperties;
|
|
328 |
public static SortedProperties getAuthBackupProperties() {
|
|
329 |
return authBackupProperties;
|
|
330 | 330 |
} |
331 | 331 |
|
332 | 332 |
/** |
... | ... | |
351 | 351 |
} |
352 | 352 |
|
353 | 353 |
/** |
354 |
* Get the LDAP properties metadata. This is retrieved from an xml
|
|
354 |
* Get the auth properties metadata. This is retrieved from an xml
|
|
355 | 355 |
* file that describes the attributes of configurable properties. |
356 | 356 |
* |
357 | 357 |
* @return a PropertiesMetaData object with the organization properties |
358 | 358 |
* metadata |
359 | 359 |
*/ |
360 |
public static PropertiesMetaData getLDAPMetaData() {
|
|
361 |
return ldapMetaData;
|
|
360 |
public static PropertiesMetaData getAuthMetaData() {
|
|
361 |
return authMetaData;
|
|
362 | 362 |
} |
363 | 363 |
|
364 | 364 |
/** |
... | ... | |
445 | 445 |
/** |
446 | 446 |
* Writes out backup configurable properties to a file. |
447 | 447 |
*/ |
448 |
public static void persistLDAPBackupProperties(ServletContext servletContext)
|
|
448 |
public static void persistAuthBackupProperties(ServletContext servletContext)
|
|
449 | 449 |
throws GeneralPropertyException { |
450 | 450 |
|
451 | 451 |
// Use the metadata to extract configurable properties from the |
452 | 452 |
// overall properties list, and store those properties. |
453 | 453 |
try { |
454 | 454 |
SortedProperties backupProperties = |
455 |
new SortedProperties(ldapBackupPropertiesFilePath);
|
|
455 |
new SortedProperties(authBackupPropertiesFilePath);
|
|
456 | 456 |
|
457 |
// Populate the backup properties for ldap properties using
|
|
457 |
// Populate the backup properties for auth properties using
|
|
458 | 458 |
// the associated metadata file |
459 |
PropertiesMetaData ldapMetadata = new PropertiesMetaData(ldapMetaDataFilePath);
|
|
459 |
PropertiesMetaData authMetadata = new PropertiesMetaData(authMetaDataFilePath);
|
|
460 | 460 |
|
461 |
Set<String> ldapKeySet = ldapMetadata.getKeys();
|
|
462 |
for (String propertyKey : ldapKeySet) {
|
|
461 |
Set<String> authKeySet = authMetadata.getKeys();
|
|
462 |
for (String propertyKey : authKeySet) {
|
|
463 | 463 |
backupProperties.addProperty(propertyKey, getProperty(propertyKey)); |
464 | 464 |
} |
465 | 465 |
|
466 | 466 |
// store the properties to file |
467 | 467 |
backupProperties.store(); |
468 |
ldapBackupProperties =
|
|
469 |
new SortedProperties(ldapBackupPropertiesFilePath);
|
|
470 |
ldapBackupProperties.load();
|
|
468 |
authBackupProperties =
|
|
469 |
new SortedProperties(authBackupPropertiesFilePath);
|
|
470 |
authBackupProperties.load();
|
|
471 | 471 |
|
472 | 472 |
} catch (TransformerException te) { |
473 | 473 |
throw new GeneralPropertyException("Could not transform backup properties xml: " |
... | ... | |
560 | 560 |
// setPropertyNoPersist(orgBackupPropertyName, value); |
561 | 561 |
// } |
562 | 562 |
|
563 |
logMetacat.debug("bypassConfiguration: setting ldap backup properties.");
|
|
564 |
SortedProperties ldapBackupProperties = getLDAPBackupProperties();
|
|
565 |
Vector<String> ldapBackupPropertyNames =
|
|
566 |
ldapBackupProperties.getPropertyNames();
|
|
567 |
for (String ldapBackupPropertyName : ldapBackupPropertyNames) {
|
|
568 |
String value = ldapBackupProperties.getProperty(ldapBackupPropertyName);
|
|
569 |
setPropertyNoPersist(ldapBackupPropertyName, value);
|
|
563 |
logMetacat.debug("bypassConfiguration: setting auth backup properties.");
|
|
564 |
SortedProperties authBackupProperties = getAuthBackupProperties();
|
|
565 |
Vector<String> authBackupPropertyNames =
|
|
566 |
authBackupProperties.getPropertyNames();
|
|
567 |
for (String authBackupPropertyName : authBackupPropertyNames) {
|
|
568 |
String value = authBackupProperties.getProperty(authBackupPropertyName);
|
|
569 |
setPropertyNoPersist(authBackupPropertyName, value);
|
|
570 | 570 |
} |
571 | 571 |
|
572 | 572 |
logMetacat.debug("bypassConfiguration: setting configutil sections to true."); |
573 | 573 |
setPropertyNoPersist("configutil.propertiesConfigured", "true"); |
574 |
setPropertyNoPersist("configutil.ldapConfigured", "true");
|
|
574 |
setPropertyNoPersist("configutil.authConfigured", "true");
|
|
575 | 575 |
// setPropertyNoPersist("configutil.organizationsConfigured", "true"); |
576 | 576 |
setPropertyNoPersist("configutil.skinsConfigured", "true"); |
577 | 577 |
setPropertyNoPersist("configutil.databaseConfigured", "true"); |
Also available in: Unified diff
Rename LDAPUtil to AuthUtil