Update CM to us Local Intermediate Certs
[aaf/authz.git] / cadi / core / src / main / java / org / onap / aaf / cadi / config / Config.java
index d7c7526..9a0a53c 100644 (file)
@@ -43,6 +43,7 @@ import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.Connector;
 import org.onap.aaf.cadi.CredVal;
 import org.onap.aaf.cadi.Locator;
+import org.onap.aaf.cadi.LocatorException;
 import org.onap.aaf.cadi.Lur;
 import org.onap.aaf.cadi.PropAccess;
 import org.onap.aaf.cadi.Symm;
@@ -143,6 +144,7 @@ public class Config {
        public static final String AAF_ENV = "aaf_env";
        public static final String AAF_URL = "aaf_url"; //URL for AAF... Use to trigger AAF configuration
        public static final String AAF_ROOT_NS = "aaf_root_ns";
+       public static final String AAF_ROOT_NS_DEF = "org.osaaf.aaf";
        public static final String AAF_ROOT_COMPANY = "aaf_root_company";
        public static final String AAF_LOCATE_URL = "aaf_locate_url"; //URL for AAF locator
        private static final String AAF_LOCATE_URL_TAG = "AAF_LOCATE_URL"; // Name of Above for use in Config Variables.
@@ -224,7 +226,7 @@ public class Config {
                }
        }
 
-       public static HttpTaf configHttpTaf(Connector con, SecurityInfoC<HttpURLConnection> si, TrustChecker tc, CredVal up, Lur lur, Object ... additionalTafLurs) throws CadiException {
+       public static HttpTaf configHttpTaf(Connector con, SecurityInfoC<HttpURLConnection> si, TrustChecker tc, CredVal up, Lur lur, Object ... additionalTafLurs) throws CadiException, LocatorException {
                Access access = si.access;
                /////////////////////////////////////////////////////
                // Setup AAFCon for any following
@@ -532,7 +534,11 @@ public class Config {
                                        access.log(Level.INIT,"AAF/OAuth LUR plugin is not available.");
                                }
                        } catch (NoSuchMethodException| SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-                               access.log(e,"AAF/OAuth LUR could not be constructed with given Constructors.");
+                               String msg = e.getMessage();
+                               if(msg==null && e.getCause()!=null) {
+                                       msg = e.getCause().getMessage();
+                               }
+                               access.log(Level.INIT,"AAF/OAuth LUR is not instantiated.",msg);
                        } 
                } else {
                        access.log(Level.INIT, "OAuth2 Lur disabled");
@@ -707,7 +713,7 @@ public class Config {
 
 
        @SuppressWarnings("unchecked")
-       public static Locator<URI> loadLocator(SecurityInfoC<HttpURLConnection> si, final String _url) {
+       public static Locator<URI> loadLocator(SecurityInfoC<HttpURLConnection> si, final String _url) throws LocatorException {
                Access access = si.access;
                Locator<URI> locator = null;
                if(_url==null) {
@@ -716,7 +722,12 @@ public class Config {
                        String url = _url, replacement;
                        int idxAAF_LOCATE_URL;
                        if((idxAAF_LOCATE_URL=_url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) {
-                               url = replacement + "/locate" + _url.substring(idxAAF_LOCATE_URL+AAF_LOCATE_URL_TAG.length());
+                               StringBuilder sb = new StringBuilder(replacement);
+                               if(!replacement.endsWith("/locate")) {
+                                       sb.append("/locate");
+                               } 
+                               sb.append(_url,idxAAF_LOCATE_URL+AAF_LOCATE_URL_TAG.length(),_url.length());
+                               url = sb.toString();
                        }
        
                        try {
@@ -743,6 +754,9 @@ public class Config {
                                        access.log(Level.INFO, "AAFLocator enabled using preloaded " + locator.getClass().getSimpleName());
                                }
                        } catch (InvocationTargetException e) {
+                               if(e.getTargetException() instanceof LocatorException) {
+                                       throw (LocatorException)e.getTargetException();
+                               }
                                access.log(Level.INIT,e.getTargetException().getMessage(),"AAFLocator for",url,"could not be created.",e);
                        } catch (Exception e) {
                                access.log(Level.INIT,"AAFLocator for",url,"could not be created.",e);