summaryrefslogtreecommitdiffstats
path: root/cadi/core
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-02-20 11:14:41 -0600
committerInstrumental <jonathan.gathman@att.com>2019-02-20 11:15:17 -0600
commit2b46f76d9a688acf326424659ec9672a2614fdcf (patch)
tree1ff396c03af82fe73615c61b10ec868f060da412 /cadi/core
parentbf3d3075cac610b901c951ae135fcdbcc6ffecb8 (diff)
fix new openssl, data, etc
Issue-ID: AAF-667 Change-Id: Ic87c5159c453c293d845abea6be0c4cfb3164fc1 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/core')
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java55
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java59
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java4
4 files changed, 78 insertions, 42 deletions
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 dc58acc6..62623fb8 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
@@ -258,6 +258,12 @@ public class Config {
public static HttpTaf configHttpTaf(Connector con, SecurityInfoC<HttpURLConnection> si, TrustChecker tc, CredVal up, Lur lur, Object ... additionalTafLurs) throws CadiException, LocatorException {
Access access = si.access;
+ RegistrationPropHolder rph;
+ try {
+ rph = new RegistrationPropHolder(access, 0);
+ } catch (UnknownHostException e2) {
+ throw new CadiException(e2);
+ }
/////////////////////////////////////////////////////
// Setup AAFCon for any following
/////////////////////////////////////////////////////
@@ -277,7 +283,7 @@ public class Config {
boolean hasDirectAAF = hasDirect("DirectAAFLur",additionalTafLurs);
// IMPORTANT! Don't attempt to load AAF Connector if there is no AAF URL
- String aafURL = access.getProperty(AAF_URL,null);
+ String aafURL = logProp(rph, AAF_URL,null);
if (!hasDirectAAF && aafcon==null && aafURL!=null) {
aafcon = loadAAFConnector(si, aafURL);
}
@@ -352,8 +358,8 @@ public class Config {
Class<HttpTaf> obasicCls = (Class<HttpTaf>)loadClass(access,CADI_OBASIC_HTTP_TAF_DEF);
if (obasicCls!=null) {
try {
- String tokenurl = logProp(access,Config.AAF_OAUTH2_TOKEN_URL, null);
- String introspecturl = logProp(access,Config.AAF_OAUTH2_INTROSPECT_URL, null);
+ String tokenurl = logProp(rph,Config.AAF_OAUTH2_TOKEN_URL, null);
+ String introspecturl = logProp(rph,Config.AAF_OAUTH2_INTROSPECT_URL, null);
if (tokenurl==null || introspecturl==null) {
access.log(Level.INIT,"Both tokenurl and introspecturl are required. Oauth Authorization is disabled.");
}
@@ -431,7 +437,7 @@ public class Config {
// Configure OAuth TAF
/////////////////////////////////////////////////////
if (!hasOAuthDirectTAF) {
- String oauthTokenUrl = logProp(access,Config.AAF_OAUTH2_TOKEN_URL,null);
+ String oauthTokenUrl = logProp(rph,Config.AAF_OAUTH2_TOKEN_URL,null);
Class<?> oadtClss;
try {
oadtClss = Class.forName(OAUTH_DIRECT_TAF);
@@ -448,7 +454,7 @@ public class Config {
additionalTafLurs = array;
access.log(Level.INIT,"OAuth2 Direct is enabled");
} else if (oauthTokenUrl!=null) {
- String oauthIntrospectUrl = logProp(access,Config.AAF_OAUTH2_INTROSPECT_URL,null);
+ String oauthIntrospectUrl = logProp(rph,Config.AAF_OAUTH2_INTROSPECT_URL,null);
@SuppressWarnings("unchecked")
Class<HttpTaf> oaTCls = (Class<HttpTaf>)loadClass(access,OAUTH_HTTP_TAF);
if (oaTCls!=null) {
@@ -549,7 +555,7 @@ public class Config {
}
access.log(Level.INIT, sb);
- Locator<URI> locator = loadLocator(si, logProp(access, AAF_LOCATE_URL, null));
+ Locator<URI> locator = loadLocator(si, logProp(rph, AAF_LOCATE_URL, null));
taf = new HttpEpiTaf(access,locator, tc, htarray); // ok to pass locator == null
String level = logProp(access, CADI_LOGLEVEL, null);
@@ -561,6 +567,18 @@ public class Config {
return taf;
}
+ public static String logProp(RegistrationPropHolder rph, String tag, String def) {
+ String rv = rph.access().getProperty(tag, def);
+ if (rv == null) {
+ rph.access().log(Level.INIT,tag,"is not explicitly set");
+ } else {
+ rv = rph.replacements(rv, null, null);
+ rph.access().log(Level.INIT,tag,"is set to",rv);
+ }
+ return rv;
+
+ }
+
public static String logProp(Access access,String tag, String def) {
String rv = access.getProperty(tag, def);
if (rv == null) {
@@ -573,6 +591,13 @@ public class Config {
public static Lur configLur(SecurityInfoC<HttpURLConnection> si, Connector con, Object ... additionalTafLurs) throws CadiException {
Access access = si.access;
+ RegistrationPropHolder rph;
+ try {
+ rph = new RegistrationPropHolder(access, 0);
+ } catch (UnknownHostException e2) {
+ throw new CadiException(e2);
+ }
+
List<Priori<Lur>> lurs = new ArrayList<>();
/////////////////////////////////////////////////////
@@ -601,8 +626,8 @@ public class Config {
/////////////////////////////////////////////////////
// Configure the OAuth Lur (if any)
/////////////////////////////////////////////////////
- String tokenUrl = logProp(access,AAF_OAUTH2_TOKEN_URL, null);
- String introspectUrl = logProp(access,AAF_OAUTH2_INTROSPECT_URL, null);
+ String tokenUrl = logProp(rph,AAF_OAUTH2_TOKEN_URL, null);
+ String introspectUrl = logProp(rph,AAF_OAUTH2_INTROSPECT_URL, null);
if (tokenUrl!=null && introspectUrl !=null) {
try {
Class<?> olurCls = loadClass(access, CADI_OLUR_CLASS_DEF);
@@ -631,7 +656,7 @@ public class Config {
/////////////////////////////////////////////////////
// Configure the AAF Lur (if any)
/////////////////////////////////////////////////////
- String aafURL = logProp(access,AAF_URL,null); // Trigger Property
+ String aafURL = logProp(rph,AAF_URL,null); // Trigger Property
String aafEnv = access.getProperty(AAF_ENV,null);
if (aafEnv == null && aafURL!=null && access instanceof PropAccess) { // set AAF_ENV from AAF_URL
int ec = aafURL.indexOf("envContext=");
@@ -822,21 +847,11 @@ public class Config {
try {
rph = new RegistrationPropHolder(access, 0);
url = rph.replacements(_url, null, null);
+ access.printf(Level.INFO, "loadLocator URL is %s",url);
} catch (UnknownHostException | CadiException e1) {
throw new LocatorException(e1);
}
- String replacement;
- int idxAAFLocateUrl;
- if ((idxAAFLocateUrl=url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) {
- StringBuilder sb = new StringBuilder(replacement);
- if (!replacement.endsWith("/locate")) {
- sb.append("/locate");
- }
- sb.append(url,idxAAFLocateUrl+AAF_LOCATE_URL_TAG.length(),url.length());
- url = sb.toString();
- }
-
try {
Class<?> lcls = loadClass(access,AAF_LOCATOR_CLASS_DEF);
if (lcls==null) {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java
index aa782313..68a018d6 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java
@@ -41,6 +41,7 @@ public class RegistrationPropHolder {
public final String default_name;
public final String lentries;
public final String lcontainer;
+ public final String default_container;
public RegistrationPropHolder(final Access access, final int port) throws UnknownHostException, CadiException {
this.access = access;
@@ -50,15 +51,15 @@ public class RegistrationPropHolder {
lentries=access.getProperty(Config.AAF_LOCATOR_ENTRIES,"");
- str = access.getProperty(Config.AAF_LOCATOR_CONTAINER, "");
- if(!str.isEmpty()) {
- lcontainer=',' + str; // "" makes a blank default Public Entry
- str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT+'.'+str, null);
+ default_container = access.getProperty(Config.AAF_LOCATOR_CONTAINER, "");
+ if(!default_container.isEmpty()) {
+ lcontainer=',' + default_container; // "" makes a blank default Public Entry
+ str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT+'.'+default_container, null);
if(str==null) {
str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT, null);
}
} else {
- lcontainer=str;
+ lcontainer=default_container;
str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT, null);
}
if(str!=null) {
@@ -149,26 +150,42 @@ public class RegistrationPropHolder {
}
- public String replacements(String source, final String name, final String dot_le) {
+ public String replacements(String source, final String name, final String _dot_le) {
if(source == null) {
return "";
} else if(source.isEmpty()) {
return source;
}
- String str;
- // aaf_locate_url
- if(source.indexOf(Config.AAF_LOCATE_URL_TAG)>=0) {
- str = access.getProperty(Config.AAF_LOCATE_URL, null);
- if(str!=null) {
- if(!str.endsWith("/")) {
- str+='/';
- }
- if(!str.endsWith("/locate/")) {
- str+="locate/";
+
+ String dot_le;
+ if(_dot_le==null) {
+ dot_le = default_container.isEmpty()?"":'.'+default_container;
+ } else {
+ dot_le = _dot_le;
+ }
+
+ String aaf_locator_host = access.getProperty(Config.AAF_LOCATE_URL+dot_le,null);
+ if(aaf_locator_host==null) {
+ aaf_locator_host = access.getProperty(Config.AAF_LOCATE_URL,null);
+ }
+
+ String str;
+ if(aaf_locator_host!=null) {
+ if("https://AAF_LOCATE_URL".equals(source)) {
+ source = aaf_locator_host;
+ } else {
+ str = aaf_locator_host;
+ if(source.indexOf(Config.AAF_LOCATE_URL_TAG)>=0) {
+ if(!str.endsWith("/")) {
+ str+='/';
+ }
+ if(!str.endsWith("/locate/")) {
+ str+="locate/";
+ }
+ source = source.replace("https://AAF_LOCATE_URL/", str);
}
- source = source.replace("https://AAF_LOCATE_URL/", str);
}
- }
+ }
int atC = source.indexOf("%C");
if(atC>=0) {
@@ -179,7 +196,7 @@ public class RegistrationPropHolder {
}
source = source.replace("%CNS", str);
- str = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le, "");
+ str = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le,default_container);
if(str.isEmpty()) {
source = source.replace("%C"+'.', str);
}
@@ -226,4 +243,8 @@ public class RegistrationPropHolder {
public_port:
port;
}
+
+ public Access access() {
+ return access;
+ }
} \ No newline at end of file
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
index 677f2139..fca99a31 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java
@@ -134,7 +134,7 @@ public class X509Taf implements HttpTaf {
// Note: If the Issuer is not in the TrustStore, it's not added to the Cert list
String issuer = certarr[0].getIssuerDN().toString();
String subject = certarr[0].getSubjectDN().getName();
- access.printf(Level.DEBUG,"Client Certificate found\n Subject %s\n Issuer %s",subject,issuer);
+ access.printf(Level.DEBUG,"Client Certificate found\n Subject '%s'\n Issuer '%s'",subject,issuer);
if (cadiIssuers.contains(issuer)) {
// avoiding extra object creation, since this is validated EVERY transaction with a Cert
int start = 0;
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java
index 46fd741d..18e26f55 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java
@@ -130,8 +130,8 @@ public class JU_RegistrationPropHolder {
target = "mycontns.org.osaaf.aaf.theName";
assertEquals(target,rph.replacements(fqdn, name, ".hello"));
- pa.setProperty(Config.AAF_LOCATOR_CONTAINER+".hello","hello");
- target = "hello.mycontns.org.osaaf.aaf.theName";
+ pa.setProperty(Config.AAF_LOCATOR_CONTAINER+".hello","helloC");
+ target = "helloC.mycontns.org.osaaf.aaf.theName";
assertEquals(target,rph.replacements(fqdn, name, ".hello"));
pa.setProperty(Config.AAF_LOCATOR_CONTAINER_NS,"c_ns");