From dbec47530c91b6cd586fb05b44fd27444301e04a Mon Sep 17 00:00:00 2001 From: Instrumental Date: Fri, 31 May 2019 15:08:37 -0500 Subject: Switch to new Locate Features Issue-ID: AAF-839 Change-Id: I3122d32330c7e0fab533db8355183dbff68f7cc7 Signed-off-by: Instrumental --- .../java/org/onap/aaf/auth/direct/DirectAAFLocator.java | 6 +++--- .../src/main/java/org/onap/aaf/auth/fs/AAF_FS.java | 2 +- .../src/main/java/org/onap/aaf/auth/gui/Page.java | 4 ++-- auth/docker/dbash.sh | 2 +- auth/sample/etc/org.osaaf.aaf.cm.props | 1 + auth/sample/etc/org.osaaf.aaf.fs.props | 1 + auth/sample/etc/org.osaaf.aaf.gui.props | 3 ++- auth/sample/etc/org.osaaf.aaf.hello.props | 1 + auth/sample/etc/org.osaaf.aaf.locate.props | 1 + auth/sample/etc/org.osaaf.aaf.oauth.props | 1 + auth/sample/etc/org.osaaf.aaf.service.props | 1 + auth/sample/local/initialConfig.props | 15 +++++++-------- .../main/java/org/onap/aaf/cadi/configure/Agent.java | 6 +++--- .../org/onap/aaf/cadi/register/RegistrationCreator.java | 5 +++-- .../org/onap/aaf/cadi/register/RemoteRegistrant.java | 6 +++++- .../aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java | 2 +- .../aaf/cadi/register/test/JU_RegistrationCreator.java | 2 +- .../src/main/java/org/onap/aaf/cadi/config/Config.java | 17 ++++++++++++++++- 18 files changed, 51 insertions(+), 25 deletions(-) diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java index bd77bee6..98459672 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java @@ -75,10 +75,10 @@ public class DirectAAFLocator extends AbsAAFLocator { try { String aaf_url = access.getProperty(Config.AAF_URL, null); if(aaf_url==null) { - RegistrationPropHolder rph = new RegistrationPropHolder(access,0); - aaf_url = rph.replacements(getClass().getSimpleName(),"https://"+Config.AAF_LOCATE_URL_TAG+"/%NS."+name, null,null); + aaf_url = "https://"+Config.AAF_LOCATE_URL_TAG+"/%NS."+name; } - //access.getProperty("/locate/"+name+':'+version; + RegistrationPropHolder rph = new RegistrationPropHolder(access,0); + aaf_url = rph.replacements(getClass().getSimpleName(),aaf_url, null,null); access.printf(Level.INIT,"Creating DirectAAFLocator to %s",aaf_url); uri = new URI(aaf_url); } catch (URISyntaxException | UnknownHostException | CadiException e) { diff --git a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java index 76041cef..b56fc03e 100644 --- a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java +++ b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java @@ -60,7 +60,7 @@ public class AAF_FS extends AbsService { CachingFileAccess cfa = new CachingFileAccess(env); route(env,GET,"/:key*", cfa); - final String aaf_locate_url = access.getProperty(Config.AAF_LOCATE_URL, null); + final String aaf_locate_url = Config.getAAFLocateUrl(access); if (aaf_locate_url == null) { access.printf(Level.WARN, "Redirection requires property %s",Config.AAF_LOCATE_URL); } else { diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java index 8924ba26..5b6eb016 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java @@ -261,7 +261,7 @@ public class Page extends HTMLCacheGen { }); hgen.html(); final String title = env.getProperty(AAF_GUI_TITLE,"Authentication/Authorization Framework"); - final String defaultTheme = env.get(sTheme); + final String defaultTheme = env.get(sTheme,"onap"); final Holder hTheme = new Holder<>(defaultTheme); Mark head = hgen.head(); @@ -368,7 +368,7 @@ public class Page extends HTMLCacheGen { cache.dynamic(hgen, new DynamicCode() { @Override public void code(AAF_GUI state, AuthzTrans trans,Cache cache, HTMLGen xgen) throws APIException, IOException { - Properties props = themeProps.get(hTheme.get()); + Properties props = themeProps==null?null:themeProps.get(hTheme.get()); if(props!=null && "TRUE".equalsIgnoreCase(props.getProperty("main_menu_in_nav"))) { xgen.incr("h2").text("Navigation").end(); Mark mark = new Mark(); diff --git a/auth/docker/dbash.sh b/auth/docker/dbash.sh index f3bb26a0..a9c90f99 100644 --- a/auth/docker/dbash.sh +++ b/auth/docker/dbash.sh @@ -20,4 +20,4 @@ # . ./d.props -${DOCKER:=docker} exec -it aaf-$1 bash +${DOCKER:=docker} exec -it aaf-$1 bash -c "cd /opt/app/osaaf/logs && exec bash" diff --git a/auth/sample/etc/org.osaaf.aaf.cm.props b/auth/sample/etc/org.osaaf.aaf.cm.props index c8e383c2..9afba43d 100644 --- a/auth/sample/etc/org.osaaf.aaf.cm.props +++ b/auth/sample/etc/org.osaaf.aaf.cm.props @@ -24,6 +24,7 @@ ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props:/opt/app/osaaf/local/org.osaaf.aaf.cm.ca.props aaf_locator_entries=cm +aaf_locator_protocol=https port=8150 aaf_locator_public_port.helm=30084 aaf_locator_public_port.oom=31114 diff --git a/auth/sample/etc/org.osaaf.aaf.fs.props b/auth/sample/etc/org.osaaf.aaf.fs.props index 8233d020..6743f746 100644 --- a/auth/sample/etc/org.osaaf.aaf.fs.props +++ b/auth/sample/etc/org.osaaf.aaf.fs.props @@ -23,6 +23,7 @@ ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props aaf_locator_entries=fs +aaf_locator_protocol=http port=8096 aaf_locator_public_port.helm=30085 aaf_locator_public_port.oom=31115 diff --git a/auth/sample/etc/org.osaaf.aaf.gui.props b/auth/sample/etc/org.osaaf.aaf.gui.props index ce2b6bee..ca667422 100644 --- a/auth/sample/etc/org.osaaf.aaf.gui.props +++ b/auth/sample/etc/org.osaaf.aaf.gui.props @@ -23,13 +23,14 @@ ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props aaf_locator_entries=gui +aaf_locator_protocol=https port=8200 aaf_locator_public_port.helm=30083 aaf_locator_public_port.oom=31113 aaf_gui_title=AAF aaf_gui_copyright=(c) 2018 AT&T Intellectual Property. All rights reserved. -aaf_gui_theme=theme/onap +aaf_gui_theme=onap cadi_loginpage_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.gui:2.0/login # GUI URLS and Help URLS diff --git a/auth/sample/etc/org.osaaf.aaf.hello.props b/auth/sample/etc/org.osaaf.aaf.hello.props index 89434685..47143186 100644 --- a/auth/sample/etc/org.osaaf.aaf.hello.props +++ b/auth/sample/etc/org.osaaf.aaf.hello.props @@ -23,6 +23,7 @@ ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props aaf_locator_entries=hello +aaf_locator_protocol=https port=8130 aaf_locator_public_port.helm=30086 aaf_locator_public_port.oom=31116 diff --git a/auth/sample/etc/org.osaaf.aaf.locate.props b/auth/sample/etc/org.osaaf.aaf.locate.props index 0290a2ec..3f75f6f9 100644 --- a/auth/sample/etc/org.osaaf.aaf.locate.props +++ b/auth/sample/etc/org.osaaf.aaf.locate.props @@ -23,6 +23,7 @@ ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props aaf_locator_entries=locate +aaf_locator_protocol=https port=8095 aaf_locator_public_port.helm=30081 aaf_locator_public_port.oom=31111 diff --git a/auth/sample/etc/org.osaaf.aaf.oauth.props b/auth/sample/etc/org.osaaf.aaf.oauth.props index a2d5fc56..10ab72e5 100644 --- a/auth/sample/etc/org.osaaf.aaf.oauth.props +++ b/auth/sample/etc/org.osaaf.aaf.oauth.props @@ -24,6 +24,7 @@ cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org. aaf_locator_entries=oauth,token,introspect aaf_locator_fqdn.helm=aaf-oauth.%CNS aaf_locator_fqdn.oom=aaf-oauth.%CNS +aaf_locator_protocol=https port=8140 aaf_locator_public_port.helm=30082 aaf_locator_public_port.oom=31112 diff --git a/auth/sample/etc/org.osaaf.aaf.service.props b/auth/sample/etc/org.osaaf.aaf.service.props index 3af5f808..6318336c 100644 --- a/auth/sample/etc/org.osaaf.aaf.service.props +++ b/auth/sample/etc/org.osaaf.aaf.service.props @@ -23,6 +23,7 @@ ## cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props aaf_locator_entries=service +aaf_locator_protocol=https port=8100 aaf_locator_public_port.helm=30080 aaf_locator_public_port.oom=31110 diff --git a/auth/sample/local/initialConfig.props b/auth/sample/local/initialConfig.props index 8b01d951..7c03e052 100644 --- a/auth/sample/local/initialConfig.props +++ b/auth/sample/local/initialConfig.props @@ -26,20 +26,19 @@ # 3) Helm (Kubernetes and Helm) # 4) OOM (Kubernetes with OOM) ################################ +aaf_locate_url.docker=https://aaf-locate:8095 +aaf_locate_url.helm=https://aaf-locate.%CNS:8095 +aaf_locate_url.oom=https://aaf-locate.%CNS:8095 + aaf_locator_app_ns=%AAF_NS aaf_locator_name=%NS.%N aaf_locator_name.docker=%CNS.%NS.%N aaf_root_ns=org.osaaf.aaf -# Dublin -aaf_locator_name.oom=%NS.%N -aaf_locator_name.helm=%NS.%N -aaf_locator_public_name.oom=public.%NS.%N -aaf_locator_public_name.helm=public.%NS.%N - # EL Alto and beyond -# aaf_locator_name.oom=%CNS.%NS.%N -# aaf_locator_name.helm=%CNS.%NS.%N +aaf_locator_name.docker=%CNS.%NS.%N +aaf_locator_name.oom=%CNS.%NS.%N +aaf_locator_name.helm=%CNS.%NS.%N aaf_locator_fqdn.docker=aaf-%N aaf_locator_fqdn.helm=aaf-%N.%CNS 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 6d0ea956..e50b52d8 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 @@ -319,11 +319,11 @@ public class Agent { lhost=Config.AAF_LOCATE_URL_TAG; } String value = rph.replacements("Agent:loadURLs", - proto + lhost + "/AAF_NS." + ("aaf".equals(u)?"service":u) + ':' + version, + proto + lhost + "/%CNS.%AAF_NS." + ("aaf".equals(u)?"service":u) + ':' + version, null,dot_le); switch(u) { case "aaf": rv.put(Config.AAF_URL, value); break; - case "locate": rv.put(Config.AAF_LOCATE_URL, value); break; + case "locate": rv.put(Config.getAAFLocateUrl(access), value); break; case "token": rv.put(Config.AAF_OAUTH2_TOKEN_URL, value); break; case "introspect": rv.put(Config.AAF_OAUTH2_INTROSPECT_URL, value); break; case "cm": rv.put(Config.AAF_URL_CM, value); break; @@ -823,7 +823,7 @@ public class Agent { app.add(es.getKey(), es.getValue()); } - app.add(Config.AAF_LOCATE_URL, propAccess, null); + app.add(Config.AAF_LOCATE_URL, Config.getAAFLocateUrl(propAccess)); app.add(Config.AAF_ENV,propAccess, "DEV"); String release = propAccess.getProperty(Config.AAF_RELEASE); if(release!=null) { diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java index f4e0a688..cbf0339b 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java @@ -51,6 +51,7 @@ public class RegistrationCreator { try { String dot_le; String version=null; + String defProtocol="https"; RegistrationPropHolder ph = new RegistrationPropHolder(access, port); @@ -67,7 +68,7 @@ public class RegistrationCreator { defData = locate = new MgmtEndpoint(); version = access.getProperty(Config.AAF_LOCATOR_VERSION, Defaults.AAF_VERSION); - locate.setProtocol(access.getProperty(Config.AAF_LOCATOR_PROTOCOL,null)); + locate.setProtocol(defProtocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL,defProtocol)); List ls = locate.getSubprotocol(); for(String sp : Split.splitTrim(',', access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL,""))) { ls.add(sp); @@ -95,7 +96,7 @@ public class RegistrationCreator { locate.setMajor(split.length>0?Integer.parseInt(split[0]):0); } - String protocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL + dot_le, null); + String protocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL + dot_le, defProtocol); if (protocol!=null) { locate.setProtocol(protocol); List ls = locate.getSubprotocol(); diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java index 883410c0..3672c624 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java @@ -24,6 +24,7 @@ package org.onap.aaf.cadi.register; import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; +import java.net.UnknownHostException; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.Access.Level; @@ -35,6 +36,7 @@ import org.onap.aaf.cadi.client.Future; import org.onap.aaf.cadi.client.Rcli; import org.onap.aaf.cadi.client.Result; import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.cadi.config.RegistrationPropHolder; import org.onap.aaf.cadi.locator.PropertyLocator; import org.onap.aaf.cadi.locator.SingleEndpointLocator; import org.onap.aaf.misc.env.APIException; @@ -66,12 +68,14 @@ public class RemoteRegistrant implements Registrant { } else { // Note: want Property Locator or Single, not AAFLocator, because we want the core service, not what it can find try { + RegistrationPropHolder rph = new RegistrationPropHolder(access, 0); + aaf_locate = rph.replacements(getClass().getSimpleName(),aaf_locate, null,null); if (aaf_locate.indexOf(',')>=0) { locator = new PropertyLocator(aaf_locate); } else { locator = new SingleEndpointLocator(aaf_locate); } - } catch (URISyntaxException e) { + } catch (URISyntaxException | UnknownHostException e) { throw new CadiException(e); } } 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 7c589ae3..10acc887 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 @@ -298,7 +298,7 @@ public class AAFSSO { err.append("-D" + Config.AAF_APPPASS + "= "); } - String locateUrl = access.getProperty(Config.AAF_LOCATE_URL); + String locateUrl = Config.getAAFLocateUrl(access); if (locateUrl==null) { locateUrl=AAFSSO.cons.readLine("AAF Locator URL=https://"); if (locateUrl==null || locateUrl.length()==0) { diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java index af344d2f..216b8660 100644 --- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java +++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java @@ -62,7 +62,7 @@ public class JU_RegistrationCreator { assertEquals(0,me.getPatch()); assertEquals(0,me.getPkg()); assertEquals(entry,me.getName()); - assertEquals(null,me.getProtocol()); + assertEquals("https",me.getProtocol()); assertEquals(0,me.getSpecialPorts().size()); } 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 52bb53ef..66fbe847 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 @@ -151,6 +151,9 @@ public class Config { public static final String AAF_ROOT_NS = "aaf_root_ns"; public static final String AAF_ROOT_NS_DEF = "org.osaaf.aaf"; public static final String AAF_ROOT_COMPANY = "aaf_root_company"; + /** + * Use Config.getAAFLocateUrl(access) to get correct property in/out of container + */ public static final String AAF_LOCATE_URL = "aaf_locate_url"; //URL for AAF locator public static final String AAF_LOCATE_URL_TAG = "AAF_LOCATE_URL"; // Name of Above for use in Config Variables. public static final String AAF_DEFAULT_API_VERSION = "2.1"; @@ -561,7 +564,7 @@ public class Config { } access.log(Level.INIT, sb); - Locator locator = loadLocator(si, logProp(rph, AAF_LOCATE_URL, null)); + Locator locator = loadLocator(si, logProp(rph, Config.getAAFLocateUrl(access), null)); taf = new HttpEpiTaf(access,locator, tc, htarray); // ok to pass locator == null String level = logProp(access, CADI_LOGLEVEL, null); @@ -904,6 +907,18 @@ public class Config { public static String getDefaultRealm() { return defaultRealm; } + + public static String getAAFLocateUrl(Access access) { + String rv = null; + String cont = access.getProperty(AAF_LOCATOR_CONTAINER,null); + if(cont!=null) { + rv = access.getProperty(AAF_LOCATE_URL + '.' +cont, null); + } + if(rv==null) { + rv = access.getProperty(AAF_LOCATE_URL, null); + } + return rv; + } private static class Priori implements Comparable> { public final T t; -- cgit 1.2.3-korg