summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/pom.xml2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java8
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLocator.java45
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFSingleLocator.java93
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java53
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java7
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java264
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java65
-rw-r--r--cadi/client/pom.xml2
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java44
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java8
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java4
-rw-r--r--cadi/core/pom.xml2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java64
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java61
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java66
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java153
-rw-r--r--cadi/oauth-enduser/pom.xml2
-rw-r--r--cadi/pom.xml2
-rw-r--r--cadi/servlet-sample/pom.xml2
22 files changed, 676 insertions, 275 deletions
diff --git a/cadi/aaf/pom.xml b/cadi/aaf/pom.xml
index 5ce05294..25a2d02d 100644
--- a/cadi/aaf/pom.xml
+++ b/cadi/aaf/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>cadiparent</artifactId>
- <version>2.1.9-SNAPSHOT</version>
+ <version>2.1.10-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java
index 08ee900f..30ea1c21 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java
@@ -47,6 +47,7 @@ import org.onap.aaf.cadi.http.HBasicAuthSS;
import org.onap.aaf.cadi.http.HClient;
import org.onap.aaf.cadi.http.HX509SS;
import org.onap.aaf.cadi.oauth.HRenewingTokenSS;
+import org.onap.aaf.cadi.util.FixURIinfo;
import org.onap.aaf.misc.env.APIException;
public class TestConnectivity {
@@ -234,11 +235,12 @@ public class TestConnectivity {
} else {
socket = new Socket();
try {
+ FixURIinfo fui = new FixURIinfo(uri);
try {
- socket.connect(new InetSocketAddress(uri.getHost(), uri.getPort()),3000);
- System.out.printf("Can Connect a Socket to %s %d\n",uri.getHost(),uri.getPort());
+ socket.connect(new InetSocketAddress(fui.getHost(), fui.getPort()),3000);
+ System.out.printf("Can Connect a Socket to %s %d\n",fui.getHost(),fui.getPort());
} catch (IOException e) {
- System.out.printf("Cannot Connect a Socket to %s %d: %s\n",uri.getHost(),uri.getPort(),e.getMessage());
+ System.out.printf("Cannot Connect a Socket to %s %d: %s\n",fui.getHost(),fui.getPort(),e.getMessage());
}
} finally {
try {
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLocator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLocator.java
index 35ef9990..16fdb79c 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLocator.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLocator.java
@@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.SecuritySetter;
@@ -35,6 +36,7 @@ import org.onap.aaf.cadi.client.Future;
import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.config.SecurityInfoC;
import org.onap.aaf.cadi.http.HClient;
+import org.onap.aaf.cadi.util.FixURIinfo;
import org.onap.aaf.cadi.util.Split;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Data.TYPE;
@@ -61,21 +63,9 @@ public class AAFLocator extends AbsAAFLocator<BasicTrans> {
int connectTimeout = Integer.parseInt(si.access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));
try {
String[] path = Split.split('/',locatorURI.getPath());
- String host = locatorURI.getHost();
- if (host==null) {
- host = locatorURI.getAuthority(); // this happens when no port
- }
- if ("AAF_LOCATE_URL".equals(host)) {
- URI uri = new URI(
- locatorURI.getScheme(),
- locatorURI.getUserInfo(),
- aaf_locator_uri.getHost(),
- aaf_locator_uri.getPort(),
- "/locate"+locatorURI.getPath(),
- null,
- null
- );
- client = createClient(si.defSS, uri, connectTimeout);
+ FixURIinfo fui = new FixURIinfo(locatorURI);
+ if ("AAF_LOCATE_URL".equals(fui.getHost())) {
+ client = createClient(si.defSS, locatorURI, connectTimeout);
} else if (path.length>1 && "locate".equals(path[1])) {
StringBuilder sb = new StringBuilder();
for (int i=3;i<path.length;++i) {
@@ -83,23 +73,26 @@ public class AAFLocator extends AbsAAFLocator<BasicTrans> {
sb.append(path[i]);
}
setPathInfo(sb.toString());
- URI uri = new URI(
- locatorURI.getScheme(),
- locatorURI.getUserInfo(),
- locatorURI.getHost(),
- locatorURI.getPort(),
- "/locate/"+name + ':' + version,
- null,
- null
- );
- client = createClient(si.defSS, uri, connectTimeout);
+// URI uri = new URI(
+// locatorURI.getScheme(),
+// locatorURI.getAuthority(),
+// locatorURI.getPath(),
+// null,
+// null
+// );
+ client = createClient(si.defSS, locatorURI, connectTimeout);
} else {
client = new HClient(si.defSS, locatorURI, connectTimeout);
}
epsDF = env.newDataFactory(Endpoints.class);
- } catch (APIException | URISyntaxException e) {
+
+ } catch (APIException /*| URISyntaxException*/ e) {
throw new LocatorException(e);
}
+
+ if(si.access.willLog(Access.Level.DEBUG)) {
+ si.access.log(Access.Level.DEBUG, "Root URI:",client.getURI());
+ }
}
@Override
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFSingleLocator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFSingleLocator.java
new file mode 100644
index 00000000..1e4e9c0f
--- /dev/null
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFSingleLocator.java
@@ -0,0 +1,93 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+
+package org.onap.aaf.cadi.aaf.v2_0;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.onap.aaf.cadi.Locator;
+import org.onap.aaf.cadi.LocatorException;
+import org.onap.aaf.misc.env.impl.BasicTrans;
+
+/**
+ * This Locator good for using Inside Docker or K8s, where there is no real lookup,
+ * and there is conflict between external and internal host names, due to
+ * Service abstraction.
+ *
+ * @author Instrumental(Jonathan)
+ *
+ */
+public class AAFSingleLocator implements Locator<URI> {
+
+ private final URI uri;
+
+ /**
+ * NS here is "container" ns. AAF NS is assumed to be AAF_NS at this level of client code.
+ * @param cont_ns
+ * @param prefix
+ * @param version
+ * @throws URISyntaxException
+ */
+ public AAFSingleLocator(final String uri) throws URISyntaxException {
+ this.uri = new URI(uri);
+ }
+
+ @Override
+ public URI get(Item item) throws LocatorException {
+ return uri;
+ }
+
+ @Override
+ public boolean hasItems() {
+ return true;
+ }
+
+ @Override
+ public void invalidate(Item item) throws LocatorException {
+ }
+
+ @Override
+ public Item best() throws LocatorException {
+ return new SingleItem();
+ }
+
+ @Override
+ public Item first() throws LocatorException {
+ return new SingleItem();
+ }
+
+ @Override
+ public Item next(Item item) throws LocatorException {
+ return null; // only one item
+ }
+
+ @Override
+ public boolean refresh() {
+ return false;
+ }
+
+ @Override
+ public void destroy() {
+ }
+
+ private class SingleItem implements Item {
+ }
+}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
index 9f617136..9b630a76 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
@@ -87,12 +87,14 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
latitude = Double.parseDouble(lat);
longitude = Double.parseDouble(lng);
}
+
if (name.startsWith(Defaults.AAF_NS)) {
String root_ns = access.getProperty(Config.AAF_ROOT_NS, null);
- if (root_ns!=null) {
- name=name.replace(Defaults.AAF_NS, root_ns);
+ if(root_ns!=null) {
+ name=name.replace(Defaults.AAF_NS, root_ns);
}
}
+
if (name.startsWith("http")) { // simple URL
this.name = name;
this.version = access.getProperty(Config.AAF_API_VERSION,Config.AAF_DEFAULT_API_VERSION);
@@ -111,52 +113,7 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
public static void setCreator(LocatorCreator lc) {
locatorCreator = lc;
}
-
- /*public static Locator<URI> create(String key) throws LocatorException {
- String name = null;
- String version = Config.AAF_DEFAULT_API_VERSION;
- String pathInfo = null;
- int prev = key.indexOf("/locate");
- if (prev>0) {
- prev = key.indexOf('/',prev+6);
- if (prev>0) {
- int next = key.indexOf('/',++prev);
- if (next>0) {
- name = key.substring(prev, next);
- pathInfo=key.substring(next);
- } else {
- name = key.substring(prev);
- }
- String[] split = Split.split(':', name);
- switch(split.length) {
- case 3:
- case 2:
- version = split[1];
- name = split[0];
- break;
- default:
- break;
- }
- }
- }
-
- if (key.startsWith("http")) {
- if (name!=null) {
- if (locatorCreator != null) {
- AbsAAFLocator<?> aal = locatorCreator.create(name, version);
- if (pathInfo!=null) {
- aal.setPathInfo(pathInfo);
- }
- return aal;
- }
- } else {
- return new PropertyLocator(key);
- }
- }
- return null;
- }
- */
-
+
public static Locator<URI> create(final String name, final String version) throws LocatorException {
return locatorCreator.create(name, version);
}
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 18430ef3..aa4e5743 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
@@ -773,6 +773,13 @@ public class Agent {
}
app.add(Config.AAF_LOCATE_URL, propAccess, null);
+ for(Entry<Object, Object> aaf_loc_prop : propAccess.getProperties().entrySet()) {
+ String key = aaf_loc_prop.getKey().toString();
+ if(key.startsWith("aaf_locator")) {
+ app.add(key, aaf_loc_prop.getValue().toString());
+ }
+ }
+
app.add(Config.AAF_APPID, fqi);
app.add(Config.AAF_URL, propAccess, Defaults.AAF_URL);
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
new file mode 100644
index 00000000..7e519c52
--- /dev/null
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java
@@ -0,0 +1,264 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+
+package org.onap.aaf.cadi.register;
+
+import java.net.Inet4Address;
+import java.net.UnknownHostException;
+import java.util.List;
+
+import org.onap.aaf.cadi.Access;
+import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.aaf.Defaults;
+import org.onap.aaf.cadi.config.Config;
+import org.onap.aaf.cadi.util.Split;
+
+import locate.v1_0.MgmtEndpoint;
+import locate.v1_0.MgmtEndpoints;
+
+public class RegistrationCreator {
+ private static final String MUST_BE_DEFINED = " must be defined\n";
+ private Access access;
+
+ public RegistrationCreator(Access access) {
+ this.access = access;
+ }
+
+ public MgmtEndpoints create(final int port) throws CadiException {
+ MgmtEndpoints me = new MgmtEndpoints();
+ List<MgmtEndpoint> lme = me.getMgmtEndpoint();
+ MgmtEndpoint defData = null;
+ MgmtEndpoint locate = null;
+
+
+ StringBuilder errs = new StringBuilder();
+ try {
+ String hostname = access.getProperty(Config.HOSTNAME, null);
+ if (hostname==null) {
+ hostname = Inet4Address.getLocalHost().getHostName();
+ }
+ if (hostname==null) {
+ errs.append(Config.HOSTNAME);
+ errs.append(MUST_BE_DEFINED);
+ }
+
+ Float latitude=null;
+ String slatitude = access.getProperty(Config.CADI_LATITUDE, null);
+ if(slatitude == null) {
+ errs.append(Config.CADI_LATITUDE);
+ errs.append(MUST_BE_DEFINED);
+ } else {
+ latitude = Float.parseFloat(slatitude);
+ }
+
+ Float longitude=null;
+ String slongitude = access.getProperty(Config.CADI_LONGITUDE, null);
+ if(slongitude == null) {
+ errs.append(Config.CADI_LONGITUDE);
+ errs.append(MUST_BE_DEFINED);
+ } else {
+ longitude = Float.parseFloat(slongitude);
+ }
+
+ if(errs.length()>0) {
+ throw new CadiException(errs.toString());
+ }
+
+ String dot_le;
+ String ns;
+ String version=null;
+ String lentries = access.getProperty(Config.AAF_LOCATOR_CONTAINER, null);
+ if(lentries==null) {
+ lentries="";
+ } else {
+ lentries=',' + lentries; // "" makes a blank default Public Entry
+ }
+
+ String defaultName = null;
+ String str;
+ int public_port = port;
+ // Note: only one of the ports can be public... Therefore, only the la
+ for(String le : Split.splitTrim(',', lentries)) {
+ dot_le = le.isEmpty()?"":"."+le;
+ str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT+dot_le, null);
+ if(str!=null) { // Get Public Port
+ public_port = Integer.decode(str);
+ }
+ }
+
+ String public_hostname = hostname;
+ for(String le : Split.splitTrim(',', lentries)) {
+ dot_le = le.isEmpty()?"":"."+le;
+ String ph = access.getProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME+dot_le,null);
+ if( ph != null) {
+ public_hostname=ph;
+ }
+ }
+
+ String default_fqdn = access.getProperty(Config.AAF_LOCATOR_FQDN, public_hostname);
+
+
+ // Now, loop through by Container
+ for(String le : Split.splitTrim(',', lentries)) {
+ // Add variable entries
+ String names;
+ if(le.length()>0) {
+ dot_le = '.' + le;
+ names = access.getProperty(Config.AAF_LOCATOR_NAMES+dot_le,null);
+ if(names==null) {
+ // Go for Default
+ names = access.getProperty(Config.AAF_LOCATOR_NAMES,"");
+ }
+ } else {
+ dot_le = "";
+ names=access.getProperty(Config.AAF_LOCATOR_NAMES,dot_le);
+ }
+
+ for(String name : Split.splitTrim(',', names)) {
+ if(defData==null) {
+ defData = locate = new MgmtEndpoint();
+
+ defaultName = name;
+ version = access.getProperty(Config.AAF_LOCATOR_VERSION, Defaults.AAF_VERSION);
+ locate.setProtocol(access.getProperty(Config.AAF_LOCATOR_PROTOCOL,null));
+ List<String> ls = locate.getSubprotocol();
+ for(String sp : Split.splitTrim(',', access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL,""))) {
+ ls.add(sp);
+ }
+ locate.setLatitude(latitude);
+ locate.setLongitude(longitude);
+
+ } else {
+ locate = copy(defData);
+ }
+
+ str = access.getProperty(Config.HOSTNAME+dot_le, null);
+ if(str==null) {
+ str = access.getProperty(Config.HOSTNAME, hostname);
+ }
+ locate.setHostname(hostname);
+
+ ns = access.getProperty(Config.AAF_LOCATOR_NS+dot_le,null);
+ if(ns==null) {
+ ns = access.getProperty(Config.AAF_LOCATOR_NS,"");
+ }
+ switch(ns) {
+ case Defaults.AAF_NS:
+ ns = access.getProperty(Config.AAF_ROOT_NS, "");
+ // Fallthrough on purpose.
+ }
+
+ String ns_dot;
+ if(ns.isEmpty()) {
+ ns_dot = ns;
+ } else {
+ ns_dot = ns + '.';
+ }
+
+ String container_id = access.getProperty(Config.AAF_LOCATOR_CONTAINER_ID+dot_le, "");
+ if(!container_id.isEmpty()) {
+ ns_dot = container_id + '.' + ns_dot;
+ }
+
+ if(!le.isEmpty()) {
+ ns_dot = le + '.' + ns_dot;
+ }
+
+ if(name.isEmpty()) {
+ locate.setName(ns_dot + defaultName);
+ } else {
+ locate.setName(ns_dot + name);
+ }
+
+ if(dot_le.isEmpty()) {
+ locate.setHostname(access.getProperty(Config.AAF_LOCATOR_FQDN, default_fqdn));
+ } else {
+ str = access.getProperty(Config.AAF_LOCATOR_FQDN+dot_le, null);
+ if(str==null) {
+ locate.setHostname(default_fqdn);
+ } else {
+ String container_ns = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS+dot_le, "");
+ str = str.replace("%CNS", container_ns);
+ String container = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le, "");
+ str = str.replace("%C", container);
+ str = str.replace("%NS", ns);
+ str = str.replace("%N", name);
+ str = str.replace("%DF", default_fqdn);
+ str = str.replace("%PH", public_hostname);
+ locate.setHostname(str);
+ }
+ }
+
+ if(le.isEmpty()) {
+ locate.setPort(public_port);
+ } else {
+ locate.setPort(port);
+ }
+
+ String specificVersion = access.getProperty(Config.AAF_LOCATOR_VERSION + dot_le,null);
+ if(specificVersion == null && locate == defData) {
+ specificVersion = version;
+ }
+ if(specificVersion!=null) {
+ String split[] = Split.splitTrim('.', specificVersion);
+ locate.setPkg(split.length>3?Integer.parseInt(split[3]):0);
+ locate.setPatch(split.length>2?Integer.parseInt(split[2]):0);
+ locate.setMinor(split.length>1?Integer.parseInt(split[1]):0);
+ locate.setMajor(split.length>0?Integer.parseInt(split[0]):0);
+ }
+
+ String protocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL + dot_le, null);
+ if (protocol!=null) {
+ locate.setProtocol(protocol);
+ String subprotocols = access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL + dot_le, null);
+ if(subprotocols!=null) {
+ List<String> ls = locate.getSubprotocol();
+ for (String s : Split.split(',', subprotocols)) {
+ ls.add(s);
+ }
+ }
+ }
+ lme.add(locate);
+ }
+ }
+ } catch (NumberFormatException | UnknownHostException e) {
+ throw new CadiException("Error extracting Data from Properties for Registrar",e);
+ }
+
+ return me;
+ }
+
+ private MgmtEndpoint copy(MgmtEndpoint mep) {
+ MgmtEndpoint out = new MgmtEndpoint();
+ out.setName(mep.getName());
+ out.setHostname(mep.getHostname());
+ out.setLatitude(mep.getLatitude());
+ out.setLongitude(mep.getLongitude());
+ out.setMajor(mep.getMajor());
+ out.setMinor(mep.getMinor());
+ out.setPkg(mep.getPkg());
+ out.setPatch(mep.getPatch());
+ out.setPort(mep.getPort());
+ out.setProtocol(mep.getProtocol());
+ out.getSpecialPorts().addAll(mep.getSpecialPorts());
+ out.getSubprotocol().addAll(mep.getSubprotocol());
+ return out;
+ }
+}
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 49d40ab4..883410c0 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
@@ -22,10 +22,8 @@
package org.onap.aaf.cadi.register;
import java.net.HttpURLConnection;
-import java.net.Inet4Address;
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;
@@ -39,16 +37,13 @@ import org.onap.aaf.cadi.client.Result;
import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.locator.PropertyLocator;
import org.onap.aaf.cadi.locator.SingleEndpointLocator;
-import org.onap.aaf.cadi.util.Split;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.impl.BasicEnv;
import org.onap.aaf.misc.rosetta.env.RosettaDF;
-import locate.v1_0.MgmtEndpoint;
import locate.v1_0.MgmtEndpoints;
public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> {
- private final MgmtEndpoint mep;
private final MgmtEndpoints meps;
private final AAFCon<HttpURLConnection> aafcon;
private final RosettaDF<MgmtEndpoints> mgmtEndpointsDF;
@@ -56,8 +51,7 @@ public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> {
private final Access access;
private final int timeout;
- @SafeVarargs
- public RemoteRegistrant(AAFCon<HttpURLConnection> aafcon, String name, String version, int port, RemoteRegistrant<ENV> ... others) throws CadiException, LocatorException {
+ public RemoteRegistrant(AAFCon<HttpURLConnection> aafcon, int port) throws CadiException, LocatorException {
this.aafcon = aafcon;
access = aafcon.access;
try {
@@ -82,60 +76,13 @@ public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> {
}
}
- mep = new MgmtEndpoint();
- mep.setName(name);
- mep.setPort(port);
-
- try {
- String hostnameToRegister = access.getProperty(Config.AAF_REGISTER_AS, null);
- if (hostnameToRegister==null) {
- hostnameToRegister = access.getProperty(Config.HOSTNAME, null);
- }
- if (hostnameToRegister==null) {
- hostnameToRegister = Inet4Address.getLocalHost().getHostName();
- }
- mep.setHostname(hostnameToRegister);
-
- String latitude = access.getProperty(Config.CADI_LATITUDE, null);
- if (latitude==null) {
- latitude = access.getProperty("AFT_LATITUDE", null);
- }
- String longitude = access.getProperty(Config.CADI_LONGITUDE, null);
- if (longitude==null) {
- longitude = access.getProperty("AFT_LONGITUDE", null);
- }
- if (latitude==null || longitude==null) {
- throw new CadiException(Config.CADI_LATITUDE + " and " + Config.CADI_LONGITUDE + " is required");
- } else {
- mep.setLatitude(Float.parseFloat(latitude));
- mep.setLongitude(Float.parseFloat(longitude));
- }
- String split[] = Split.split('.', version);
- mep.setPkg(split.length>3?Integer.parseInt(split[3]):0);
- mep.setPatch(split.length>2?Integer.parseInt(split[2]):0);
- mep.setMinor(split.length>1?Integer.parseInt(split[1]):0);
- mep.setMajor(split.length>0?Integer.parseInt(split[0]):0);
-
- String subprotocols = access.getProperty(Config.CADI_PROTOCOLS, null);
- if (subprotocols==null) {
- mep.setProtocol("http");
- } else {
- mep.setProtocol("https");
- for (String s : Split.split(',', subprotocols)) {
- mep.getSubprotocol().add(s);
- }
- }
- } catch (NumberFormatException | UnknownHostException e) {
- throw new CadiException("Error extracting Data from Properties for Registrar",e);
- }
- meps = new MgmtEndpoints();
- meps.getMgmtEndpoint().add(mep);
- for (RemoteRegistrant<ENV> rr : others) {
- meps.getMgmtEndpoint().add(rr.mep);
- }
+ RegistrationCreator rcreator = new RegistrationCreator(access);
+ meps = rcreator.create(port);
}
- @Override
+
+
+ @Override
public Result<Void> update(ENV env) {
try {
Rcli<?> client = aafcon.client(locator);
diff --git a/cadi/client/pom.xml b/cadi/client/pom.xml
index 3563be7a..b27d37c4 100644
--- a/cadi/client/pom.xml
+++ b/cadi/client/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>cadiparent</artifactId>
- <version>2.1.9-SNAPSHOT</version>
+ <version>2.1.10-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java
index d8852834..daca47df 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java
@@ -40,6 +40,7 @@ import org.onap.aaf.cadi.SecuritySetter;
import org.onap.aaf.cadi.client.EClient;
import org.onap.aaf.cadi.client.Future;
import org.onap.aaf.cadi.client.Rcli;
+import org.onap.aaf.cadi.util.FixURIinfo;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Data;
import org.onap.aaf.misc.env.Data.TYPE;
@@ -109,24 +110,23 @@ public class HClient implements EClient<HttpURLConnection> {
@Override
public void send() throws APIException {
- try {
- // Build URL from given URI plus current Settings
- if (uri.getPath()==null) {
- throw new APIException("Invalid URL entered for HClient");
- }
- StringBuilder pi=null;
- if (pathinfo!=null) { // additional pathinfo
- pi = new StringBuilder(uri.getPath());
- if (!pathinfo.startsWith("/")) {
- pi.append('/');
- }
- pi.append(pathinfo);
+ // Build URL from given URI plus current Settings
+ if (uri.getPath()==null) {
+ throw new APIException("Invalid URL entered for HClient");
+ }
+ StringBuilder pi=null;
+ if (pathinfo!=null) { // additional pathinfo
+ pi = new StringBuilder(uri.getPath());
+ if (!pathinfo.startsWith("/")) {
+ pi.append('/');
}
- URI sendURI = new URI(
+ pi.append(pathinfo);
+ }
+ URI sendURI = null;
+ try {
+ sendURI = new URI(
uri.getScheme(),
- uri.getUserInfo(),
- uri.getHost(),
- uri.getPort(),
+ uri.getAuthority(),
pi==null?uri.getPath():pi.toString(),
query==null?uri.getQuery():query,
fragment==null?uri.getFragment():fragment
@@ -149,8 +149,14 @@ public class HClient implements EClient<HttpURLConnection> {
transfer.transfer(huc.getOutputStream());
}
// TODO other settings? There's a bunch here.
+ } catch (APIException e) {
+ throw e;
} catch (Exception e) {
- throw new APIException(e);
+ if(sendURI==null) {
+ throw new APIException("Cannot connect to Root URI: " + uri.toString(),e);
+ } else {
+ throw new APIException("Cannot connect to " + sendURI.toString() + "(Root URI: " + uri.toString() +')',e);
+ }
} finally { // ensure all these are reset after sends
meth=pathinfo=null;
if (headers!=null) {
@@ -171,9 +177,7 @@ public class HClient implements EClient<HttpURLConnection> {
protected HttpURLConnection getConnection(URI uri, StringBuilder pi) throws IOException, URISyntaxException {
URL url = new URI(
uri.getScheme(),
- uri.getUserInfo(),
- uri.getHost(),
- uri.getPort(),
+ uri.getAuthority(),
pi==null?uri.getPath():pi.toString(),
query,
fragment).toURL();
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java
index 8e3138af..1e5c5211 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java
@@ -30,14 +30,15 @@ import java.net.URISyntaxException;
import javax.net.ssl.SSLHandshakeException;
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.Locator.Item;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.SecuritySetter;
-import org.onap.aaf.cadi.Access.Level;
-import org.onap.aaf.cadi.Locator.Item;
import org.onap.aaf.cadi.client.Rcli;
import org.onap.aaf.cadi.client.Retryable;
+import org.onap.aaf.cadi.util.FixURIinfo;
import org.onap.aaf.misc.env.APIException;
public class HMangr {
@@ -174,7 +175,8 @@ public class HMangr {
loc.refresh();
for (Item li=loc.first();li!=null;li=loc.next(li)) {
URI uri=loc.get(li);
- if (host!=null && !host.equals(uri.getHost())) {
+ FixURIinfo fui = new FixURIinfo(uri);
+ if (host!=null && !host.equals(fui.getHost())) {
break;
}
try {
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java
index eb0ecf11..bccb8116 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java
@@ -36,6 +36,7 @@ import java.util.TimerTask;
import org.onap.aaf.cadi.Locator;
import org.onap.aaf.cadi.LocatorException;
+import org.onap.aaf.cadi.util.FixURIinfo;
import org.onap.aaf.misc.env.util.Split;
public class PropertyLocator implements Locator<URI> {
@@ -181,7 +182,8 @@ public class PropertyLocator implements Locator<URI> {
String realname;
for (int i = 0; i < orig.length ; ++i) {
try {
- InetAddress ia[] = InetAddress.getAllByName(orig[i].getHost());
+ FixURIinfo fui = new FixURIinfo(orig[i]);
+ InetAddress ia[] = InetAddress.getAllByName(fui.getHost());
URI o,n;
for (int j=0;j<ia.length;++j) {
diff --git a/cadi/core/pom.xml b/cadi/core/pom.xml
index 51a0d09f..c02d0f84 100644
--- a/cadi/core/pom.xml
+++ b/cadi/core/pom.xml
@@ -16,7 +16,7 @@
<groupId>org.onap.aaf.authz</groupId>
<artifactId>cadiparent</artifactId>
<relativePath>..</relativePath>
- <version>2.1.9-SNAPSHOT</version>
+ <version>2.1.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java b/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
index a9d671cc..599bb984 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
@@ -26,6 +26,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -106,7 +108,7 @@ public class PropAccess implements Access {
// First, load related System Properties
for (Entry<Object,Object> es : System.getProperties().entrySet()) {
String key = es.getKey().toString();
- for (String start : new String[] {"cadi_","aaf_","cm_"}) {
+ for (String start : new String[] {"HOSTNAME","cadi_","aaf_","cm_"}) {
if (key.startsWith(start)) {
props.put(key, es.getValue());
}
@@ -274,41 +276,53 @@ public class PropAccess implements Access {
sb.append("] ");
} else {
int idx = 0;
- if (elements[idx] instanceof Integer) {
+ if(elements[idx]!=null &&
+ elements[idx] instanceof Integer) {
sb.append('-');
sb.append(elements[idx]);
++idx;
}
sb.append("] ");
- String s;
- boolean first = true;
- for (Object o : elements) {
- if (o!=null) {
- s=o.toString();
- if (first) {
- first = false;
- } else {
- int l = s.length();
- if (l>0) {
- switch(s.charAt(l-1)) {
- case ' ':
- break;
- default:
- sb.append(' ');
- }
- }
- }
- sb.append(s);
- }
- }
+ write(true,sb,elements);
}
return sb;
}
+
+ private static boolean write(boolean first, StringBuilder sb, Object[] elements) {
+ String s;
+ for (Object o : elements) {
+ if (o!=null) {
+ if(o.getClass().isArray()) {
+ first = write(first,sb,(Object[])o);
+ } else {
+ s=o.toString();
+ if (first) {
+ first = false;
+ } else {
+ int l = s.length();
+ if (l>0) {
+ switch(s.charAt(l-1)) {
+ case ' ':
+ break;
+ default:
+ sb.append(' ');
+ }
+ }
+ }
+ sb.append(s);
+ }
+ }
+ }
+ return first;
+ }
@Override
public void log(Exception e, Object... elements) {
- log(Level.ERROR,e.getMessage(),elements);
- e.printStackTrace(System.err);
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ pw.println();
+ e.printStackTrace(pw);
+ log(Level.ERROR,elements,sw.toString());
}
@Override
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 353e8e38..245b6539 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
@@ -58,6 +58,7 @@ import org.onap.aaf.cadi.taf.HttpTaf;
import org.onap.aaf.cadi.taf.basic.BasicHttpTaf;
import org.onap.aaf.cadi.taf.cert.X509Taf;
import org.onap.aaf.cadi.taf.dos.DenialOfServiceTaf;
+import org.onap.aaf.cadi.util.FixURIinfo;
import org.onap.aaf.cadi.util.Split;
/**
@@ -158,13 +159,31 @@ public class Config {
public static final String OAUTH2_TOKEN_URL = "https://AAF_LOCATE_URL/AAF_NS.token:" + AAF_DEFAULT_API_VERSION;
public static final String OAUTH2_INTROSPECT_URL = "https://AAF_LOCATE_URL/AAF_NS.introspect:" + AAF_DEFAULT_API_VERSION;
- public static final String AAF_REGISTER_AS = "aaf_register_as";
+ public static final String AAF_LOCATOR_CLASS = "aaf_locator_class";
+ // AAF Locator Entries are ADDITIONAL entries, which also gives the Property ability
+ // to set these entries manually
+ // example: adding a K8S name like "oom"
+ // this will allow Registrations to pick up
+ // locator_ns.oom for onap's "OOM" based k8s entries, etc.
+ public static final String AAF_LOCATOR_CONTAINER="aaf_locator_container";
+ // An ID for another Container, to be used to avoid picking up the wrong internal info
+ // for another container.
+ public static final String AAF_LOCATOR_CONTAINER_ID = "aaf_locator_container_id";
+ public static final String AAF_LOCATOR_CONTAINER_NS = "aaf_locator_container_ns";
+ public static final String AAF_LOCATOR_VERSION = "aaf_locator_version";
+ public static final String AAF_LOCATOR_PROTOCOL = "aaf_locator_protocol";
+ public static final String AAF_LOCATOR_SUBPROTOCOL = "aaf_locator_subprotocol";
+ public static final String AAF_LOCATOR_NS = "aaf_locator_ns";
+ public static final String AAF_LOCATOR_NAMES = "aaf_locator_names";
+ public static final String AAF_LOCATOR_FQDN = "aaf_locator_fqdn";
+ public static final String AAF_LOCATOR_PUBLIC_PORT = "aaf_locator_public_port";
+ public static final String AAF_LOCATOR_PUBLIC_HOSTNAME = "aaf_locator_public_hostname";
+
public static final String AAF_APPID = "aaf_id";
public static final String AAF_APPPASS = "aaf_password";
public static final String AAF_LUR_CLASS = "aaf_lur_class";
public static final String AAF_TAF_CLASS = "aaf_taf_class";
public static final String AAF_CONNECTOR_CLASS = "aaf_connector_class";
- public static final String AAF_LOCATOR_CLASS = "aaf_locator_class";
public static final String AAF_CONN_TIMEOUT = "aaf_conn_timeout";
public static final String AAF_CONN_TIMEOUT_DEF = "3000";
public static final String AAF_CONN_IDLE_TIMEOUT = "aaf_conn_idle_timeout"; // only for Direct Jetty Access.
@@ -189,7 +208,7 @@ public class Config {
public static final String AAF_HIGH_COUNT = "aaf_high_count";
public static final String AAF_HIGH_COUNT_DEF = "1000"; // Default is 1000 entries
public static final String AAF_PERM_MAP = "aaf_perm_map";
- public static final String AAF_COMPONENT = "aaf_component";
+// public static final String AAF_COMPONENT = "aaf_component";
public static final String AAF_CERT_IDS = "aaf_cert_ids";
public static final String AAF_DEBUG_IDS = "aaf_debug_ids"; // comma delimited
public static final String AAF_DATA_DIR = "aaf_data_dir"; // AAF processes and Components only.
@@ -795,18 +814,39 @@ public class Config {
if (_url==null) {
access.log(Level.INIT,"No URL passed to 'loadLocator'. Disabled");
} else {
- String url = _url;
+ String url = _url.replace("/AAF_NS.", "/%C%CID%AAF_NS.");
+ String root_ns = access.getProperty(Config.AAF_ROOT_NS, null);
+ if(url.indexOf('%')>=0) {
+ String str = access.getProperty(Config.AAF_LOCATOR_CONTAINER_ID, null);
+ if(str==null) {
+ url = url.replace("%CID","");
+ } else {
+ url = url.replace("%CID",str+'.');
+ }
+ str = access.getProperty(Config.AAF_LOCATOR_CONTAINER, null);
+ if(str==null) {
+ url = url.replace("%C","");
+ } else {
+ url = url.replace("%C",str+'.');
+ }
+
+ if (root_ns==null) {
+ url = url.replace("%AAF_NS","");
+ } else {
+ url = url.replace("%AAF_NS",root_ns);
+ }
+ }
String replacement;
int idxAAFLocateUrl;
- if ((idxAAFLocateUrl=_url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) {
+ 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());
+ 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) {
@@ -821,12 +861,13 @@ public class Config {
}
if (locator==null) {
URI locatorURI = new URI(url);
+ FixURIinfo fui = new FixURIinfo(locatorURI);
Constructor<?> cnst = lcls.getConstructor(SecurityInfoC.class,URI.class);
locator = (Locator<URI>)cnst.newInstance(new Object[] {si,locatorURI});
- int port = locatorURI.getPort();
- String portS = port<0?"":(":"+locatorURI.getPort());
+ int port = fui.getPort();
+ String portS = port<0?"":(":"+port);
- access.log(Level.INFO, "AAFLocator enabled using " + locatorURI.getScheme() +"://"+locatorURI.getHost() + portS);
+ access.log(Level.INFO, "AAFLocator enabled using " + locatorURI.getScheme() +"://"+fui.getHost() + portS);
} else {
access.log(Level.INFO, "AAFLocator enabled using preloaded " + locator.getClass().getSimpleName());
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
index 2305eacd..cd8eff44 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
@@ -139,7 +139,7 @@ public class CadiFilter implements Filter {
@SuppressWarnings("unchecked")
- private void init(Get getter) throws ServletException {
+ protected void init(Get getter) throws ServletException {
sideChain = new SideChain();
// Start with the assumption of "Don't trust anyone".
TrustChecker tc = TrustChecker.NOTRUST; // default position
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java
index cf7c922d..1805c782 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java
@@ -32,7 +32,7 @@ import org.onap.aaf.cadi.config.Get;
* A private method to query the Filter config and if not exists, return the default. This
* cleans up the initialization code.
*/
-class FCGet implements Get {
+public class FCGet implements Get {
/**
*
*/
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java
new file mode 100644
index 00000000..7e3a239b
--- /dev/null
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java
@@ -0,0 +1,66 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+
+package org.onap.aaf.cadi.util;
+
+import java.net.URI;
+
+/**
+ * URI and URL, if the host does not have "dots", will interpret Host:port as Authority
+ *
+ * This is very problematic for Containers, which like single name entries.
+ * @author Instrumental(Jonathan)
+ *
+ */
+public class FixURIinfo {
+ private String auth;
+ private String host;
+ private int port;
+
+ public FixURIinfo(URI uri) {
+ auth = uri.getAuthority();
+ host = uri.getHost();
+ if(host==null) {
+ if(auth!=null) {
+ int colon = auth.indexOf(':');
+ if(colon >= 0 ) {
+ host = auth.substring(0, colon);
+ port = Integer.parseInt(auth.substring(colon+1));
+ } else {
+ host = auth;
+ port = uri.getPort();
+ }
+ auth=null;
+ }
+ }
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public String getUserInfo() {
+ return auth;
+ }
+}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java
index 4bb1d3b8..97afa65c 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java
@@ -31,84 +31,93 @@ package org.onap.aaf.cadi.util;
*/
public class Split {
- public static String[] split(char c, String value) {
- return split(c,value,0,value.length());
- }
+ private static final String[] EMPTY = new String[0];
- public static String[] split(char c, String value, int start, int end) {
- if (value==null) {
- return new String[0];
- }
+ public static String[] split(char c, String value) {
+ if (value==null) {
+ return EMPTY;
+ }
- // Count items to preallocate Array (memory alloc is more expensive than counting twice)
- int count,idx;
- for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
- String[] rv = new String[count];
- if (count==1) {
- rv[0]=value.substring(start,end);
- } else {
- int last=0;
- count=-1;
- for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
- rv[++count]=value.substring(last,idx);
- last = ++idx;
- }
- rv[++count]=value.substring(last,end);
- }
- return rv;
- }
+ return split(c,value,0,value.length());
+ }
- public static String[] splitTrim(char c, String value, int start, int end) {
- if (value==null) {
- return new String[0];
- }
+ public static String[] split(char c, String value, int start, int end) {
+ if (value==null) {
+ return EMPTY;
+ }
- // Count items to preallocate Array (memory alloc is more expensive than counting twice)
- int count,idx;
- for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
- String[] rv = new String[count];
- if (count==1) {
- rv[0]=value.substring(start,end).trim();
- } else {
- int last=0;
- count=-1;
- for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
- rv[++count]=value.substring(last,idx).trim();
- last = ++idx;
- }
- rv[++count]=value.substring(last,end).trim();
- }
- return rv;
- }
+ // Count items to preallocate Array (memory alloc is more expensive than counting twice)
+ int count,idx;
+ for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
+ String[] rv = new String[count];
+ if (count==1) {
+ rv[0]=value.substring(start,end);
+ } else {
+ int last=0;
+ count=-1;
+ for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
+ rv[++count]=value.substring(last,idx);
+ last = ++idx;
+ }
+ rv[++count]=value.substring(last,end);
+ }
+ return rv;
+ }
- public static String[] splitTrim(char c, String value) {
- return splitTrim(c,value,0,value.length());
- }
+ public static String[] splitTrim(char c, String value, int start, int end) {
+ if (value==null) {
+ return EMPTY;
+ }
- public static String[] splitTrim(char c, String value, int size) {
- if (value==null) {
- return new String[0];
- }
+ // Count items to preallocate Array (memory alloc is more expensive than counting twice)
+ int count,idx;
+ for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
+ String[] rv = new String[count];
+ if (count==1) {
+ rv[0]=value.substring(start,end).trim();
+ } else {
+ int last=0;
+ count=-1;
+ for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
+ rv[++count]=value.substring(last,idx).trim();
+ last = ++idx;
+ }
+ rv[++count]=value.substring(last,end).trim();
+ }
+ return rv;
+ }
- int idx;
- String[] rv = new String[size];
- if (size==1) {
- rv[0]=value.trim();
- } else {
- int last=0;
- int count=-1;
- size-=2;
- for (idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {
- rv[++count]=value.substring(last,idx).trim();
- last = ++idx;
- }
- if (idx>0) {
- rv[++count]=value.substring(last,idx).trim();
- } else {
- rv[++count]=value.substring(last).trim();
- }
- }
- return rv;
- }
+ public static String[] splitTrim(char c, String value) {
+ if (value==null) {
+ return EMPTY;
+ }
+ return splitTrim(c,value,0,value.length());
+ }
+
+ public static String[] splitTrim(char c, String value, int size) {
+ if (value==null) {
+ return EMPTY;
+ }
+
+ int idx;
+ String[] rv = new String[size];
+ if (size==1) {
+ rv[0]=value.trim();
+ } else {
+ int last=0;
+ int count=-1;
+ size-=2;
+ for (idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {
+ rv[++count]=value.substring(last,idx).trim();
+ last = ++idx;
+ }
+ if (idx>0) {
+ rv[++count]=value.substring(last,idx).trim();
+ } else {
+ rv[++count]=value.substring(last).trim();
+ }
+ }
+ return rv;
+ }
}
diff --git a/cadi/oauth-enduser/pom.xml b/cadi/oauth-enduser/pom.xml
index d9d52141..d04e12b5 100644
--- a/cadi/oauth-enduser/pom.xml
+++ b/cadi/oauth-enduser/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>cadiparent</artifactId>
- <version>2.1.9-SNAPSHOT</version>
+ <version>2.1.10-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
diff --git a/cadi/pom.xml b/cadi/pom.xml
index 4b02ebef..7e7458a6 100644
--- a/cadi/pom.xml
+++ b/cadi/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>parent</artifactId>
- <version>2.1.9-SNAPSHOT</version>
+ <version>2.1.10-SNAPSHOT</version>
</parent>
<artifactId>cadiparent</artifactId>
<name>AAF CADI Parent (Code, Access, Data, Identity)</name>
diff --git a/cadi/servlet-sample/pom.xml b/cadi/servlet-sample/pom.xml
index ec73e2f3..ca441079 100644
--- a/cadi/servlet-sample/pom.xml
+++ b/cadi/servlet-sample/pom.xml
@@ -4,7 +4,7 @@
<groupId>org.onap.aaf.authz</groupId>
<artifactId>cadiparent</artifactId>
<relativePath>..</relativePath>
- <version>2.1.9-SNAPSHOT</version>
+ <version>2.1.10-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>CADI Servlet Sample (Test Only)</name>