import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.Symm;
-import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.util.Chmod;
import org.onap.aaf.misc.env.util.Chrono;
return keyfile.getAbsolutePath();
}
- public void add(final String tag, final String value) {
- if(value==null) {
- props.put(tag,"");
- } else {
- props.put(tag, value);
- }
+ public String add(final String tag, final String value) {
+ final String rv = value==null?"":value;
+ props.put(tag, rv);
+ return rv;
}
- public void add(final String tag, Access orig, final String def) {
- add(tag, orig.getProperty(tag, def));
+ public String add(final String tag, Access orig, final String def) {
+ return add(tag, orig.getProperty(tag, def));
}
- public void addEnc(final String tag, final String value) throws IOException {
+ public String addEnc(final String tag, final String value) throws IOException {
+ String rv;
if(value==null) {
- props.put(tag,"");
+ rv = "";
} else {
if(symm==null) { // Lazy Instantiations... on a few PropFiles have Security
symm = ArtifactDir.getSymm(keyfile);
}
- props.put(tag, "enc:"+symm.enpass(value));
+ rv = "enc:"+symm.enpass(value);
}
+ props.put(tag, rv);
+ return rv;
}
public void addEnc(final String tag, Access orig, final String def) throws IOException {
- addEnc(tag,orig.getProperty(tag, def));
+ String pwd = orig.getProperty(tag, def);
+ if(pwd==null) {
+ return;
+ } else if(pwd.startsWith("enc:")) {
+ pwd = orig.decrypt(pwd, true);
+ }
+ addEnc(tag,pwd);
}
public void write() throws IOException {
pw.println(System.getProperty("user.name"));
pw.print("# on ");
pw.println(Chrono.dateStamp());
- pw.println("# @copyright 2016, AT&T");
+ pw.println("# @copyright 2019, AT&T");
for (int i=0;i<60;++i) {
pw.print('#');
}
for (Map.Entry<String,String> me : props.entrySet()) {
String key = me.getKey();
- //if ( key.startsWith("cm_")
-// || key.startsWith(Config.HOSTNAME)
-// || key.startsWith("aaf")
-// || key.startsWith("cadi")
-// || key.startsWith("Challenge")
-// ) {
pw.print(key);
pw.print('=');
pw.println(me.getValue());
-// }
}
} finally {
pw.close();