More refinement, Agent.sh 03/78703/1
authorInstrumental <jonathan.gathman@att.com>
Mon, 18 Feb 2019 20:01:07 +0000 (14:01 -0600)
committerInstrumental <jonathan.gathman@att.com>
Mon, 18 Feb 2019 20:02:27 +0000 (14:02 -0600)
Issue-ID: AAF-667
Change-Id: I3898f3378fffb0ed89ad84cb80942d1ded51b3d4
Signed-off-by: Instrumental <jonathan.gathman@att.com>
13 files changed:
auth/docker/agent.sh
auth/sample/bin/client.sh
auth/sample/etc/org.osaaf.aaf.gui.props
auth/sample/local/initialConfig.props
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/Defaults.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/oauth/TokenClientFactory.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java
cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java
cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OAuthExample.java
cadi/oauth-enduser/src/test/java/org/onap/aaf/cadi/enduser/test/OnapClientExample.java

index c330b1c..d319de4 100644 (file)
@@ -48,15 +48,21 @@ for V in VERSION DOCKER_REPOSITORY HOSTNAME AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_
                # Need AAF_FQDN's IP, because not might not be available in mini-container
                PROMPT="AAF FQDN IP"
                LOOKUP=$(host "${AAF_FQDN}" | grep "has address")
-               if [ -z ${LOOKUP} ]; then
-                    DEF= 
-                else 
+               if [ -n "${LOOKUP}" ]; then
                    DEF=$(echo ${LOOKUP} | tail -1 | cut -f 4 -d ' ')
                 fi
                 ;;
-         APP_FQI)    PROMPT="App's FQI";; 
-         APP_FQDN)   PROMPT="App's Root FQDN";; 
-         VOLUME)     PROMPT="APP's AAF Configuration Volume";;
+         APP_FQDN)   PROMPT="App's Root FQDN";;
+         APP_FQI)    PROMPT="App's FQI"
+                    if [[ "${APP_FQDN}" != *"."* ]]; then
+                      DEF="${APP_FQDN}@${APP_FQDN}.onap.org"
+                     fi
+                    ;; 
+         VOLUME)     PROMPT="APP's AAF Configuration Volume"
+                    if [[ "${APP_FQDN}" != *"."* ]]; then
+                      DEF="${APP_FQDN}_config"
+                    fi
+                ;;
          DRIVER)     PROMPT=$V;DEF=local;;
         VERSION)    PROMPT="CADI Version";DEF=$CADI_VERSION;;
          LATITUDE|LONGITUDE) PROMPT="$V of Node";;
index 7af8a97..9b146c5 100755 (executable)
@@ -158,12 +158,17 @@ else
         $JAVA_AGENT showpass ${APP_FQI} ${APP_FQDN}
         ;;
     check)
+        echo "## Check Certificate"
         $JAVA_AGENT check ${APP_FQI} ${APP_FQDN}
         ;;
     validate)
         echo "## validate requested"
         $JAVA_AGENT_SELF validate 
         ;;
+    renew)
+        echo "## Renew Certificate"
+        $JAVA_AGENT place ${APP_FQI} ${APP_FQDN}
+        ;;
     bash)
         shift
         cd $LOCAL || exit
index b6e9072..caad208 100644 (file)
@@ -30,7 +30,7 @@ aaf_locator_port.helm=30083
 aaf_gui_title=AAF
 aaf_gui_copyright=(c) 2018 AT&T Intellectual Property. All rights reserved.
 aaf_gui_theme=theme/onap
-cadi_loginpage_url=https://AAF_LOCATE_URL/AAF_NS.gui:2.0/login
+cadi_loginpage_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.gui:2.0/login
 
 # GUI URLS and Help URLS
 aaf_url.gui_onboard=https://wiki.onap.org/display/DW/Client+Onboarding
index 91d5338..93cfae5 100644 (file)
@@ -41,10 +41,10 @@ aaf_locator_fqdn.oom=aaf-%N.%CNS
 # AAF URLs \r
 ################################\r
 aaf_locate_url=https://localhost:8095\r
