- private void specialConversions() {
- // Critical - if no Security Protocols set, then set it. We'll just get messed up if not
- if(props.get(Config.CADI_PROTOCOLS)==null) {
- props.setProperty(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT);
- }
-
- Object temp;
- temp=props.get(Config.CADI_PROTOCOLS);
- if(props.get(Config.HTTPS_PROTOCOLS)==null && temp!=null) {
- props.put(Config.HTTPS_PROTOCOLS, temp);
- }
-
- if(temp!=null) {
- if("1.7".equals(System.getProperty("java.specification.version"))
- && (temp==null || (temp instanceof String && ((String)temp).contains("TLSv1.2")))) {
- System.setProperty(Config.HTTPS_CIPHER_SUITES, Config.HTTPS_CIPHER_SUITES_DEFAULT);
- }
- }
- }
+
+ for(String filename : Split.splitTrim(File.pathSeparatorChar, cadi_prop_files)) {
+ Properties fileProps = new Properties();
+ File file = new File(filename);
+ if (file.exists()) {
+ printf(Level.INIT,"Loading CADI Properties from %s",file.getAbsolutePath());
+ try {
+ FileInputStream fis = new FileInputStream(file);
+ try {
+ fileProps.load(fis);
+ // Only load props from recursion which are not already in props
+ // meaning top Property file takes precedence
+ for(Entry<Object, Object> es : fileProps.entrySet()) {
+ if(props.get(es.getKey())==null) {
+ String key = es.getKey().toString();
+ String value = es.getValue().toString();
+ props.put(key, value);
+ if(key.contains("pass")) {
+ value = "XXXXXXX";
+ }
+ printf(Level.DEBUG," %s=%s",key,value);
+ }
+ }
+ // Recursively Load
+ String chainProp = fileProps.getProperty(Config.CADI_PROP_FILES);
+ if (chainProp!=null) {
+ if (recursionProtection==null) {
+ recursionProtection = new ArrayList<>();
+ recursionProtection.add(cadi_prop_files);
+ }
+ if (!recursionProtection.contains(chainProp)) {
+ recursionProtection.add(chainProp);
+ load(chainProp); // recurse
+ }
+ }
+ } finally {
+ fis.close();
+ }
+ } catch (Exception e) {
+ log(e,filename,"cannot be opened");
+ }
+ } else {
+ printf(Level.WARN,"Warning: recursive CADI Property %s does not exist",file.getAbsolutePath());
+ }
+ }
+
+ // Trim
+ for (Entry<Object, Object> es : props.entrySet()) {
+ Object value = es.getValue();
+ if (value instanceof String) {
+ String trim = ((String)value).trim();
+ // Remove Beginning/End Quotes, which might be there if mixed with Bash Props
+ int s = 0, e=trim.length()-1;
+ if (s<e && trim.charAt(s)=='"' && trim.charAt(e)=='"') {
+ trim=trim.substring(s+1,e);
+ }
+ if (trim!=value) { // Yes, I want OBJECT equals
+ props.setProperty((String)es.getKey(), trim);
+ }
+ }
+ }
+ // Reset Symm if Keyfile Changes:
+ String newKeyFile = props.getProperty(Config.CADI_KEYFILE);
+ if ((prevKeyFile!=null && newKeyFile!=null) || (newKeyFile!=null && !newKeyFile.equals(prevKeyFile))) {
+ try {
+ symm = Symm.obtain(this);
+ } catch (CadiException e) {
+ System.err.append("FATAL ERROR: Cannot obtain Key Information.");
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }