* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
if(ph == null) {
ph = new PropHolder(dir,file,new File(dir,arti.getNs()+".keyfile"));
propHolders.put(file.getAbsolutePath(), ph);
- }
+ }
return ph;
}
-
+
private PropHolder(File dir, File file, File keyfile) throws IOException {
this.dir = dir;
this.file = file;
symm = null;
props = new TreeMap<>();
}
-
+
public String getPath() {
return file.getAbsolutePath();
}
-
+
public File getDir() {
return dir;
}
}
addEnc(tag,pwd);
}
-
+
public void write() throws IOException {
if (props.size()==0) {
return;
} else {
System.out.println("Creating new " + file.getCanonicalPath());
}
-
+
// Append if not first
PrintWriter pw = new PrintWriter(new FileWriter(file));
try {
pw.print('#');
}
pw.println();
-
+
for (Map.Entry<String,String> me : props.entrySet()) {
String key = me.getKey();
pw.print(key);
}
Chmod.to644.chmod(file);
}
-
+
public static void writeAll() throws IOException {
for(PropHolder ph : propHolders.values()) {
ph.write();
}
}
-
+
@Override
public String toString() {
return file.getAbsolutePath() + ": " + props;