summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-07-12 11:14:10 -0500
committerInstrumental <jonathan.gathman@att.com>2018-07-12 11:15:07 -0500
commit9ec2895301056a9e8967eadb139e56f03776fe26 (patch)
tree6a25ad45269de5149462c51a020b60e245e18ddd /cadi
parentd37b5467a3b8b375b603579d2888a4443a8b06a7 (diff)
Configuration Agent and MS for AAF
Issue-ID: AAF-361 Change-Id: I26f3d49e3d7eae4a932489bd677cf0b903fb7977 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/pom.xml2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java139
2 files changed, 113 insertions, 28 deletions
diff --git a/cadi/aaf/pom.xml b/cadi/aaf/pom.xml
index aa3899aa..2a7cd058 100644
--- a/cadi/aaf/pom.xml
+++ b/cadi/aaf/pom.xml
@@ -194,7 +194,7 @@
<classifier>tests</classifier>
<archive>
<manifest>
- <mainClass>org.onap.aaf.cadi.cm.CmAgent</mainClass>
+ <mainClass>org.onap.aaf.cadi.configure.Agent</mainClass>
</manifest>
<manifestEntries>
<Sealed>true</Sealed>
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java
index 09f5ed7e..a86649db 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java
@@ -176,7 +176,7 @@ public class Agent {
System.out.println(" check <FQI> [<machine>]");
System.out.println(" keypairgen <FQI>");
System.out.println(" config <FQI>");
- System.out.println(" validate <FQI>.props>");
+ System.out.println(" validate <NS>.props>");
System.out.println(" --- Additional Tool Access ---");
System.out.println(" ** Type with no params for Tool Help");
System.out.println(" ** If using with Agent, preface with \"cadi\"");
@@ -251,7 +251,13 @@ public class Agent {
keypairGen(trans, access, cmds);
break;
case "config":
- config(trans,access,aafcon(access),cmds);
+ if(access.getProperty(Config.CADI_PROP_FILES)!=null) {
+ // Get Properties from initialization Prop Files
+ config(trans,access,null,cmds);
+ } else {
+ // Get Properties from existing AAF Instance
+ config(trans,access,aafcon(access),cmds);
+ }
break;
case "validate":
validate(access);
@@ -721,7 +727,6 @@ public class Agent {
private static void config(Trans trans, PropAccess pa, AAFCon<?> aafcon, Deque<String> cmds) throws Exception {
final String fqi = fqi(cmds);
- final String locator = getProperty(pa,aafcon.env,false,Config.AAF_LOCATE_URL,"AAF Locator URL: ");
final String rootFile = FQI.reverseDomain(fqi);
final File dir = new File(pa.getProperty(Config.CADI_ETCDIR, "."));
if(dir.exists()) {
@@ -796,35 +801,115 @@ public class Agent {
String ps = pa.decrypt(pa.getProperty(Config.AAF_APPPASS), false);
ps = filesymm.enpass(ps);
psCredProps.println(ps);
-
- psCredProps.print(Config.CADI_TRUSTSTORE);
- psCredProps.print("=");
- File origTruststore = new File(pa.getProperty(Config.CADI_TRUSTSTORE));
- File newTruststore = new File(dir,origTruststore.getName());
- if(!newTruststore.exists()) {
- Files.copy(origTruststore.toPath(), newTruststore.toPath());
- }
- psCredProps.println(newTruststore.getCanonicalPath());
+
+ String cts = pa.getProperty(Config.CADI_TRUSTSTORE);
+ if(cts!=null) {
+ File origTruststore = new File(cts);
+ if(!origTruststore.exists()) {
+ // Try same directory as cadi_prop_files
+ String cpf = pa.getProperty(Config.CADI_PROP_FILES);
+ if(cpf!=null) {
+ for(String f : Split.split(File.pathSeparatorChar, cpf)) {
+ File fcpf = new File(f);
+ if(fcpf.exists()) {
+ int lastSep = cts.lastIndexOf(File.pathSeparator);
+ origTruststore = new File(fcpf.getParentFile(),lastSep>=0?cts.substring(lastSep):cts);
+ if(origTruststore.exists()) {
+ break;
+ }
+ }
+ }
+ if(!origTruststore.exists()) {
+ throw new CadiException(cts + "does not exist");
+ }
+ }
+
+ }
+ File newTruststore = new File(dir,origTruststore.getName());
+ if(!newTruststore.exists()) {
+ Files.copy(origTruststore.toPath(), newTruststore.toPath());
+ }
+ psCredProps.print(Config.CADI_TRUSTSTORE);
+ psCredProps.print("=");
+ psCredProps.println(newTruststore.getCanonicalPath());
- psCredProps.print(Config.CADI_TRUSTSTORE_PASSWORD);
- psCredProps.print("=enc:");
- ps = pa.decrypt(pa.getProperty(Config.CADI_TRUSTSTORE_PASSWORD), false);
- ps = filesymm.enpass(ps);
- psCredProps.println(ps);
+ psCredProps.print(Config.CADI_TRUSTSTORE_PASSWORD);
+ psCredProps.print("=enc:");
+ ps = pa.decrypt(pa.getProperty(Config.CADI_TRUSTSTORE_PASSWORD), false);
+ ps = filesymm.enpass(ps);
+ psCredProps.println(ps);
+ }
+
+// String cadi_x509_issuers = pa.getProperty(Config.CADI_X509_ISSUERS);
+// if(cadi_x509_issuers!=null) {
+// psCredProps.print(Config.CADI_X509_ISSUERS);
+// psCredProps.print('=');
+// psCredProps.println(cadi_x509_issuers);
+// }
+
try {
- Future<Configuration> acf = aafcon.client(new SingleEndpointLocator(locator))
- .read("/configure/"+fqi+"/aaf", configDF);
- if(acf.get(TIMEOUT)) {
- // out.println(acf.value.getName());
- for(Props props : acf.value.getProps()) {
- psProps.println(props.getTag() + '=' + props.getValue());
+ if(aafcon!=null) { // get Properties from Remote AAF
+ final String locator = getProperty(pa,aafcon.env,false,Config.AAF_LOCATE_URL,"AAF Locator URL: ");
+
+ Future<Configuration> acf = aafcon.client(new SingleEndpointLocator(locator))
+ .read("/configure/"+fqi+"/aaf", configDF);
+ if(acf.get(TIMEOUT)) {
+ PrintStream pstemp;
+ for(Props props : acf.value.getProps()) {
+ if(Config.CADI_X509_ISSUERS.equals(props.getTag())) {
+ pstemp=psCredProps;
+ } else {
+ pstemp = psProps;
+ }
+ pstemp.print(props.getTag());
+ pstemp.print('=');
+ pstemp.println(props.getValue());
+ }
+ ok = true;
+ } else if(acf.code()==401){
+ trans.error().log("Bad Password sent to AAF");
+ } else {
+ trans.error().log(errMsg.toMsg(acf));
}
- ok = true;
- } else if(acf.code()==401){
- trans.error().log("Bad Password sent to AAF");
} else {
- trans.error().log(errMsg.toMsg(acf));
+ String cpf = pa.getProperty(Config.CADI_PROP_FILES);
+ if(cpf!=null){
+ for(String f : Split.split(File.pathSeparatorChar, cpf)) {
+ System.out.format("Reading %s\n",f);
+ FileInputStream fis = new FileInputStream(f);
+ try {
+ Properties props = new Properties();
+ props.load(fis);
+ PrintStream pstemp;
+ String key,value;
+ for(Entry<Object, Object> prop : props.entrySet()) {
+ key = prop.getKey().toString();
+ if(Config.CADI_X509_ISSUERS.equals(key)) {
+ pstemp=psCredProps;
+ value = prop.getValue().toString();
+ } else if(key.endsWith("_password")){
+ if(Config.AAF_APPPASS.equals(key) || Config.CADI_TRUSTSTORE_PASSWORD.equals(key)) {
+ continue;
+ }
+ value = "enc:" + filesymm.enpass(prop.getValue().toString());
+ pstemp = psCredProps;
+ } else if(Config.CADI_TRUSTSTORE.equals(key)) {
+ continue;
+ } else {
+ value = prop.getValue().toString();
+ pstemp = psProps;
+ }
+ pstemp.print(key);
+ pstemp.print('=');
+ pstemp.println(value);
+ }
+ } finally {
+ fis.close();
+ }
+ }
+ }
+ ok = true;
}
} finally {
psProps.close();