summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java6
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java16
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java90
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/ErrMessage.java2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/Examples.java34
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java234
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLocator.java2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFSingleLocator.java100
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFTaf.java16
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java36
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLur.java2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java408
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/ArtifactDir.java22
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PlaceArtifactInKeystore.java20
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java172
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java12
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java406
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java6
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java74
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthn.java320
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFSingleLocator.java182
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java262
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/sso/test/JU_AAFSSO.java10
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java2
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java16
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java4
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java16
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java2
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java6
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java138
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java4
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java280
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java494
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java116
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiApiEnforcementFilter.java156
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java10
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java34
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java156
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/filter/SideChain.java60
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/AbsTafResp.java16
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/NullTafResp.java14
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/PuntTafResp.java14
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustNotTafResp.java14
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustTafResp.java14
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java16
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/cert/X509Taf.java74
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java458
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java64
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java158
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_MapBathConverter.java386
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_RegistrationPropHolder.java208
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_CSV.java146
-rw-r--r--cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OAuthExample.java16
-rw-r--r--cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OnapClientExample.java6
57 files changed, 2768 insertions, 2768 deletions
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java
index 037ee8be..8c39e44d 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/AAFPermission.java
@@ -83,9 +83,9 @@ public class AAFPermission implements Permission {
* If you want a simple field comparison, it is faster without REGEX
*/
public boolean match(Permission p) {
- if(p==null) {
- return false;
- }
+ if(p==null) {
+ return false;
+ }
String aafNS;
String aafType;
String aafInstance;
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java
index 7c843dbd..498f1bf9 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java
@@ -67,20 +67,20 @@ public class PermEval {
String[] skeys=Split.split(startChar,sInst);
String[] pkeys=Split.split(startChar,pInst);
if (pkeys.length<skeys.length) {
- return false;
+ return false;
} else if(pkeys.length > skeys.length &&
- (skeys.length==0 || !ASTERIX.equals(skeys[skeys.length-1]))) {
- return false;
+ (skeys.length==0 || !ASTERIX.equals(skeys[skeys.length-1]))) {
+ return false;
}
boolean pass = true;
for (int i=1;pass && i<skeys.length;++i) { // We start at 1, because the first one, being ":" is always ""
if (ASTERIX.equals(skeys[i])) {
- if(i==skeys.length-1) {
- // accept all after
- return true;
- }
- continue; // Server data accepts all for this key spot
+ if(i==skeys.length-1) {
+ // accept all after
+ return true;
+ }
+ continue; // Server data accepts all for this key spot
}
pass = false;
for (String sItem : Split.split(LIST_SEP,skeys[i])) { // allow for "," definition in Action
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 efcaa7ef..2f2d2ac3 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
@@ -57,7 +57,7 @@ public class TestConnectivity {
private static Map<String, String> aaf_urls;
- public static void main(String[] args) {
+ public static void main(String[] args) {
if (args.length<1) {
System.out.println("Usage: ConnectivityTester <cadi_prop_files> [<AAF FQDN (i.e. aaf.dev.att.com)>]");
} else {
@@ -84,48 +84,48 @@ public class TestConnectivity {
SecuritySetter<HttpURLConnection> ss = si.defSS;
permTest(locator,ss);
} else {
- /////////
- print(true,"Test Connections driven by AAFLocator");
- String serviceURI = aaf_urls.get(Config.AAF_URL);
-
- for (String url : new String[] {
- serviceURI,
- aaf_urls.get(Config.AAF_OAUTH2_TOKEN_URL),
- aaf_urls.get(Config.AAF_OAUTH2_INTROSPECT_URL),
- aaf_urls.get(Config.AAF_URL_CM),
- aaf_urls.get(Config.AAF_URL_GUI),
- aaf_urls.get(Config.AAF_URL_FS),
- aaf_urls.get(Config.AAF_URL_HELLO)
- }) {
- URI uri = new URI(url);
- Locator<URI> locator = new AAFLocator(si, uri);
- try {
- connectTest(locator, uri);
- } catch (Exception e) {
- e.printStackTrace();
- System.err.flush();
- }
- }
+ /////////
+ print(true,"Test Connections driven by AAFLocator");
+ String serviceURI = aaf_urls.get(Config.AAF_URL);
+
+ for (String url : new String[] {
+ serviceURI,
+ aaf_urls.get(Config.AAF_OAUTH2_TOKEN_URL),
+ aaf_urls.get(Config.AAF_OAUTH2_INTROSPECT_URL),
+ aaf_urls.get(Config.AAF_URL_CM),
+ aaf_urls.get(Config.AAF_URL_GUI),
+ aaf_urls.get(Config.AAF_URL_FS),
+ aaf_urls.get(Config.AAF_URL_HELLO)
+ }) {
+ URI uri = new URI(url);
+ Locator<URI> locator = new AAFLocator(si, uri);
+ try {
+ connectTest(locator, uri);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.err.flush();
+ }
+ }
- /////////
- print(true,"Test Service for Perms driven by AAFLocator");
- Locator<URI> locator = new AAFLocator(si,new URI(serviceURI));
- for (SecuritySetter<HttpURLConnection> ss : lss) {
- permTest(locator,ss);
- }
+ /////////
+ print(true,"Test Service for Perms driven by AAFLocator");
+ Locator<URI> locator = new AAFLocator(si,new URI(serviceURI));
+ for (SecuritySetter<HttpURLConnection> ss : lss) {
+ permTest(locator,ss);
+ }
- //////////
- print(true,"Test essential BasicAuth Service call, driven by AAFLocator");
- boolean hasBath=false;
- for (SecuritySetter<HttpURLConnection> ss : lss) {
- if (ss instanceof HBasicAuthSS) {
- hasBath=true;
- basicAuthTest(new AAFLocator(si, new URI(serviceURI)),ss);
- }
- }
- if(!hasBath) {
- System.out.println("No User/Password to test");
- }
+ //////////
+ print(true,"Test essential BasicAuth Service call, driven by AAFLocator");
+ boolean hasBath=false;
+ for (SecuritySetter<HttpURLConnection> ss : lss) {
+ if (ss instanceof HBasicAuthSS) {
+ hasBath=true;
+ basicAuthTest(new AAFLocator(si, new URI(serviceURI)),ss);
+ }
+ }
+ if(!hasBath) {
+ System.out.println("No User/Password to test");
+ }
}
} catch (Exception e) {
@@ -137,7 +137,7 @@ public class TestConnectivity {
}
- private static List<SecuritySetter<HttpURLConnection>> loadSetters(PropAccess access, SecurityInfoC<HttpURLConnection> si) {
+ private static List<SecuritySetter<HttpURLConnection>> loadSetters(PropAccess access, SecurityInfoC<HttpURLConnection> si) {
print(true,"Load Security Setters from Configuration Information");
String user = access.getProperty(Config.AAF_APPID);
@@ -227,10 +227,10 @@ public class TestConnectivity {
if ((uri = dl.get(li)) == null) {
System.out.println("Locator Item empty");
} else {
- System.out.printf("Located %s using %s\n",uri.toString(), locatorURI.toString());
+ System.out.printf("Located %s using %s\n",uri.toString(), locatorURI.toString());
socket = new Socket();
try {
- FixURIinfo fui = new FixURIinfo(uri);
+ FixURIinfo fui = new FixURIinfo(uri);
try {
socket.connect(new InetSocketAddress(fui.getHost(), fui.getPort()),3000);
System.out.printf("Can Connect a Socket to %s %d\n",fui.getHost(),fui.getPort());
@@ -261,7 +261,7 @@ public class TestConnectivity {
if (ss instanceof HRenewingTokenSS) {
System.out.println(" " + ((HRenewingTokenSS)ss).tokenURL());
} else {
- System.out.println();
+ System.out.println();
}
HClient client = new HClient(ss, uri, 3000);
client.setMethod("GET");
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/ErrMessage.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/ErrMessage.java
index 42efd89b..d5a2e58a 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/ErrMessage.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/ErrMessage.java
@@ -95,6 +95,6 @@ public class ErrMessage {
}
public Error getError(Future<?> future) throws APIException {
- return errDF.newData().in(TYPE.JSON).load(future.body()).asObject();
+ return errDF.newData().in(TYPE.JSON).load(future.body()).asObject();
}
}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/Examples.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/Examples.java
index b43c418b..921b5096 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/Examples.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/client/Examples.java
@@ -100,25 +100,25 @@ public class Examples {
}
Class<?> cls=null;
- int minorIdx = version.indexOf('_');
- if(minorIdx<0) {
- throw new APIException("Invalid Interface Version " + version);
- }
- int minor = Integer.parseInt(version.substring(minorIdx+1));
- String vprefix=version.substring(0, minorIdx+1);
- while(cls==null && minor>=0) {
- try {
- cls = Examples.class.getClassLoader().loadClass("aaf."+vprefix+minor+'.'+className);
+ int minorIdx = version.indexOf('_');
+ if(minorIdx<0) {
+ throw new APIException("Invalid Interface Version " + version);
+ }
+ int minor = Integer.parseInt(version.substring(minorIdx+1));
+ String vprefix=version.substring(0, minorIdx+1);
+ while(cls==null && minor>=0) {
+ try {
+ cls = Examples.class.getClassLoader().loadClass("aaf."+vprefix+minor+'.'+className);
} catch (ClassNotFoundException e) {
- if(--minor<0) {
- throw new APIException("No Example for Version " + version + " found.");
- }
+ if(--minor<0) {
+ throw new APIException("No Example for Version " + version + " found.");
+ }
}
- }
-
- if(cls==null) {
- throw new APIException("ERROR: " + "aaf."+vprefix+"X not found.");
- }
+ }
+
+ if(cls==null) {
+ throw new APIException("ERROR: " + "aaf."+vprefix+"X not found.");
+ }
Method meth;
try {
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java
index e40743da..40684057 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java
@@ -79,123 +79,123 @@ public abstract class AAFCon<CLIENT> implements Connector {
final public RosettaEnv env;
protected AAFCon(AAFCon<CLIENT> copy) {
- access = copy.access;
- apiVersion = access.getProperty(Config.AAF_API_VERSION, Config.AAF_DEFAULT_API_VERSION);
- timeout = copy.timeout;
- cleanInterval = copy.cleanInterval;
- connTimeout = copy.connTimeout;
- highCount = copy.highCount;
- userExpires = copy.userExpires;
- usageRefreshTriggerCount = copy.usageRefreshTriggerCount;
- permsDF = copy.permsDF;
- certsDF = copy.certsDF;
- usersDF = copy.usersDF;
- errDF = copy.errDF;
- app = copy.app;
- si = copy.si;
- env = copy.env;
- realm = copy.realm;
- }
- protected AAFCon(Access access, String tag, SecurityInfoC<CLIENT> si) throws CadiException{
- apiVersion = access.getProperty(Config.AAF_API_VERSION, Config.AAF_DEFAULT_API_VERSION);
- if (tag==null) {
- throw new CadiException("AAFCon cannot be constructed without a property tag or URL");
- } else {
- String str = access.getProperty(tag,null);
- if (str==null) {
- if (tag.contains("://")) { // assume a URL
- str = tag;
- } else {
- throw new CadiException("A URL or " + tag + " property is required.");
- }
- }
- try {
- RegistrationPropHolder rph = new RegistrationPropHolder(access, 0);
- str = rph.replacements("AAFCon",str, null,null);
- } catch (UnknownHostException e) {
- throw new CadiException(e);
- }
- access.printf(Level.INFO, "AAFCon has URL of %s",str);
- setInitURI(str);
- }
- try {
- this.access = access;
- this.si = si;
- if (si.defSS.getID().equals(SecurityInfoC.DEF_ID)) { // it's the Preliminary SS, try to get a better one
- String mechid = access.getProperty(Config.AAF_APPID, null);
- if (mechid==null) {
- mechid=access.getProperty(Config.OAUTH_CLIENT_ID,null);
- }
- String alias = access.getProperty(Config.CADI_ALIAS, null);
- if(alias != null) {
- si.defSS=x509Alias(alias);
- set(si.defSS);
- } else {
-
- String encpass = access.getProperty(Config.AAF_APPPASS, null);
- if (encpass==null) {
- encpass = access.getProperty(Config.OAUTH_CLIENT_SECRET,null);
- }
-
- if (encpass==null) {
- if (alias==null) {
- access.printf(Access.Level.WARN,"%s, %s or %s required before use.", Config.CADI_ALIAS, Config.AAF_APPID, Config.OAUTH_CLIENT_ID);
- set(si.defSS);
- }
- } else {
- if (mechid!=null) {
- si.defSS=basicAuth(mechid, encpass);
- set(si.defSS);
- } else {
- si.defSS=new SecuritySetter<CLIENT>() {
-
- @Override
- public String getID() {
- return "";
- }
-
- @Override
- public void setSecurity(CLIENT client) throws CadiException {
- throw new CadiException("AAFCon has not been initialized with Credentials (SecuritySetter)");
- }
-
- @Override
- public int setLastResponse(int respCode) {
- return 0;
- }
- };
- set(si.defSS);
- }
- }
- }
- }
-
- timeout = Integer.parseInt(access.getProperty(Config.AAF_CALL_TIMEOUT, Config.AAF_CALL_TIMEOUT_DEF));
- cleanInterval = Integer.parseInt(access.getProperty(Config.AAF_CLEAN_INTERVAL, Config.AAF_CLEAN_INTERVAL_DEF));
- highCount = Integer.parseInt(access.getProperty(Config.AAF_HIGH_COUNT, Config.AAF_HIGH_COUNT_DEF).trim());
- connTimeout = Integer.parseInt(access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF).trim());
- userExpires = Integer.parseInt(access.getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF).trim());
- usageRefreshTriggerCount = Integer.parseInt(access.getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF).trim())-1; // zero based
-
- app=FQI.reverseDomain(si.defSS.getID());
- //TODO Get Realm from AAF
- realm="people.osaaf.org";
-
- env = new RosettaEnv();
- permsDF = env.newDataFactory(Perms.class);
- usersDF = env.newDataFactory(Users.class);
- certsDF = env.newDataFactory(Certs.class);
- certsDF.rootMarshal(new CertsMarshal()); // Speedier Marshaling
- errDF = env.newDataFactory(Error.class);
- } catch (APIException e) {
- throw new CadiException("AAFCon cannot be configured",e);
- }
- }
- protected abstract URI initURI();
+ access = copy.access;
+ apiVersion = access.getProperty(Config.AAF_API_VERSION, Config.AAF_DEFAULT_API_VERSION);
+ timeout = copy.timeout;
+ cleanInterval = copy.cleanInterval;
+ connTimeout = copy.connTimeout;
+ highCount = copy.highCount;
+ userExpires = copy.userExpires;
+ usageRefreshTriggerCount = copy.usageRefreshTriggerCount;
+ permsDF = copy.permsDF;
+ certsDF = copy.certsDF;
+ usersDF = copy.usersDF;
+ errDF = copy.errDF;
+ app = copy.app;
+ si = copy.si;
+ env = copy.env;
+ realm = copy.realm;
+ }
+ protected AAFCon(Access access, String tag, SecurityInfoC<CLIENT> si) throws CadiException{
+ apiVersion = access.getProperty(Config.AAF_API_VERSION, Config.AAF_DEFAULT_API_VERSION);
+ if (tag==null) {
+ throw new CadiException("AAFCon cannot be constructed without a property tag or URL");
+ } else {
+ String str = access.getProperty(tag,null);
+ if (str==null) {
+ if (tag.contains("://")) { // assume a URL
+ str = tag;
+ } else {
+ throw new CadiException("A URL or " + tag + " property is required.");
+ }
+ }
+ try {
+ RegistrationPropHolder rph = new RegistrationPropHolder(access, 0);
+ str = rph.replacements("AAFCon",str, null,null);
+ } catch (UnknownHostException e) {
+ throw new CadiException(e);
+ }
+ access.printf(Level.INFO, "AAFCon has URL of %s",str);
+ setInitURI(str);
+ }
+ try {
+ this.access = access;
+ this.si = si;
+ if (si.defSS.getID().equals(SecurityInfoC.DEF_ID)) { // it's the Preliminary SS, try to get a better one
+ String mechid = access.getProperty(Config.AAF_APPID, null);
+ if (mechid==null) {
+ mechid=access.getProperty(Config.OAUTH_CLIENT_ID,null);
+ }
+ String alias = access.getProperty(Config.CADI_ALIAS, null);
+ if(alias != null) {
+ si.defSS=x509Alias(alias);
+ set(si.defSS);
+ } else {
+
+ String encpass = access.getProperty(Config.AAF_APPPASS, null);
+ if (encpass==null) {
+ encpass = access.getProperty(Config.OAUTH_CLIENT_SECRET,null);
+ }
+
+ if (encpass==null) {
+ if (alias==null) {
+ access.printf(Access.Level.WARN,"%s, %s or %s required before use.", Config.CADI_ALIAS, Config.AAF_APPID, Config.OAUTH_CLIENT_ID);
+ set(si.defSS);
+ }
+ } else {
+ if (mechid!=null) {
+ si.defSS=basicAuth(mechid, encpass);
+ set(si.defSS);
+ } else {
+ si.defSS=new SecuritySetter<CLIENT>() {
+
+ @Override
+ public String getID() {
+ return "";
+ }
+
+ @Override
+ public void setSecurity(CLIENT client) throws CadiException {
+ throw new CadiException("AAFCon has not been initialized with Credentials (SecuritySetter)");
+ }
+
+ @Override
+ public int setLastResponse(int respCode) {
+ return 0;
+ }
+ };
+ set(si.defSS);
+ }
+ }
+ }
+ }
+
+ timeout = Integer.parseInt(access.getProperty(Config.AAF_CALL_TIMEOUT, Config.AAF_CALL_TIMEOUT_DEF));
+ cleanInterval = Integer.parseInt(access.getProperty(Config.AAF_CLEAN_INTERVAL, Config.AAF_CLEAN_INTERVAL_DEF));
+ highCount = Integer.parseInt(access.getProperty(Config.AAF_HIGH_COUNT, Config.AAF_HIGH_COUNT_DEF).trim());
+ connTimeout = Integer.parseInt(access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF).trim());
+ userExpires = Integer.parseInt(access.getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF).trim());
+ usageRefreshTriggerCount = Integer.parseInt(access.getProperty(Config.AAF_USER_EXPIRES, Config.AAF_USER_EXPIRES_DEF).trim())-1; // zero based
+
+ app=FQI.reverseDomain(si.defSS.getID());
+ //TODO Get Realm from AAF
+ realm="people.osaaf.org";
+
+ env = new RosettaEnv();
+ permsDF = env.newDataFactory(Perms.class);
+ usersDF = env.newDataFactory(Users.class);
+ certsDF = env.newDataFactory(Certs.class);
+ certsDF.rootMarshal(new CertsMarshal()); // Speedier Marshaling
+ errDF = env.newDataFactory(Error.class);
+ } catch (APIException e) {
+ throw new CadiException("AAFCon cannot be configured",e);
+ }
+ }
+ protected abstract URI initURI();
protected abstract void setInitURI(String uriString) throws CadiException;
public final String aafVersion() {
- return apiVersion;
+ return apiVersion;
}
/**
@@ -207,8 +207,8 @@ public abstract class AAFCon<CLIENT> implements Connector {
* @throws CadiException
*/
public Rcli<CLIENT> client() throws CadiException {
- return client(apiVersion);
- }
+ return client(apiVersion);
+ }
/**
* Use this call to get the appropriate client based on configuration (HTTP, future)
@@ -218,7 +218,7 @@ public abstract class AAFCon<CLIENT> implements Connector {
* @throws CadiException
*/
public Rcli<CLIENT> client(final String apiVersion) throws CadiException {
- Rcli<CLIENT> client = clients.get(apiVersion);
+ Rcli<CLIENT> client = clients.get(apiVersion);
if (client==null) {
client = rclient(initURI(),si.defSS);
client.apiVersion(apiVersion)
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 eda4a5aa..ed24b1ee 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
@@ -91,7 +91,7 @@ public class AAFLocator extends AbsAAFLocator<BasicTrans> {
}
if(si.access.willLog(Access.Level.DEBUG)) {
- si.access.log(Access.Level.DEBUG, "Root URI:",client.getURI());
+ si.access.log(Access.Level.DEBUG, "Root URI:",client.getURI());
}
}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java
index ace2c73f..9f537bd9 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLurPerm.java
@@ -122,7 +122,7 @@ public class AAFLurPerm extends AbsAAFLur<AAFPermission> {
StringBuilder sb = new StringBuilder("/authz/perms/user/");
sb.append(name);
if(details) {
- sb.append("?force");
+ sb.append("?force");
}
Future<Perms> fp = client.read(sb.toString(),aaf.permsDF);
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
index 80e9f190..8f4fff67 100644
--- 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
@@ -36,62 +36,62 @@ import org.onap.aaf.cadi.LocatorException;
*
*/
public class AAFSingleLocator implements Locator<URI> {
-
- private final URI 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;
- }
+ /**
+ * 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 boolean hasItems() {
+ return true;
+ }
- @Override
- public void invalidate(Item item) throws LocatorException {
- }
+ @Override
+ public void invalidate(Item item) throws LocatorException {
+ }
- @Override
- public Item best() throws LocatorException {
- return new SingleItem();
- }
+ @Override
+ public Item best() throws LocatorException {
+ return new SingleItem();
+ }
- @Override
- public Item first() 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 Item next(Item item) throws LocatorException {
+ return null; // only one item
+ }
- @Override
- public boolean refresh() {
- return false;
- }
+ @Override
+ public boolean refresh() {
+ return false;
+ }
- @Override
- public void destroy() {
- }
-
- private class SingleItem implements Item {
- }
-
- public static AAFSingleLocator create(Access access, String url) throws URISyntaxException {
- return new AAFSingleLocator(url);
- }
+ @Override
+ public void destroy() {
+ }
+
+ private class SingleItem implements Item {
+ }
+
+ public static AAFSingleLocator create(Access access, String url) throws URISyntaxException {
+ return new AAFSingleLocator(url);
+ }
}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFTaf.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFTaf.java
index a25d2502..81b55507 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFTaf.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFTaf.java
@@ -89,14 +89,14 @@ public class AAFTaf<CLIENT> extends AbsUserCache<AAFPermission> implements HttpT
private void initMapBathConverter() {
String csvFile = access.getProperty(Config.CADI_BATH_CONVERT, null);
if(csvFile==null) {
- mapIds=null;
+ mapIds=null;
} else {
- try {
- mapIds = new MapBathConverter(access, new CSV(access,csvFile));
- access.log(Level.INIT,"Basic Auth Conversion using",csvFile,"enabled" );
- } catch (IOException | CadiException e) {
- access.log(e,"Bath Map Conversion is not initialized (non fatal)");
- }
+ try {
+ mapIds = new MapBathConverter(access, new CSV(access,csvFile));
+ access.log(Level.INIT,"Basic Auth Conversion using",csvFile,"enabled" );
+ } catch (IOException | CadiException e) {
+ access.log(e,"Bath Map Conversion is not initialized (non fatal)");
+ }
}
}
@@ -112,7 +112,7 @@ public class AAFTaf<CLIENT> extends AbsUserCache<AAFPermission> implements HttpT
aaf.access.log(Level.WARN,"WARNING! BasicAuth has been used over an insecure channel");
}
if(mapIds != null) {
- authz = mapIds.convert(access, authz);
+ authz = mapIds.convert(access, authz);
}
try {
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 e43250a0..2fe3ffdb 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
@@ -66,20 +66,20 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
public AbsAAFLocator(Access access, String name, final long refreshMin) throws LocatorException {
- RegistrationPropHolder rph;
- try {
- rph = new RegistrationPropHolder(access, 0);
- } catch (UnknownHostException | CadiException e1) {
- throw new LocatorException(e1);
- }
+ RegistrationPropHolder rph;
try {
- aaf_locator_host = rph.replacements(getClass().getSimpleName(),"https://"+Config.AAF_LOCATE_URL_TAG,null,null);
- if(aaf_locator_host.endsWith("/locate")) {
+ rph = new RegistrationPropHolder(access, 0);
+ } catch (UnknownHostException | CadiException e1) {
+ throw new LocatorException(e1);
+ }
+ try {
+ aaf_locator_host = rph.replacements(getClass().getSimpleName(),"https://"+Config.AAF_LOCATE_URL_TAG,null,null);
+ if(aaf_locator_host.endsWith("/locate")) {
aaf_locator_uri = new URI(aaf_locator_host);
- } else {
- aaf_locator_uri = new URI(aaf_locator_host+"/locate");
- }
-
+ } else {
+ aaf_locator_uri = new URI(aaf_locator_host+"/locate");
+ }
+
access.printf(Level.INFO, "AbsAAFLocator AAF URI is %s",aaf_locator_uri);
} catch (URISyntaxException e) {
throw new LocatorException(e);
@@ -122,9 +122,9 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
}
public static Locator<URI> create(final String name, final String version) throws LocatorException {
- if(locatorCreator==null) {
- throw new LocatorException("LocatorCreator is not set");
- }
+ if(locatorCreator==null) {
+ throw new LocatorException("LocatorCreator is not set");
+ }
return locatorCreator.create(name, version);
}
@@ -138,7 +138,7 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
if (path.length>1 && "locate".equals(path[1])) {
return path[2];
} else if(path.length>1) {
- return path[1];
+ return path[1];
} else {
return locatorURI.toString();
}
@@ -471,8 +471,8 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
}
protected void clear() {
- epList.clear();
- earliest=0L;
+ epList.clear();
+ earliest=0L;
}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLur.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLur.java
index 34c55cee..ac6fc063 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLur.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLur.java
@@ -65,7 +65,7 @@ public abstract class AbsAAFLur<PERM extends Permission> extends AbsUserCache<PE
}
public void details(boolean on) {
- details = on;
+ details = on;
}
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 1a1d68da..1f6937bb 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
@@ -88,7 +88,7 @@ import locate.v1_1.Configuration.Props;
public class Agent {
private static final String AGENT_LOAD_URLS = "Agent:loadURLs";
- private static final String HASHES = "################################################################";
+ private static final String HASHES = "################################################################";
private static final String PRINT = "print";
private static final String FILE = "file";
public static final String PKCS12 = "pkcs12";
@@ -119,11 +119,11 @@ public class Agent {
Config.CADI_ALIAS, Config.CADI_X509_ISSUERS
});
private static List<String> LOC_TAGS = Arrays.asList(new String[] {
- Config.CADI_LATITUDE, Config.CADI_LONGITUDE
- });
+ Config.CADI_LATITUDE, Config.CADI_LONGITUDE
+ });
// Note: This is set by loadURLs. Use that function as singleton, not directly.
- private static Map<String,String> aaf_urls = null;
- private static boolean configNoPasswd = false;
+ private static Map<String,String> aaf_urls = null;
+ private static boolean configNoPasswd = false;
public static void main(String[] args) {
@@ -143,83 +143,83 @@ public class Agent {
String[] newArgs = new String[args.length-1];
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
if(newArgs.length>0 && newArgs[0].indexOf('@')>=0) {
- newArgs[0]=FQI.reverseDomain(newArgs[0])+".props";
+ newArgs[0]=FQI.reverseDomain(newArgs[0])+".props";
}
- TestConnectivity.main(newArgs);
+ TestConnectivity.main(newArgs);
} else {
try {
AAFSSO aafsso=null;
PropAccess access=null;
- String hasEtc = null;
+ String hasEtc = null;
for(String a : args) {
- if(a.startsWith(Config.CADI_PROP_FILES)) {
- access = new PropAccess(args);
- break;
- } else if(a.startsWith(Config.CADI_ETCDIR)) {
- int idx = a.indexOf('=');
- if(idx>=0 && idx<a.length()) {
- hasEtc = a.substring(idx+1);
- }
- } else if(a.equals("--nopasswd")) {
- configNoPasswd=true;
- }
+ if(a.startsWith(Config.CADI_PROP_FILES)) {
+ access = new PropAccess(args);
+ break;
+ } else if(a.startsWith(Config.CADI_ETCDIR)) {
+ int idx = a.indexOf('=');
+ if(idx>=0 && idx<a.length()) {
+ hasEtc = a.substring(idx+1);
+ }
+ } else if(a.equals("--nopasswd")) {
+ configNoPasswd=true;
+ }
}
if(access==null) {
- if(args.length>1 && args[1].contains("@")) {
- String domain = FQI.reverseDomain(args[1]);
- if(domain!=null) {
- if(hasEtc==null) {
- hasEtc = ".";
- }
- File etc = new File(hasEtc);
- if(etc.exists()) {
- File nsprops = new File(etc,domain+".props");
- if(nsprops.exists()) {
- access = new PropAccess(new String[] {Config.CADI_PROP_FILES+'='+nsprops.getAbsolutePath()});
- }
- }
- }
- }
+ if(args.length>1 && args[1].contains("@")) {
+ String domain = FQI.reverseDomain(args[1]);
+ if(domain!=null) {
+ if(hasEtc==null) {
+ hasEtc = ".";
+ }
+ File etc = new File(hasEtc);
+ if(etc.exists()) {
+ File nsprops = new File(etc,domain+".props");
+ if(nsprops.exists()) {
+ access = new PropAccess(new String[] {Config.CADI_PROP_FILES+'='+nsprops.getAbsolutePath()});
+ }
+ }
+ }
+ }
}
if(access==null) {
- for(Entry<Object, Object> es : System.getProperties().entrySet()) {
- if(Config.CADI_PROP_FILES.equals(es.getKey())) {
- access = new PropAccess();
- }
- }
+ for(Entry<Object, Object> es : System.getProperties().entrySet()) {
+ if(Config.CADI_PROP_FILES.equals(es.getKey())) {
+ access = new PropAccess();
+ }
+ }
}
- // When using Config file, check if Cred Exists, and if not, work with Deployer.
- if(access!=null && !"config".equals(args[0]) && access.getProperty(Config.AAF_APPPASS)==null && access.getProperty(Config.CADI_ALIAS)==null) {
- // not enough credentials to use Props. Use AAFSSO
- access = null;
- }
+ // When using Config file, check if Cred Exists, and if not, work with Deployer.
+ if(access!=null && !"config".equals(args[0]) && access.getProperty(Config.AAF_APPPASS)==null && access.getProperty(Config.CADI_ALIAS)==null) {
+ // not enough credentials to use Props. Use AAFSSO
+ access = null;
+ }
if(access==null) {
- if (args.length>1 && args[0].equals("validate") ) {
- int idx = args[1].indexOf('=');
- aafsso = null;
- access = new PropAccess(
- (idx<0?Config.CADI_PROP_FILES:args[1].substring(0, idx))+
- '='+
- (idx<0?args[1]:args[1].substring(idx+1)));
- } else {
- aafsso= new AAFSSO(args, new AAFSSO.ProcessArgs() {
- @Override
- public Properties process(String[] args, Properties props) {
- if (args.length>1) {
- if (!args[0].equals("keypairgen")) {
- props.put(Config.AAF_APPID, args[1]);
- }
- }
- return props;
- }
- });
- access = aafsso.access();
- }
+ if (args.length>1 && args[0].equals("validate") ) {
+ int idx = args[1].indexOf('=');
+ aafsso = null;
+ access = new PropAccess(
+ (idx<0?Config.CADI_PROP_FILES:args[1].substring(0, idx))+
+ '='+
+ (idx<0?args[1]:args[1].substring(idx+1)));
+ } else {
+ aafsso= new AAFSSO(args, new AAFSSO.ProcessArgs() {
+ @Override
+ public Properties process(String[] args, Properties props) {
+ if (args.length>1) {
+ if (!args[0].equals("keypairgen")) {
+ props.put(Config.AAF_APPID, args[1]);
+ }
+ }
+ return props;
+ }
+ });
+ access = aafsso.access();
+ }
}
if (aafsso!=null && aafsso.loginOnly()) {
@@ -230,13 +230,13 @@ public class Agent {
env = new RosettaEnv(access.getProperties());
Deque<String> cmds = new ArrayDeque<String>();
for (String p : args) {
- int eq;
+ int eq;
if ("-noexit".equalsIgnoreCase(p)) {
doExit = false;
} else if ((eq=p.indexOf('=')) < 0) {
cmds.add(p);
} else {
- access.setProperty(p.substring(0,eq), p.substring(eq+1));
+ access.setProperty(p.substring(0,eq), p.substring(eq+1));
}
}
@@ -328,7 +328,7 @@ public class Agent {
keypairGen(trans, access, cmds);
break;
case "config":
- config(trans,access,args,cmds);
+ config(trans,access,args,cmds);
break;
case "validate":
validate(access);
@@ -365,62 +365,62 @@ public class Agent {
}
public synchronized static Map<String,String> loadURLs(Access access) throws UnknownHostException, CadiException {
- if(aaf_urls==null) {
- Map<String,String> rv = new HashMap<>();
- RegistrationPropHolder rph = new RegistrationPropHolder(access, 0);
- String dot_le = access.getProperty(Config.AAF_LOCATOR_CONTAINER,null);
- dot_le=dot_le==null?"":'.'+dot_le;
- String version = access.getProperty(Config.AAF_API_VERSION,Config.AAF_DEFAULT_API_VERSION);
- for(String u : new String[] {"locate","aaf","oauth","cm","gui","fs","hello","token","introspect"}) {
- String tag;
- String append=null;
- switch(u) {
- case "aaf": tag = Config.AAF_URL; break;
- case "locate":tag = Config.AAF_LOCATE_URL; break;
- case "oauth": tag = Config.AAF_URL_OAUTH; break;
- case "token": tag = Config.AAF_OAUTH2_TOKEN_URL; append="/token"; break;
- case "introspect": tag = Config.AAF_OAUTH2_INTROSPECT_URL; append="/introspect"; break;
- case "cm": tag = Config.AAF_URL_CM; break;
- case "gui": tag = Config.AAF_URL_GUI; break;
- case "fs": tag = Config.AAF_URL_FS; break;
- case "hello": tag = Config.AAF_URL_HELLO; break;
- default:
- tag = "aaf_url_" + u;
- }
- String value;
- if((value=access.getProperty(tag,null))==null) {
- String proto = "fs".equals(u)?"http://":"https://";
- String lhost;
- if("locate".equals(u)) {
- lhost=rph.default_fqdn;
- } else {
- lhost=Config.AAF_LOCATE_URL_TAG;
- }
- value = rph.replacements(AGENT_LOAD_URLS,
- proto + lhost + "/%CNS.%AAF_NS." + ("aaf".equals(u)?"service":u) + ':' + version,
- null,dot_le);
- if(append!=null) {
- value+=append;
- }
- } else {
- value = rph.replacements(AGENT_LOAD_URLS, value,null,dot_le);
- }
- rv.put(tag, value);
- };
- aaf_urls = rv;
- }
- return aaf_urls;
- }
+ if(aaf_urls==null) {
+ Map<String,String> rv = new HashMap<>();
+ RegistrationPropHolder rph = new RegistrationPropHolder(access, 0);
+ String dot_le = access.getProperty(Config.AAF_LOCATOR_CONTAINER,null);
+ dot_le=dot_le==null?"":'.'+dot_le;
+ String version = access.getProperty(Config.AAF_API_VERSION,Config.AAF_DEFAULT_API_VERSION);
+ for(String u : new String[] {"locate","aaf","oauth","cm","gui","fs","hello","token","introspect"}) {
+ String tag;
+ String append=null;
+ switch(u) {
+ case "aaf": tag = Config.AAF_URL; break;
+ case "locate":tag = Config.AAF_LOCATE_URL; break;
+ case "oauth": tag = Config.AAF_URL_OAUTH; break;
+ case "token": tag = Config.AAF_OAUTH2_TOKEN_URL; append="/token"; break;
+ case "introspect": tag = Config.AAF_OAUTH2_INTROSPECT_URL; append="/introspect"; break;
+ case "cm": tag = Config.AAF_URL_CM; break;
+ case "gui": tag = Config.AAF_URL_GUI; break;
+ case "fs": tag = Config.AAF_URL_FS; break;
+ case "hello": tag = Config.AAF_URL_HELLO; break;
+ default:
+ tag = "aaf_url_" + u;
+ }
+ String value;
+ if((value=access.getProperty(tag,null))==null) {
+ String proto = "fs".equals(u)?"http://":"https://";
+ String lhost;
+ if("locate".equals(u)) {
+ lhost=rph.default_fqdn;
+ } else {
+ lhost=Config.AAF_LOCATE_URL_TAG;
+ }
+ value = rph.replacements(AGENT_LOAD_URLS,
+ proto + lhost + "/%CNS.%AAF_NS." + ("aaf".equals(u)?"service":u) + ':' + version,
+ null,dot_le);
+ if(append!=null) {
+ value+=append;
+ }
+ } else {
+ value = rph.replacements(AGENT_LOAD_URLS, value,null,dot_le);
+ }
+ rv.put(tag, value);
+ };
+ aaf_urls = rv;
+ }
+ return aaf_urls;
+ }
- public static void fillMissing(PropAccess access, Map<String, String> map) {
- for(Entry<String, String> es : map.entrySet()) {
- if(access.getProperty(es.getKey())==null) {
- access.setProperty(es.getKey(),es.getValue());
- }
- }
- }
+ public static void fillMissing(PropAccess access, Map<String, String> map) {
+ for(Entry<String, String> es : map.entrySet()) {
+ if(access.getProperty(es.getKey())==null) {
+ access.setProperty(es.getKey(),es.getValue());
+ }
+ }
+ }
- private static synchronized AAFCon<?> aafcon(Access access) throws APIException, CadiException, LocatorException {
+ private static synchronized AAFCon<?> aafcon(Access access) throws APIException, CadiException, LocatorException {
if (aafcon==null) {
aafcon = new AAFConHttp(access,Config.AAF_URL_CM);
}
@@ -453,7 +453,7 @@ public class Agent {
if (cmds.size()<1) {
String alias = env.getProperty(Config.CADI_ALIAS);
if(alias==null) {
- alias = env.getProperty(Config.AAF_APPID);
+ alias = env.getProperty(Config.AAF_APPID);
}
return alias!=null?alias:AAFSSO.cons.readLine("AppID: ");
}
@@ -803,8 +803,8 @@ public class Agent {
File chalFile = new File(dir,a.getNs()+".chal");
if(chalFile.exists()) {
fis.close();
- fis = new FileInputStream(chalFile);
- props.load(fis);
+ fis = new FileInputStream(chalFile);
+ props.load(fis);
}
} finally {
fis.close();
@@ -862,66 +862,66 @@ public class Agent {
private static void config(Trans trans, PropAccess propAccess, String[] args, Deque<String> cmds) throws Exception {
TimeTaken tt = trans.start("Get Configuration", Env.REMOTE);
try {
- final String fqi = fqi(cmds);
- Artifact arti = new Artifact();
- arti.setDir(propAccess.getProperty(Config.CADI_ETCDIR, System.getProperty("user.dir")));
- arti.setNs(FQI.reverseDomain(fqi));
+ final String fqi = fqi(cmds);
+ Artifact arti = new Artifact();
+ arti.setDir(propAccess.getProperty(Config.CADI_ETCDIR, System.getProperty("user.dir")));
+ arti.setNs(FQI.reverseDomain(fqi));
PropHolder loc = PropHolder.get(arti, "location.props");
PropHolder cred = PropHolder.get(arti,"cred.props");
PropHolder app= PropHolder.get(arti,"props");
for(String c : args) {
- int idx = c.indexOf('=');
- if(idx>0) {
- app.add(c.substring(0,idx), c.substring(idx+1));
- }
+ int idx = c.indexOf('=');
+ if(idx>0) {
+ app.add(c.substring(0,idx), c.substring(idx+1));
+ }
}
app.add(Config.CADI_PROP_FILES, loc.getPath()+':'+cred.getPath());
for (String tag : LOC_TAGS) {
- loc.add(tag, getProperty(propAccess, trans, false, tag, "%s: ",tag));
+ loc.add(tag, getProperty(propAccess, trans, false, tag, "%s: ",tag));
}
String keyfile = cred.getKeyPath();
if(keyfile!=null) {
- File fkeyfile = new File(keyfile);
- if(!fkeyfile.exists()) {
- ArtifactDir.write(fkeyfile,Chmod.to400,Symm.keygen());
- }
+ File fkeyfile = new File(keyfile);
+ if(!fkeyfile.exists()) {
+ ArtifactDir.write(fkeyfile,Chmod.to400,Symm.keygen());
+ }
}
cred.add(Config.CADI_KEYFILE, cred.getKeyPath());
final String ssoAppID = propAccess.getProperty(Config.AAF_APPID);
if(fqi!=null && fqi.equals(ssoAppID)) {
- cred.addEnc(Config.AAF_APPPASS, propAccess, null);
+ cred.addEnc(Config.AAF_APPPASS, propAccess, null);
// only Ask for Password when starting scratch
} else if(propAccess.getProperty(Config.CADI_PROP_FILES)==null) {
- if(!configNoPasswd) {
- char[] pwd = AAFSSO.cons.readPassword("Password for %s (leave blank for NO password): ", fqi);
- if(pwd.length>0) {
- cred.addEnc(Config.AAF_APPPASS, new String(pwd));
- }
- }
+ if(!configNoPasswd) {
+ char[] pwd = AAFSSO.cons.readPassword("Password for %s (leave blank for NO password): ", fqi);
+ if(pwd.length>0) {
+ cred.addEnc(Config.AAF_APPPASS, new String(pwd));
+ }
+ }
}
// load all properties that are already setup.
Map<String, String> aaf_urls = loadURLs(propAccess);
for(Entry<String, String> es : aaf_urls.entrySet()) {
- app.add(es.getKey(), es.getValue());
+ app.add(es.getKey(), es.getValue());
}
app.add(Config.AAF_LOCATE_URL, Config.getAAFLocateUrl(propAccess));
app.add(Config.AAF_ENV,propAccess, "DEV");
String release = propAccess.getProperty(Config.AAF_DEPLOYED_VERSION);
if(release==null) {
- release = System.getProperty(Config.AAF_DEPLOYED_VERSION,null);
+ release = System.getProperty(Config.AAF_DEPLOYED_VERSION,null);
}
if(release!=null) {
- app.add(Config.AAF_DEPLOYED_VERSION, release);
+ app.add(Config.AAF_DEPLOYED_VERSION, release);
}
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());
- }
+ 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);
@@ -932,64 +932,64 @@ public class Agent {
File origTruststore = new File(cts);
File newTruststore = new File(app.getDir(),origTruststore.getName());
if(!newTruststore.exists()) {
- if (!origTruststore.exists()) {
- // Try same directory as cadi_prop_files
- String cpf = propAccess.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");
- }
- }
-
- }
- if (!newTruststore.exists() && origTruststore.exists()) {
- Files.copy(origTruststore.toPath(), newTruststore.toPath());
- }
+ if (!origTruststore.exists()) {
+ // Try same directory as cadi_prop_files
+ String cpf = propAccess.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");
+ }
+ }
+
+ }
+ if (!newTruststore.exists() && origTruststore.exists()) {
+ Files.copy(origTruststore.toPath(), newTruststore.toPath());
+ }
}
- System.out.println("New Truststore is " + newTruststore);
+ System.out.println("New Truststore is " + newTruststore);
cred.add(Config.CADI_TRUSTSTORE, newTruststore.getCanonicalPath());
cred.add(Config.CADI_TRUSTSTORE_PASSWORD, "changeit" /* Java default */);
String cpf = propAccess.getProperty(Config.CADI_PROP_FILES);
if (cpf!=null){
- String[] propFiles = Split.splitTrim(File.pathSeparatorChar, cpf);
+ String[] propFiles = Split.splitTrim(File.pathSeparatorChar, cpf);
for (int pfi = propFiles.length-1;pfi>=0;--pfi) {
- String f = propFiles[pfi];
+ String f = propFiles[pfi];
System.out.format("Reading %s\n",f);
FileInputStream fis = new FileInputStream(f);
try {
Properties props = new Properties();
props.load(fis);
for (Entry<Object, Object> prop : props.entrySet()) {
- boolean lower = true;
- String key = prop.getKey().toString();
- if(LOC_TAGS.contains(key)) {
- break;
- }
- for(int i=0;lower && i<key.length();++i) {
- if(Character.isUpperCase(key.charAt(i))) {
- lower = false;
- }
- }
- if(lower) {
- PropHolder ph = CRED_TAGS.contains(key)?cred:app;
- if(key.endsWith("_password")) {
- ph.addEnc(key, prop.getValue().toString());
- } else {
- ph.add(key, prop.getValue().toString());
- }
- }
+ boolean lower = true;
+ String key = prop.getKey().toString();
+ if(LOC_TAGS.contains(key)) {
+ break;
+ }
+ for(int i=0;lower && i<key.length();++i) {
+ if(Character.isUpperCase(key.charAt(i))) {
+ lower = false;
+ }
+ }
+ if(lower) {
+ PropHolder ph = CRED_TAGS.contains(key)?cred:app;
+ if(key.endsWith("_password")) {
+ ph.addEnc(key, prop.getValue().toString());
+ } else {
+ ph.add(key, prop.getValue().toString());
+ }
+ }
}
} finally {
fis.close();
@@ -999,12 +999,12 @@ public class Agent {
aafcon = aafcon(propAccess);
if (aafcon!=null) { // get Properties from Remote AAF
for (Props props : aafProps(trans,aafcon,getProperty(propAccess,aafcon.env,false,Config.AAF_LOCATE_URL,"AAF Locator URL: "),fqi)) {
- PropHolder ph = CRED_TAGS.contains(props.getTag())?cred:app;
- if(props.getTag().endsWith("_password")) {
- ph.addEnc(props.getTag(), props.getValue());
- } else {
- ph.add(props.getTag(), props.getValue());
- }
+ PropHolder ph = CRED_TAGS.contains(props.getTag())?cred:app;
+ if(props.getTag().endsWith("_password")) {
+ ph.addEnc(props.getTag(), props.getValue());
+ } else {
+ ph.add(props.getTag(), props.getValue());
+ }
}
}
@@ -1018,10 +1018,10 @@ public class Agent {
}
public static List<Props> aafProps(Trans trans, AAFCon<?> aafcon, String locator, String fqi) throws CadiException, APIException, URISyntaxException {
- Future<Configuration> acf = aafcon.client(new SingleEndpointLocator(locator))
+ Future<Configuration> acf = aafcon.client(new SingleEndpointLocator(locator))
.read("/configure/"+fqi+"/aaf", configDF);
if (acf.get(TIMEOUT)) {
- return acf.value.getProps();
+ return acf.value.getProps();
} else if (acf.code()==401){
trans.error().log("Bad Password sent to AAF");
} else if (acf.code()==404){
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/ArtifactDir.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/ArtifactDir.java
index 36ee42d8..0971ae0c 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/ArtifactDir.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/ArtifactDir.java
@@ -45,8 +45,8 @@ public abstract class ArtifactDir implements PlaceArtifact {
// This checks for multiple passes of Dir on the same objects. Run clear after done.
protected final static Map<String,Object> processed = new HashMap<>();
- private static final Map<String, Symm> symms = new HashMap<>();
-
+ private static final Map<String, Symm> symms = new HashMap<>();
+
/**
* Note: Derived Classes should ALWAYS call "super.place(cert,arti)" first, and
* then "placeProperties(arti)" just after they implement
@@ -94,7 +94,7 @@ public abstract class ArtifactDir implements PlaceArtifact {
return true;
}
- /**
+ /**
* Derived Classes implement this instead, so Dir can process first, and write any Properties last
* @param cert
* @param arti
@@ -104,7 +104,7 @@ public abstract class ArtifactDir implements PlaceArtifact {
protected abstract boolean _place(Trans trans, CertInfo certInfo, Artifact arti) throws CadiException;
public static void write(File f, Chmod c, String ... data) throws IOException {
- System.out.println("Writing file " + f.getCanonicalPath());
+ System.out.println("Writing file " + f.getCanonicalPath());
f.setWritable(true,true);
FileOutputStream fos = new FileOutputStream(f);
@@ -120,7 +120,7 @@ public abstract class ArtifactDir implements PlaceArtifact {
}
public static void write(File f, Chmod c, byte[] bytes) throws IOException {
- System.out.println("Writing file " + f.getCanonicalPath());
+ System.out.println("Writing file " + f.getCanonicalPath());
f.setWritable(true,true);
FileOutputStream fos = new FileOutputStream(f);
@@ -133,7 +133,7 @@ public abstract class ArtifactDir implements PlaceArtifact {
}
public static void write(File f, Chmod c, KeyStore ks, char[] pass ) throws IOException, CadiException {
- System.out.println("Writing file " + f.getCanonicalPath());
+ System.out.println("Writing file " + f.getCanonicalPath());
f.setWritable(true,true);
FileOutputStream fos = new FileOutputStream(f);
@@ -149,17 +149,17 @@ public abstract class ArtifactDir implements PlaceArtifact {
// Get the Symm associated with specific File (there can be several active at once)
public synchronized static final Symm getSymm(File f) throws IOException {
- Symm symm = symms.get(f.getCanonicalPath());
- if(symm==null) {
+ Symm symm = symms.get(f.getCanonicalPath());
+ if(symm==null) {
if (!f.exists()) {
write(f,Chmod.to400,Symm.keygen());
// } else {
-// System.out.println("Encryptor using " + f.getCanonicalPath());
+// System.out.println("Encryptor using " + f.getCanonicalPath());
}
symm = Symm.obtain(f);
symms.put(f.getCanonicalPath(),symm);
- }
- return symm;
+ }
+ return symm;
}
private void validate(Artifact a) throws CadiException {
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PlaceArtifactInKeystore.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PlaceArtifactInKeystore.java
index 67b3df09..18d74fba 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PlaceArtifactInKeystore.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PlaceArtifactInKeystore.java
@@ -50,7 +50,7 @@ public class PlaceArtifactInKeystore extends ArtifactDir {
@Override
public boolean _place(Trans trans, CertInfo certInfo, Artifact arti) throws CadiException {
- final String ext = (kst==Agent.PKCS12?"p12":kst);
+ final String ext = (kst==Agent.PKCS12?"p12":kst);
File fks = new File(dir,arti.getNs()+'.'+ext);
try {
KeyStore jks = KeyStore.getInstance(kst);
@@ -73,17 +73,17 @@ public class PlaceArtifactInKeystore extends ArtifactDir {
if (x509.getSubjectDN().equals(x509.getIssuerDN())) {
caSet.add(x509);
} else {
- // Expect Certs in Trust Chain Order.
- if(curr==null) {
+ // Expect Certs in Trust Chain Order.
+ if(curr==null) {
chainList.add(x509);
curr=x509;
- } else {
- // Only Add Cert next on the list
- if(curr.getIssuerDN().equals(x509.getSubjectDN())) {
- chainList.add(x509);
- curr=x509;
- }
- }
+ } else {
+ // Only Add Cert next on the list
+ if(curr.getIssuerDN().equals(x509.getSubjectDN())) {
+ chainList.add(x509);
+ curr=x509;
+ }
+ }
}
}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java
index 1b8b76e4..3140df61 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/PropHolder.java
@@ -39,104 +39,104 @@ import certman.v1_0.Artifacts.Artifact;
// Doing this because there are lots of lists spread out in this model...
// we want these to be unique.
public class PropHolder {
- private File dir;
- private File file;
- private File keyfile;
- private Symm symm;
- private Map<String,String> props;
+ private File dir;
+ private File file;
+ private File keyfile;
+ private Symm symm;
+ private Map<String,String> props;
- private static boolean dirMessage = true;
+ private static boolean dirMessage = true;
protected final static Map<String,PropHolder> propHolders = new HashMap<>();
public static PropHolder get(Artifact arti, String suffix) throws IOException {
- File dir = new File(arti.getDir());
+ File dir = new File(arti.getDir());
if (dir.exists()) {
- if(dirMessage) {
- System.out.println("Writing to " + dir.getCanonicalFile());
- }
+ if(dirMessage) {
+ System.out.println("Writing to " + dir.getCanonicalFile());
+ }
} else if (dir.mkdirs()) {
- if(dirMessage) {
- System.out.println("Created directory " + dir.getCanonicalFile());
- }
+ if(dirMessage) {
+ System.out.println("Created directory " + dir.getCanonicalFile());
+ }
} else {
throw new IOException("Unable to create or write to " + dir.getCanonicalPath());
}
dirMessage = false;
- File file = new File(dir,arti.getNs()+'.'+suffix);
+ File file = new File(dir,arti.getNs()+'.'+suffix);
- PropHolder ph = propHolders.get(file.getAbsolutePath());
- if(ph == null) {
- ph = new PropHolder(dir,file,new File(dir,arti.getNs()+".keyfile"));
- propHolders.put(file.getAbsolutePath(), ph);
- }
- return ph;
+ PropHolder ph = propHolders.get(file.getAbsolutePath());
+ if(ph == null) {
+ ph = new PropHolder(dir,file,new File(dir,arti.getNs()+".keyfile"));
+ propHolders.put(file.getAbsolutePath(), ph);
+ }
+ return ph;
+ }
+
+ private PropHolder(File dir, File file, File keyfile) throws IOException {
+ this.dir = dir;
+ this.file = file;
+ this.keyfile = keyfile;
+ symm = null;
+ props = new TreeMap<>();
+ }
+
+ public String getPath() {
+ return file.getAbsolutePath();
+ }
+
+ public File getDir() {
+ return dir;
}
-
- private PropHolder(File dir, File file, File keyfile) throws IOException {
- this.dir = dir;
- this.file = file;
- this.keyfile = keyfile;
- symm = null;
- props = new TreeMap<>();
- }
-
- public String getPath() {
- return file.getAbsolutePath();
- }
-
- public File getDir() {
- return dir;
- }
- public String getKeyPath() {
- return keyfile.getAbsolutePath();
- }
+ public String getKeyPath() {
+ return keyfile.getAbsolutePath();
+ }
- public String add(final String tag, final String value) {
- final String rv = value==null?"":value;
- props.put(tag, rv);
- return rv;
- }
+ public String add(final String tag, final String value) {
+ final String rv = value==null?"":value;
+ props.put(tag, rv);
+ return rv;
+ }
- public String add(final String tag, Access orig, final String def) {
- return add(tag, orig.getProperty(tag, def));
- }
+ public String add(final String tag, Access orig, final String def) {
+ return add(tag, orig.getProperty(tag, def));
+ }
- public String addEnc(final String tag, final String value) throws IOException {
- String rv;
- if(value==null) {
- rv = "";
- } else {
- if(symm==null) { // Lazy Instantiations... on a few PropFiles have Security
- symm = ArtifactDir.getSymm(keyfile);
- }
- rv = "enc:"+symm.enpass(value);
- }
- props.put(tag, rv);
- return rv;
- }
+ public String addEnc(final String tag, final String value) throws IOException {
+ String rv;
+ if(value==null) {
+ rv = "";
+ } else {
+ if(symm==null) { // Lazy Instantiations... on a few PropFiles have Security
+ symm = ArtifactDir.getSymm(keyfile);
+ }
+ rv = "enc:"+symm.enpass(value);
+ }
+ props.put(tag, rv);
+ return rv;
+ }
- public void addEnc(final String tag, Access orig, final String def) throws IOException {
- String pwd = orig.getProperty(tag, def);
- if(pwd==null) {
- return;
- } else if(pwd.startsWith("enc:")) {
- pwd = orig.decrypt(pwd, true);
- }
- addEnc(tag,pwd);
- }
-
- public void write() throws IOException {
+ public void addEnc(final String tag, Access orig, final String def) throws IOException {
+ String pwd = orig.getProperty(tag, def);
+ if(pwd==null) {
+ return;
+ } else if(pwd.startsWith("enc:")) {
+ pwd = orig.decrypt(pwd, true);
+ }
+ addEnc(tag,pwd);
+ }
+
+ public void write() throws IOException {
if (props.size()==0) {
return;
}
if (file.exists()) {
- System.out.println("Backing up " + file.getCanonicalPath());
+ System.out.println("Backing up " + file.getCanonicalPath());
File backup = File.createTempFile(file.getName()+'.', ".backup",dir);
file.renameTo(backup);
} else {
- System.out.println("Creating new " + file.getCanonicalPath());
+ System.out.println("Creating new " + file.getCanonicalPath());
}
// Append if not first
@@ -159,7 +159,7 @@ public class PropHolder {
pw.println();
for (Map.Entry<String,String> me : props.entrySet()) {
- String key = me.getKey();
+ String key = me.getKey();
pw.print(key);
pw.print('=');
pw.println(me.getValue());
@@ -168,16 +168,16 @@ public class PropHolder {
pw.close();
}
Chmod.to644.chmod(file);
- }
-
- public static void writeAll() throws IOException {
- for(PropHolder ph : propHolders.values()) {
- ph.write();
- }
- }
-
- @Override
- public String toString() {
- return file.getAbsolutePath() + ": " + props;
- }
+ }
+
+ public static void writeAll() throws IOException {
+ for(PropHolder ph : propHolders.values()) {
+ ph.write();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return file.getAbsolutePath() + ": " + props;
+ }
}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java
index 14cf0f62..8c47b6cb 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java
@@ -78,11 +78,11 @@ public class TokenClientFactory extends Persist<Token,TimedToken> {
}
for(String tag : new String[] {Config.AAF_ALT_OAUTH2_TOKEN_URL, Config.AAF_ALT_OAUTH2_INTROSPECT_URL}) {
- String value = access.getProperty(tag, null);
- if(value!=null) {
- alts.add(tag);
- alts.add(value);
- }
+ String value = access.getProperty(tag, null);
+ if(value!=null) {
+ alts.add(tag);
+ alts.add(value);
+ }
}
symm = Symm.encrypt.obtain();
@@ -121,7 +121,7 @@ public class TokenClientFactory extends Persist<Token,TimedToken> {
}
char okind;
if (alts.contains(tagOrURL)) {
- okind = Kind.OAUTH;
+ okind = Kind.OAUTH;
} else {
okind = Kind.AAF_OAUTH;
}
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java
index c3dc4f6a..18eb7357 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/Registrar.java
@@ -71,7 +71,7 @@ public class Registrar<ENV extends BasicEnv> {
erroringTimer = null;
}
} else {
- env.error().log(rv.toString());
+ env.error().log(rv.toString());
// Account for different Registrations not being to same place
if (erroringTimer==null) {
erroringTimer = new Timer(REGISTRAR + " error re-check ",true);
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 fc3c18b0..80fc1a4f 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
@@ -36,227 +36,227 @@ import locate.v1_0.MgmtEndpoint.SpecialPorts;
import locate.v1_0.MgmtEndpoints;
public class RegistrationCreator {
- private Access access;
+ private Access access;
public RegistrationCreator(Access access) {
- this.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;
+ MgmtEndpoints me = new MgmtEndpoints();
+ List<MgmtEndpoint> lme = me.getMgmtEndpoint();
+ MgmtEndpoint defData = null;
+ MgmtEndpoint locate = null;
- try {
- String dot_le;
- String version=null;
- String defProtocol="https";
-
- RegistrationPropHolder ph = new RegistrationPropHolder(access, port);
-
- String firstPrivateHostname = null;
- // Now, loop through by Container
- for(String le : Split.splitTrim(',', ph.lcontainer)) {
- if(le.isEmpty()) {
- dot_le = le;
- } else {
- dot_le = "."+le;
- }
+ try {
+ String dot_le;
+ String version=null;
+ String defProtocol="https";
+
+ RegistrationPropHolder ph = new RegistrationPropHolder(access, port);
+
+ String firstPrivateHostname = null;
+ // Now, loop through by Container
+ for(String le : Split.splitTrim(',', ph.lcontainer)) {
+ if(le.isEmpty()) {
+ dot_le = le;
+ } else {
+ dot_le = "."+le;
+ }
- for(String entry : Split.splitTrim(',', ph.lentries)) {
- if(defData==null) {
- defData = locate = new MgmtEndpoint();
+ for(String entry : Split.splitTrim(',', ph.lentries)) {
+ if(defData==null) {
+ defData = locate = new MgmtEndpoint();
- version = access.getProperty(Config.AAF_LOCATOR_VERSION, Defaults.AAF_VERSION);
- locate.setProtocol(defProtocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL,defProtocol));
- List<String> ls = locate.getSubprotocol();
- for(String sp : Split.splitTrim(',', access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL,""))) {
- ls.add(sp);
- }
- locate.setLatitude(ph.latitude);
- locate.setLongitude(ph.longitude);
+ version = access.getProperty(Config.AAF_LOCATOR_VERSION, Defaults.AAF_VERSION);
+ locate.setProtocol(defProtocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL,defProtocol));
+ List<String> ls = locate.getSubprotocol();
+ for(String sp : Split.splitTrim(',', access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL,""))) {
+ ls.add(sp);
+ }
+ locate.setLatitude(ph.latitude);
+ locate.setLongitude(ph.longitude);
- } else {
- locate = copy(defData);
- }
-
- locate.setName(ph.getEntryName(entry,dot_le));
- /* Cover the situation where there is a Container, and multiple locator Entries,
- * the first of which is the only real private FQDN
- * example: oauth
- * aaf_locator_entries=oauth,token,introspect
- *
- * Entries for token and introspect, but they point to oauth service.
- */
- String locateHostname;
- if(le.isEmpty()) {
- locateHostname=ph.getEntryFQDN(entry, dot_le);
- } else if(firstPrivateHostname==null) {
- firstPrivateHostname=locateHostname=ph.getEntryFQDN(entry, dot_le);
- } else {
- locateHostname=firstPrivateHostname;
- }
-
- locate.setHostname(locateHostname);
- locate.setPort(ph.getEntryPort(dot_le));
-
- 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);
- String deply[]= Split.splitTrim('.', access.getProperty(Config.AAF_DEPLOYED_VERSION, ""));
- locate.setMajor(best(split,deply,0));
- locate.setMinor(best(split,deply,1));
- locate.setPatch(best(split,deply,2));
- locate.setPkg(best(split,deply,3));
- }
+ } else {
+ locate = copy(defData);
+ }
+
+ locate.setName(ph.getEntryName(entry,dot_le));
+ /* Cover the situation where there is a Container, and multiple locator Entries,
+ * the first of which is the only real private FQDN
+ * example: oauth
+ * aaf_locator_entries=oauth,token,introspect
+ *
+ * Entries for token and introspect, but they point to oauth service.
+ */
+ String locateHostname;
+ if(le.isEmpty()) {
+ locateHostname=ph.getEntryFQDN(entry, dot_le);
+ } else if(firstPrivateHostname==null) {
+ firstPrivateHostname=locateHostname=ph.getEntryFQDN(entry, dot_le);
+ } else {
+ locateHostname=firstPrivateHostname;
+ }
+
+ locate.setHostname(locateHostname);
+ locate.setPort(ph.getEntryPort(dot_le));
+
+ 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);
+ String deply[]= Split.splitTrim('.', access.getProperty(Config.AAF_DEPLOYED_VERSION, ""));
+ locate.setMajor(best(split,deply,0));
+ locate.setMinor(best(split,deply,1));
+ locate.setPatch(best(split,deply,2));
+ locate.setPkg(best(split,deply,3));
+ }
- String protocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL + dot_le, defProtocol);
- if (protocol!=null) {
- locate.setProtocol(protocol);
- List<String> ls = locate.getSubprotocol();
- // ls cannot be null, per generated getSubprotocol code
- if(ls.isEmpty()) {
- String subprotocols = access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL + dot_le, null);
- if(subprotocols==null) {
- subprotocols = access.getProperty(Config.CADI_PROTOCOLS, null);
- }
- if(subprotocols!=null) {
- for (String s : Split.split(',', subprotocols)) {
- ls.add(s);
- }
- } else {
- access.printf(Level.ERROR, "%s is required for Locator Registration of %s",
- Config.AAF_LOCATOR_SUBPROTOCOL,Config.AAF_LOCATOR_PROTOCOL);
- }
- }
- lme.add(locate);
- } else {
- access.printf(Level.ERROR, "%s is required for Locator Registration",Config.AAF_LOCATOR_PROTOCOL);
- }
- }
- }
- } catch (NumberFormatException | UnknownHostException e) {
- throw new CadiException("Error extracting Data from Properties for Registrar",e);
- }
-
- if(access.willLog(Level.INFO)) {
- access.log(Level.INFO, print(new StringBuilder(),me.getMgmtEndpoint()));
- }
- return me;
+ String protocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL + dot_le, defProtocol);
+ if (protocol!=null) {
+ locate.setProtocol(protocol);
+ List<String> ls = locate.getSubprotocol();
+ // ls cannot be null, per generated getSubprotocol code
+ if(ls.isEmpty()) {
+ String subprotocols = access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL + dot_le, null);
+ if(subprotocols==null) {
+ subprotocols = access.getProperty(Config.CADI_PROTOCOLS, null);
+ }
+ if(subprotocols!=null) {
+ for (String s : Split.split(',', subprotocols)) {
+ ls.add(s);
+ }
+ } else {
+ access.printf(Level.ERROR, "%s is required for Locator Registration of %s",
+ Config.AAF_LOCATOR_SUBPROTOCOL,Config.AAF_LOCATOR_PROTOCOL);
+ }
+ }
+ lme.add(locate);
+ } else {
+ access.printf(Level.ERROR, "%s is required for Locator Registration",Config.AAF_LOCATOR_PROTOCOL);
+ }
+ }
+ }
+ } catch (NumberFormatException | UnknownHostException e) {
+ throw new CadiException("Error extracting Data from Properties for Registrar",e);
+ }
+
+ if(access.willLog(Level.INFO)) {
+ access.log(Level.INFO, print(new StringBuilder(),me.getMgmtEndpoint()));
+ }
+ return me;
}
-
+
/*
* Find the best version between Actual Interface and Deployed version
*/
private int best(String[] split, String[] deploy, int i) {
- StringBuilder sb = new StringBuilder();
- char c;
- String s;
- if(split.length>i) {
- s=split[i];
- for(int j=0;j<s.length();++j) {
- if(Character.isDigit(c=s.charAt(j))) {
- sb.append(c);
- } else {
- break;
- }
- }
- }
-
- if(sb.length()==0 && deploy.length>i) {
- s=deploy[i];
- for(int j=0;j<s.length();++j) {
- if(Character.isDigit(c=s.charAt(j))) {
- sb.append(c);
- } else {
- break;
- }
- }
- }
-
- return sb.length()==0?0:Integer.parseInt(sb.toString());
+ StringBuilder sb = new StringBuilder();
+ char c;
+ String s;
+ if(split.length>i) {
+ s=split[i];
+ for(int j=0;j<s.length();++j) {
+ if(Character.isDigit(c=s.charAt(j))) {
+ sb.append(c);
+ } else {
+ break;
+ }
+ }
+ }
+
+ if(sb.length()==0 && deploy.length>i) {
+ s=deploy[i];
+ for(int j=0;j<s.length();++j) {
+ if(Character.isDigit(c=s.charAt(j))) {
+ sb.append(c);
+ } else {
+ break;
+ }
+ }
+ }
+
+ return sb.length()==0?0:Integer.parseInt(sb.toString());
}
- private StringBuilder print(StringBuilder sb, List<MgmtEndpoint> lme) {
- int cnt = 0;
- for(MgmtEndpoint m : lme) {
- print(sb,cnt++,m);
- }
- return sb;
- }
+ private StringBuilder print(StringBuilder sb, List<MgmtEndpoint> lme) {
+ int cnt = 0;
+ for(MgmtEndpoint m : lme) {
+ print(sb,cnt++,m);
+ }
+ return sb;
+ }
- private void print(StringBuilder out, int cnt, MgmtEndpoint mep) {
- out.append("\nManagement Endpoint - ");
- out.append(cnt);
- out.append("\n\tName: ");
- out.append(mep.getName());
- out.append("\n\tHostname: ");
- out.append(mep.getHostname());
- out.append("\n\tLatitude: ");
- out.append(mep.getLatitude());
- out.append("\n\tLongitude: ");
- out.append(mep.getLongitude());
- out.append("\n\tVersion: ");
- out.append(mep.getMajor());
- out.append('.');
- out.append(mep.getMinor());
- out.append('.');
- out.append(mep.getPatch());
- out.append('.');
- out.append(mep.getPkg());
- out.append("\n\tPort: ");
- out.append(mep.getPort());
- out.append("\n\tProtocol: ");
- out.append(mep.getProtocol());
- out.append("\n\tSpecial Ports:");
- for( SpecialPorts sp : mep.getSpecialPorts()) {
- out.append("\n\t\tName: ");
- out.append(sp.getName());
- out.append("\n\t\tPort: ");
- out.append(sp.getPort());
- out.append("\n\t\tProtocol: ");
- out.append(sp.getProtocol());
- out.append("\n\t\t Versions: ");
- boolean first = true;
- for(String s : sp.getProtocolVersions()) {
- if(first) {
- first = false;
- } else {
- out.append(',');
- }
- out.append(s);
- }
- }
- boolean first = true;
- out.append("\n\tSubProtocol: ");
- for(String s : mep.getSubprotocol()) {
- if(first) {
- first = false;
- } else {
- out.append(',');
- }
- out.append(s);
- }
- }
+ private void print(StringBuilder out, int cnt, MgmtEndpoint mep) {
+ out.append("\nManagement Endpoint - ");
+ out.append(cnt);
+ out.append("\n\tName: ");
+ out.append(mep.getName());
+ out.append("\n\tHostname: ");
+ out.append(mep.getHostname());
+ out.append("\n\tLatitude: ");
+ out.append(mep.getLatitude());
+ out.append("\n\tLongitude: ");
+ out.append(mep.getLongitude());
+ out.append("\n\tVersion: ");
+ out.append(mep.getMajor());
+ out.append('.');
+ out.append(mep.getMinor());
+ out.append('.');
+ out.append(mep.getPatch());
+ out.append('.');
+ out.append(mep.getPkg());
+ out.append("\n\tPort: ");
+ out.append(mep.getPort());
+ out.append("\n\tProtocol: ");
+ out.append(mep.getProtocol());
+ out.append("\n\tSpecial Ports:");
+ for( SpecialPorts sp : mep.getSpecialPorts()) {
+ out.append("\n\t\tName: ");
+ out.append(sp.getName());
+ out.append("\n\t\tPort: ");
+ out.append(sp.getPort());
+ out.append("\n\t\tProtocol: ");
+ out.append(sp.getProtocol());
+ out.append("\n\t\t Versions: ");
+ boolean first = true;
+ for(String s : sp.getProtocolVersions()) {
+ if(first) {
+ first = false;
+ } else {
+ out.append(',');
+ }
+ out.append(s);
+ }
+ }
+ boolean first = true;
+ out.append("\n\tSubProtocol: ");
+ for(String s : mep.getSubprotocol()) {
+ if(first) {
+ first = false;
+ } else {
+ out.append(',');
+ }
+ out.append(s);
+ }
+ }
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.setPatch(mep.getPatch());
- out.setPkg(mep.getPkg());
- out.setPort(mep.getPort());
- out.setProtocol(mep.getProtocol());
- out.getSpecialPorts().addAll(mep.getSpecialPorts());
- out.getSubprotocol().addAll(mep.getSubprotocol());
- return out;
- }
+ 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.setPatch(mep.getPatch());
+ out.setPkg(mep.getPkg());
+ 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 3672c624..0e4945d0 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
@@ -68,8 +68,8 @@ public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> {
} 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);
+ 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 {
@@ -86,7 +86,7 @@ public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> {
- @Override
+ @Override
public Result<Void> update(ENV env) {
try {
Rcli<?> client = aafcon.client(locator);
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 c0ac43e9..a472ed5b 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
@@ -146,7 +146,7 @@ public class AAFSSO {
// Config.setDefaultRealm(access);
if (!dot_aaf_kf.exists()) {
- // This will create, as required, or reuse
+ // This will create, as required, or reuse
ArtifactDir.getSymm(dot_aaf_kf);
}
@@ -192,18 +192,18 @@ public class AAFSSO {
String aaf_container_ns = "";
if (appID!=null) {
- if( access.getProperty(Config.AAF_APPPASS)==null) {
- appID = user = cons.readLine("Deployer ID [%s]: ", user);
- access.setProperty(Config.AAF_APPID,appID);
- char[] password = cons.readPassword("Password for %s: ", user);
- if(password.length>0) {
- String app_pass = access.encrypt(new String(password));
- access.setProperty(Config.AAF_APPPASS,app_pass);
- diskprops.setProperty(Config.AAF_APPPASS,app_pass);
- }
- aaf_container_ns = cons.readLine("Container Namespace (blank if none)? [\"\"]: ", aaf_container_ns);
- }
- diskprops.setProperty(Config.AAF_APPID,appID);
+ if( access.getProperty(Config.AAF_APPPASS)==null) {
+ appID = user = cons.readLine("Deployer ID [%s]: ", user);
+ access.setProperty(Config.AAF_APPID,appID);
+ char[] password = cons.readPassword("Password for %s: ", user);
+ if(password.length>0) {
+ String app_pass = access.encrypt(new String(password));
+ access.setProperty(Config.AAF_APPPASS,app_pass);
+ diskprops.setProperty(Config.AAF_APPPASS,app_pass);
+ }
+ aaf_container_ns = cons.readLine("Container Namespace (blank if none)? [\"\"]: ", aaf_container_ns);
+ }
+ diskprops.setProperty(Config.AAF_APPID,appID);
}
String keystore=access.getProperty(Config.CADI_KEYSTORE);
@@ -380,39 +380,39 @@ public class AAFSSO {
access.setProperty(Config.AAF_LOCATE_URL, locateUrl);
addProp(Config.AAF_LOCATE_URL, locateUrl);
try {
- if(access.getProperty(Config.AAF_URL)==null) {
- access.setProperty(Config.AAF_URL, Defaults.AAF_ROOT+".service:"+Defaults.AAF_VERSION);
- }
- AAFCon<?> aafCon = AAFCon.newInstance(access);
- Future<Configuration> acf;
- RosettaDF<Configuration> configDF = new RosettaEnv().newDataFactory(Configuration.class);
- acf = aafCon.client(new SingleEndpointLocator(locateUrl))
- .read("/configure/"+user+"/aaf", configDF);
- if (acf.get(aafCon.connTimeout)) {
- for(Props p : acf.value.getProps()) {
- addProp(p.getTag(),p.getValue());
- if(access.getProperty(p.getTag())==null) {
- access.setProperty(p.getTag(), p.getValue());
- }
- }
- } else {
- access.log(Level.INFO,acf.body());
- }
- } catch (LocatorException | APIException | URISyntaxException e) {
- access.log(e);
- }
+ if(access.getProperty(Config.AAF_URL)==null) {
+ access.setProperty(Config.AAF_URL, Defaults.AAF_ROOT+".service:"+Defaults.AAF_VERSION);
+ }
+ AAFCon<?> aafCon = AAFCon.newInstance(access);
+ Future<Configuration> acf;
+ RosettaDF<Configuration> configDF = new RosettaEnv().newDataFactory(Configuration.class);
+ acf = aafCon.client(new SingleEndpointLocator(locateUrl))
+ .read("/configure/"+user+"/aaf", configDF);
+ if (acf.get(aafCon.connTimeout)) {
+ for(Props p : acf.value.getProps()) {
+ addProp(p.getTag(),p.getValue());
+ if(access.getProperty(p.getTag())==null) {
+ access.setProperty(p.getTag(), p.getValue());
+ }
+ }
+ } else {
+ access.log(Level.INFO,acf.body());
+ }
+ } catch (LocatorException | APIException | URISyntaxException e) {
+ access.log(e);
+ }
}
final String apiVersion = access.getProperty(Config.AAF_API_VERSION, Config.AAF_DEFAULT_API_VERSION);
final String aaf_root_ns = access.getProperty(Config.AAF_ROOT_NS);
String locateRoot;
if(aaf_root_ns==null) {
- locateRoot=Defaults.AAF_ROOT;
+ locateRoot=Defaults.AAF_ROOT;
} else {
- locateRoot = Defaults.AAF_LOCATE_CONST + "/%CNS." + aaf_root_ns;
+ locateRoot = Defaults.AAF_LOCATE_CONST + "/%CNS." + aaf_root_ns;
}
if(access.getProperty(Config.AAF_URL)==null) {
- access.setProperty(Config.AAF_URL, locateRoot+".service:"+apiVersion);
+ access.setProperty(Config.AAF_URL, locateRoot+".service:"+apiVersion);
}
writeFiles();
diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthn.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthn.java
index 962397cc..7dccc8c1 100644
--- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthn.java
+++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthn.java
@@ -40,165 +40,165 @@ import org.onap.aaf.cadi.principal.BasicPrincipal;
public class JU_AAFAuthn {
- @Mock
- AAFCon con;
-
- @Mock
- AbsUserCache<AAFPermission> cache;
-
- @Mock
- PropAccess propaccess;
-
- @Before
- public void setUp() {
- initMocks(this);
- }
+ @Mock
+ AAFCon con;
+
+ @Mock
+ AbsUserCache<AAFPermission> cache;
+
+ @Mock
+ PropAccess propaccess;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ }
- @Test
- public void testGetRealm() {
- AAFAuthn authnObj = new AAFAuthn(con);
- String realm = authnObj.getRealm();
- assertNull(realm);
- }
-
- @Test
- public void testValidateFailure() {
- AAFAuthnImplWithGetUserNull authnObj = new AAFAuthnImplWithGetUserNull(con, cache);
- String realm="";
- try {
- Mockito.doReturn("test").when(propaccess).decrypt("test", false);
- realm = authnObj.validate("test", "test");
- assertNull(realm);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- assertNull( e.getLocalizedMessage());
- }
- }
-
- @Test
- public void testValidate() {
- AAFAuthnImpl authnObj = new AAFAuthnImpl(con);
- String realm="";
- try {
- Mockito.doReturn("test").when(propaccess).decrypt("test", false);
- Rcli rcliObj = Mockito.mock(Rcli.class);
- Mockito.doReturn(rcliObj).when(con).client();
- Mockito.doReturn(rcliObj).when(rcliObj).forUser(null);
- Future<String> futureObj = Mockito.mock(Future.class);
- Mockito.doReturn(futureObj).when(rcliObj).read( "/authn/basicAuth","text/plain");
- realm = authnObj.validate("test", "test","test");
- assertTrue(realm.contains("user/pass combo invalid"));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testValidateRevalidate() {
- AAFAuthnImpl authnObj = new AAFAuthnImpl(con);
- String realm="";
- try {
- Mockito.doReturn("test").when(propaccess).decrypt("test", false);
- Rcli rcliObj = Mockito.mock(Rcli.class);
- Mockito.doReturn(rcliObj).when(con).client();
- Mockito.doReturn(rcliObj).when(rcliObj).forUser(null);
- Future<String> futureObj = Mockito.mock(Future.class);
- Mockito.doReturn(futureObj).when(rcliObj).read( "/authn/basicAuth","text/plain");
- Mockito.doReturn(true).when(futureObj).get( 0);
- realm = authnObj.validate("test", "test","test");
- assertNull(realm);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testValidateValidUser() {
- AAFAuthnImplWithGetUser authnObj = new AAFAuthnImplWithGetUser(con);
- String realm="";
- try {
- Mockito.doReturn("test").when(propaccess).decrypt("test", false);
- realm = authnObj.validate("test", "test","test");
- assertTrue(realm.contains("User already denied"));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testValidateValidUserNull() {
- AAFAuthnImplWithGetUserNull authnObj = new AAFAuthnImplWithGetUserNull(con);
- String realm="";
- try {
- Mockito.doReturn("test").when(propaccess).decrypt("test", false);
- realm = authnObj.validate("test", "test","test");
- assertNull(realm);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- class AAFAuthnImpl extends AAFAuthn{
- AAFAuthnImpl(AAFCon con) {
- super(con);
- this.access = propaccess;
- // TODO Auto-generated constructor stub
- }
-
- AAFAuthnImpl(AAFCon con, AbsUserCache cache) {
- super(con, cache);
- this.access = propaccess;
- // TODO Auto-generated constructor stub
- }
-
-
- }
-
- class AAFAuthnImplWithGetUser extends AAFAuthn{
- AAFAuthnImplWithGetUser(AAFCon con) {
- super(con);
- this.access = propaccess;
- // TODO Auto-generated constructor stub
- }
-
- AAFAuthnImplWithGetUser(AAFCon con, AbsUserCache cache) {
- super(con, cache);
- this.access = propaccess;
- // TODO Auto-generated constructor stub
- }
-
- @Override
- protected User getUser(String user, byte[] cred) {
- return new User<>("test",new byte[] {});
- }
- }
-
- class AAFAuthnImplWithGetUserNull extends AAFAuthn{
- AAFAuthnImplWithGetUserNull(AAFCon con) {
- super(con);
- this.access = propaccess;
- // TODO Auto-generated constructor stub
- }
-
- AAFAuthnImplWithGetUserNull(AAFCon con, AbsUserCache cache) {
- super(con, cache);
- this.access = propaccess;
- // TODO Auto-generated constructor stub
- }
-
- @Override
- protected User getUser(String user, byte[] cred) {
- User user1 = null;
- try {
- user1 = new User(new BasicPrincipal("test","test"));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return user1;
- }
- }
+ @Test
+ public void testGetRealm() {
+ AAFAuthn authnObj = new AAFAuthn(con);
+ String realm = authnObj.getRealm();
+ assertNull(realm);
+ }
+
+ @Test
+ public void testValidateFailure() {
+ AAFAuthnImplWithGetUserNull authnObj = new AAFAuthnImplWithGetUserNull(con, cache);
+ String realm="";
+ try {
+ Mockito.doReturn("test").when(propaccess).decrypt("test", false);
+ realm = authnObj.validate("test", "test");
+ assertNull(realm);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ assertNull( e.getLocalizedMessage());
+ }
+ }
+
+ @Test
+ public void testValidate() {
+ AAFAuthnImpl authnObj = new AAFAuthnImpl(con);
+ String realm="";
+ try {
+ Mockito.doReturn("test").when(propaccess).decrypt("test", false);
+ Rcli rcliObj = Mockito.mock(Rcli.class);
+ Mockito.doReturn(rcliObj).when(con).client();
+ Mockito.doReturn(rcliObj).when(rcliObj).forUser(null);
+ Future<String> futureObj = Mockito.mock(Future.class);
+ Mockito.doReturn(futureObj).when(rcliObj).read( "/authn/basicAuth","text/plain");
+ realm = authnObj.validate("test", "test","test");
+ assertTrue(realm.contains("user/pass combo invalid"));
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateRevalidate() {
+ AAFAuthnImpl authnObj = new AAFAuthnImpl(con);
+ String realm="";
+ try {
+ Mockito.doReturn("test").when(propaccess).decrypt("test", false);
+ Rcli rcliObj = Mockito.mock(Rcli.class);
+ Mockito.doReturn(rcliObj).when(con).client();
+ Mockito.doReturn(rcliObj).when(rcliObj).forUser(null);
+ Future<String> futureObj = Mockito.mock(Future.class);
+ Mockito.doReturn(futureObj).when(rcliObj).read( "/authn/basicAuth","text/plain");
+ Mockito.doReturn(true).when(futureObj).get( 0);
+ realm = authnObj.validate("test", "test","test");
+ assertNull(realm);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateValidUser() {
+ AAFAuthnImplWithGetUser authnObj = new AAFAuthnImplWithGetUser(con);
+ String realm="";
+ try {
+ Mockito.doReturn("test").when(propaccess).decrypt("test", false);
+ realm = authnObj.validate("test", "test","test");
+ assertTrue(realm.contains("User already denied"));
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testValidateValidUserNull() {
+ AAFAuthnImplWithGetUserNull authnObj = new AAFAuthnImplWithGetUserNull(con);
+ String realm="";
+ try {
+ Mockito.doReturn("test").when(propaccess).decrypt("test", false);
+ realm = authnObj.validate("test", "test","test");
+ assertNull(realm);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ class AAFAuthnImpl extends AAFAuthn{
+ AAFAuthnImpl(AAFCon con) {
+ super(con);
+ this.access = propaccess;
+ // TODO Auto-generated constructor stub
+ }
+
+ AAFAuthnImpl(AAFCon con, AbsUserCache cache) {
+ super(con, cache);
+ this.access = propaccess;
+ // TODO Auto-generated constructor stub
+ }
+
+
+ }
+
+ class AAFAuthnImplWithGetUser extends AAFAuthn{
+ AAFAuthnImplWithGetUser(AAFCon con) {
+ super(con);
+ this.access = propaccess;
+ // TODO Auto-generated constructor stub
+ }
+
+ AAFAuthnImplWithGetUser(AAFCon con, AbsUserCache cache) {
+ super(con, cache);
+ this.access = propaccess;
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected User getUser(String user, byte[] cred) {
+ return new User<>("test",new byte[] {});
+ }
+ }
+
+ class AAFAuthnImplWithGetUserNull extends AAFAuthn{
+ AAFAuthnImplWithGetUserNull(AAFCon con) {
+ super(con);
+ this.access = propaccess;
+ // TODO Auto-generated constructor stub
+ }
+
+ AAFAuthnImplWithGetUserNull(AAFCon con, AbsUserCache cache) {
+ super(con, cache);
+ this.access = propaccess;
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected User getUser(String user, byte[] cred) {
+ User user1 = null;
+ try {
+ user1 = new User(new BasicPrincipal("test","test"));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return user1;
+ }
+ }
}
diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFSingleLocator.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFSingleLocator.java
index 488c2857..89066c99 100644
--- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFSingleLocator.java
+++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFSingleLocator.java
@@ -42,97 +42,97 @@ import org.onap.aaf.cadi.aaf.AAFPermission;
public class JU_AAFSingleLocator {
- @Mock
- AAFCon con;
-
- @Mock
- AbsUserCache<AAFPermission> cache;
-
- @Mock
- PropAccess propaccess;
-
+ @Mock
+ AAFCon con;
+
+ @Mock
+ AbsUserCache<AAFPermission> cache;
+
+ @Mock
+ PropAccess propaccess;
+
- AAFSingleLocator authnObj;
-
- @Before
- public void setUp() {
- initMocks(this);
- try {
- authnObj = new AAFSingleLocator("http://www.google.com");
- } catch (URISyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ AAFSingleLocator authnObj;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ try {
+ authnObj = new AAFSingleLocator("http://www.google.com");
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
- @Test
- public void testGetRealm() {
- try {
- URI retVal = authnObj.get(Mockito.mock( Locator.Item.class));
- assertEquals("www.google.com",retVal.getHost());
- } catch (LocatorException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testHasItem() {
- boolean retVal = authnObj.hasItems();
- assertTrue(retVal);
- }
-
- @Test
- public void testInvalidate() {
- try {
- authnObj.invalidate(Mockito.mock( Locator.Item.class));
- } catch (LocatorException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testBest() {
- try {
- Locator.Item retVal = authnObj.best();
- assertTrue(retVal.toString().contains("org.onap.aaf.cadi.aaf.v2_0.AAFSingleLocator$SingleItem"));
- } catch (LocatorException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- @Test
- public void testFirst() {
- try {
- Locator.Item retVal = authnObj.first();
- assertTrue(retVal.toString().contains("org.onap.aaf.cadi.aaf.v2_0.AAFSingleLocator$SingleItem"));
- } catch (LocatorException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- @Test
- public void testNext() {
- try {
- Locator.Item retVal = authnObj.next(Mockito.mock( Locator.Item.class));
- assertNull(retVal);
- } catch (LocatorException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testRefres() {
- boolean retVal = authnObj.refresh();
- assertFalse(retVal);
- }
-
- @Test
- public void testdestroy() {
- authnObj.destroy();
- }
-
-
+ @Test
+ public void testGetRealm() {
+ try {
+ URI retVal = authnObj.get(Mockito.mock( Locator.Item.class));
+ assertEquals("www.google.com",retVal.getHost());
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testHasItem() {
+ boolean retVal = authnObj.hasItems();
+ assertTrue(retVal);
+ }
+
+ @Test
+ public void testInvalidate() {
+ try {
+ authnObj.invalidate(Mockito.mock( Locator.Item.class));
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testBest() {
+ try {
+ Locator.Item retVal = authnObj.best();
+ assertTrue(retVal.toString().contains("org.onap.aaf.cadi.aaf.v2_0.AAFSingleLocator$SingleItem"));
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testFirst() {
+ try {
+ Locator.Item retVal = authnObj.first();
+ assertTrue(retVal.toString().contains("org.onap.aaf.cadi.aaf.v2_0.AAFSingleLocator$SingleItem"));
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testNext() {
+ try {
+ Locator.Item retVal = authnObj.next(Mockito.mock( Locator.Item.class));
+ assertNull(retVal);
+ } catch (LocatorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testRefres() {
+ boolean retVal = authnObj.refresh();
+ assertFalse(retVal);
+ }
+
+ @Test
+ public void testdestroy() {
+ authnObj.destroy();
+ }
+
+
}
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 216b8660..0394be97 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
@@ -38,143 +38,143 @@ import locate.v1_0.MgmtEndpoint;
public class JU_RegistrationCreator {
- private static final String DOT_OOM = ".oom";
+ private static final String DOT_OOM = ".oom";
- @Test
- public void test() {
- PropAccess pa = new PropAccess();
- pa.setProperty(Config.CADI_LATITUDE, "32.7");
- pa.setProperty(Config.CADI_LONGITUDE, "-72.0");
- pa.setProperty(Config.AAF_LOCATOR_NAME, "");
-
- try {
- String hostname = Inet4Address.getLocalHost().getHostName();
- String entry = "";
- RegistrationCreator rc = new RegistrationCreator(pa);
- int port = 999;
- for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
- assertEquals(hostname,me.getHostname());
- assertEquals(port,me.getPort());
- assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
- assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
- assertEquals(2,me.getMajor());
- assertEquals(1,me.getMinor());
- assertEquals(0,me.getPatch());
- assertEquals(0,me.getPkg());
- assertEquals(entry,me.getName());
- assertEquals("https",me.getProtocol());
- assertEquals(0,me.getSpecialPorts().size());
- }
+ @Test
+ public void test() {
+ PropAccess pa = new PropAccess();
+ pa.setProperty(Config.CADI_LATITUDE, "32.7");
+ pa.setProperty(Config.CADI_LONGITUDE, "-72.0");
+ pa.setProperty(Config.AAF_LOCATOR_NAME, "");
+
+ try {
+ String hostname = Inet4Address.getLocalHost().getHostName();
+ String entry = "";
+ RegistrationCreator rc = new RegistrationCreator(pa);
+ int port = 999;
+ for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
+ assertEquals(hostname,me.getHostname());
+ assertEquals(port,me.getPort());
+ assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
+ assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
+ assertEquals(2,me.getMajor());
+ assertEquals(1,me.getMinor());
+ assertEquals(0,me.getPatch());
+ assertEquals(0,me.getPkg());
+ assertEquals(entry,me.getName());
+ assertEquals("https",me.getProtocol());
+ assertEquals(0,me.getSpecialPorts().size());
+ }
- String protocol = "http";
- pa.setProperty(Config.AAF_LOCATOR_PROTOCOL, protocol);
- rc = new RegistrationCreator(pa);
- for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
- assertEquals(hostname,me.getHostname());
- assertEquals(port,me.getPort());
- assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
- assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
- assertEquals(2,me.getMajor());
- assertEquals(1,me.getMinor());
- assertEquals(0,me.getPatch());
- assertEquals(0,me.getPkg());
- assertEquals("",me.getName());
- assertEquals(protocol,me.getProtocol());
- assertEquals(0,me.getSpecialPorts().size());
- }
-
- pa.setProperty(Config.AAF_LOCATOR_ENTRIES, "service");
- rc = new RegistrationCreator(pa);
- for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
- switch(me.getName()) {
- case "":
- assertEquals(hostname,me.getHostname());
- assertEquals(port,me.getPort());
- break;
- case "service":
- assertEquals(hostname,me.getHostname());
- assertEquals(port,me.getPort());
- break;
- default:
- fail("unknown Locator Entry");
- }
- assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
- assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
- assertEquals(2,me.getMajor());
- assertEquals(1,me.getMinor());
- assertEquals(0,me.getPatch());
- assertEquals(0,me.getPkg());
- assertEquals(protocol,me.getProtocol());
- assertEquals(0,me.getSpecialPorts().size());
- }
+ String protocol = "http";
+ pa.setProperty(Config.AAF_LOCATOR_PROTOCOL, protocol);
+ rc = new RegistrationCreator(pa);
+ for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
+ assertEquals(hostname,me.getHostname());
+ assertEquals(port,me.getPort());
+ assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
+ assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
+ assertEquals(2,me.getMajor());
+ assertEquals(1,me.getMinor());
+ assertEquals(0,me.getPatch());
+ assertEquals(0,me.getPkg());
+ assertEquals("",me.getName());
+ assertEquals(protocol,me.getProtocol());
+ assertEquals(0,me.getSpecialPorts().size());
+ }
+
+ pa.setProperty(Config.AAF_LOCATOR_ENTRIES, "service");
+ rc = new RegistrationCreator(pa);
+ for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
+ switch(me.getName()) {
+ case "":
+ assertEquals(hostname,me.getHostname());
+ assertEquals(port,me.getPort());
+ break;
+ case "service":
+ assertEquals(hostname,me.getHostname());
+ assertEquals(port,me.getPort());
+ break;
+ default:
+ fail("unknown Locator Entry");
+ }
+ assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
+ assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
+ assertEquals(2,me.getMajor());
+ assertEquals(1,me.getMinor());
+ assertEquals(0,me.getPatch());
+ assertEquals(0,me.getPkg());
+ assertEquals(protocol,me.getProtocol());
+ assertEquals(0,me.getSpecialPorts().size());
+ }
- entry = "service";
- pa.setProperty(Config.AAF_LOCATOR_ENTRIES, entry);
- rc = new RegistrationCreator(pa);
- for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
- switch(me.getName()) {
- case "":
- assertEquals(hostname,me.getHostname());
- assertEquals(port,me.getPort());
- break;
- case "service":
- assertEquals(hostname,me.getHostname());
- assertEquals(port,me.getPort());
- break;
- default:
- fail("unknown Locator Entry");
- }
- assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
- assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
- assertEquals(2,me.getMajor());
- assertEquals(1,me.getMinor());
- assertEquals(0,me.getPatch());
- assertEquals(0,me.getPkg());
- assertEquals(protocol,me.getProtocol());
- assertEquals(0,me.getSpecialPorts().size());
- }
+ entry = "service";
+ pa.setProperty(Config.AAF_LOCATOR_ENTRIES, entry);
+ rc = new RegistrationCreator(pa);
+ for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
+ switch(me.getName()) {
+ case "":
+ assertEquals(hostname,me.getHostname());
+ assertEquals(port,me.getPort());
+ break;
+ case "service":
+ assertEquals(hostname,me.getHostname());
+ assertEquals(port,me.getPort());
+ break;
+ default:
+ fail("unknown Locator Entry");
+ }
+ assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
+ assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
+ assertEquals(2,me.getMajor());
+ assertEquals(1,me.getMinor());
+ assertEquals(0,me.getPatch());
+ assertEquals(0,me.getPkg());
+ assertEquals(protocol,me.getProtocol());
+ assertEquals(0,me.getSpecialPorts().size());
+ }
- pa.setProperty(Config.AAF_LOCATOR_CONTAINER, "oom");
- pa.setProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF);
- pa.setProperty(Config.AAF_LOCATOR_NAME,"%NS.%N");
- pa.setProperty(Config.AAF_LOCATOR_NAME+DOT_OOM,"%CNS.%NS.%N");
- pa.setProperty(Config.AAF_LOCATOR_CONTAINER_NS+DOT_OOM, "onap");
- String k8s_public_hostname="k8s.public.com";
- int public_port = 30001;
-
- pa.setProperty(Config.AAF_LOCATOR_PUBLIC_FQDN,k8s_public_hostname);
- pa.setProperty(Config.AAF_LOCATOR_PUBLIC_PORT+DOT_OOM,Integer.toString(public_port));
- pa.setProperty(Config.AAF_LOCATOR_APP_NS, Config.AAF_ROOT_NS_DEF);
- rc = new RegistrationCreator(pa);
- for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
- switch(me.getName()) {
- case "org.osaaf.aaf.service":
- assertEquals(k8s_public_hostname,me.getHostname());
- assertEquals(public_port,me.getPort());
- break;
- case "onap.org.osaaf.aaf.service":
- assertEquals(hostname,me.getHostname());
- assertEquals(port,me.getPort());
- break;
- default:
- fail("unknown Entry Name, " + me.getName());
- }
- assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
- assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
- assertEquals(2,me.getMajor());
- assertEquals(1,me.getMinor());
- assertEquals(0,me.getPatch());
- assertEquals(0,me.getPkg());
- assertEquals(protocol,me.getProtocol());
- assertEquals(0,me.getSpecialPorts().size());
- }
+ pa.setProperty(Config.AAF_LOCATOR_CONTAINER, "oom");
+ pa.setProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF);
+ pa.setProperty(Config.AAF_LOCATOR_NAME,"%NS.%N");
+ pa.setProperty(Config.AAF_LOCATOR_NAME+DOT_OOM,"%CNS.%NS.%N");
+ pa.setProperty(Config.AAF_LOCATOR_CONTAINER_NS+DOT_OOM, "onap");
+ String k8s_public_hostname="k8s.public.com";
+ int public_port = 30001;
+
+ pa.setProperty(Config.AAF_LOCATOR_PUBLIC_FQDN,k8s_public_hostname);
+ pa.setProperty(Config.AAF_LOCATOR_PUBLIC_PORT+DOT_OOM,Integer.toString(public_port));
+ pa.setProperty(Config.AAF_LOCATOR_APP_NS, Config.AAF_ROOT_NS_DEF);
+ rc = new RegistrationCreator(pa);
+ for(MgmtEndpoint me : rc.create(port).getMgmtEndpoint()) {
+ switch(me.getName()) {
+ case "org.osaaf.aaf.service":
+ assertEquals(k8s_public_hostname,me.getHostname());
+ assertEquals(public_port,me.getPort());
+ break;
+ case "onap.org.osaaf.aaf.service":
+ assertEquals(hostname,me.getHostname());
+ assertEquals(port,me.getPort());
+ break;
+ default:
+ fail("unknown Entry Name, " + me.getName());
+ }
+ assertEquals(pa.getProperty(Config.CADI_LATITUDE),Float.toString(me.getLatitude()));
+ assertEquals(pa.getProperty(Config.CADI_LONGITUDE),Float.toString(me.getLongitude()));
+ assertEquals(2,me.getMajor());
+ assertEquals(1,me.getMinor());
+ assertEquals(0,me.getPatch());
+ assertEquals(0,me.getPkg());
+ assertEquals(protocol,me.getProtocol());
+ assertEquals(0,me.getSpecialPorts().size());
+ }
- } catch (CadiException | UnknownHostException e) {
- Assert.fail(e.getMessage());
- }
-
+ } catch (CadiException | UnknownHostException e) {
+ Assert.fail(e.getMessage());
+ }
+
- }
+ }
}
diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/sso/test/JU_AAFSSO.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/sso/test/JU_AAFSSO.java
index f70fc279..9871c471 100644
--- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/sso/test/JU_AAFSSO.java
+++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/sso/test/JU_AAFSSO.java
@@ -60,7 +60,7 @@ public class JU_AAFSSO {
@Test
public void test() {
-
+
// Note this is desctructive of personal dirs, and doesn't really test anything. Needs redoing.
// AAFSSO sso;
// String[] args;
@@ -70,7 +70,7 @@ public class JU_AAFSSO {
// "-noexit",
// };
// try {
-// sso = new AAFSSO(args);
+// sso = new AAFSSO(args);
//
// assertThat(new File(aafDir).exists(), is(true));
// assertThat(new File(aafDir + "/.aaf").exists(), is(true));
@@ -108,9 +108,9 @@ public class JU_AAFSSO {
// assertThat(sso.useX509(), is(false));
////
//// sso.close();
-// } catch (IOException | CadiException e) {
-// e.printStackTrace();
-// }
+// } catch (IOException | CadiException e) {
+// e.printStackTrace();
+// }
}
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java
index 30673f75..38465da4 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java
@@ -34,7 +34,7 @@ public class HBasicAuthSS extends HAuthorizationHeader implements BasicAuth {
public HBasicAuthSS(SecurityInfoC<HttpURLConnection> si, String user, String password) throws IOException {
super(si, user, "Basic " + Symm.base64noSplit.encode(user + ':' + password));
if(password==null) {
- throw new IOException("No password passed for " + user);
+ throw new IOException("No password passed for " + user);
}
}
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 9255128c..61112c47 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
@@ -121,7 +121,7 @@ public class HClient implements EClient<HttpURLConnection> {
}
pi.append(pathinfo);
}
- URI sendURI = null;
+ URI sendURI = null;
try {
sendURI = new URI(
uri.getScheme(),
@@ -149,13 +149,13 @@ public class HClient implements EClient<HttpURLConnection> {
}
// TODO other settings? There's a bunch here.
} catch (APIException e) {
- throw e;
+ throw e;
} catch (Exception 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);
- }
+ 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) {
@@ -170,7 +170,7 @@ public class HClient implements EClient<HttpURLConnection> {
}
public void setURI(URI uri) {
- this.uri = uri;
+ this.uri = uri;
}
public int timeout() {
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 ae562cb2..19e40b3a 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
@@ -170,11 +170,11 @@ public class HMangr {
}
public <RET> RET allExcept(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable,boolean notify, String selfHost) throws LocatorException, CadiException, APIException {
- return call(ss,retryable,notify,selfHost);
+ return call(ss,retryable,notify,selfHost);
}
public<RET> RET oneOf(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable,boolean notify,String host) throws LocatorException, CadiException, APIException {
- return call(ss,retryable,notify,host);
+ return call(ss,retryable,notify,host);
}
private<RET> RET call(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable,boolean notify,String host) throws LocatorException, CadiException, APIException {
RET ret = null;
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java
index 66ef4b1e..4711aee6 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java
@@ -77,10 +77,10 @@ public class DNSLocator implements Locator<URI> {
}
public static DNSLocator create(Access access, String url) throws LocatorException {
- return new DNSLocator(access, url);
- }
+ return new DNSLocator(access, url);
+ }
- @Override
+ @Override
public URI get(Item item) throws LocatorException {
return hosts[((DLItem)item).cnt].uri;
}
@@ -167,7 +167,7 @@ public class DNSLocator implements Locator<URI> {
int slash, start;
int colon = aaf_locate.indexOf(':',_start);
if (colon > 0) {
- host = aaf_locate.substring(_start,colon);
+ host = aaf_locate.substring(_start,colon);
start = colon + 1;
int left = aaf_locate.indexOf('[', start);
if (left > 0) {
@@ -189,7 +189,7 @@ public class DNSLocator implements Locator<URI> {
}
slash = aaf_locate.indexOf('/', start);
if(slash>=0) {
- suffix = aaf_locate.substring(slash);
+ suffix = aaf_locate.substring(slash);
}
} else {
@@ -205,8 +205,8 @@ public class DNSLocator implements Locator<URI> {
}
}
} else {
- slash = aaf_locate.indexOf('/', _start);
- host = slash<_start?aaf_locate.substring(_start):aaf_locate.substring(_start,slash);
+ slash = aaf_locate.indexOf('/', _start);
+ host = slash<_start?aaf_locate.substring(_start):aaf_locate.substring(_start,slash);
startPort = endPort = defaultPort;
}
@@ -225,7 +225,7 @@ public class DNSLocator implements Locator<URI> {
}
public String toString() {
- return uri.toString() + " - " + status.name();
+ return uri.toString() + " - " + status.name();
}
}
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 bccb8116..34889138 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
@@ -182,7 +182,7 @@ public class PropertyLocator implements Locator<URI> {
String realname;
for (int i = 0; i < orig.length ; ++i) {
try {
- FixURIinfo fui = new FixURIinfo(orig[i]);
+ FixURIinfo fui = new FixURIinfo(orig[i]);
InetAddress ia[] = InetAddress.getAllByName(fui.getHost());
URI o,n;
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java
index d1744253..10eb8184 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java
@@ -184,10 +184,10 @@ public class JU_HMangr {
assertThat(hman.best(ssMock, retryableMock), is(nullValue()));
try {
- hman.all(ssMock, retryableMock, true);
- Assert.fail("Should have thrown LocatorException");
+ hman.all(ssMock, retryableMock, true);
+ Assert.fail("Should have thrown LocatorException");
} catch (LocatorException e) {
- assertEquals(e.getLocalizedMessage(),"No available clients to call");
+ assertEquals(e.getLocalizedMessage(),"No available clients to call");
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java b/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
index 0a1f38db..b697f373 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/CmdLine.java
@@ -114,7 +114,7 @@ public class CmdLine {
// One still needs access to the keyfile to read.
// July 2016 - thought of a tool "CMPass" to regurgitate from properties, but only if allowed.
} else if (("regurgitate".equalsIgnoreCase(args[0]) || "undigest".equalsIgnoreCase(args[0]))
- && args.length>2) {
+ && args.length>2) {
try {
Symm symm;
FileInputStream fis = new FileInputStream(args[2]);
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 9f4b4b9f..1bf0230e 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
@@ -48,9 +48,9 @@ public class PropAccess implements Access {
// Sonar says cannot be static... it's ok. not too many PropAccesses created.
private final SimpleDateFormat iso8601 = newISO8601();
private Symm symm;
-
+
public static SimpleDateFormat newISO8601() {
- return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
}
public static final Level DEFAULT = Level.AUDIT;
@@ -135,12 +135,12 @@ public class PropAccess implements Access {
load(props.getProperty(Config.CADI_PROP_FILES));
if(sLevel==null) { // if LogLev wasn't set before, check again after Chained Load
- sLevel = props.getProperty(Config.CADI_LOGLEVEL);
- if (sLevel==null) {
- level=DEFAULT.maskOf();
- } else {
- level=Level.valueOf(sLevel).maskOf();
- }
+ sLevel = props.getProperty(Config.CADI_LOGLEVEL);
+ if (sLevel==null) {
+ level=DEFAULT.maskOf();
+ } else {
+ level=Level.valueOf(sLevel).maskOf();
+ }
}
// Setup local Symmetrical key encryption
if (symm==null) {
@@ -179,15 +179,15 @@ public class PropAccess implements Access {
// Only load props from recursion which are not already in props
// meaning top Property file takes precedence
for(Entry<Object, Object> es : fileProps.entrySet()) {
- if(props.get(es.getKey())==null) {
- String key = es.getKey().toString();
- String value = es.getValue().toString();
- props.put(key, value);
- if(key.contains("pass")) {
- value = "XXXXXXX";
- }
- printf(Level.DEBUG," %s=%s",key,value);
- }
+ if(props.get(es.getKey())==null) {
+ String key = es.getKey().toString();
+ String value = es.getValue().toString();
+ props.put(key, value);
+ if(key.contains("pass")) {
+ value = "XXXXXXX";
+ }
+ printf(Level.DEBUG," %s=%s",key,value);
+ }
}
// Recursively Load
String chainProp = fileProps.getProperty(Config.CADI_PROP_FILES);
@@ -272,64 +272,64 @@ public class PropAccess implements Access {
* Need to pass in DateFormat per thread, because not marked as thread safe
*/
public static StringBuilder buildMsg(final String name, final DateFormat sdf, Level level, Object[] elements) {
- final StringBuilder sb;
+ final StringBuilder sb;
int end = elements.length;
- if(sdf==null) {
- sb = new StringBuilder();
- write(true,sb,elements);
- } else {
- sb = new StringBuilder(
- sdf.format(new Date())
- );
+ if(sdf==null) {
+ sb = new StringBuilder();
+ write(true,sb,elements);
+ } else {
+ sb = new StringBuilder(
+ sdf.format(new Date())
+ );
sb.append(' ');
sb.append(level.name());
sb.append(" [");
sb.append(name);
- if (end<=0) {
- sb.append("] ");
- } else {
- int idx = 0;
- if(elements[idx]!=null &&
- elements[idx] instanceof Integer) {
- sb.append('-');
- sb.append(elements[idx]);
- ++idx;
- }
- sb.append("] ");
- write(true,sb,elements);
- }
- }
+ if (end<=0) {
+ sb.append("] ");
+ } else {
+ int idx = 0;
+ if(elements[idx]!=null &&
+ elements[idx] instanceof Integer) {
+ sb.append('-');
+ sb.append(elements[idx]);
+ ++idx;
+ }
+ sb.append("] ");
+ write(true,sb,elements);
+ }
+ }
return sb;
}
private static boolean write(boolean first, StringBuilder sb, Object[] elements) {
- String s;
+ String s;
for (Object o : elements) {
if (o!=null) {
- if(o.getClass().isArray()) {
- first = write(first,sb,(Object[])o);
- } else if(o instanceof Throwable) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- ((Throwable)o).printStackTrace(ps);
- sb.append(baos.toString());
- } 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);
- }
+ if(o.getClass().isArray()) {
+ first = write(first,sb,(Object[])o);
+ } else if(o instanceof Throwable) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos);
+ ((Throwable)o).printStackTrace(ps);
+ sb.append(baos.toString());
+ } 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;
@@ -337,10 +337,10 @@ public class PropAccess implements Access {
@Override
public void log(Exception e, Object... elements) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- pw.println();
- e.printStackTrace(pw);
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ pw.println();
+ e.printStackTrace(pw);
log(Level.ERROR,elements,sw.toString());
}
@@ -436,6 +436,6 @@ public class PropAccess implements Access {
}
public String toString() {
- return props.toString();
+ return props.toString();
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java b/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
index 9a66d313..e7533610 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/Symm.java
@@ -82,7 +82,7 @@ public class Symm {
private byte[] keyBytes = null;
//Note: AES Encryption is not Thread Safe. It is Synchronized
//private AES aes = null; // only initialized from File, and only if needed for Passwords
- private String name;
+ private String name;
/**
* This is the standard base64 Key Set.
@@ -900,6 +900,6 @@ public class Symm {
@Override
public String toString() {
- return name;
+ return name;
}
}
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 30508b7d..7bd578a5 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
@@ -275,10 +275,10 @@ public class Config {
Access access = si.access;
RegistrationPropHolder rph;
try {
- rph = new RegistrationPropHolder(access, 0);
- } catch (UnknownHostException e2) {
- throw new CadiException(e2);
- }
+ rph = new RegistrationPropHolder(access, 0);
+ } catch (UnknownHostException e2) {
+ throw new CadiException(e2);
+ }
/////////////////////////////////////////////////////
// Setup AAFCon for any following
/////////////////////////////////////////////////////
@@ -504,7 +504,7 @@ public class Config {
// Any Additional Tafs passed in Constructor
/////////////////////////////////////////////////////
if (additionalTafLurs!=null) {
- int i=0;
+ int i=0;
for (Object additional : additionalTafLurs) {
if (additional instanceof BasicHttpTaf) {
BasicHttpTaf ht = (BasicHttpTaf)additional;
@@ -556,17 +556,17 @@ public class Config {
// just return the one
taf = htlist.get(0).t;
} else {
- Collections.sort(htlist);
+ Collections.sort(htlist);
HttpTaf[] htarray = new HttpTaf[htlist.size()];
int i=-1;
StringBuilder sb = new StringBuilder("Tafs processed in this order:\n");
for(Priori<HttpTaf> pht : htlist) {
- htarray[++i] = pht.t;
- sb.append(" ");
- sb.append(pht.t.getClass().getName());
- sb.append('(');
- sb.append(pht.priority);
- sb.append(")\n");
+ htarray[++i] = pht.t;
+ sb.append(" ");
+ sb.append(pht.t.getClass().getName());
+ sb.append('(');
+ sb.append(pht.priority);
+ sb.append(")\n");
}
access.log(Level.INIT, sb);
@@ -585,13 +585,13 @@ public class Config {
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");
+ rph.access().log(Level.INIT,tag,"is not explicitly set");
} else {
- rv = rph.replacements("Config.logProp",rv, null, null);
- rph.access().log(Level.INIT,tag,"is set to",rv);
+ rv = rph.replacements("Config.logProp",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) {
@@ -608,10 +608,10 @@ public class Config {
Access access = si.access;
RegistrationPropHolder rph;
try {
- rph = new RegistrationPropHolder(access, 0);
- } catch (UnknownHostException e2) {
- throw new CadiException(e2);
- }
+ rph = new RegistrationPropHolder(access, 0);
+ } catch (UnknownHostException e2) {
+ throw new CadiException(e2);
+ }
List<Priori<Lur>> lurs = new ArrayList<>();
@@ -728,7 +728,7 @@ public class Config {
// Any Additional passed in Constructor
/////////////////////////////////////////////////////
if (additionalTafLurs!=null) {
- int i=0;
+ int i=0;
for (Object additional : additionalTafLurs) {
if (additional instanceof Lur) {
lurs.add(new Priori<Lur>((Lur)additional,50+i++));
@@ -754,17 +754,17 @@ public class Config {
return lurs.get(0).t; // Only one, just return it, save processing
default:
// Multiple Lurs, use EpiLUR to handle
- Collections.sort(lurs);
+ Collections.sort(lurs);
Lur[] la = new Lur[lurs.size()];
int i=-1;
StringBuilder sb = new StringBuilder("Lurs processed in this order:\n");
for(Priori<Lur> pht : lurs) {
- la[++i] = pht.t;
- sb.append(" ");
- sb.append(pht.t.getClass().getName());
- sb.append('(');
- sb.append(pht.priority);
- sb.append(")\n");
+ la[++i] = pht.t;
+ sb.append(" ");
+ sb.append(pht.t.getClass().getName());
+ sb.append('(');
+ sb.append(pht.priority);
+ sb.append(")\n");
}
access.log(Level.INIT, sb);
return new EpiLur(la);
@@ -855,53 +855,53 @@ public class Config {
if (_url==null) {
access.log(Level.INIT,"No URL passed to 'loadLocator'. Disabled");
} else {
- try {
- Class<?> aalCls = Class.forName("org.onap.aaf.cadi.aaf.v2_0.AbsAAFLocator");
- Method aalMth = aalCls.getMethod("create", String.class,String.class);
- int colon = _url.lastIndexOf(':');
- if(colon>=0) {
- int slash = _url.indexOf('/',colon);
- String version;
- if(slash<0) {
- version = _url.substring(colon+1);
- } else {
- version = _url.substring(colon+1,slash);
- }
- slash = _url.lastIndexOf('/',colon);
- if(slash>=0) {
- Object aal = aalMth.invoke(null/*static*/, _url.substring(slash+1, colon),version);
- return (Locator<URI>)aal;
- }
- }
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- String msg;
- char quote;
- if(e.getCause()!=null) {
- msg=e.getCause().getMessage();
- quote='"';
- } else {
- msg = "-";
- quote=' ';
- }
- access.printf(Level.DEBUG, "Configured AbsAAFLocator not found%c%s%cContinuing Locator creation ",quote,msg,quote);
- }
+ try {
+ Class<?> aalCls = Class.forName("org.onap.aaf.cadi.aaf.v2_0.AbsAAFLocator");
+ Method aalMth = aalCls.getMethod("create", String.class,String.class);
+ int colon = _url.lastIndexOf(':');
+ if(colon>=0) {
+ int slash = _url.indexOf('/',colon);
+ String version;
+ if(slash<0) {
+ version = _url.substring(colon+1);
+ } else {
+ version = _url.substring(colon+1,slash);
+ }
+ slash = _url.lastIndexOf('/',colon);
+ if(slash>=0) {
+ Object aal = aalMth.invoke(null/*static*/, _url.substring(slash+1, colon),version);
+ return (Locator<URI>)aal;
+ }
+ }
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ String msg;
+ char quote;
+ if(e.getCause()!=null) {
+ msg=e.getCause().getMessage();
+ quote='"';
+ } else {
+ msg = "-";
+ quote=' ';
+ }
+ access.printf(Level.DEBUG, "Configured AbsAAFLocator not found%c%s%cContinuing Locator creation ",quote,msg,quote);
+ }
// String url = _url.replace("/AAF_NS.", "/%C%CID%AAF_NS.");
// String root_ns = access.getProperty(Config.AAF_ROOT_NS, null);
- String url;
+ String url;
RegistrationPropHolder rph;
try {
- rph = new RegistrationPropHolder(access, 0);
- url = rph.replacements("Config.loadLocator",_url, null, null);
- access.printf(Level.INFO, "loadLocator URL is %s",url);
- } catch (UnknownHostException | CadiException e1) {
- throw new LocatorException(e1);
- }
+ rph = new RegistrationPropHolder(access, 0);
+ url = rph.replacements("Config.loadLocator",_url, null, null);
+ access.printf(Level.INFO, "loadLocator URL is %s",url);
+ } catch (UnknownHostException | CadiException e1) {
+ throw new LocatorException(e1);
+ }
String aaf_locator_class;
if(_url.equals(url) && !url.contains("/locate/")) {
- aaf_locator_class = "org.onap.aaf.cadi.locator.DNSLocator";
+ aaf_locator_class = "org.onap.aaf.cadi.locator.DNSLocator";
} else {
- aaf_locator_class = AAF_LOCATOR_CLASS_DEF;
+ aaf_locator_class = AAF_LOCATOR_CLASS_DEF;
}
try {
Class<?> lcls = loadClass(access,aaf_locator_class);
@@ -945,83 +945,83 @@ public class Config {
}
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;
+ 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<T> implements Comparable<Priori<T>> {
- public final T t;
- public final int priority;
-
- public Priori(final T t, final int priority) {
- this.t = t;
- this.priority = priority;
- }
+ public final T t;
+ public final int priority;
+
+ public Priori(final T t, final int priority) {
+ this.t = t;
+ this.priority = priority;
+ }
- @Override
- public int compareTo(Priori<T> o) {
- if(priority==o.priority) {
- return 0;
- } else if(priority<o.priority) {
- return -1;
- } else {
- return 1;
- }
- }
- public static<T> void add(Access access, final String tag, List<Priori<T>> list) {
- String plugins = access.getProperty(tag, null);
- if(plugins!=null) {
- access.log(Level.INIT, "Adding TAF Plugins: ", plugins);
- for(String tafs : Split.splitTrim(';', plugins)) {
- String[] pluginArray = Split.splitTrim(',', tafs);
- String clssn = null;
- int priority = 60;
- switch(pluginArray.length) {
- case 0:
- break;
- case 1:
- clssn = tafs;
- break;
- default:
- clssn = pluginArray[0];
- try {
- priority = Integer.parseInt(pluginArray[1]);
- } catch (NumberFormatException nfe) {
- access.printf(Level.ERROR, "%s format is <classname>,priority[;...]\n",CADI_ADD_TAFS);
- }
- }
-
- if(clssn!=null) {
- Class<?> cls = loadClass(access, clssn);
- if(cls!=null) {
- try {
- @SuppressWarnings("unchecked")
- Constructor<T> cnst = (Constructor<T>)cls.getConstructor(Access.class);
- try {
- list.add(new Priori<T>(cnst.newInstance(access),priority));
- } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- String hostname = access.getProperty(Config.HOSTNAME,null);
- if(hostname==null) {
- access.printf(Level.ERROR, "%s cannot be constructed on this machine. Set valid 'hostname' in your properties\n",clssn);
- } else {
- access.printf(Level.ERROR, "%s cannot be constructed on %s with Access.\n",clssn, hostname);
- }
- }
- } catch (NoSuchMethodException | SecurityException e) {
- access.printf(Level.ERROR, "%s needs a Constructor taking Access as sole param.\n",clssn);
- }
- }
- }
- }
- }
- }
+ @Override
+ public int compareTo(Priori<T> o) {
+ if(priority==o.priority) {
+ return 0;
+ } else if(priority<o.priority) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ public static<T> void add(Access access, final String tag, List<Priori<T>> list) {
+ String plugins = access.getProperty(tag, null);
+ if(plugins!=null) {
+ access.log(Level.INIT, "Adding TAF Plugins: ", plugins);
+ for(String tafs : Split.splitTrim(';', plugins)) {
+ String[] pluginArray = Split.splitTrim(',', tafs);
+ String clssn = null;
+ int priority = 60;
+ switch(pluginArray.length) {
+ case 0:
+ break;
+ case 1:
+ clssn = tafs;
+ break;
+ default:
+ clssn = pluginArray[0];
+ try {
+ priority = Integer.parseInt(pluginArray[1]);
+ } catch (NumberFormatException nfe) {
+ access.printf(Level.ERROR, "%s format is <classname>,priority[;...]\n",CADI_ADD_TAFS);
+ }
+ }
+
+ if(clssn!=null) {
+ Class<?> cls = loadClass(access, clssn);
+ if(cls!=null) {
+ try {
+ @SuppressWarnings("unchecked")
+ Constructor<T> cnst = (Constructor<T>)cls.getConstructor(Access.class);
+ try {
+ list.add(new Priori<T>(cnst.newInstance(access),priority));
+ } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ String hostname = access.getProperty(Config.HOSTNAME,null);
+ if(hostname==null) {
+ access.printf(Level.ERROR, "%s cannot be constructed on this machine. Set valid 'hostname' in your properties\n",clssn);
+ } else {
+ access.printf(Level.ERROR, "%s cannot be constructed on %s with Access.\n",clssn, hostname);
+ }
+ }
+ } catch (NoSuchMethodException | SecurityException e) {
+ access.printf(Level.ERROR, "%s needs a Constructor taking Access as sole param.\n",clssn);
+ }
+ }
+ }
+ }
+ }
+ }
}
}
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 2a8760f4..f73179a9 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
@@ -29,259 +29,259 @@ import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.util.Split;
public class RegistrationPropHolder {
- private final String PUBLIC_NAME="%NS.%N";
- private final String REGI="RegistrationProperty: %s='%s'";
- private final Access access;
- public String hostname;
- private int port;
- public String public_fqdn;
- private Integer public_port;
- public Float latitude;
- public Float longitude;
- public final String default_fqdn;
- public final String default_container_ns;
- public final String default_name;
- public final String lentries;
- public final String lcontainer;
- public final String default_container;
- private static boolean firstlog = true;
+ private final String PUBLIC_NAME="%NS.%N";
+ private final String REGI="RegistrationProperty: %s='%s'";
+ private final Access access;
+ public String hostname;
+ private int port;
+ public String public_fqdn;
+ private Integer public_port;
+ public Float latitude;
+ public Float longitude;
+ public final String default_fqdn;
+ public final String default_container_ns;
+ public final String default_name;
+ public final String lentries;
+ public final String lcontainer;
+ public final String default_container;
+ private static boolean firstlog = true;
- public RegistrationPropHolder(final Access access, final int port) throws UnknownHostException, CadiException {
- this.access = access;
- StringBuilder errs = new StringBuilder();
- String str;
- this.port = port;
+ public RegistrationPropHolder(final Access access, final int port) throws UnknownHostException, CadiException {
+ this.access = access;
+ StringBuilder errs = new StringBuilder();
+ String str;
+ this.port = port;
- lentries=access.getProperty(Config.AAF_LOCATOR_ENTRIES,"");
- default_container = access.getProperty(Config.AAF_LOCATOR_CONTAINER, "");
- if(firstlog) {
- access.printf(Level.INIT, REGI,"default_container",default_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=default_container;
- str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT, null);
- }
- if(str!=null) {
- public_port=Integer.decode(str);
- }
- if(firstlog) {
- access.printf(Level.INIT, "RegistrationProperty: public_port='%d'",public_port);
- }
+ lentries=access.getProperty(Config.AAF_LOCATOR_ENTRIES,"");
+ default_container = access.getProperty(Config.AAF_LOCATOR_CONTAINER, "");
+ if(firstlog) {
+ access.printf(Level.INIT, REGI,"default_container",default_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=default_container;
+ str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT, null);
+ }
+ if(str!=null) {
+ public_port=Integer.decode(str);
+ }
+ if(firstlog) {
+ access.printf(Level.INIT, "RegistrationProperty: public_port='%d'",public_port);
+ }
- hostname = access.getProperty(Config.HOSTNAME, null);
- if (hostname==null) {
- hostname = Inet4Address.getLocalHost().getHostName();
- }
- if (hostname==null) {
- mustBeDefined(errs,Config.HOSTNAME);
- }
- if(firstlog) {
- access.printf(Level.INIT, REGI,"hostname",hostname);
- }
+ hostname = access.getProperty(Config.HOSTNAME, null);
+ if (hostname==null) {
+ hostname = Inet4Address.getLocalHost().getHostName();
+ }
+ if (hostname==null) {
+ mustBeDefined(errs,Config.HOSTNAME);
+ }
+ if(firstlog) {
+ access.printf(Level.INIT, REGI,"hostname",hostname);
+ }
- public_fqdn = access.getProperty(Config.AAF_LOCATOR_PUBLIC_FQDN, hostname);
- if(firstlog) {
- access.printf(Level.INIT, REGI,"public_fqdn",public_fqdn);
- }
+ public_fqdn = access.getProperty(Config.AAF_LOCATOR_PUBLIC_FQDN, hostname);
+ if(firstlog) {
+ access.printf(Level.INIT, REGI,"public_fqdn",public_fqdn);
+ }
- // Allow Container to reset the standard name for public
- String container_public_name = access.getProperty(Config.AAF_LOCATOR_PUBLIC_NAME+'.'+default_container, null);
- if(container_public_name==null) {
- container_public_name = access.getProperty(Config.AAF_LOCATOR_PUBLIC_NAME, null);
- if(container_public_name==null) {
- container_public_name = access.getProperty(Config.AAF_LOCATOR_NAME, PUBLIC_NAME);
- }
- }
- default_name = container_public_name;
-
- if(firstlog) {
- access.printf(Level.INIT, REGI,"default_name",default_name);
- }
-
- latitude=null;
- String slatitude = access.getProperty(Config.CADI_LATITUDE, null);
- if(slatitude == null) {
- mustBeDefined(errs,Config.CADI_LATITUDE);
- } else {
- latitude = Float.parseFloat(slatitude);
- }
- if(firstlog) {
- access.printf(Level.INIT, REGI,"latitude",slatitude);
- }
+ // Allow Container to reset the standard name for public
+ String container_public_name = access.getProperty(Config.AAF_LOCATOR_PUBLIC_NAME+'.'+default_container, null);
+ if(container_public_name==null) {
+ container_public_name = access.getProperty(Config.AAF_LOCATOR_PUBLIC_NAME, null);
+ if(container_public_name==null) {
+ container_public_name = access.getProperty(Config.AAF_LOCATOR_NAME, PUBLIC_NAME);
+ }
+ }
+ default_name = container_public_name;
+
+ if(firstlog) {
+ access.printf(Level.INIT, REGI,"default_name",default_name);
+ }
+
+ latitude=null;
+ String slatitude = access.getProperty(Config.CADI_LATITUDE, null);
+ if(slatitude == null) {
+ mustBeDefined(errs,Config.CADI_LATITUDE);
+ } else {
+ latitude = Float.parseFloat(slatitude);
+ }
+ if(firstlog) {
+ access.printf(Level.INIT, REGI,"latitude",slatitude);
+ }
- longitude=null;
- String slongitude = access.getProperty(Config.CADI_LONGITUDE, null);
- if(slongitude == null) {
- mustBeDefined(errs,Config.CADI_LONGITUDE);
- } else {
- longitude = Float.parseFloat(slongitude);
- }
- if(firstlog) {
- access.printf(Level.INIT, REGI,"longitude",slongitude);
- }
+ longitude=null;
+ String slongitude = access.getProperty(Config.CADI_LONGITUDE, null);
+ if(slongitude == null) {
+ mustBeDefined(errs,Config.CADI_LONGITUDE);
+ } else {
+ longitude = Float.parseFloat(slongitude);
+ }
+ if(firstlog) {
+ access.printf(Level.INIT, REGI,"longitude",slongitude);
+ }
- String dot_le;
- // Note: only one of the ports can be public... Therefore, only the last
- for(String le : Split.splitTrim(',', lcontainer)) {
- dot_le = le.isEmpty()?le :"."+le;
- str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_FQDN+dot_le,null);
- if( str != null && !str.isEmpty()) {
- public_fqdn=str;
- if(firstlog) {
- access.printf(Level.INIT, "RegistrationProperty: public_hostname(overloaded by %s)='%s'",dot_le,public_fqdn);
- }
- }
- }
-
- default_fqdn = access.getProperty(Config.AAF_LOCATOR_FQDN, hostname);
- if(firstlog) {
- access.printf(Level.INIT, REGI,"default_fqdn",default_fqdn);
- }
- default_container_ns = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS,"");
- if(firstlog) {
- access.printf(Level.INIT, REGI,"default_container_ns",default_container_ns);
- }
- if(errs.length()>0) {
- throw new CadiException(errs.toString());
- }
- firstlog = false;
- }
+ String dot_le;
+ // Note: only one of the ports can be public... Therefore, only the last
+ for(String le : Split.splitTrim(',', lcontainer)) {
+ dot_le = le.isEmpty()?le :"."+le;
+ str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_FQDN+dot_le,null);
+ if( str != null && !str.isEmpty()) {
+ public_fqdn=str;
+ if(firstlog) {
+ access.printf(Level.INIT, "RegistrationProperty: public_hostname(overloaded by %s)='%s'",dot_le,public_fqdn);
+ }
+ }
+ }
+
+ default_fqdn = access.getProperty(Config.AAF_LOCATOR_FQDN, hostname);
+ if(firstlog) {
+ access.printf(Level.INIT, REGI,"default_fqdn",default_fqdn);
+ }
+ default_container_ns = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS,"");
+ if(firstlog) {
+ access.printf(Level.INIT, REGI,"default_container_ns",default_container_ns);
+ }
+ if(errs.length()>0) {
+ throw new CadiException(errs.toString());
+ }
+ firstlog = false;
+ }
- private void mustBeDefined(StringBuilder errs, String propname) {
- errs.append('\n');
- errs.append(propname);
- errs.append(" must be defined.");
-
- }
+ private void mustBeDefined(StringBuilder errs, String propname) {
+ errs.append('\n');
+ errs.append(propname);
+ errs.append(" must be defined.");
+
+ }
- public String getEntryFQDN(final String entry, final String dot_le) {
- String str;
- if(public_fqdn!=null && dot_le.isEmpty()) {
- str = public_fqdn;
- } else {
- str = access.getProperty(Config.AAF_LOCATOR_FQDN+dot_le, default_fqdn);
- }
- return replacements("RegistrationPropHolder.getEntryFQDN",str,entry,dot_le);
- }
-
- public String getEntryName(final String entry, final String dot_le) {
- String str;
- if(dot_le.isEmpty()) {
- str = default_name;
- } else {
- str = access.getProperty(Config.AAF_LOCATOR_NAME+dot_le, default_name);
- }
- return replacements("RegistrationPropHolder.getEntryName",str,entry,dot_le);
- }
-
- public String getPublicEntryName(final String entry, final String dot_le) {
- String str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_NAME+dot_le, null);
- if(str==null) {
- str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_NAME,null);
- }
- if(str==null) {
- str = default_name;
- }
- return replacements("RegistrationPropHolder.getEntryName",str,entry,dot_le);
- }
-
-
- private String getNS(String dot_le) {
- String ns;
- ns = access.getProperty(Config.AAF_LOCATOR_APP_NS+dot_le,null);
- if(ns==null) {
- ns = access.getProperty(Config.AAF_LOCATOR_APP_NS, "AAF_NS");
- }
- return ns;
- }
+ public String getEntryFQDN(final String entry, final String dot_le) {
+ String str;
+ if(public_fqdn!=null && dot_le.isEmpty()) {
+ str = public_fqdn;
+ } else {
+ str = access.getProperty(Config.AAF_LOCATOR_FQDN+dot_le, default_fqdn);
+ }
+ return replacements("RegistrationPropHolder.getEntryFQDN",str,entry,dot_le);
+ }
+
+ public String getEntryName(final String entry, final String dot_le) {
+ String str;
+ if(dot_le.isEmpty()) {
+ str = default_name;
+ } else {
+ str = access.getProperty(Config.AAF_LOCATOR_NAME+dot_le, default_name);
+ }
+ return replacements("RegistrationPropHolder.getEntryName",str,entry,dot_le);
+ }
+
+ public String getPublicEntryName(final String entry, final String dot_le) {
+ String str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_NAME+dot_le, null);
+ if(str==null) {
+ str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_NAME,null);
+ }
+ if(str==null) {
+ str = default_name;
+ }
+ return replacements("RegistrationPropHolder.getEntryName",str,entry,dot_le);
+ }
+
+
+ private String getNS(String dot_le) {
+ String ns;
+ ns = access.getProperty(Config.AAF_LOCATOR_APP_NS+dot_le,null);
+ if(ns==null) {
+ ns = access.getProperty(Config.AAF_LOCATOR_APP_NS, "AAF_NS");
+ }
+ return ns;
+ }
-
- public String replacements(final String fromCode, final String source, final String name, final String _dot_le) {
- if(source == null) {
- return "";
- } else if(source.isEmpty()) {
- return source;
- }
- String value = source;
- String dot_le;
- if(_dot_le==null) {
- dot_le = default_container.isEmpty()?"":'.'+default_container;
- } else {
- dot_le = _dot_le;
- }
+
+ public String replacements(final String fromCode, final String source, final String name, final String _dot_le) {
+ if(source == null) {
+ return "";
+ } else if(source.isEmpty()) {
+ return source;
+ }
+ String value = source;
+ 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);
+ aaf_locator_host = access.getProperty(Config.AAF_LOCATE_URL,null);
}
String str;
if(aaf_locator_host!=null) {
- if("https://AAF_LOCATE_URL".equals(value)) {
- value = aaf_locator_host;
- } else {
- str = aaf_locator_host;
- if(value.indexOf(Config.AAF_LOCATE_URL_TAG)>=0) {
- if(!str.endsWith("/")) {
- str+='/';
- }
- if(!str.endsWith("/locate/")) {
- str+="locate/";
- }
- if(value.startsWith("http:")) {
- value = value.replace("http://AAF_LOCATE_URL/", str);
- } else {
- value = value.replace("https://AAF_LOCATE_URL/", str);
-
- }
- }
- }
+ if("https://AAF_LOCATE_URL".equals(value)) {
+ value = aaf_locator_host;
+ } else {
+ str = aaf_locator_host;
+ if(value.indexOf(Config.AAF_LOCATE_URL_TAG)>=0) {
+ if(!str.endsWith("/")) {
+ str+='/';
+ }
+ if(!str.endsWith("/locate/")) {
+ str+="locate/";
+ }
+ if(value.startsWith("http:")) {
+ value = value.replace("http://AAF_LOCATE_URL/", str);
+ } else {
+ value = value.replace("https://AAF_LOCATE_URL/", str);
+
+ }
+ }
+ }
}
- int atC = value.indexOf("%C");
- if(atC>=0) {
- // aaf_locator_container_ns
- str = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS+dot_le, default_container_ns);
- if(str.isEmpty()) {
- value = value.replace("%CNS"+'.', str);
- }
- value = value.replace("%CNS", str);
-
- str = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le,default_container);
- if(str.isEmpty()) {
- value = value.replace("%C"+'.', str);
- }
- value = value.replace("%C", str);
- }
-
- if(value.indexOf("%NS")>=0) {
- str = getNS(dot_le);
- if(str==null || str.isEmpty()) {
- value = value.replace("%NS"+'.', "");
- } else {
- value = value.replace("%NS", str);
- }
- }
+ int atC = value.indexOf("%C");
+ if(atC>=0) {
+ // aaf_locator_container_ns
+ str = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS+dot_le, default_container_ns);
+ if(str.isEmpty()) {
+ value = value.replace("%CNS"+'.', str);
+ }
+ value = value.replace("%CNS", str);
+
+ str = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le,default_container);
+ if(str.isEmpty()) {
+ value = value.replace("%C"+'.', str);
+ }
+ value = value.replace("%C", str);
+ }
+
+ if(value.indexOf("%NS")>=0) {
+ str = getNS(dot_le);
+ if(str==null || str.isEmpty()) {
+ value = value.replace("%NS"+'.', "");
+ } else {
+ value = value.replace("%NS", str);
+ }
+ }
- // aaf_root_ns
- if(value.indexOf("AAF_NS")>=0) {
- str = access.getProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF) + '.';
- String temp = value.replace("%AAF_NS.", str);
- if(temp.equals(value)) { // intended
- value = value.replace("AAF_NS.", str); // Backward Compatibility
- } else {
- value = temp;
- }
- }
+ // aaf_root_ns
+ if(value.indexOf("AAF_NS")>=0) {
+ str = access.getProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF) + '.';
+ String temp = value.replace("%AAF_NS.", str);
+ if(temp.equals(value)) { // intended
+ value = value.replace("AAF_NS.", str); // Backward Compatibility
+ } else {
+ value = temp;
+ }
+ }
-
- if(value.indexOf('%')>=0) {
+
+ if(value.indexOf('%')>=0) {
// These shouldn't be expected to have dot elements
if(name!=null) {
value = value.replace("%N", name);
@@ -292,21 +292,21 @@ public class RegistrationPropHolder {
if(public_fqdn!=null) {
value = value.replace("%PH", public_fqdn);
}
- }
- access.printf(Level.DEBUG,
- "RegistrationReplacement from %s, source: %s, dot_le: %s, value: %s",
- fromCode,source,dot_le,value);
+ }
+ access.printf(Level.DEBUG,
+ "RegistrationReplacement from %s, source: %s, dot_le: %s, value: %s",
+ fromCode,source,dot_le,value);
- return value;
- }
-
- public int getEntryPort(final String dot_le) {
- return public_port!=null && dot_le.isEmpty()?
- public_port:
- port;
- }
+ return value;
+ }
+
+ public int getEntryPort(final String dot_le) {
+ return public_port!=null && dot_le.isEmpty()?
+ public_port:
+ port;
+ }
- public Access access() {
- return access;
- }
+ public Access access() {
+ return access;
+ }
} \ No newline at end of file
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java
index 5d1d23fa..8dbc38e1 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/SecurityInfo.java
@@ -56,12 +56,12 @@ import org.onap.aaf.cadi.util.NetMask;
import org.onap.aaf.cadi.util.Split;
public class SecurityInfo {
- private static final String SECURITY_ALGO = "RSA";
+ private static final String SECURITY_ALGO = "RSA";
private static final String HTTPS_PROTOCOLS = "https.protocols";
private static final String JDK_TLS_CLIENT_PROTOCOLS = "jdk.tls.client.protocols";
private static final String INITIALIZING_ERR_FMT = "Error initializing %s: %s";
- private static final String LOADED_FROM_CADI_PROPERTIES = "%s loaded from CADI Properties";
- private static final String LOADED_FROM_SYSTEM_PROPERTIES = "%s loaded from System Properties";
+ private static final String LOADED_FROM_CADI_PROPERTIES = "%s loaded from CADI Properties";
+ private static final String LOADED_FROM_SYSTEM_PROPERTIES = "%s loaded from System Properties";
public static final String SSL_KEY_MANAGER_FACTORY_ALGORITHM;
@@ -86,26 +86,26 @@ public class SecurityInfo {
public SecurityInfo(final Access access) throws CadiException {
- String msgHelp = "";
+ String msgHelp = "";
try {
this.access = access;
// reuse DME2 Properties for convenience if specific Properties don't exist
String str = access.getProperty(Config.CADI_ALIAS, null);
if(str==null || str.isEmpty()) {
- defaultAlias = null;
+ defaultAlias = null;
} else {
- defaultAlias = str;
+ defaultAlias = str;
}
str = access.getProperty(Config.CADI_CLIENT_ALIAS, null);
if(str==null) {
- defaultClientAlias = defaultAlias;
+ defaultClientAlias = defaultAlias;
} else if(str.isEmpty()) {
- // intentionally off, i.e. cadi_client_alias=
- defaultClientAlias = null;
+ // intentionally off, i.e. cadi_client_alias=
+ defaultClientAlias = null;
} else {
- defaultClientAlias = str;
+ defaultClientAlias = str;
}
msgHelp = String.format(INITIALIZING_ERR_FMT,"Keystore", access.getProperty(Config.CADI_KEYSTORE, ""));
@@ -134,34 +134,34 @@ public class SecurityInfo {
public static void setHTTPProtocols(Access access) {
String httpsProtocols = System.getProperty(Config.HTTPS_PROTOCOLS);
if(httpsProtocols!=null) {
- access.printf(Level.INIT, LOADED_FROM_SYSTEM_PROPERTIES, HTTPS_PROTOCOLS);
+ access.printf(Level.INIT, LOADED_FROM_SYSTEM_PROPERTIES, HTTPS_PROTOCOLS);
} else {
- httpsProtocols = access.getProperty(Config.HTTPS_PROTOCOLS,null);
- if(httpsProtocols!=null) {
- access.printf(Level.INIT, LOADED_FROM_CADI_PROPERTIES, HTTPS_PROTOCOLS);
- } else {
- httpsProtocols = access.getProperty(HTTPS_PROTOCOLS, Config.HTTPS_PROTOCOLS_DEFAULT);
- access.printf(Level.INIT, "%s set by %s in CADI Properties",Config.HTTPS_PROTOCOLS,Config.CADI_PROTOCOLS);
- }
- // This needs to be set when people do not.
+ httpsProtocols = access.getProperty(Config.HTTPS_PROTOCOLS,null);
+ if(httpsProtocols!=null) {
+ access.printf(Level.INIT, LOADED_FROM_CADI_PROPERTIES, HTTPS_PROTOCOLS);
+ } else {
+ httpsProtocols = access.getProperty(HTTPS_PROTOCOLS, Config.HTTPS_PROTOCOLS_DEFAULT);
+ access.printf(Level.INIT, "%s set by %s in CADI Properties",Config.HTTPS_PROTOCOLS,Config.CADI_PROTOCOLS);
+ }
+ // This needs to be set when people do not.
System.setProperty(HTTPS_PROTOCOLS, httpsProtocols);
}
String httpsClientProtocols = System.getProperty(JDK_TLS_CLIENT_PROTOCOLS,null);
if(httpsClientProtocols!=null) {
- access.printf(Level.INIT, LOADED_FROM_SYSTEM_PROPERTIES, JDK_TLS_CLIENT_PROTOCOLS);
+ access.printf(Level.INIT, LOADED_FROM_SYSTEM_PROPERTIES, JDK_TLS_CLIENT_PROTOCOLS);
} else {
- httpsClientProtocols = access.getProperty(Config.HTTPS_CLIENT_PROTOCOLS, null);
- if(httpsClientProtocols!=null) {
- access.printf(Level.INIT, LOADED_FROM_CADI_PROPERTIES, Config.HTTPS_CLIENT_PROTOCOLS);
- } else {
- httpsClientProtocols = Config.HTTPS_PROTOCOLS_DEFAULT;
- access.printf(Level.INIT, "%s set from %s",Config.HTTPS_CLIENT_PROTOCOLS, "Default Protocols");
- }
- System.setProperty(JDK_TLS_CLIENT_PROTOCOLS, httpsClientProtocols);
+ httpsClientProtocols = access.getProperty(Config.HTTPS_CLIENT_PROTOCOLS, null);
+ if(httpsClientProtocols!=null) {
+ access.printf(Level.INIT, LOADED_FROM_CADI_PROPERTIES, Config.HTTPS_CLIENT_PROTOCOLS);
+ } else {
+ httpsClientProtocols = Config.HTTPS_PROTOCOLS_DEFAULT;
+ access.printf(Level.INIT, "%s set from %s",Config.HTTPS_CLIENT_PROTOCOLS, "Default Protocols");
+ }
+ System.setProperty(JDK_TLS_CLIENT_PROTOCOLS, httpsClientProtocols);
}
- }
+ }
- /**
+ /**
* @return the scf
*/
public SSLSocketFactory getSSLSocketFactory() {
@@ -201,7 +201,7 @@ public class SecurityInfo {
protected void initializeKeyManager() throws CadiException, IOException, NoSuchAlgorithmException, KeyStoreException, CertificateException, UnrecoverableKeyException {
String keyStore = access.getProperty(Config.CADI_KEYSTORE, null);
if(keyStore==null) {
- return;
+ return;
} else if (!new File(keyStore).exists()) {
throw new CadiException(keyStore + " does not exist");
}
@@ -244,20 +244,20 @@ public class SecurityInfo {
StringBuilder sb = null;
for (KeyManager keyManager : keyManagerFactory.getKeyManagers()) {
if (keyManager instanceof X509KeyManager) {
- X509KeyManager xkm = (X509KeyManager)keyManager;
+ X509KeyManager xkm = (X509KeyManager)keyManager;
keyManagers.add(xkm);
if(defaultAlias!=null) {
- sb=new StringBuilder("X509 Chain\n");
- x509Info(sb,xkm.getCertificateChain(defaultAlias));
+ sb=new StringBuilder("X509 Chain\n");
+ x509Info(sb,xkm.getCertificateChain(defaultAlias));
}
if(defaultClientAlias!=null && !defaultClientAlias.equals(defaultAlias)) {
- if(sb==null) {
- sb = new StringBuilder();
- } else {
- sb.append('\n');
- }
- sb.append("X509 Client Chain\n");
- x509Info(sb,xkm.getCertificateChain(defaultAlias));
+ if(sb==null) {
+ sb = new StringBuilder();
+ } else {
+ sb.append('\n');
+ }
+ sb.append("X509 Client Chain\n");
+ x509Info(sb,xkm.getCertificateChain(defaultAlias));
}
}
}
@@ -265,32 +265,32 @@ public class SecurityInfo {
keyManagers.toArray(x509KeyManager);
if(sb!=null) {
- access.log(Level.INIT, sb);
+ access.log(Level.INIT, sb);
}
}
private void x509Info(StringBuilder sb, X509Certificate[] chain) {
- if(chain!=null) {
- int i=0;
- for(X509Certificate x : chain) {
- sb.append(" ");
- sb.append(i++);
- sb.append(')');
- sb.append("\n Subject: ");
- sb.append(x.getSubjectDN());
- sb.append("\n Issuer : ");
- sb.append(x.getIssuerDN());
- sb.append("\n Expires: ");
- sb.append(x.getNotAfter());
- sb.append('\n');
- }
- }
+ if(chain!=null) {
+ int i=0;
+ for(X509Certificate x : chain) {
+ sb.append(" ");
+ sb.append(i++);
+ sb.append(')');
+ sb.append("\n Subject: ");
+ sb.append(x.getSubjectDN());
+ sb.append("\n Issuer : ");
+ sb.append(x.getIssuerDN());
+ sb.append("\n Expires: ");
+ sb.append(x.getNotAfter());
+ sb.append('\n');
+ }
+ }
}
protected void initializeTrustManager() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException, CadiException {
String trustStore = access.getProperty(Config.CADI_TRUSTSTORE, null);
if(trustStore==null) {
- return;
+ return;
} else if(!new File(trustStore).exists()) {
throw new CadiException(trustStore + " does not exist");
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiApiEnforcementFilter.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiApiEnforcementFilter.java
index e32b30d0..292f8e1c 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiApiEnforcementFilter.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiApiEnforcementFilter.java
@@ -45,92 +45,92 @@ import org.onap.aaf.cadi.util.Split;
* @author Instrumental(Jonathan)
*/
public class CadiApiEnforcementFilter implements Filter {
- private String type;
- private Map<String,List<String>> publicPaths;
- private Access access;
-
-
- public CadiApiEnforcementFilter(Access access, String enforce) throws ServletException {
- this.access = access;
- init(enforce);
- }
+ private String type;
+ private Map<String,List<String>> publicPaths;
+ private Access access;
+
+
+ public CadiApiEnforcementFilter(Access access, String enforce) throws ServletException {
+ this.access = access;
+ init(enforce);
+ }
- @Override
- public void init(FilterConfig fc) throws ServletException {
- init(fc.getInitParameter(Config.CADI_API_ENFORCEMENT));
+ @Override
+ public void init(FilterConfig fc) throws ServletException {
+ init(fc.getInitParameter(Config.CADI_API_ENFORCEMENT));
// need the Context for Logging, instantiating ClassLoader, etc
ServletContextAccess sca=new ServletContextAccess(fc);
if (access==null) {
access = sca;
}
- }
-
- private void init(final String ptypes) throws ServletException {
- if(ptypes==null) {
- throw new ServletException("CadiApiEnforcement requires " + Config.CADI_API_ENFORCEMENT + " property");
- }
- String[] full = Split.splitTrim(';', ptypes);
- if(full.length==0) {
- throw new ServletException(Config.CADI_API_ENFORCEMENT + " property is empty");
- }
- if(full.length>0) {
- type=full[0];
- }
- publicPaths = new TreeMap<String,List<String>>();
- if(full.length>1) {
- for(int i=1;i<full.length;++i) {
- String pubArray[] = Split.split(':', full[i]);
- if(pubArray.length==2) {
- List<String> ls = publicPaths.get(pubArray[0]);
- if(ls==null) {
- ls = new ArrayList<String>();
- publicPaths.put(pubArray[0], ls);
- }
- ls.add(pubArray[1]);
- }
- }
- }
- }
+ }
+
+ private void init(final String ptypes) throws ServletException {
+ if(ptypes==null) {
+ throw new ServletException("CadiApiEnforcement requires " + Config.CADI_API_ENFORCEMENT + " property");
+ }
+ String[] full = Split.splitTrim(';', ptypes);
+ if(full.length==0) {
+ throw new ServletException(Config.CADI_API_ENFORCEMENT + " property is empty");
+ }
+ if(full.length>0) {
+ type=full[0];
+ }
+ publicPaths = new TreeMap<String,List<String>>();
+ if(full.length>1) {
+ for(int i=1;i<full.length;++i) {
+ String pubArray[] = Split.split(':', full[i]);
+ if(pubArray.length==2) {
+ List<String> ls = publicPaths.get(pubArray[0]);
+ if(ls==null) {
+ ls = new ArrayList<String>();
+ publicPaths.put(pubArray[0], ls);
+ }
+ ls.add(pubArray[1]);
+ }
+ }
+ }
+ }
- @Override
- public void doFilter(ServletRequest req, ServletResponse resp, FilterChain fc) throws IOException, ServletException {
- HttpServletRequest hreq = (HttpServletRequest)req;
- final String meth = hreq.getMethod();
- String path = hreq.getContextPath()+hreq.getPathInfo();
-
- if(path == null || path.isEmpty() || "null".equals(path))
- path = hreq.getRequestURI().substring(hreq.getContextPath().length());
-
- List<String> list = publicPaths.get(meth);
- if(list!=null) {
- for( String p : publicPaths.get(meth)) {
- if(path.startsWith(p)) {
- access.printf(Level.INFO, "%s accessed public API %s %s\n",
- hreq.getUserPrincipal().getName(),
- meth,
- path);
- fc.doFilter(req, resp);
- return;
- }
- }
- }
- if(hreq.isUserInRole(type + '|'+path+'|'+meth)) {
- access.printf(Level.INFO, "%s is allowed access to %s %s\n",
- hreq.getUserPrincipal().getName(),
- meth,
- path);
- fc.doFilter(req, resp);
- } else {
- access.printf(Level.AUDIT, "%s is denied access to %s %s\n",
- hreq.getUserPrincipal().getName(),
- meth,
- path);
- }
- }
+ @Override
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain fc) throws IOException, ServletException {
+ HttpServletRequest hreq = (HttpServletRequest)req;
+ final String meth = hreq.getMethod();
+ String path = hreq.getContextPath()+hreq.getPathInfo();
+
+ if(path == null || path.isEmpty() || "null".equals(path))
+ path = hreq.getRequestURI().substring(hreq.getContextPath().length());
+
+ List<String> list = publicPaths.get(meth);
+ if(list!=null) {
+ for( String p : publicPaths.get(meth)) {
+ if(path.startsWith(p)) {
+ access.printf(Level.INFO, "%s accessed public API %s %s\n",
+ hreq.getUserPrincipal().getName(),
+ meth,
+ path);
+ fc.doFilter(req, resp);
+ return;
+ }
+ }
+ }
+ if(hreq.isUserInRole(type + '|'+path+'|'+meth)) {
+ access.printf(Level.INFO, "%s is allowed access to %s %s\n",
+ hreq.getUserPrincipal().getName(),
+ meth,
+ path);
+ fc.doFilter(req, resp);
+ } else {
+ access.printf(Level.AUDIT, "%s is denied access to %s %s\n",
+ hreq.getUserPrincipal().getName(),
+ meth,
+ path);
+ }
+ }
- @Override
- public void destroy() {
- }
+ @Override
+ public void destroy() {
+ }
}
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 01bf6f2e..50efe8b4 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
@@ -161,7 +161,7 @@ public class CadiFilter implements Filter {
cf= (Class<Filter>) Class.forName("org.onap.aaf.cadi.oauth.OAuthFilter");
sideChain.add(cf.newInstance());
} catch (ClassNotFoundException e) {
- access.log(Level.DEBUG, "OAuthFilter not enabled");
+ access.log(Level.DEBUG, "OAuthFilter not enabled");
}
} catch (Exception e) {
access.log(Level.INIT, "AAFTrustChecker cannot be loaded",e.getMessage());
@@ -229,7 +229,7 @@ public class CadiFilter implements Filter {
// Add API Enforcement Point
String enforce = getter.get(Config.CADI_API_ENFORCEMENT, null, true);
if(enforce!=null && enforce.length()>0) {
- sideChain.add(new CadiApiEnforcementFilter(access,enforce));
+ sideChain.add(new CadiApiEnforcementFilter(access,enforce));
}
// Remove Getter
getter = Get.NULL;
@@ -304,11 +304,11 @@ public class CadiFilter implements Filter {
if (pathExceptions!=null) {
String pi = hreq.getPathInfo();
if (pi==null) {
- // Attempt to get from URI only (Daniel Rose)
+ // Attempt to get from URI only (Daniel Rose)
pi = hreq.getRequestURI().substring(hreq.getContextPath().length());
if(pi==null) {
- // Nothing works.
- return false; // JBoss sometimes leaves null
+ // Nothing works.
+ return false; // JBoss sometimes leaves null
}
}
for (String pe : pathExceptions) {
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java
index 5920a260..0a89af0c 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiHTTPManip.java
@@ -56,12 +56,12 @@ import org.onap.aaf.cadi.util.UserChainManip;
*/
public class CadiHTTPManip {
private static final String ACCESS_DENIED = "Access Denied";
- private static final String NO_TAF_WILL_AUTHORIZE = "No TAF will authorize";
- private static final String AUTHENTICATION_FAILURE = "Authentication Failure";
- private static final String AUTHENTICATING_VIA_REDIRECTION = "Authenticating via redirection";
- private static final String MSG_FMT = "user=%s,ip=%s:%d,msg=\"%s: %s\"";
- private static final String AUTHENTICATED = "Authenticated";
- private static final String ACCESS_CADI_CONTROL = ".access|cadi|control";
+ private static final String NO_TAF_WILL_AUTHORIZE = "No TAF will authorize";
+ private static final String AUTHENTICATION_FAILURE = "Authentication Failure";
+ private static final String AUTHENTICATING_VIA_REDIRECTION = "Authenticating via redirection";
+ private static final String MSG_FMT = "user=%s,ip=%s:%d,msg=\"%s: %s\"";
+ private static final String AUTHENTICATED = "Authenticated";
+ private static final String ACCESS_CADI_CONTROL = ".access|cadi|control";
private static final String METH = "OPTIONS";
private static final String CADI = "/cadi/";
private static final String CADI_CACHE_PRINT = "/cadi/cache/print";
@@ -127,38 +127,38 @@ public class CadiHTTPManip {
switch(tresp.isAuthenticated()) {
case IS_AUTHENTICATED:
access.printf(Level.DEBUG,MSG_FMT,tresp.getTarget(),hreq.getRemoteAddr(),
- hreq.getRemotePort(),AUTHENTICATED,tresp.desc());
+ hreq.getRemotePort(),AUTHENTICATED,tresp.desc());
break;
case TRY_AUTHENTICATING:
switch (tresp.authenticate()) {
case IS_AUTHENTICATED:
- access.printf(Level.DEBUG,MSG_FMT,tresp.getTarget(),hreq.getRemoteAddr(),
- hreq.getRemotePort(),AUTHENTICATED,tresp.desc());
+ access.printf(Level.DEBUG,MSG_FMT,tresp.getTarget(),hreq.getRemoteAddr(),
+ hreq.getRemotePort(),AUTHENTICATED,tresp.desc());
break;
case HTTP_REDIRECT_INVOKED:
- access.printf(Level.DEBUG,MSG_FMT,tresp.getTarget(),hreq.getRemoteAddr(),
- hreq.getRemotePort(),AUTHENTICATING_VIA_REDIRECTION,tresp.desc());
+ access.printf(Level.DEBUG,MSG_FMT,tresp.getTarget(),hreq.getRemoteAddr(),
+ hreq.getRemotePort(),AUTHENTICATING_VIA_REDIRECTION,tresp.desc());
break;
case NO_FURTHER_PROCESSING:
access.printf(Level.AUDIT,MSG_FMT,tresp.getTarget(),hreq.getRemoteAddr(),
- hreq.getRemotePort(),AUTHENTICATION_FAILURE,tresp.desc());
+ hreq.getRemotePort(),AUTHENTICATION_FAILURE,tresp.desc());
hresp.sendError(403, tresp.desc()); // Forbidden
break;
default:
- access.printf(Level.AUDIT,MSG_FMT,tresp.getTarget(),hreq.getRemoteAddr(),
- hreq.getRemotePort(),NO_TAF_WILL_AUTHORIZE,tresp.desc());
+ access.printf(Level.AUDIT,MSG_FMT,tresp.getTarget(),hreq.getRemoteAddr(),
+ hreq.getRemotePort(),NO_TAF_WILL_AUTHORIZE,tresp.desc());
hresp.sendError(403, tresp.desc()); // Forbidden
}
break;
case NO_FURTHER_PROCESSING:
access.printf(Level.AUDIT,MSG_FMT, tresp.getTarget(),hreq.getRemoteAddr(),
- hreq.getRemotePort(),NO_TAF_WILL_AUTHORIZE,tresp.desc());
+ hreq.getRemotePort(),NO_TAF_WILL_AUTHORIZE,tresp.desc());
hresp.sendError(403, ACCESS_DENIED); // FORBIDDEN
break;
default:
- access.printf(Level.AUDIT,MSG_FMT, tresp.getTarget(),hreq.getRemoteAddr(),
- hreq.getRemotePort(),NO_TAF_WILL_AUTHORIZE,tresp.desc());
+ access.printf(Level.AUDIT,MSG_FMT, tresp.getTarget(),hreq.getRemoteAddr(),
+ hreq.getRemotePort(),NO_TAF_WILL_AUTHORIZE,tresp.desc());
hresp.sendError(403, ACCESS_DENIED); // FORBIDDEN
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java
index 36372eb3..8c616f4a 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/MapBathConverter.java
@@ -59,7 +59,7 @@ import org.onap.aaf.cadi.util.CSV.Visitor;
*/
public class MapBathConverter {
private static final String BASIC = "Basic ";
- private final Map<String,String> map;
+ private final Map<String,String> map;
/**
* Create with colon separated name value pairs
@@ -78,53 +78,53 @@ public class MapBathConverter {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
final Date now = new Date();
csv.visit(new Visitor() {
- @Override
- public void visit(List<String> row) throws CadiException {
- if(row.size()<3) {
- throw new CadiException("CSV file " + csv + " must have at least 2 Basic Auth columns and an Expiration Date(YYYY-MM-DD) in each row");
- }
- try {
- Date date = sdf.parse(row.get(2));
- String oldID = row.get(0);
- String newID = row.get(1);
- if(date.after(now)) {
- if(!oldID.startsWith(BASIC) && newID.startsWith(BASIC)) {
- throw new CadiException("CSV file " + csv + ": Uncredentialed ID " + idFromBasic(oldID,null) +
- " may not transfer to credentialed ID " + idFromBasic(newID,null));
- } else {
- map.put(oldID,newID);
- access.printf(Level.INIT, "ID Conversion from %s to %s enabled",
- idFromBasic(oldID,null),
- idFromBasic(newID,null));
- }
- } else {
- access.printf(Level.INIT, "ID Conversion from %s to %s has expired.",
- idFromBasic(oldID,null),
- idFromBasic(newID,null));
- }
- } catch (ParseException e) {
- throw new CadiException("Cannot Parse Date: " + row.get(2));
- } catch (IOException e) {
- throw new CadiException(e);
- }
- }
- });
+ @Override
+ public void visit(List<String> row) throws CadiException {
+ if(row.size()<3) {
+ throw new CadiException("CSV file " + csv + " must have at least 2 Basic Auth columns and an Expiration Date(YYYY-MM-DD) in each row");
+ }
+ try {
+ Date date = sdf.parse(row.get(2));
+ String oldID = row.get(0);
+ String newID = row.get(1);
+ if(date.after(now)) {
+ if(!oldID.startsWith(BASIC) && newID.startsWith(BASIC)) {
+ throw new CadiException("CSV file " + csv + ": Uncredentialed ID " + idFromBasic(oldID,null) +
+ " may not transfer to credentialed ID " + idFromBasic(newID,null));
+ } else {
+ map.put(oldID,newID);
+ access.printf(Level.INIT, "ID Conversion from %s to %s enabled",
+ idFromBasic(oldID,null),
+ idFromBasic(newID,null));
+ }
+ } else {
+ access.printf(Level.INIT, "ID Conversion from %s to %s has expired.",
+ idFromBasic(oldID,null),
+ idFromBasic(newID,null));
+ }
+ } catch (ParseException e) {
+ throw new CadiException("Cannot Parse Date: " + row.get(2));
+ } catch (IOException e) {
+ throw new CadiException(e);
+ }
+ }
+ });
}
private static String idFromBasic(String bath, Holder<String> hpass) throws IOException, CadiException {
- if(bath.startsWith(BASIC)) {
- String cred = Symm.base64noSplit.decode(bath.substring(6));
- int colon = cred.indexOf(':');
- if(colon<0) {
- throw new CadiException("Invalid Authentication Credential for " + cred);
- }
- if(hpass!=null) {
- hpass.value = cred.substring(colon+1);
- }
- return cred.substring(0, colon);
- } else {
- return bath;
- }
+ if(bath.startsWith(BASIC)) {
+ String cred = Symm.base64noSplit.decode(bath.substring(6));
+ int colon = cred.indexOf(':');
+ if(colon<0) {
+ throw new CadiException("Invalid Authentication Credential for " + cred);
+ }
+ if(hpass!=null) {
+ hpass.value = cred.substring(colon+1);
+ }
+ return cred.substring(0, colon);
+ } else {
+ return bath;
+ }
}
/**
@@ -137,40 +137,40 @@ public class MapBathConverter {
}
public String convert(Access access, final String bath) {
- String rv = map.get(bath);
+ String rv = map.get(bath);
- String cred;
- String tcred=null;
- Holder<String> hpass=null;
- try {
- if(bath.startsWith(BASIC)) {
- cred = idFromBasic(bath,(hpass=new Holder<String>()));
- if(rv==null) {
- rv = map.get(cred);
- }
- } else {
- cred = bath;
- }
+ String cred;
+ String tcred=null;
+ Holder<String> hpass=null;
+ try {
+ if(bath.startsWith(BASIC)) {
+ cred = idFromBasic(bath,(hpass=new Holder<String>()));
+ if(rv==null) {
+ rv = map.get(cred);
+ }
+ } else {
+ cred = bath;
+ }
- if(rv==null) {
- // Nothing here, just return original
- rv = bath;
- } else {
- if(rv.startsWith(BASIC)) {
- tcred = idFromBasic(rv,null);
- } else {
- if(hpass!=null) {
- tcred = rv;
- rv = BASIC + Symm.base64noSplit.encode(rv+':'+hpass.value);
- }
- }
- if(tcred != null) {
- access.printf(Level.AUDIT, "ID %s converted to %s",cred,tcred);
- }
- }
- } catch (IOException | CadiException e) {
- access.log(e,"Invalid Authorization");
- }
- return rv==null?bath:rv;
+ if(rv==null) {
+ // Nothing here, just return original
+ rv = bath;
+ } else {
+ if(rv.startsWith(BASIC)) {
+ tcred = idFromBasic(rv,null);
+ } else {
+ if(hpass!=null) {
+ tcred = rv;
+ rv = BASIC + Symm.base64noSplit.encode(rv+':'+hpass.value);
+ }
+ }
+ if(tcred != null) {
+ access.printf(Level.AUDIT, "ID %s converted to %s",cred,tcred);
+ }
+ }
+ } catch (IOException | CadiException e) {
+ access.log(e,"Invalid Authorization");
+ }
+ return rv==null?bath:rv;
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/SideChain.java b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/SideChain.java
index 8283b4dd..18e76b96 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/filter/SideChain.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/filter/SideChain.java
@@ -38,36 +38,36 @@ import javax.xml.ws.Holder;
*
*/
public class SideChain {
- private List<Filter> sideChain;
-
- public SideChain() {
- sideChain = new ArrayList<Filter>();
- }
-
- public void add(Filter f) {
- sideChain.add(f);
- }
-
+ private List<Filter> sideChain;
+
+ public SideChain() {
+ sideChain = new ArrayList<Filter>();
+ }
+
+ public void add(Filter f) {
+ sideChain.add(f);
+ }
+
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)throws IOException, ServletException {
- final Holder<Boolean> hbool = new Holder<Boolean>(Boolean.TRUE);
- FilterChain truth = new FilterChain() {
- @Override
- public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
- hbool.value=Boolean.TRUE;
- }
- public String toString() {
- return hbool.value.toString();
- }
- };
- for(Filter f : sideChain) {
- hbool.value=Boolean.FALSE;
- f.doFilter(request, response, truth);
- if(!hbool.value) {
- return;
- }
- }
- if(hbool.value) {
- chain.doFilter(request, response);
- }
+ final Holder<Boolean> hbool = new Holder<Boolean>(Boolean.TRUE);
+ FilterChain truth = new FilterChain() {
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
+ hbool.value=Boolean.TRUE;
+ }
+ public String toString() {
+ return hbool.value.toString();
+ }
+ };
+ for(Filter f : sideChain) {
+ hbool.value=Boolean.FALSE;
+ f.doFilter(request, response, truth);
+ if(!hbool.value) {
+ return;
+ }
+ }
+ if(hbool.value) {
+ chain.doFilter(request, response);
+ }
}
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/AbsTafResp.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/AbsTafResp.java
index 364a0728..f420f41f 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/AbsTafResp.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/AbsTafResp.java
@@ -127,14 +127,14 @@ public abstract class AbsTafResp implements TafResp {
}
/* (non-Javadoc)
- * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
- */
- @Override
- public String getTarget() {
- return target;
- }
-
- /**
+ * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
+ */
+ @Override
+ public String getTarget() {
+ return target;
+ }
+
+ /**
* getAccess()
*
* Get the Access object from the TAF, so that appropriate Logging, etc can be coordinated.
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/NullTafResp.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/NullTafResp.java
index fb66ec08..b3b7fb59 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/NullTafResp.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/NullTafResp.java
@@ -61,14 +61,14 @@ class NullTafResp implements TafResp {
}
/* (non-Javadoc)
- * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
- */
- @Override
- public String getTarget() {
- return "unknown";
- }
+ * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
+ */
+ @Override
+ public String getTarget() {
+ return "unknown";
+ }
- public Access getAccess() {
+ public Access getAccess() {
return Access.NULL;
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/PuntTafResp.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/PuntTafResp.java
index 3bc278e5..6bb57d36 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/PuntTafResp.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/PuntTafResp.java
@@ -64,14 +64,14 @@ public class PuntTafResp implements TafResp {
}
/* (non-Javadoc)
- * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
- */
- @Override
- public String getTarget() {
- return "punt";
- }
+ * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
+ */
+ @Override
+ public String getTarget() {
+ return "punt";
+ }
- public Access getAccess() {
+ public Access getAccess() {
return NullTafResp.singleton().getAccess();
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustNotTafResp.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustNotTafResp.java
index f397cbab..dee0ba07 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustNotTafResp.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustNotTafResp.java
@@ -63,14 +63,14 @@ public class TrustNotTafResp implements TafResp {
}
/* (non-Javadoc)
- * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
- */
- @Override
- public String getTarget() {
- return delegate.getTarget();
- }
+ * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
+ */
+ @Override
+ public String getTarget() {
+ return delegate.getTarget();
+ }
- @Override
+ @Override
public Access getAccess() {
return delegate.getAccess();
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustTafResp.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustTafResp.java
index 061d4e2f..2701c27a 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustTafResp.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/TrustTafResp.java
@@ -65,14 +65,14 @@ public class TrustTafResp implements TafResp {
}
/* (non-Javadoc)
- * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
- */
- @Override
- public String getTarget() {
- return delegate.getTarget();
- }
+ * @see org.onap.aaf.cadi.taf.TafResp#getTarget()
+ */
+ @Override
+ public String getTarget() {
+ return delegate.getTarget();
+ }
- @Override
+ @Override
public Access getAccess() {
return delegate.getAccess();
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
index dcd27d63..93360761 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
@@ -70,7 +70,7 @@ public class BasicHttpTaf implements HttpTaf {
private Map<String,CredVal> rbacs = new TreeMap<>();
private boolean warn;
private long timeToLive;
- private MapBathConverter mapIds;
+ private MapBathConverter mapIds;
public BasicHttpTaf(Access access, CredVal rbac, String realm, long timeToLive, boolean turnOnWarning) {
this.access = access;
@@ -80,13 +80,13 @@ public class BasicHttpTaf implements HttpTaf {
this.timeToLive = timeToLive;
String csvFile = access.getProperty(Config.CADI_BATH_CONVERT, null);
if(csvFile==null) {
- mapIds=null;
+ mapIds=null;
} else {
- try {
- mapIds = new MapBathConverter(access, new CSV(access,csvFile));
- } catch (IOException | CadiException e) {
- access.log(e,"Bath Map Conversion is not initialzed (non fatal)");
- }
+ try {
+ mapIds = new MapBathConverter(access, new CSV(access,csvFile));
+ } catch (IOException | CadiException e) {
+ access.log(e,"Bath Map Conversion is not initialzed (non fatal)");
+ }
}
}
@@ -134,7 +134,7 @@ public class BasicHttpTaf implements HttpTaf {
access.log(Level.WARN,"WARNING! BasicAuth has been used over an insecure channel");
}
if(mapIds != null) {
- authz = mapIds.convert(access, authz);
+ authz = mapIds.convert(access, authz);
}
try {
CachedBasicPrincipal ba = new CachedBasicPrincipal(this,authz,realm,timeToLive);
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 5f5ff574..914c57b5 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
@@ -137,52 +137,52 @@ public class X509Taf implements HttpTaf {
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;
- int end = 1;
- int comma;
- int length = subject.length();
-
- compare:
- while(start<length) {
- while(Character.isWhitespace(subject.charAt(start))) {
- if(++start>length) {
- break compare;
- }
- }
- comma = subject.indexOf(',',start);
- if(comma<0) {
- end = subject.length();
- } else {
- end = comma<=0?0:comma-1;
- }
- while(Character.isWhitespace(subject.charAt(end))) {
- if(--end < 0) {
- break compare;
- }
- }
- if(subject.regionMatches(start, "OU=", 0, 3) ||
- subject.regionMatches(start, "CN=", 0, 3)) {
- int at = subject.indexOf('@', start);
- if(at<end && at>=0) {
+ int start = 0;
+ int end = 1;
+ int comma;
+ int length = subject.length();
+
+ compare:
+ while(start<length) {
+ while(Character.isWhitespace(subject.charAt(start))) {
+ if(++start>length) {
+ break compare;
+ }
+ }
+ comma = subject.indexOf(',',start);
+ if(comma<0) {
+ end = subject.length();
+ } else {
+ end = comma<=0?0:comma-1;
+ }
+ while(Character.isWhitespace(subject.charAt(end))) {
+ if(--end < 0) {
+ break compare;
+ }
+ }
+ if(subject.regionMatches(start, "OU=", 0, 3) ||
+ subject.regionMatches(start, "CN=", 0, 3)) {
+ int at = subject.indexOf('@', start);
+ if(at<end && at>=0) {
String[] sa = Split.splitTrim(':', subject, start+3,end+1);
if (sa.length==1 || (sa.length>1 && env!=null && env.equals(sa[1]))) { // Check Environment
return new X509HttpTafResp(access,
new X509Principal(sa[0], certarr[0],(byte[])null,bht),
"X509Taf validated " + sa[0] + (sa.length<2?"":" for aaf_env " + env ), RESP.IS_AUTHENTICATED);
} else {
- access.printf(Level.DEBUG,"Certificate is not for environment '%s'",env);
- break;
+ access.printf(Level.DEBUG,"Certificate is not for environment '%s'",env);
+ break;
}
- }
- }
- start = comma+1;
- }
- access.log(Level.DEBUG,"Certificate is not acceptable for Authentication");
+ }
+ }
+ start = comma+1;
+ }
+ access.log(Level.DEBUG,"Certificate is not acceptable for Authentication");
} else {
- access.log(Level.DEBUG,"Issuer is not trusted for Authentication");
+ access.log(Level.DEBUG,"Issuer is not trusted for Authentication");
}
} else {
- access.log(Level.DEBUG,"There is no client certificate on the transaction");
+ access.log(Level.DEBUG,"There is no client certificate on the transaction");
}
@@ -266,7 +266,7 @@ public class X509Taf implements HttpTaf {
// if Principal is found, check for "AS_USER" and whether this entity is trusted to declare
if (prin!=null) {
- // Note: Tag for Certs is Fingerprint, but that takes computation... leaving off
+ // Note: Tag for Certs is Fingerprint, but that takes computation... leaving off
return new X509HttpTafResp(
access,
prin,
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
index 35d85b9a..fbaa4a5a 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
@@ -41,240 +41,240 @@ import org.onap.aaf.cadi.CadiException;
*
*/
public class CSV {
- private File csv;
- private Access access;
- private boolean processAll;
- private char delimiter = ',';
-
- public CSV(Access access, File file) {
- this.access = access;
- csv = file;
- processAll = false;
- }
-
- public CSV(Access access, String csvFilename) {
- this.access = access;
- csv = new File(csvFilename);
- processAll = false;
- }
-
- public CSV setDelimiter(char delimiter) {
- this.delimiter = delimiter;
- return this;
- }
-
- public String name() {
- return csv.getName();
- }
+ private File csv;
+ private Access access;
+ private boolean processAll;
+ private char delimiter = ',';
+
+ public CSV(Access access, File file) {
+ this.access = access;
+ csv = file;
+ processAll = false;
+ }
+
+ public CSV(Access access, String csvFilename) {
+ this.access = access;
+ csv = new File(csvFilename);
+ processAll = false;
+ }
+
+ public CSV setDelimiter(char delimiter) {
+ this.delimiter = delimiter;
+ return this;
+ }
+
+ public String name() {
+ return csv.getName();
+ }
- public CSV processAll() {
- processAll = true;
- return this;
- }
- /*
- * Create your code to accept the List<String> row.
- *
- * Your code may keep the List... CSV does not hold onto it.
- *
- * @author Instrumental(Jonathan)
- *
- */
- public interface Visitor {
- void visit(List<String> row) throws IOException, CadiException;
- }
-
- public void visit(Visitor visitor) throws IOException, CadiException {
- BufferedReader br = new BufferedReader(new FileReader(csv));
- try {
- String line;
- StringBuilder sb = new StringBuilder();
- while((line = br.readLine())!=null) {
- line=line.trim();
- if(!line.startsWith("#") && line.length()>0) {
-// System.out.println(line); uncomment to debug
- List<String> row = new ArrayList<>();
- boolean quotes=false;
- boolean escape=false;
- char c = 0;
- for(int i=0;i<line.length();++i) {
- switch(c=line.charAt(i)) {
- case '"':
- if(quotes) {
- if(i<line.length()-1) { // may look ahead
- if('"' == line.charAt(i+1)) {
- sb.append(c);
- ++i;
- } else {
- quotes = false;
- }
- } else {
- quotes=false;
- }
- } else {
- quotes=true;
- }
- break;
- case '\\':
- if(escape) {
- sb.append(c);
- escape = false;
- } else {
- escape = true;
- }
- break;
- case 'n':
- if(escape) {
- sb.append("\\n");
- escape=false;
- } else {
- sb.append(c);
- }
- break;
- default:
- if(delimiter==c) {
- if(quotes) {
- sb.append(c);
- } else {
- row.add(sb.toString());
- sb.setLength(0);
- }
- } else {
- sb.append(c);
- }
- }
- }
- if(sb.length()>0 || c==',') {
- row.add(sb.toString());
- sb.setLength(0);
- }
- try {
- visitor.visit(row);
- } catch (CadiException e) {
- if(processAll) {
- access.log(Level.ERROR,e);
- } else {
- throw e;
- }
- }
- }
- }
- } finally {
- br.close();
- }
- }
-
- public Writer writer() throws FileNotFoundException {
- return new Writer(false);
- }
+ public CSV processAll() {
+ processAll = true;
+ return this;
+ }
+ /*
+ * Create your code to accept the List<String> row.
+ *
+ * Your code may keep the List... CSV does not hold onto it.
+ *
+ * @author Instrumental(Jonathan)
+ *
+ */
+ public interface Visitor {
+ void visit(List<String> row) throws IOException, CadiException;
+ }
+
+ public void visit(Visitor visitor) throws IOException, CadiException {
+ BufferedReader br = new BufferedReader(new FileReader(csv));
+ try {
+ String line;
+ StringBuilder sb = new StringBuilder();
+ while((line = br.readLine())!=null) {
+ line=line.trim();
+ if(!line.startsWith("#") && line.length()>0) {
+// System.out.println(line); uncomment to debug
+ List<String> row = new ArrayList<>();
+ boolean quotes=false;
+ boolean escape=false;
+ char c = 0;
+ for(int i=0;i<line.length();++i) {
+ switch(c=line.charAt(i)) {
+ case '"':
+ if(quotes) {
+ if(i<line.length()-1) { // may look ahead
+ if('"' == line.charAt(i+1)) {
+ sb.append(c);
+ ++i;
+ } else {
+ quotes = false;
+ }
+ } else {
+ quotes=false;
+ }
+ } else {
+ quotes=true;
+ }
+ break;
+ case '\\':
+ if(escape) {
+ sb.append(c);
+ escape = false;
+ } else {
+ escape = true;
+ }
+ break;
+ case 'n':
+ if(escape) {
+ sb.append("\\n");
+ escape=false;
+ } else {
+ sb.append(c);
+ }
+ break;
+ default:
+ if(delimiter==c) {
+ if(quotes) {
+ sb.append(c);
+ } else {
+ row.add(sb.toString());
+ sb.setLength(0);
+ }
+ } else {
+ sb.append(c);
+ }
+ }
+ }
+ if(sb.length()>0 || c==',') {
+ row.add(sb.toString());
+ sb.setLength(0);
+ }
+ try {
+ visitor.visit(row);
+ } catch (CadiException e) {
+ if(processAll) {
+ access.log(Level.ERROR,e);
+ } else {
+ throw e;
+ }
+ }
+ }
+ }
+ } finally {
+ br.close();
+ }
+ }
+
+ public Writer writer() throws FileNotFoundException {
+ return new Writer(false);
+ }
- public Writer writer(boolean append) throws FileNotFoundException {
- return new Writer(append);
- }
+ public Writer writer(boolean append) throws FileNotFoundException {
+ return new Writer(append);
+ }
- public interface RowSetter {
- public void row(Object ... objs);
- }
-
- public static class Saver implements RowSetter {
- List<String> ls= new ArrayList<>();
-
- @Override
- public void row(Object ... objs) {
- if(objs.length>0) {
- for(Object o : objs) {
- if(o != null) {
- if(o instanceof String[]) {
- for(String str : (String[])o) {
- ls.add(str);
- }
- } else {
- ls.add(o.toString());
- }
- }
- }
- }
- }
-
- public List<String> asList() {
- List<String> rv = ls;
- ls = new ArrayList<>();
- return rv;
- }
- }
+ public interface RowSetter {
+ public void row(Object ... objs);
+ }
+
+ public static class Saver implements RowSetter {
+ List<String> ls= new ArrayList<>();
+
+ @Override
+ public void row(Object ... objs) {
+ if(objs.length>0) {
+ for(Object o : objs) {
+ if(o != null) {
+ if(o instanceof String[]) {
+ for(String str : (String[])o) {
+ ls.add(str);
+ }
+ } else {
+ ls.add(o.toString());
+ }
+ }
+ }
+ }
+ }
+
+ public List<String> asList() {
+ List<String> rv = ls;
+ ls = new ArrayList<>();
+ return rv;
+ }
+ }
- public class Writer implements RowSetter {
- private PrintStream ps;
- private Writer(final boolean append) throws FileNotFoundException {
- ps = new PrintStream(new FileOutputStream(csv,append));
- }
-
- @Override
- public void row(Object ... objs) {
- if(objs.length>0) {
- boolean first = true;
- for(Object o : objs) {
- if(first) {
- first = false;
- } else {
- ps.append(delimiter);
- }
- if(o == null) {
- } else if(o instanceof String[]) {
- for(String str : (String[])o) {
- print(str);
- }
- } else {
- print(o.toString());
- }
- }
- ps.println();
- }
- }
-
- private void print(String s) {
- boolean quote = s.matches(".*[,|\"].*");
- if(quote) {
- ps.append('"');
- ps.print(s.replace("\"", "\"\"")
- .replace("'", "''")
- .replace("\\", "\\\\"));
- ps.append('"');
- } else {
- ps.append(s);
- }
+ public class Writer implements RowSetter {
+ private PrintStream ps;
+ private Writer(final boolean append) throws FileNotFoundException {
+ ps = new PrintStream(new FileOutputStream(csv,append));
+ }
+
+ @Override
+ public void row(Object ... objs) {
+ if(objs.length>0) {
+ boolean first = true;
+ for(Object o : objs) {
+ if(first) {
+ first = false;
+ } else {
+ ps.append(delimiter);
+ }
+ if(o == null) {
+ } else if(o instanceof String[]) {
+ for(String str : (String[])o) {
+ print(str);
+ }
+ } else {
+ print(o.toString());
+ }
+ }
+ ps.println();
+ }
+ }
+
+ private void print(String s) {
+ boolean quote = s.matches(".*[,|\"].*");
+ if(quote) {
+ ps.append('"');
+ ps.print(s.replace("\"", "\"\"")
+ .replace("'", "''")
+ .replace("\\", "\\\\"));
+ ps.append('"');
+ } else {
+ ps.append(s);
+ }
-
- }
- /**
- * Note: CSV files do not actually support Comments as a standard, but it is useful
- * @param comment
- */
- public void comment(String comment, Object ... objs) {
- ps.print("# ");
- ps.printf(comment,objs);
- ps.println();
- }
-
- public void flush() {
- ps.flush();
- }
-
- public void close() {
- flush();
- ps.close();
- }
-
- public String toString() {
- return csv.getAbsolutePath();
- }
- }
+
+ }
+ /**
+ * Note: CSV files do not actually support Comments as a standard, but it is useful
+ * @param comment
+ */
+ public void comment(String comment, Object ... objs) {
+ ps.print("# ");
+ ps.printf(comment,objs);
+ ps.println();
+ }
+
+ public void flush() {
+ ps.flush();
+ }
+
+ public void close() {
+ flush();
+ ps.close();
+ }
+
+ public String toString() {
+ return csv.getAbsolutePath();
+ }
+ }
- public void delete() {
- csv.delete();
- }
-
- public String toString() {
- return csv.getAbsolutePath();
- }
+ public void delete() {
+ csv.delete();
+ }
+
+ public String toString() {
+ return csv.getAbsolutePath();
+ }
}
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
index b4085361..f2c6be6f 100644
--- 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
@@ -30,37 +30,37 @@ import java.net.URI;
*
*/
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 || (auth!=null && auth.startsWith(host))) {
- 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;
- }
+ private String auth;
+ private String host;
+ private int port;
+
+ public FixURIinfo(URI uri) {
+ auth = uri.getAuthority();
+ host = uri.getHost();
+ if(host==null || (auth!=null && auth.startsWith(host))) {
+ 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;
- }
+ 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 c6f8bd0a..4f41629d 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,93 +31,93 @@ package org.onap.aaf.cadi.util;
*/
public class Split {
- private static final String[] EMPTY = new String[0];
+ private static final String[] EMPTY = new String[0];
- public static String[] split(char c, String value) {
- if (value==null) {
- return EMPTY;
- }
+ public static String[] split(char c, String value) {
+ if (value==null) {
+ return EMPTY;
+ }
- return split(c,value,0,value.length());
- }
+ return split(c,value,0,value.length());
+ }
- public static String[] split(char c, String value, int start, int end) {
- if (value==null) {
- return EMPTY;
- }
+ 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);
- } 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;
- }
+ // 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, int start, int end) {
- if (value==null) {
- return EMPTY;
- }
+ public static String[] splitTrim(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=start;
- 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).trim();
+ } else {
+ int last=start;
+ 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;
+ }
- 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) {
+ 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;
- }
+ 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;
- }
+ 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/core/src/test/java/org/onap/aaf/cadi/config/test/JU_MapBathConverter.java b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_MapBathConverter.java
index d9a5a0eb..2be51ece 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_MapBathConverter.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_MapBathConverter.java
@@ -50,199 +50,199 @@ import junit.framework.Assert;
*
*/
public class JU_MapBathConverter {
- private static final String NEW_USER_SOMETHING_ORG = "NEW_USER@Something.org";
- private static final String OLD_ID = "OLD_ID";
- private static final String SHARED_PASS = "SHARED_PASS";
- private static CSV csv;
- private static ArrayList<String> expected;
- private static final Access access = new PropAccess();
+ private static final String NEW_USER_SOMETHING_ORG = "NEW_USER@Something.org";
+ private static final String OLD_ID = "OLD_ID";
+ private static final String SHARED_PASS = "SHARED_PASS";
+ private static CSV csv;
+ private static ArrayList<String> expected;
+ private static final Access access = new PropAccess();
private final static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- @BeforeClass
- public static void createFile() throws IOException {
- // Note, you cate a "MapBathConverter" by access to a File.
- // We will create that file now. Local is fine.
- csv = new CSV(access,"JU_MapBathConverter.csv");
- }
-
- @BeforeClass
- public static void beforeClass() {
- expected = new ArrayList<>();
- }
-
- @Before
- public void before() {
- expected.clear();
- }
-
- @Test
- public void test() throws IOException, CadiException {
- CSV.Writer cw = csv.writer();
- GregorianCalendar gc = new GregorianCalendar();
- gc.add(GregorianCalendar.MONTH, 6);
- try {
- try {
- // CSV can simply be OLD ID and NEW, no passwords
- cw.row(exp(OLD_ID), exp(NEW_USER_SOMETHING_ORG),sdf.format(gc.getTime()));
-
- // Style 1 - Incoming ID/pass, create new cred with NweID and same Pass
- cw.row(exp(bath(OLD_ID,SHARED_PASS)), exp(NEW_USER_SOMETHING_ORG),sdf.format(gc.getTime()));
- // the response should be Basic with NEW_ID and OLD_PASS
-
- // Style 2
- cw.row(exp(bath(OLD_ID,"OLD_PASS")), exp(bath(NEW_USER_SOMETHING_ORG,"NEW_PASS")),sdf.format(gc.getTime()));
-
- } finally {
- cw.close();
- }
-
- final Iterator<String> exp = expected.iterator();
- csv.visit(new Visitor() {
- @Override
- public void visit(List<String> row) {
- int i=0;
- for(String s : row) {
- switch(i++) {
- case 0:
- case 1:
- Assert.assertEquals(exp.next(), s);
- break;
- case 2:
- try {
- Date.valueOf(s);
- } catch (Exception e) {
- Assert.assertTrue("Last entry should be a date",false);
- }
- break;
- default:
- Assert.fail("There should only be 3 columns in this test case.");
- }
- }
- }
- });
-
- MapBathConverter mbc = new MapBathConverter(access, csv);
-
- // Check no lookup just returns the same
- Assert.assertEquals("NonKey", "NonKey"); // if not in map, expect same value
-
- Iterator<String> exp1 = expected.iterator();
- // there's no passwords in CSV
- String old = exp1.next();
- String nw = exp1.next();
- Assert.assertEquals(nw, mbc.convert(access,old));
-
- Assert.assertEquals(bath(NEW_USER_SOMETHING_ORG,SHARED_PASS), mbc.convert(access,bath(OLD_ID,SHARED_PASS)));
-
- // Style 1 (new cred, old password)
- old = exp1.next();
- nw = bath(exp1.next(),SHARED_PASS);
- Assert.assertEquals(nw, mbc.convert(access,old));
-
- // Style 2
- old = exp1.next();
- nw = exp1.next();
- Assert.assertEquals(nw, mbc.convert(access,old));
-
- } finally {
- csv.delete();
- }
- }
-
- @Test
- public void testInsecureRole() throws IOException {
- CSV.Writer cw = csv.writer();
- GregorianCalendar gc = new GregorianCalendar();
- gc.add(GregorianCalendar.MONTH, 6);
- try {
- try {
- // Invalid Scenario - Non Authenticated ID to authenticated User
- cw.row(exp(OLD_ID), exp(bath(NEW_USER_SOMETHING_ORG,"NEW_PASS")),sdf.format(gc.getTime()));
-
- } finally {
- cw.close();
- }
-
- try {
- new MapBathConverter(access, csv);
- Assert.fail("Invalid Data should throw Exception");
- } catch (CadiException e) {
- Assert.assertTrue("Invalid Data should throw Exception",true);
- }
-
- } finally {
- csv.delete();
- }
- }
-
- @Test
- public void testTooFewColumns() throws IOException, CadiException {
- CSV.Writer cw = csv.writer();
- try {
- try {
- cw.row(exp(bath(OLD_ID,"OLD_PASS")), exp(bath(NEW_USER_SOMETHING_ORG,"NEW_PASS")));
- } finally {
- cw.close();
- }
-
- try {
- new MapBathConverter(access, csv);
- Assert.fail("file with too few rows should throw exception");
- } catch(CadiException | IOException e) {
- Assert.assertTrue("Correctly thrown Exception",true);
- }
- } finally {
- csv.delete();
- }
- }
-
- @Test
- public void testNoFile() {
- try {
- new MapBathConverter(access, new CSV(access,"Bogus"));
- Assert.fail("Non Existent File should throw exception");
- } catch(CadiException | IOException e) {
- Assert.assertTrue("Correctly thrown Exception",true);
- }
- }
-
- @Test
- public void testBadRows() throws IOException {
- try {
- Writer cw = csv.writer();
- try {
- cw.row("Single Column");
- } finally {
- cw.close();
- }
-
- try {
- new MapBathConverter(access,csv);
- Assert.fail("Non Existent File should throw exception");
- } catch(CadiException | IOException e) {
- Assert.assertTrue("Correctly thrown Exception",true);
- }
- } finally {
- csv.delete();
- }
-
- // Check for deletion
- Assert.assertFalse(csv.toString() + "should have been deleted",new File(csv.toString()).exists());
- }
-
- private String bath(String user, String password) throws IOException {
- StringBuilder sb = new StringBuilder(user);
- sb.append(':');
- sb.append(password);
- byte[] encoded = Symm.base64noSplit.encode(sb.toString().getBytes());
- sb.setLength(0);
- sb.append("Basic ");
- sb.append(new String(encoded));
- return sb.toString();
- }
-
- private String exp(String s) {
- expected.add(s);
- return s;
- }
+ @BeforeClass
+ public static void createFile() throws IOException {
+ // Note, you cate a "MapBathConverter" by access to a File.
+ // We will create that file now. Local is fine.
+ csv = new CSV(access,"JU_MapBathConverter.csv");
+ }
+
+ @BeforeClass
+ public static void beforeClass() {
+ expected = new ArrayList<>();
+ }
+
+ @Before
+ public void before() {
+ expected.clear();
+ }
+
+ @Test
+ public void test() throws IOException, CadiException {
+ CSV.Writer cw = csv.writer();
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.add(GregorianCalendar.MONTH, 6);
+ try {
+ try {
+ // CSV can simply be OLD ID and NEW, no passwords
+ cw.row(exp(OLD_ID), exp(NEW_USER_SOMETHING_ORG),sdf.format(gc.getTime()));
+
+ // Style 1 - Incoming ID/pass, create new cred with NweID and same Pass
+ cw.row(exp(bath(OLD_ID,SHARED_PASS)), exp(NEW_USER_SOMETHING_ORG),sdf.format(gc.getTime()));
+ // the response should be Basic with NEW_ID and OLD_PASS
+
+ // Style 2
+ cw.row(exp(bath(OLD_ID,"OLD_PASS")), exp(bath(NEW_USER_SOMETHING_ORG,"NEW_PASS")),sdf.format(gc.getTime()));
+
+ } finally {
+ cw.close();
+ }
+
+ final Iterator<String> exp = expected.iterator();
+ csv.visit(new Visitor() {
+ @Override
+ public void visit(List<String> row) {
+ int i=0;
+ for(String s : row) {
+ switch(i++) {
+ case 0:
+ case 1:
+ Assert.assertEquals(exp.next(), s);
+ break;
+ case 2:
+ try {
+ Date.valueOf(s);
+ } catch (Exception e) {
+ Assert.assertTrue("Last entry should be a date",false);
+ }
+ break;
+ default:
+ Assert.fail("There should only be 3 columns in this test case.");
+ }
+ }
+ }
+ });
+
+ MapBathConverter mbc = new MapBathConverter(access, csv);
+
+ // Check no lookup just returns the same
+ Assert.assertEquals("NonKey", "NonKey"); // if not in map, expect same value
+
+ Iterator<String> exp1 = expected.iterator();
+ // there's no passwords in CSV
+ String old = exp1.next();
+ String nw = exp1.next();
+ Assert.assertEquals(nw, mbc.convert(access,old));
+
+ Assert.assertEquals(bath(NEW_USER_SOMETHING_ORG,SHARED_PASS), mbc.convert(access,bath(OLD_ID,SHARED_PASS)));
+
+ // Style 1 (new cred, old password)
+ old = exp1.next();
+ nw = bath(exp1.next(),SHARED_PASS);
+ Assert.assertEquals(nw, mbc.convert(access,old));
+
+ // Style 2
+ old = exp1.next();
+ nw = exp1.next();
+ Assert.assertEquals(nw, mbc.convert(access,old));
+
+ } finally {
+ csv.delete();
+ }
+ }
+
+ @Test
+ public void testInsecureRole() throws IOException {
+ CSV.Writer cw = csv.writer();
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.add(GregorianCalendar.MONTH, 6);
+ try {
+ try {
+ // Invalid Scenario - Non Authenticated ID to authenticated User
+ cw.row(exp(OLD_ID), exp(bath(NEW_USER_SOMETHING_ORG,"NEW_PASS")),sdf.format(gc.getTime()));
+
+ } finally {
+ cw.close();
+ }
+
+ try {
+ new MapBathConverter(access, csv);
+ Assert.fail("Invalid Data should throw Exception");
+ } catch (CadiException e) {
+ Assert.assertTrue("Invalid Data should throw Exception",true);
+ }
+
+ } finally {
+ csv.delete();
+ }
+ }
+
+ @Test
+ public void testTooFewColumns() throws IOException, CadiException {
+ CSV.Writer cw = csv.writer();
+ try {
+ try {
+ cw.row(exp(bath(OLD_ID,"OLD_PASS")), exp(bath(NEW_USER_SOMETHING_ORG,"NEW_PASS")));
+ } finally {
+ cw.close();
+ }
+
+ try {
+ new MapBathConverter(access, csv);
+ Assert.fail("file with too few rows should throw exception");
+ } catch(CadiException | IOException e) {
+ Assert.assertTrue("Correctly thrown Exception",true);
+ }
+ } finally {
+ csv.delete();
+ }
+ }
+
+ @Test
+ public void testNoFile() {
+ try {
+ new MapBathConverter(access, new CSV(access,"Bogus"));
+ Assert.fail("Non Existent File should throw exception");
+ } catch(CadiException | IOException e) {
+ Assert.assertTrue("Correctly thrown Exception",true);
+ }
+ }
+
+ @Test
+ public void testBadRows() throws IOException {
+ try {
+ Writer cw = csv.writer();
+ try {
+ cw.row("Single Column");
+ } finally {
+ cw.close();
+ }
+
+ try {
+ new MapBathConverter(access,csv);
+ Assert.fail("Non Existent File should throw exception");
+ } catch(CadiException | IOException e) {
+ Assert.assertTrue("Correctly thrown Exception",true);
+ }
+ } finally {
+ csv.delete();
+ }
+
+ // Check for deletion
+ Assert.assertFalse(csv.toString() + "should have been deleted",new File(csv.toString()).exists());
+ }
+
+ private String bath(String user, String password) throws IOException {
+ StringBuilder sb = new StringBuilder(user);
+ sb.append(':');
+ sb.append(password);
+ byte[] encoded = Symm.base64noSplit.encode(sb.toString().getBytes());
+ sb.setLength(0);
+ sb.append("Basic ");
+ sb.append(new String(encoded));
+ return sb.toString();
+ }
+
+ private String exp(String s) {
+ expected.add(s);
+ return s;
+ }
}
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 68235e1a..1fe6a753 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
@@ -33,117 +33,117 @@ import org.onap.aaf.cadi.config.RegistrationPropHolder;
public class JU_RegistrationPropHolder {
- @Test
- public void testBlank() {
- PropAccess pa = new PropAccess();
- RegistrationPropHolder rph;
- int ju_port = 20;
- try {
- ////////////////
- // Check Required Properties
- ////////////////
- try {
- rph = new RegistrationPropHolder(pa,20);
- } catch (CadiException e) {
- Assert.assertEquals(
- "\ncadi_latitude must be defined." +
- "\ncadi_longitude must be defined.",e.getMessage());
- }
-
- try {
- pa.setProperty(Config.CADI_LATITUDE, "32.7");
- rph = new RegistrationPropHolder(pa,20);
- } catch (CadiException e) {
- Assert.assertEquals(
- "\ncadi_longitude must be defined.",e.getMessage());
- }
-
- pa.setProperty(Config.CADI_LONGITUDE, "-72.0");
- rph = new RegistrationPropHolder(pa,ju_port);
-
- ////////////////
- // Validate Default Properties
- ////////////////
- for(String dot_le : new String[] {"",".helm"}) {
- assertEquals(rph.hostname,rph.default_fqdn);
- assertEquals("",rph.lcontainer);
- assertEquals(rph.hostname,rph.public_fqdn);
- assertEquals(ju_port,rph.getEntryPort(dot_le));
- assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le));
- }
+ @Test
+ public void testBlank() {
+ PropAccess pa = new PropAccess();
+ RegistrationPropHolder rph;
+ int ju_port = 20;
+ try {
+ ////////////////
+ // Check Required Properties
+ ////////////////
+ try {
+ rph = new RegistrationPropHolder(pa,20);
+ } catch (CadiException e) {
+ Assert.assertEquals(
+ "\ncadi_latitude must be defined." +
+ "\ncadi_longitude must be defined.",e.getMessage());
+ }
+
+ try {
+ pa.setProperty(Config.CADI_LATITUDE, "32.7");
+ rph = new RegistrationPropHolder(pa,20);
+ } catch (CadiException e) {
+ Assert.assertEquals(
+ "\ncadi_longitude must be defined.",e.getMessage());
+ }
+
+ pa.setProperty(Config.CADI_LONGITUDE, "-72.0");
+ rph = new RegistrationPropHolder(pa,ju_port);
+
+ ////////////////
+ // Validate Default Properties
+ ////////////////
+ for(String dot_le : new String[] {"",".helm"}) {
+ assertEquals(rph.hostname,rph.default_fqdn);
+ assertEquals("",rph.lcontainer);
+ assertEquals(rph.hostname,rph.public_fqdn);
+ assertEquals(ju_port,rph.getEntryPort(dot_le));
+ assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le));
+ }
- String ns = "myns";
- pa.setProperty(Config.AAF_LOCATOR_APP_NS, ns);
- for(String dot_le : new String[] {"",".helm"}) {
- assertEquals(rph.hostname,rph.default_fqdn);
- assertEquals("",rph.lcontainer);
- assertEquals(rph.hostname,rph.public_fqdn);
- assertEquals(ju_port,rph.getEntryPort(dot_le));
- assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le));
- }
+ String ns = "myns";
+ pa.setProperty(Config.AAF_LOCATOR_APP_NS, ns);
+ for(String dot_le : new String[] {"",".helm"}) {
+ assertEquals(rph.hostname,rph.default_fqdn);
+ assertEquals("",rph.lcontainer);
+ assertEquals(rph.hostname,rph.public_fqdn);
+ assertEquals(ju_port,rph.getEntryPort(dot_le));
+ assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le));
+ }
- String ns2 = "onap";
- pa.setProperty(Config.AAF_LOCATOR_APP_NS+".helm", ns2);
- for(String dot_le : new String[] {"",".helm"}) {
- assertEquals(rph.hostname,rph.default_fqdn);
- assertEquals("",rph.lcontainer);
- assertEquals(rph.hostname,rph.public_fqdn);
- assertEquals(ju_port,rph.getEntryPort(dot_le));
- assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le));
- }
+ String ns2 = "onap";
+ pa.setProperty(Config.AAF_LOCATOR_APP_NS+".helm", ns2);
+ for(String dot_le : new String[] {"",".helm"}) {
+ assertEquals(rph.hostname,rph.default_fqdn);
+ assertEquals("",rph.lcontainer);
+ assertEquals(rph.hostname,rph.public_fqdn);
+ assertEquals(ju_port,rph.getEntryPort(dot_le));
+ assertEquals(rph.hostname,rph.getEntryFQDN("",dot_le));
+ }
- ////////////////
- // Validate Public Host and Port settings
- ////////////////
- String public_hostname = "com.public.hostname";
- int public_port = 999;
- pa.setProperty(Config.AAF_LOCATOR_PUBLIC_FQDN, public_hostname);
- pa.setProperty(Config.AAF_LOCATOR_PUBLIC_PORT,Integer.toString(public_port));
- RegistrationPropHolder pubRPH = new RegistrationPropHolder(pa,ju_port);
- assertEquals(public_hostname,pubRPH.public_fqdn);
- assertEquals(public_port,pubRPH.getEntryPort(""));
+ ////////////////
+ // Validate Public Host and Port settings
+ ////////////////
+ String public_hostname = "com.public.hostname";
+ int public_port = 999;
+ pa.setProperty(Config.AAF_LOCATOR_PUBLIC_FQDN, public_hostname);
+ pa.setProperty(Config.AAF_LOCATOR_PUBLIC_PORT,Integer.toString(public_port));
+ RegistrationPropHolder pubRPH = new RegistrationPropHolder(pa,ju_port);
+ assertEquals(public_hostname,pubRPH.public_fqdn);
+ assertEquals(public_port,pubRPH.getEntryPort(""));
- final String url = "https://aaf.osaaf.org:8095/org.osaaf.aaf.service:2.1";
- String name="theName";
- assertEquals(url,rph.replacements(getClass().getSimpleName(),url, name, ""));
-
- String alu = "aaf.osaaf.org:8095";
- String curl = url.replace(alu, Config.AAF_LOCATE_URL_TAG);
- pa.setProperty(Config.AAF_LOCATE_URL,"https://"+alu);
- assertEquals(url.replace("8095","8095/locate"),rph.replacements(getClass().getSimpleName(),curl, name, ""));
-
- String root_ns = "org.osaaf.aaf";
- curl = url.replace(root_ns, "AAF_NS");
- pa.setProperty(Config.AAF_ROOT_NS,root_ns);
- assertEquals(url,rph.replacements(getClass().getSimpleName(),curl, name, ""));
-
- curl = url.replace(root_ns, "%AAF_NS");
- pa.setProperty(Config.AAF_ROOT_NS,root_ns);
- assertEquals(url,rph.replacements(getClass().getSimpleName(),curl, name, ""));
-
- final String fqdn = "%C.%CNS.%NS.%N";
- String target = "myns.theName";
- assertEquals(target,rph.replacements(getClass().getSimpleName(),fqdn, name, ""));
+ final String url = "https://aaf.osaaf.org:8095/org.osaaf.aaf.service:2.1";
+ String name="theName";
+ assertEquals(url,rph.replacements(getClass().getSimpleName(),url, name, ""));
+
+ String alu = "aaf.osaaf.org:8095";
+ String curl = url.replace(alu, Config.AAF_LOCATE_URL_TAG);
+ pa.setProperty(Config.AAF_LOCATE_URL,"https://"+alu);
+ assertEquals(url.replace("8095","8095/locate"),rph.replacements(getClass().getSimpleName(),curl, name, ""));
+
+ String root_ns = "org.osaaf.aaf";
+ curl = url.replace(root_ns, "AAF_NS");
+ pa.setProperty(Config.AAF_ROOT_NS,root_ns);
+ assertEquals(url,rph.replacements(getClass().getSimpleName(),curl, name, ""));
+
+ curl = url.replace(root_ns, "%AAF_NS");
+ pa.setProperty(Config.AAF_ROOT_NS,root_ns);
+ assertEquals(url,rph.replacements(getClass().getSimpleName(),curl, name, ""));
+
+ final String fqdn = "%C.%CNS.%NS.%N";
+ String target = "myns.theName";
+ assertEquals(target,rph.replacements(getClass().getSimpleName(),fqdn, name, ""));
- pa.setProperty(Config.AAF_LOCATOR_CONTAINER_NS+".hello", "mycontns");
- target = "mycontns.myns.theName";
- assertEquals(target,rph.replacements(getClass().getSimpleName(),fqdn, name, ".hello"));
-
- pa.setProperty(Config.AAF_LOCATOR_CONTAINER+".hello","helloC");
- target = "helloC.mycontns.myns.theName";
- assertEquals(target,rph.replacements(getClass().getSimpleName(),fqdn, name, ".hello"));
-
- pa.setProperty(Config.AAF_LOCATOR_CONTAINER_NS,"c_ns");
- target = "c_ns.myns.theName";
- assertEquals(target,rph.replacements(getClass().getSimpleName(),fqdn, name, ""));
+ pa.setProperty(Config.AAF_LOCATOR_CONTAINER_NS+".hello", "mycontns");
+ target = "mycontns.myns.theName";
+ assertEquals(target,rph.replacements(getClass().getSimpleName(),fqdn, name, ".hello"));
+
+ pa.setProperty(Config.AAF_LOCATOR_CONTAINER+".hello","helloC");
+ target = "helloC.mycontns.myns.theName";
+ assertEquals(target,rph.replacements(getClass().getSimpleName(),fqdn, name, ".hello"));
+
+ pa.setProperty(Config.AAF_LOCATOR_CONTAINER_NS,"c_ns");
+ target = "c_ns.myns.theName";
+ assertEquals(target,rph.replacements(getClass().getSimpleName(),fqdn, name, ""));
- } catch (UnknownHostException | CadiException e) {
- e.printStackTrace();
- Assert.fail();
- }
- }
-
+ } catch (UnknownHostException | CadiException e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+ }
+
}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_CSV.java b/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_CSV.java
index 9df6de7b..d4feac6f 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_CSV.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_CSV.java
@@ -43,83 +43,83 @@ import org.onap.aaf.cadi.util.CSV.Writer;
public class JU_CSV {
- private String filename;
- private File file;
- private static ArrayList<Object> expected;
+ private String filename;
+ private File file;
+ private static ArrayList<Object> expected;
- @Before
- public void start() {
- filename = "Sample.csv";
- file = new File(filename);
- }
-
- @After
- public void end() {
- if(file!=null) {
- file.delete();
- }
- }
+ @Before
+ public void start() {
+ filename = "Sample.csv";
+ file = new File(filename);
+ }
+
+ @After
+ public void end() {
+ if(file!=null) {
+ file.delete();
+ }
+ }
- @BeforeClass
- public static void before() {
- expected = new ArrayList<>();
- }
-
- @Test
- public void test() throws IOException, CadiException {
- Access access = new PropAccess();
- CSV csv = new CSV(access,file);
- // Can't visit for file that doesn't exist
- try {
- csv.visit(new Visitor() {
- @Override
- public void visit(List<String> row) {
- }});
- } catch(IOException e) {
- Assert.assertTrue("CSV correctly created exception",true);
- }
-
- Writer writer = csv.writer();
- try {
- writer.row(add("\"hello\""));
- writer.comment("Ignore Comments");
- writer.row(add("dXNlcjpwYXNzd29yZA=="),add("dXNlckBzb21ldGhpbmcub3JnOm90aGVyUGFzc3dvcmQ="));
- writer.row(); // no output
- writer.row(add("There is, but one thing to say"), add(" and that is"), add("\"All the best\""));
- } finally {
- writer.close();
- }
-
- PrintStream garbage = new PrintStream(new FileOutputStream(file, true));
- try {
- garbage.println("# Ignore empty spaces, etc");
- garbage.println(" ");
- garbage.println("# Ignore blank lines");
- garbage.println();
- } finally {
- garbage.close();
- }
+ @BeforeClass
+ public static void before() {
+ expected = new ArrayList<>();
+ }
+
+ @Test
+ public void test() throws IOException, CadiException {
+ Access access = new PropAccess();
+ CSV csv = new CSV(access,file);
+ // Can't visit for file that doesn't exist
+ try {
+ csv.visit(new Visitor() {
+ @Override
+ public void visit(List<String> row) {
+ }});
+ } catch(IOException e) {
+ Assert.assertTrue("CSV correctly created exception",true);
+ }
+
+ Writer writer = csv.writer();
+ try {
+ writer.row(add("\"hello\""));
+ writer.comment("Ignore Comments");
+ writer.row(add("dXNlcjpwYXNzd29yZA=="),add("dXNlckBzb21ldGhpbmcub3JnOm90aGVyUGFzc3dvcmQ="));
+ writer.row(); // no output
+ writer.row(add("There is, but one thing to say"), add(" and that is"), add("\"All the best\""));
+ } finally {
+ writer.close();
+ }
+
+ PrintStream garbage = new PrintStream(new FileOutputStream(file, true));
+ try {
+ garbage.println("# Ignore empty spaces, etc");
+ garbage.println(" ");
+ garbage.println("# Ignore blank lines");
+ garbage.println();
+ } finally {
+ garbage.close();
+ }
-
- ////////////
- // Tests
- ////////////
- final Holder<Integer> hi = new Holder<>(0);
- csv.visit(new CSV.Visitor() {
- @Override
- public void visit(List<String> row) {
- for(String s: row) {
-// System.out.println(hi.value + ") " + s);
- Assert.assertEquals(expected.get(hi.value++),s);
- }
- }
- });
+
+ ////////////
+ // Tests
+ ////////////
+ final Holder<Integer> hi = new Holder<>(0);
+ csv.visit(new CSV.Visitor() {
+ @Override
+ public void visit(List<String> row) {
+ for(String s: row) {
+// System.out.println(hi.value + ") " + s);
+ Assert.assertEquals(expected.get(hi.value++),s);
+ }
+ }
+ });
- }
+ }
- private String add(String s) {
- expected.add(s);
- return s;
- }
+ private String add(String s) {
+ expected.add(s);
+ return s;
+ }
}
diff --git a/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OAuthExample.java b/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OAuthExample.java
index b09c2b78..d0c800bf 100644
--- a/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OAuthExample.java
+++ b/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OAuthExample.java
@@ -75,14 +75,14 @@ public class OAuthExample {
// Obtain Endpoints for OAuth2 from Properties. Expected is "cadi.properties" file, pointed to by "cadi_prop_files"
try {
- Map<String, String> aaf_urls = Agent.loadURLs(access);
- Agent.fillMissing(access, aaf_urls);
- String tokenServiceURL = access.getProperty(Config.AAF_OAUTH2_TOKEN_URL); // Default to AAF
- String tokenIntrospectURL = access.getProperty(Config.AAF_OAUTH2_INTROSPECT_URL); // Default to AAF);
- // Get Hello Service
- final String endServicesURL = access.getProperty(Config.AAF_OAUTH2_HELLO_URL);
-
- final int CALL_TIMEOUT = Integer.parseInt(access.getProperty(Config.AAF_CALL_TIMEOUT,Config.AAF_CALL_TIMEOUT_DEF));
+ Map<String, String> aaf_urls = Agent.loadURLs(access);
+ Agent.fillMissing(access, aaf_urls);
+ String tokenServiceURL = access.getProperty(Config.AAF_OAUTH2_TOKEN_URL); // Default to AAF
+ String tokenIntrospectURL = access.getProperty(Config.AAF_OAUTH2_INTROSPECT_URL); // Default to AAF);
+ // Get Hello Service
+ final String endServicesURL = access.getProperty(Config.AAF_OAUTH2_HELLO_URL);
+
+ final int CALL_TIMEOUT = Integer.parseInt(access.getProperty(Config.AAF_CALL_TIMEOUT,Config.AAF_CALL_TIMEOUT_DEF));
//////////////////////////////////////////////////////////////////////
// Scenario 1:
diff --git a/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OnapClientExample.java b/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OnapClientExample.java
index b5d087ea..b8cce9e5 100644
--- a/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OnapClientExample.java
+++ b/cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OnapClientExample.java
@@ -63,10 +63,10 @@ public class OnapClientExample {
// Note: This style will load "cadi_prop_files" from VM Args
// access = PropAccess();
try {
- Map<String, String> aaf_urls = Agent.loadURLs(access);
- Agent.fillMissing(access, aaf_urls);
+ Map<String, String> aaf_urls = Agent.loadURLs(access);
+ Agent.fillMissing(access, aaf_urls);
- // Token aware Client Factory
+ // Token aware Client Factory
tcf = TokenClientFactory.instance(access);
} catch (APIException | GeneralSecurityException | IOException | CadiException e1) {
access.log(e1, "Unable to setup OAuth Client Factory, Fail Fast");