-aaf_url=https://AAF_LOCATE_URL/%C.%AAF_NS.service:2.1\r
-aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/%C.%AAF_NS.oauth:2.1/introspect\r
-aaf_oauth2_token_url=https://AAF_LOCATE_URL/%C.%AAF_NS.oauth:2.1/token\r
-cm_url=https://AAF_LOCATE_URL/%C.%AAF_NS.cm:2.1\r
-gui_url=https://AAF_LOCATE_URL/%C.%AAF_NS.gui.2.1\r
-fs_url=https://AAF_LOCATE_URL/%C.%AAF_NS.fs.2.1\r
+aaf_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.service:2.1\r
+aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.oauth:2.1/introspect\r
+aaf_oauth2_token_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.oauth:2.1/token\r
+cm_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.cm:2.1\r
+gui_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.gui.2.1\r
+fs_url=https://AAF_LOCATE_URL/%CNS.%AAF_NS.fs.2.1\r
 \r
index 0dc5110..c631cb9 100644 (file)
@@ -24,12 +24,6 @@ public interface Defaults {
     public final static String AAF_VERSION = "2.1";
     public final static String AAF_NS = "AAF_NS";
     public final static String AAF_LOCATE_CONST="https://AAF_LOCATE_URL";
-    public final static String AAF_ROOT =   AAF_LOCATE_CONST + '/' + AAF_NS;
-    public final static String AAF_URL = AAF_ROOT + ".service:" + AAF_VERSION;
-    public final static String GUI_URL = AAF_ROOT + ".gui:" + AAF_VERSION;
-    public final static String CM_URL = AAF_ROOT + ".cm:" + AAF_VERSION;
-    public final static String FS_URL = AAF_ROOT + ".fs:" + AAF_VERSION;
-    public final static String HELLO_URL = AAF_ROOT + ".hello:" + AAF_VERSION;
-    public final static String OAUTH2_TOKEN_URL = AAF_ROOT  + ".token:" + AAF_VERSION;
-    public final static String OAUTH2_INTROSPECT_URL = AAF_ROOT + ".introspect:" + AAF_VERSION;
+    public final static String AAF_ROOT =   AAF_LOCATE_CONST + "/%CNS.%" + AAF_NS;
+
 }
