01: /*
02: * JOSSO: Java Open Single Sign-On
03: *
04: * Copyright 2004-2008, Atricore, Inc.
05: *
06: * This is free software; you can redistribute it and/or modify it
07: * under the terms of the GNU Lesser General Public License as
08: * published by the Free Software Foundation; either version 2.1 of
09: * the License, or (at your option) any later version.
10: *
11: * This software is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this software; if not, write to the Free
18: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20: */
21:
22: package org.josso;
23:
24: import org.josso.util.config.ConfigurationContext;
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27:
28: import java.io.File;
29:
30: /**
31: * ConfigurationContext implementation.
32: */
33: public class ConfigurationContextImpl implements ConfigurationContext {
34:
35: private File file;
36: private boolean updatable;
37: private boolean backupConfiguration;
38: private static final Log logger = LogFactory
39: .getLog(ConfigurationContextImpl.class);
40:
41: public ConfigurationContextImpl(File f, boolean updatable,
42: boolean backupConfiguration) {
43: this (f, updatable);
44: this .backupConfiguration = backupConfiguration;
45: }
46:
47: public ConfigurationContextImpl(File f, boolean updatable) {
48: this (f);
49: this .updatable = this .updatable && updatable;
50: }
51:
52: public ConfigurationContextImpl(File f) {
53: file = f;
54: updatable = file != null && file.exists() && file.canRead()
55: && file.canWrite() && !file.isDirectory();
56:
57: if (file != null && !file.exists())
58: logger.warn("Configuration file does not exists : "
59: + f.getAbsolutePath());
60: }
61:
62: public boolean isConfigurationUpdatable() {
63: return updatable;
64: }
65:
66: public File getConfigurationFile() {
67: return file;
68: }
69:
70: public boolean isBackupEnabled() {
71: return backupConfiguration;
72: }
73: }
|