diff options
author | Instrumental <jonathan.gathman@att.com> | 2018-06-22 18:41:08 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2018-06-22 18:41:14 -0500 |
commit | 68f3e5a2875f74863b6cbe8eb6dc7138b89668a5 (patch) | |
tree | dabbd3526cc64b9a6310678346a46b36122a6efc | |
parent | f932f1c8b0e1d29536405c27b8543f4a78e60433 (diff) |
Refine aafcli for Tests
Issue-ID: AAF-361
Change-Id: Ib28ab9e4ccea7bacc165946cf7075ee1b75edd76
Signed-off-by: Instrumental <jonathan.gathman@att.com>
3 files changed, 35 insertions, 34 deletions
diff --git a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java index ab41eb85..7e25084d 100644 --- a/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java +++ b/auth/auth-cmd/src/main/java/org/onap/aaf/auth/cmd/AAFcli.java @@ -30,7 +30,6 @@ import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.net.HttpURLConnection; -import java.net.URI; import java.util.ArrayList; import java.util.List; @@ -44,10 +43,9 @@ import org.onap.aaf.auth.env.AuthzEnv; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.Access.Level; import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.Locator; import org.onap.aaf.cadi.PropAccess; import org.onap.aaf.cadi.SecuritySetter; -import org.onap.aaf.cadi.aaf.v2_0.AAFLocator; +import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; import org.onap.aaf.cadi.client.Retryable; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.config.SecurityInfoC; @@ -132,10 +130,10 @@ public class AAFcli { } public void close() { - if (hman != null) { - hman.close(); - hman = null; - } +// if (hman != null) { +// hman.close(); +// hman = null; +// } if (close) { pw.close(); } @@ -200,7 +198,7 @@ public class AAFcli { if (pass != null) { pass = access.decrypt(pass, false); access.getProperties().put(user, pass); - ss = new HBasicAuthSS(si, user, pass); + ss=new HBasicAuthSS(si, user, pass); pw.println("as " + user); } else { // get Pass from System Properties, under name of // Tag @@ -478,36 +476,39 @@ public class AAFcli { sb.append(args[i]); } } - - SecurityInfoC<HttpURLConnection> si = SecurityInfoC.instance(access, HttpURLConnection.class); - Locator<URI> loc; + + AAFConHttp aafcon = new AAFConHttp(access); +// +// SecurityInfoC<?> si = aafcon.securityInfo(); +// Locator<URI> loc; aafsso.setLogDefault(); aafsso.setStdErrDefault(); // Note, with AAF Locator, this may not longer be necessary 3/2018 Jonathan if(!aafsso.loginOnly()) { - try { - loc = new AAFLocator(si,new URI(access.getProperty(Config.AAF_URL))); - } catch (Throwable t) { - aafsso.setStdErrDefault(); - throw t; - } finally { - // Other Access is done writing to StdOut and StdErr, reset Std out - aafsso.setLogDefault(); - } +// try { +// loc = new AAFLocator(si,new URI(access.getProperty(Config.AAF_URL))); +// } catch (Throwable t) { +// aafsso.setStdErrDefault(); +// throw t; +// } finally { +// // Other Access is done writing to StdOut and StdErr, reset Std out +// aafsso.setLogDefault(); +// } TIMEOUT = Integer.parseInt(access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF)); - HMangr hman = new HMangr(access, loc).readTimeout(TIMEOUT).apiVersion(Config.AAF_DEFAULT_VERSION); +// HMangr hman = new HMangr(access, loc).readTimeout(TIMEOUT).apiVersion(Config.AAF_DEFAULT_VERSION); if(access.getProperty(Config.AAF_DEFAULT_REALM)==null) { access.setProperty(Config.AAF_DEFAULT_REALM, "people.osaaf.org"); aafsso.addProp(Config.AAF_DEFAULT_REALM, "people.osaaf.org"); } - - AAFcli aafcli = new AAFcli(access,env, new OutputStreamWriter(System.out), hman, si, - new HBasicAuthSS(si,aafsso.user(), access.decrypt(aafsso.enc_pass(),false))); + AAFcli aafcli = new AAFcli(access,env, new OutputStreamWriter(System.out), + aafcon.hman(), aafcon.securityInfo(), aafcon.securityInfo().defSS); +// new HBasicAuthSS(si,aafsso.user(), access.decrypt(aafsso.enc_pass(),false))); +// } if(!ignoreDelay) { File delay = new File("aafcli.delay"); if(delay.exists()) { @@ -617,7 +618,7 @@ public class AAFcli { } public String typeString(Class<?> cls, boolean json) { - return "application/" + cls.getSimpleName() + "+" + (json ? "json" : "xml") + ";version=" + hman.apiVersion(); + return "application/" + cls.getSimpleName() + "+" + (json ? "json" : "xml");//+ ";version=" + hman.apiVersion(); } public String forceString() { diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java index 522568a9..7d01b70b 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java @@ -95,11 +95,6 @@ public class AAFSSO { } } -// String keyfile = diskprops.getProperty(Config.CADI_KEYFILE); -// if(keyfile==null) { -// keyfile = dot_aaf.getCanonicalPath()+".keyfile"; -// touchDiskprops=true; -// } File dot_aaf_kf = new File(dot_aaf, "keyfile"); if (removeSSO) { @@ -300,9 +295,9 @@ public class AAFSSO { addProp(Config.AAF_LOCATE_URL, locateUrl); } - String aafUrl = "https://AAF_LOCATE_URL/AAF_NS.service/2.0"; + String aafUrl = "https://AAF_LOCATE_URL/AAF_NS.service:2.0"; access.setProperty(Config.AAF_URL, aafUrl); - access.setProperty(Config.CM_URL, "https://AAF_LOCATE_URL/AAF_NS.cm/2.0"); + access.setProperty(Config.CM_URL, "https://AAF_LOCATE_URL/AAF_NS.cm:2.0"); String cadiLatitude = access.getProperty(Config.CADI_LATITUDE); if(cadiLatitude==null) { System.out.println("# If you do not know your Global Coordinates, we suggest bing.com/maps"); @@ -366,7 +361,7 @@ public class AAFSSO { public void setStdErrDefault() { access.setLogLevel(PropAccess.DEFAULT); - System.setOut(stdErrOrig); + System.setErr(stdErrOrig); } public void setLogDefault(Level level) { diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java index 1f778ad6..7c897e37 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java @@ -720,7 +720,12 @@ public class Config { String url = _url, replacement; int idxAAF_LOCATE_URL; if((idxAAF_LOCATE_URL=_url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) { - url = replacement + "/locate" + _url.substring(idxAAF_LOCATE_URL+AAF_LOCATE_URL_TAG.length()); + StringBuilder sb = new StringBuilder(replacement); + if(!replacement.endsWith("/locate")) { + sb.append("/locate"); + } + sb.append(_url,idxAAF_LOCATE_URL+AAF_LOCATE_URL_TAG.length(),_url.length()); + url = sb.toString(); } try { |