index bf7ed6d..004c43c 100644 (file)
@@ -185,7 +185,7 @@ public class TestConnectivity {
         String tokenURL = access.getProperty(Config.AAF_OAUTH2_TOKEN_URL);
         String locateURL=access.getProperty(Config.AAF_LOCATE_URL);
         if (tokenURL==null || (tokenURL.contains("/locate/") && locateURL!=null)) {
-            tokenURL=Defaults.OAUTH2_TOKEN_URL+"/token";
+            tokenURL=Config.OAUTH2_TOKEN_URL_DEF;
         }
 
         try {
index aa4e574..c7a7496 100644 (file)
@@ -229,7 +229,7 @@ public class Agent {
                             aafsso.setStdErrDefault();
                             
                             // if CM_URL can be obtained, add to sso.props, if written
-                            String cm_url = getProperty(access,env,false, Config.CM_URL,Config.CM_URL+": ");
+                            String cm_url = getProperty(access,env,false, Config.CM_URL,Config.CM_URL_DEF);
                             if (cm_url!=null) {
                                 aafsso.addProp(Config.CM_URL, cm_url);
                             }
@@ -781,7 +781,7 @@ public class Agent {
             }
             
             app.add(Config.AAF_APPID, fqi);
-            app.add(Config.AAF_URL, propAccess, Defaults.AAF_URL);
+            app.add(Config.AAF_URL, propAccess, Config.AAF_URL_DEF);
 
             String cts = propAccess.getProperty(Config.CADI_TRUSTSTORE);
             if (cts!=null) {
index 21b65f1..c507a82 100644 (file)
@@ -64,10 +64,10 @@ public class TokenClientFactory extends Persist<Token,TimedToken> {
         super(pa, new RosettaEnv(pa.getProperties()),Token.class,"outgoing");
         
         if (access.getProperty(Config.AAF_OAUTH2_TOKEN_URL,null)==null) {
-            access.getProperties().put(Config.AAF_OAUTH2_TOKEN_URL, Defaults.OAUTH2_TOKEN_URL); // Default to AAF
+            access.getProperties().put(Config.AAF_OAUTH2_TOKEN_URL, Config.OAUTH2_TOKEN_URL_DEF); // Default to AAF
         }
         if (access.getProperty(Config.AAF_OAUTH2_INTROSPECT_URL,null)==null) {
-            access.getProperties().put(Config.AAF_OAUTH2_INTROSPECT_URL, Defaults.OAUTH2_INTROSPECT_URL); // Default to AAF);
+            access.getProperties().put(Config.AAF_OAUTH2_INTROSPECT_URL, Config.OAUTH2_INTROSPECT_URL_DEF); // Default to AAF);
         }
 
         symm = Symm.encrypt.obtain();
index 66f1af0..75cddff 100644 (file)
@@ -319,7 +319,7 @@ public class AAFSSO {
             if(aaf_root_ns==null) {
                locateRoot=Defaults.AAF_ROOT;
             } else {
-               locateRoot = Defaults.AAF_LOCATE_CONST + '/' + aaf_root_ns;
+               locateRoot = Defaults.AAF_LOCATE_CONST + "/%CNS.%" + aaf_root_ns;
             }
             if(access.getProperty(Config.AAF_URL)==null) {
                
@@ -425,7 +425,6 @@ public class AAFSSO {
                     diskprops.store(fos, "AAF Single Signon");
                 } finally {
                     fos.close();
-                    setReadonly(sso);
                 }
             }
             if (sso != null) {
index 6649195..dc58acc 100644 (file)
@@ -156,8 +156,8 @@ public class Config {
     public static final String CM_URL_DEF = "https://AAF_LOCATE_URL/%CNS.%AAF_NS.cm:" + AAF_DEFAULT_API_VERSION;
     public static final String FS_URL_DEF = "https://AAF_LOCATE_URL/%CNS.%AAF_NS.fs:" + AAF_DEFAULT_API_VERSION;
     public static final String HELLO_URL_DEF = "https://AAF_LOCATE_URL/%CNS.%AAF_NS.hello:" + AAF_DEFAULT_API_VERSION;
-    public static final String OAUTH2_TOKEN_URL = "https://AAF_LOCATE_URL/%CNS.%AAF_NS.token:" + AAF_DEFAULT_API_VERSION +"/token";
-    public static final String OAUTH2_INTROSPECT_URL = "https://AAF_LOCATE_URL/%CNS.%AAF_NS.introspect:" + AAF_DEFAULT_API_VERSION +"/introspect";;
+    public static final String OAUTH2_TOKEN_URL_DEF = "https://AAF_LOCATE_URL/%CNS.%AAF_NS.token:" + AAF_DEFAULT_API_VERSION +"/token";
+    public static final String OAUTH2_INTROSPECT_URL_DEF = "https://AAF_LOCATE_URL/%CNS.%AAF_NS.introspect:" + AAF_DEFAULT_API_VERSION +"/introspect";;
 
     public static final String AAF_LOCATOR_CLASS = "aaf_locator_class";
     // AAF Locator Entries are ADDITIONAL entries, which also gives the Property ability
@@ -826,26 +826,6 @@ public class Config {
                        throw new LocatorException(e1);
                }
             
-//            if(url.indexOf('%')>=0) {
-//                 String str = access.getProperty(Config.AAF_LOCATOR_CONTAINER_ID, null);
-//                 if(str==null) {
-//                     url = url.replace("%CID","");
-//                 } else {
-//                     url = url.replace("%CID",str+'.');
-//                 }
-//                 str = access.getProperty(Config.AAF_LOCATOR_CONTAINER, null);
-//                 if(str==null) {
-//                     url = url.replace("%C","");
-//                 } else {
-//                     url = url.replace("%C",str+'.');
-//                 }
-//     
-//                 if (root_ns==null) {
-//                     url = url.replace("%AAF_NS","");
-//                 } else {
-//                     url = url.replace("%AAF_NS",root_ns);
-//                 }
-//            }
             String replacement;
             int idxAAFLocateUrl;
             if ((idxAAFLocateUrl=url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) {
index b6cd533..aa78231 100644 (file)
@@ -170,27 +170,6 @@ public class RegistrationPropHolder {
                        }
                }
 
-               if(source.indexOf("%NS")>=0) {
-                       str = getNS(dot_le);
-                       if(str==null || str.isEmpty()) {
-                               source = source.replace("%NS"+'.', str);
-                       }
-                       source = source.replace("%NS", str);
-               }
-
-               // aaf_root_ns
-               if(source.indexOf("AAF_NS")>=0) {
-                       str = access.getProperty(Config.AAF_ROOT_NS, null);
-                       if(str!=null) {
-                               String temp = source.replace("%AAF_NS", str);
-                               if(temp == source) { // intended
-                                       source = source.replace("AAF_NS", str); // Backward Compatibility
-                               } else {
-                                       source = temp;
-                               }
-                       }
-               }
-
                int atC = source.indexOf("%C"); 
                if(atC>=0) {
                        // aaf_locator_container_ns
@@ -207,11 +186,37 @@ public class RegistrationPropHolder {
                        source = source.replace("%C", str);
                }
                
+               if(source.indexOf("%NS")>=0) {
+                       str = getNS(dot_le);
+                       if(str==null || str.isEmpty()) {
+                               source = source.replace("%NS"+'.', str);
+                       }
+                       source = source.replace("%NS", str);
+               }
+
+               // aaf_root_ns
+               if(source.indexOf("AAF_NS")>=0) {
+                       str = access.getProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF);
+                       String temp = source.replace("%AAF_NS", str);
+                       if(temp.equals(source)) { // intended
+                               source = source.replace("AAF_NS", str); // Backward Compatibility
+                       } else {
+                               source = temp;
+                       }
+               }
+
+               
                if(source.indexOf('%')>=0) {
-                       // These shouldn't be expected to have dot elements
-                       source = source.replace("%N", name);
-                       source = source.replace("%DF", default_fqdn);
-                       source = source.replace("%PH", public_hostname);
+            // These shouldn't be expected to have dot elements
+            if(name!=null) {
+              source = source.replace("%N", name);
+            }
+            if(default_fqdn!=null) {
+              source = source.replace("%DF", default_fqdn);
+            }
+            if(public_hostname!=null) {
+              source = source.replace("%PH", public_hostname);
+            }
                }
                return source;
        }
index cd9c231..10bcdcc 100644 (file)
@@ -73,10 +73,10 @@ public class OAuthExample {
         
         
         // Obtain Endpoints for OAuth2 from Properties.  Expected is "cadi.properties" file, pointed to by "cadi_prop_files"
-        String tokenServiceURL = access.getProperty(Config.AAF_OAUTH2_TOKEN_URL,Defaults.OAUTH2_TOKEN_URL); // Default to AAF
-        String tokenIntrospectURL = access.getProperty(Config.AAF_OAUTH2_INTROSPECT_URL,Defaults.OAUTH2_INTROSPECT_URL); // Default to AAF);
+        String tokenServiceURL = access.getProperty(Config.AAF_OAUTH2_TOKEN_URL,Config.OAUTH2_TOKEN_URL_DEF); // Default to AAF
+        String tokenIntrospectURL = access.getProperty(Config.AAF_OAUTH2_INTROSPECT_URL,Config.OAUTH2_INTROSPECT_URL_DEF); // Default to AAF);
         // Get Hello Service
-        final String endServicesURL = access.getProperty(Config.AAF_OAUTH2_HELLO_URL,Defaults.HELLO_URL);
+        final String endServicesURL = access.getProperty(Config.AAF_OAUTH2_HELLO_URL,Config.HELLO_URL_DEF);
 
         final int CALL_TIMEOUT = Integer.parseInt(access.getProperty(Config.AAF_CALL_TIMEOUT,Config.AAF_CALL_TIMEOUT_DEF));
         
index f4fe017..0a65329 100644 (file)
@@ -104,7 +104,7 @@ public class OnapClientExample {
                 // Use this Token in your client calls with "Tokenized Client" (TzClient)
                 // These should NOT be used cross thread.
                 // Get Hello Service URL... roll your own in your own world.
-                final String endServicesURL = access.getProperty(Config.AAF_OAUTH2_HELLO_URL,Defaults.HELLO_URL);
+                final String endServicesURL = access.getProperty(Config.AAF_OAUTH2_HELLO_URL,Config.HELLO_URL_DEF);
 
 
                 TzClient helloClient = tcf.newTzClient(endServicesURL);