Public and Private Locate entries 39/76139/1
authorInstrumental <jonathan.gathman@att.com>
Tue, 22 Jan 2019 16:27:32 +0000 (10:27 -0600)
committerInstrumental <jonathan.gathman@att.com>
Tue, 22 Jan 2019 16:32:14 +0000 (10:32 -0600)
Issue-ID: AAF-723
Change-Id: I9dcd2e732ce64b39aaa57a6e9404f275f7ad540c
Signed-off-by: Instrumental <jonathan.gathman@att.com>
108 files changed:
auth-client/pom.xml
auth/auth-batch/pom.xml
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NsRoleUserReport.java [new file with mode: 0644]
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/NotifyCredExpiring.java
auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java
auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/creators/RowCreator.java
auth/auth-cass/cass_init/cmd.sh
auth/auth-cass/docker/dinstall.sh
auth/auth-cass/docker/drun.sh
auth/auth-cass/pom.xml
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java
auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java
auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java
auth/auth-certman/pom.xml
auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java
auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java
auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java
auth/auth-cmd/pom.xml
auth/auth-core/pom.xml
auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java
auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java
auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java
auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java [new file with mode: 0644]
auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java
auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java
auth/auth-deforg/pom.xml
auth/auth-fs/pom.xml
auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java
auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java
auth/auth-gui/pom.xml
auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java
auth/auth-hello/pom.xml
auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java
auth/auth-locate/pom.xml
auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
auth/auth-oauth/pom.xml
auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java
auth/auth-service/pom.xml
auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java
auth/docker/.gitignore
auth/docker/Dockerfile.base [new file with mode: 0644]
auth/docker/Dockerfile.client
auth/docker/Dockerfile.config
auth/docker/Dockerfile.core
auth/docker/Dockerfile.ms
auth/docker/aaf.sh
auth/docker/agent.sh
auth/docker/components
auth/docker/d.props.init
auth/docker/dbash.sh
auth/docker/dbuild.sh
auth/docker/drun.sh
auth/docker/dstart.sh
auth/docker/dstop.sh
auth/pom.xml
auth/sample/bin/client.sh
auth/sample/bin/pod_wait.sh
auth/sample/bin/service.sh
auth/sample/etc/org.osaaf.aaf.cm.props
auth/sample/etc/org.osaaf.aaf.fs.props
auth/sample/etc/org.osaaf.aaf.gui.props
auth/sample/etc/org.osaaf.aaf.hello.props
auth/sample/etc/org.osaaf.aaf.locate.props
auth/sample/etc/org.osaaf.aaf.oauth.props
auth/sample/etc/org.osaaf.aaf.service.props
auth/sample/local/aaf.props
auth/sample/local/initialConfig.props
cadi/aaf/pom.xml
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/TestConnectivity.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFLocator.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFSingleLocator.java [new file with mode: 0644]
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java [new file with mode: 0644]
cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java
cadi/client/pom.xml
cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java
cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java
cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java
cadi/core/pom.xml
cadi/core/src/main/java/org/onap/aaf/cadi/PropAccess.java
cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
cadi/core/src/main/java/org/onap/aaf/cadi/filter/CadiFilter.java
cadi/core/src/main/java/org/onap/aaf/cadi/filter/FCGet.java
cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java [new file with mode: 0644]
cadi/core/src/main/java/org/onap/aaf/cadi/util/Split.java
cadi/oauth-enduser/pom.xml
cadi/pom.xml
cadi/servlet-sample/pom.xml
conf/CA/bootstrap.sh
conf/CA/san_root.aaf
misc/env/pom.xml
misc/env/src/main/java/org/onap/aaf/misc/env/StaticSlot.java
misc/env/src/test/java/org/onap/aaf/misc/env/JU_JavaUtilLogTarget.java
misc/env/src/test/java/org/onap/aaf/misc/env/JU_NullLifeCycle.java
misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_StoreImplTest.java [moved from misc/env/src/test/java/org/onap/aaf/misc/env/JU_StoreImplTest.java with 94% similarity]
misc/log4j/pom.xml
misc/pom.xml
misc/rosetta/pom.xml
misc/xgen/pom.xml
pom.xml

index 837d647..5c32218 100644 (file)
@@ -25,7 +25,7 @@
     <parent>
         <groupId>org.onap.aaf.authz</groupId>
         <artifactId>parent</artifactId>
-        <version>2.1.9-SNAPSHOT</version>
+        <version>2.1.10-SNAPSHOT</version>
     </parent>
        
        <artifactId>aaf-auth-client</artifactId>
index c30a32a..1994d9e 100644 (file)
@@ -25,7 +25,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index ff60520..d49f4fa 100644 (file)
@@ -81,6 +81,8 @@ public abstract class Batch {
     protected static boolean dryRun; 
     protected static String batchEnv;
 
+       private static File logdir;
+
     public static final String CASS_ENV = "CASS_ENV";
     public static final String LOG_DIR = "LOG_DIR";
     protected static final String MAX_EMAILS="MAX_EMAILS";
@@ -324,16 +326,22 @@ public abstract class Batch {
         }
     }
     
-    protected static String logDir() {
-        String ld = env.getProperty(LOG_DIR);
-        if (ld==null) {
-            if (batchEnv==null) { // Deployed Batch doesn't use different ENVs, and a common logdir
-                ld = "logs/";
-            } else {
-                ld = "logs/"+batchEnv;
-            }
-        }
-        return ld;
+    protected static File logDir() {
+        if(logdir == null) {
+               String ld = env.getProperty(LOG_DIR);
+               if (ld==null) {
+                   if (batchEnv==null) { // Deployed Batch doesn't use different ENVs, and a common logdir
+                       ld = "logs/";
+                   } else {
+                       ld = "logs/"+batchEnv;
+                   }
+               }
+               logdir = new File(ld);
+               if(!logdir.exists()) {
+                       logdir.mkdirs();
+               }
+        } 
+        return logdir;
     }
     protected int count(String str, char c) {
         if (str==null || str.isEmpty()) {
index 7ed26ce..e171d17 100644 (file)
@@ -63,7 +63,6 @@ public class Expiring extends Batch {
        private static final String EXPIRED_OWNERS = "ExpiredOwners";
        private int minOwners;
        private Map<String, CSV.Writer> writerList;
-       private File logDir;
        private ExpireRange expireRange;
        private Date deleteDate;
        
@@ -87,15 +86,13 @@ public class Expiring extends Batch {
 
             // Create Intermediate Output 
             writerList = new HashMap<>();
-            logDir = new File(logDir());
-            logDir.mkdirs();
             
             expireRange = new ExpireRange(trans.env().access());
             String sdate = Chrono.dateOnlyStamp(expireRange.now);
             for( List<Range> lr : expireRange.ranges.values()) {
                for(Range r : lr ) {
                        if(writerList.get(r.name())==null) {
-                       File file = new File(logDir,r.name() + sdate +CSV);
+                       File file = new File(logDir(),r.name() + sdate +CSV);
                        CSV csv = new CSV(file);
                        CSV.Writer cw = csv.writer(false);
                        cw.row(INFO,r.name(),Chrono.dateOnlyStamp(expireRange.now),r.reportingLevel());
@@ -116,7 +113,7 @@ public class Expiring extends Batch {
     @Override
     protected void run(AuthzTrans trans) {
                try {
-                       File file = new File(logDir, EXPIRED_OWNERS + Chrono.dateOnlyStamp(expireRange.now) + CSV);
+                       File file = new File(logDir(), EXPIRED_OWNERS + Chrono.dateOnlyStamp(expireRange.now) + CSV);
                        final CSV ownerCSV = new CSV(file);
 
                        Map<String, Set<UserRole>> owners = new TreeMap<String, Set<UserRole>>();
index 2ba5d02..fe754c1 100644 (file)
@@ -52,7 +52,6 @@ public class NotInOrg extends Batch {
        private static final String INFO = "info";
        private Map<String, CSV.Writer> writerList;
        private Map<String, CSV.Writer> whichWriter; 
-       private File logDir;
        private Date now;
        private Writer notInOrgW;
        private Writer notInOrgDeleteW;
@@ -76,12 +75,10 @@ public class NotInOrg extends Batch {
             // Create Intermediate Output 
             writerList = new HashMap<>();
             whichWriter = new TreeMap<>();
-            logDir = new File(logDir());
-            logDir.mkdirs();
 
             now = new Date();
             String sdate = Chrono.dateOnlyStamp(now);
-               File file = new File(logDir,NOT_IN_ORG + sdate +CSV);
+               File file = new File(logDir(),NOT_IN_ORG + sdate +CSV);
             CSV csv = new CSV(file);
             notInOrgW = csv.writer(false);
             notInOrgW.row(INFO,NOT_IN_ORG,Chrono.dateOnlyStamp(now),0);
@@ -89,7 +86,7 @@ public class NotInOrg extends Batch {
             
             // These will have been double-checked by the Organization, and can be deleted immediately.
             String fn = NOT_IN_ORG+"Delete";
-            file = new File(logDir,fn + sdate +CSV);
+            file = new File(logDir(),fn + sdate +CSV);
             CSV csvDelete = new CSV(file);
             notInOrgDeleteW = csvDelete.writer(false);
             notInOrgDeleteW.row(INFO,fn,Chrono.dateOnlyStamp(now),0);
index daf5192..547b657 100644 (file)
@@ -95,7 +95,7 @@ public class Notify extends Batch {
                NotifyBody.load(env.access());
                
         // Create Intermediate Output 
-        File logDir = new File(logDir());
+        File logDir = logDir();
         notifyFile = new ArrayList<>();
         if(args().length>0) {
                for(int i=0;i<args().length;++i) {
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NsRoleUserReport.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NsRoleUserReport.java
new file mode 100644 (file)
index 0000000..8281e74
--- /dev/null
@@ -0,0 +1,127 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+
+package org.onap.aaf.auth.batch.reports;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
+import org.onap.aaf.auth.batch.Batch;
+import org.onap.aaf.auth.batch.helpers.NS;
+import org.onap.aaf.auth.batch.helpers.Role;
+import org.onap.aaf.auth.batch.helpers.UserRole;
+import org.onap.aaf.auth.batch.helpers.Visitor;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.org.OrganizationException;
+import org.onap.aaf.cadi.util.CSV;
+import org.onap.aaf.cadi.util.CSV.Writer;
+import org.onap.aaf.misc.env.APIException;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.TimeTaken;
+import org.onap.aaf.misc.env.util.Chrono;
+
+
+public class NsRoleUserReport extends Batch {
+    
+       private static final String REPORT = NsRoleUserReport.class.getSimpleName();
+       private static final String CSV = ".csv";
+       private Date now;
+       private Writer report;
+       private Map<String,Map<String,Integer>> theMap;
+       
+       public NsRoleUserReport(AuthzTrans trans) throws APIException, IOException, OrganizationException {
+        super(trans.env());
+        trans.info().log("Starting Connection Process");
+        
+        TimeTaken tt0 = trans.start("Cassandra Initialization", Env.SUB);
+        try {
+            TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE);
+            try {
+                session = cluster.connect();
+            } finally {
+                tt.done();
+            }
+            
+            // Create Intermediate Output 
+            now = new Date();
+            String sdate = Chrono.dateOnlyStamp(now);
+               File file = new File(logDir(),REPORT + sdate +CSV);
+            CSV csv = new CSV(file);
+            report = csv.writer(false);
+            
+            theMap = new TreeMap<>();
+
+            NS.load(trans, session, NS.v2_0_11);
+            Role.load(trans, session);
+        } finally {
+            tt0.done();
+        }
+    }
+
+    @Override
+    protected void run(AuthzTrans trans) {
+               try {
+                       trans.info().log("Create Report on Roles by NS");
+                       
+                       final AuthzTrans transNoAvg = trans.env().newTransNoAvg();
+                       UserRole.load(transNoAvg, session, UserRole.v2_0_11, new Visitor<UserRole>() {
+                               @Override
+                               public void visit(UserRole ur) {
+                                       if(ur.expires().after(now)) {
+                                               Map<String, Integer> roleCount = theMap.get(ur.ns());
+                                               Integer count;
+                                               if(roleCount==null) {
+                                                       roleCount = new TreeMap<>();
+                                                       theMap.put(ur.ns(),roleCount);
+                                                       count = 0;
+                                               } else {
+                                                       count = roleCount.get(ur.rname());
+                                                       if(count == null) {
+                                                               count = 0;
+                                                       }
+                                               }
+                                               roleCount.put(ur.rname(), count+1);
+                                       }
+                               }
+                       });
+                       
+                       for(Entry<String, Map<String, Integer>> ns_es : theMap.entrySet()) {
+                               for(Entry<String, Integer> r_es : ns_es.getValue().entrySet()) {
+                                       report.row(ns_es.getKey(),r_es.getKey(),r_es.getValue());
+                               }
+                       }
+
+
+               } finally {
+               }
+       }
+       @Override
+    protected void _close(AuthzTrans trans) {
+        session.close();
+        report.close();
+    }
+
+}
index ce00816..4288b2e 100644 (file)
@@ -29,12 +29,10 @@ import java.io.IOException;
 import java.io.PrintStream;
 import java.text.ParseException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
 
@@ -42,19 +40,10 @@ import org.onap.aaf.auth.batch.Batch;
 import org.onap.aaf.auth.batch.BatchPrincipal;
 import org.onap.aaf.auth.batch.actions.Email;
 import org.onap.aaf.auth.batch.actions.EmailPrint;
-import org.onap.aaf.auth.batch.actions.Message;
-import org.onap.aaf.auth.batch.helpers.Cred;
-import org.onap.aaf.auth.batch.helpers.NS;
 import org.onap.aaf.auth.batch.helpers.Notification;
 import org.onap.aaf.auth.batch.helpers.UserRole;
-import org.onap.aaf.auth.batch.helpers.Notification.TYPE;
-import org.onap.aaf.auth.dao.hl.Question;
 import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.layer.Result;
-import org.onap.aaf.auth.org.Organization;
-import org.onap.aaf.auth.org.Organization.Identity;
 import org.onap.aaf.auth.org.OrganizationException;
-import org.onap.aaf.auth.org.OrganizationFactory;
 import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.util.CSV;
 import org.onap.aaf.misc.env.APIException;
index 5f6021b..f2425f4 100644 (file)
@@ -84,7 +84,7 @@ public class Remove extends Batch {
         final int maxBatch = 25;
 
         // Create Intermediate Output 
-        File logDir = new File(logDir());
+        File logDir = logDir();
         
         List<File> remove = new ArrayList<>();
         if(args().length>0) {
index 661105d..6902a42 100644 (file)
@@ -45,367 +45,367 @@ public class RowCreator {
                Row row = new Row() {
 
                        @Override
-                       public boolean isNull(String name) {
+                       public boolean isNull(int i) {
                                // TODO Auto-generated method stub
                                return false;
                        }
 
                        @Override
-                       public BigInteger getVarint(String name) {
+                       public boolean getBool(int i) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return false;
                        }
 
                        @Override
-                       public UUID getUUID(String name) {
+                       public byte getByte(int i) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public UDTValue getUDTValue(String name) {
+                       public short getShort(int i) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public TupleValue getTupleValue(String name) {
+                       public int getInt(int i) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public Date getTimestamp(String name) {
+                       public long getLong(int i) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public long getTime(String name) {
+                       public Date getTimestamp(int i) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public String getString(String name) {
+                       public LocalDate getDate(int i) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public short getShort(String name) {
+                       public long getTime(int i) {
                                // TODO Auto-generated method stub
                                return 0;
                        }
 
                        @Override
-                       public <T> Set<T> getSet(String name, TypeToken<T> elementsType) {
+                       public float getFloat(int i) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public <T> Set<T> getSet(String name, Class<T> elementsClass) {
+                       public double getDouble(int i) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public Object getObject(String name) {
+                       public ByteBuffer getBytesUnsafe(int i) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <K, V> Map<K, V> getMap(String name, TypeToken<K> keysType, TypeToken<V> valuesType) {
+                       public ByteBuffer getBytes(int i) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <K, V> Map<K, V> getMap(String name, Class<K> keysClass, Class<V> valuesClass) {
+                       public String getString(int i) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public long getLong(String name) {
+                       public BigInteger getVarint(int i) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public <T> List<T> getList(String name, TypeToken<T> elementsType) {
+                       public BigDecimal getDecimal(int i) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <T> List<T> getList(String name, Class<T> elementsClass) {
+                       public UUID getUUID(int i) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public int getInt(String name) {
+                       public InetAddress getInet(int i) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public InetAddress getInet(String name) {
+                       public <T> List<T> getList(int i, Class<T> elementsClass) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public float getFloat(String name) {
+                       public <T> List<T> getList(int i, TypeToken<T> elementsType) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public double getDouble(String name) {
+                       public <T> Set<T> getSet(int i, Class<T> elementsClass) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public BigDecimal getDecimal(String name) {
+                       public <T> Set<T> getSet(int i, TypeToken<T> elementsType) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public LocalDate getDate(String name) {
+                       public <K, V> Map<K, V> getMap(int i, Class<K> keysClass, Class<V> valuesClass) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public ByteBuffer getBytesUnsafe(String name) {
+                       public <K, V> Map<K, V> getMap(int i, TypeToken<K> keysType, TypeToken<V> valuesType) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public ByteBuffer getBytes(String name) {
+                       public UDTValue getUDTValue(int i) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public byte getByte(String name) {
+                       public TupleValue getTupleValue(int i) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public boolean getBool(String name) {
+                       public Object getObject(int i) {
                                // TODO Auto-generated method stub
-                               return false;
+                               return null;
                        }
 
                        @Override
-                       public <T> T get(String name, TypeCodec<T> codec) {
+                       public <T> T get(int i, Class<T> targetClass) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <T> T get(String name, TypeToken<T> targetType) {
+                       public <T> T get(int i, TypeToken<T> targetType) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <T> T get(String name, Class<T> targetClass) {
+                       public <T> T get(int i, TypeCodec<T> codec) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public boolean isNull(int i) {
+                       public boolean isNull(String name) {
                                // TODO Auto-generated method stub
                                return false;
                        }
 
                        @Override
-                       public BigInteger getVarint(int i) {
+                       public boolean getBool(String name) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return false;
                        }
 
                        @Override
-                       public UUID getUUID(int i) {
+                       public byte getByte(String name) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public UDTValue getUDTValue(int i) {
+                       public short getShort(String name) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public TupleValue getTupleValue(int i) {
+                       public int getInt(String name) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public Date getTimestamp(int i) {
+                       public long getLong(String name) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public long getTime(int i) {
+                       public Date getTimestamp(String name) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public String getString(int i) {
+                       public LocalDate getDate(String name) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public short getShort(int i) {
+                       public long getTime(String name) {
                                // TODO Auto-generated method stub
                                return 0;
                        }
 
                        @Override
-                       public <T> Set<T> getSet(int i, TypeToken<T> elementsType) {
+                       public float getFloat(String name) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public <T> Set<T> getSet(int i, Class<T> elementsClass) {
+                       public double getDouble(String name) {
                                // TODO Auto-generated method stub
-                               return null;
+                               return 0;
                        }
 
                        @Override
-                       public Object getObject(int i) {
+                       public ByteBuffer getBytesUnsafe(String name) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <K, V> Map<K, V> getMap(int i, TypeToken<K> keysType, TypeToken<V> valuesType) {
+                       public ByteBuffer getBytes(String name) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <K, V> Map<K, V> getMap(int i, Class<K> keysClass, Class<V> valuesClass) {
+                       public String getString(String name) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public long getLong(int i) {
+                       public BigInteger getVarint(String name) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public <T> List<T> getList(int i, TypeToken<T> elementsType) {
+                       public BigDecimal getDecimal(String name) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <T> List<T> getList(int i, Class<T> elementsClass) {
+                       public UUID getUUID(String name) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public int getInt(int i) {
+                       public InetAddress getInet(String name) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public InetAddress getInet(int i) {
+                       public <T> List<T> getList(String name, Class<T> elementsClass) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public float getFloat(int i) {
+                       public <T> List<T> getList(String name, TypeToken<T> elementsType) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public double getDouble(int i) {
+                       public <T> Set<T> getSet(String name, Class<T> elementsClass) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public BigDecimal getDecimal(int i) {
+                       public <T> Set<T> getSet(String name, TypeToken<T> elementsType) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public LocalDate getDate(int i) {
+                       public <K, V> Map<K, V> getMap(String name, Class<K> keysClass, Class<V> valuesClass) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public ByteBuffer getBytesUnsafe(int i) {
+                       public <K, V> Map<K, V> getMap(String name, TypeToken<K> keysType, TypeToken<V> valuesType) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public ByteBuffer getBytes(int i) {
+                       public UDTValue getUDTValue(String name) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public byte getByte(int i) {
+                       public TupleValue getTupleValue(String name) {
                                // TODO Auto-generated method stub
-                               return 0;
+                               return null;
                        }
 
                        @Override
-                       public boolean getBool(int i) {
+                       public Object getObject(String name) {
                                // TODO Auto-generated method stub
-                               return false;
+                               return null;
                        }
 
                        @Override
-                       public <T> T get(int i, TypeCodec<T> codec) {
+                       public <T> T get(String name, Class<T> targetClass) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <T> T get(int i, TypeToken<T> targetType) {
+                       public <T> T get(String name, TypeToken<T> targetType) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public <T> T get(int i, Class<T> targetClass) {
+                       public <T> T get(String name, TypeCodec<T> codec) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public Token getToken(String name) {
+                       public ColumnDefinitions getColumnDefinitions() {
                                // TODO Auto-generated method stub
                                return null;
                        }
@@ -417,16 +417,17 @@ public class RowCreator {
                        }
 
                        @Override
-                       public Token getPartitionKeyToken() {
+                       public Token getToken(String name) {
                                // TODO Auto-generated method stub
                                return null;
                        }
 
                        @Override
-                       public ColumnDefinitions getColumnDefinitions() {
+                       public Token getPartitionKeyToken() {
                                // TODO Auto-generated method stub
                                return null;
                        }
+
                };
                return row;
        }
index 98194e0..ffaf182 100644 (file)
@@ -37,7 +37,7 @@ fi
 
 function status {
      echo "$@"
-     echo "$@" > $DIR/aaf_cass
+     echo "$@" > $DIR/aaf-cass
 }
 
 function wait_start {
@@ -69,7 +69,7 @@ function wait_cql {
 function wait_ready {
    status wait for cassandra to be fully ready
    for CNT in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
-       STATUS="$(cat $DIR/aaf_cass)"
+       STATUS="$(cat $DIR/aaf-cass)"
        if [ "$STATUS" = "ready" ]; then
        break
      else
@@ -88,7 +88,7 @@ function install_cql {
     if [ -z "`/usr/bin/cqlsh -e 'describe keyspaces' | grep authz`" ]; then
         status install 
         echo "Initializing Cassandra DB" 
-        echo "Docker Installed Basic Cassandra on aaf_cass.  Executing the following "
+        echo "Docker Installed Basic Cassandra on aaf.cass.  Executing the following "
         echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently"
         echo ""
         echo " cd /opt/app/aaf/cass_init"
index 83fb060..e6da5e4 100644 (file)
 
 echo "Waiting for Cass to be initialized"
 for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
-  $DOCKER exec -it aaf_cass bash aaf_cmd wait 2> /dev/null
+  $DOCKER exec -it aaf-cass bash aaf_cmd wait 2> /dev/null
   if [ "$?" -ne "0" ]; then
     echo "Container not ready... Sleep 10"
     sleep 10
   else
-    echo "aaf_cass is ready"
+    echo "aaf-cass is ready"
     break
   fi 
 done
index a412296..778947e 100644 (file)
@@ -35,11 +35,11 @@ fi
 
 # Optional mount instead of v
 #    --mount 'type=volume,src=aaf_cass_data,dst=/var/lib/cassandra,volume-driver=local' \
-if [ "`$DOCKER ps -a | grep aaf_cass`" == "" ]; then
+if [ "`$DOCKER ps -a | grep aaf-cass`" == "" ]; then
   echo "starting Cass from 'run'"
   # NOTE: These HEAP Sizes are minimal. Not set for full organizations.
   $DOCKER run \
-    --name aaf_cass \
+    --name aaf-cass \
     -e HEAP_NEWSIZE=512M \
     -e MAX_HEAP_SIZE=1024M \
     -e CASSANDRA_DC=dc1 \
@@ -49,5 +49,5 @@ if [ "`$DOCKER ps -a | grep aaf_cass`" == "" ]; then
     $PUBLISH \
     -d ${PREFIX}${ORG}/${PROJECT}/aaf_cass:${VERSION} "onap"
 else 
-  $DOCKER start aaf_cass
+  $DOCKER start aaf-cass
 fi
index cfff8f7..c43a696 100644 (file)
@@ -17,7 +17,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 4813186..6fe9bde 100644 (file)
@@ -102,9 +102,9 @@ public class CassAccess {
             }
     
             str = env.getProperty(Config.CADI_LATITUDE);
-            Double lat = str!=null?Double.parseDouble(str):null;
+            Double lat = str!=null && !str.isEmpty()?Double.parseDouble(str):null;
             str = env.getProperty(Config.CADI_LONGITUDE);
-            Double lon = str!=null?Double.parseDouble(str):null;
+            Double lon = str!=null && !str.isEmpty()?Double.parseDouble(str):null;
             if (lat == null || lon == null) {
                 throw new APIException(Config.CADI_LATITUDE + " and/or " + Config.CADI_LONGITUDE + " are not set");
             }
index 757efa5..085f419 100644 (file)
@@ -99,6 +99,24 @@ public class LocateDAO extends CassDAOImpl<AuthzTrans,LocateDAO.Data> {
         public void reconstitute(ByteBuffer bb) throws IOException {
             LocateLoader.deflt.unmarshal(this, toDIS(bb));
         }
+
+               public Data copy() {
+                       Data out = new Data();
+            out.name = name;
+            out.hostname = hostname;
+            out.port = port;
+            out.major = major;
+            out.minor = minor;
+            out.patch = patch;
+            out.pkg = pkg;
+            out.latitude = latitude;
+            out.longitude = longitude;
+            out.protocol = protocol;
+            out.subprotocol = new HashSet<>();
+            out.subprotocol.addAll(subprotocol);
+            out.port_key = port_key;
+                       return out;
+               }
     }
 
     private static class LocateLoader extends Loader<Data> implements Streamer<Data>{
index 9eea77e..ec5449d 100644 (file)
 
 package org.onap.aaf.auth.direct;
 
-import java.net.Inet4Address;
-import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.onap.aaf.auth.dao.cass.LocateDAO;
-import org.onap.aaf.auth.dao.cass.LocateDAO.Data;
 import org.onap.aaf.auth.env.AuthzEnv;
+import org.onap.aaf.auth.env.AuthzTrans;
 import org.onap.aaf.cadi.Access;
 import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.client.Result;
-import org.onap.aaf.cadi.config.Config;
 import org.onap.aaf.cadi.register.Registrant;
-import org.onap.aaf.cadi.util.Split;
+import org.onap.aaf.cadi.register.RegistrationCreator;
+
+import locate.v1_0.MgmtEndpoint;
+import locate.v1_0.MgmtEndpoints;
 
 public class DirectRegistrar implements Registrant<AuthzEnv> {
-    private Data locate;
+
     private LocateDAO ldao;
-    public DirectRegistrar(Access access, LocateDAO ldao, String name, String version, int port) throws CadiException {
-        this.ldao = ldao;
-        locate = new LocateDAO.Data();
-        locate.name = name;
-        locate.port = port;
-        
-        try {
-            String latitude = access.getProperty(Config.CADI_LATITUDE, null);
-            if (latitude==null) {
-                latitude = access.getProperty("AFT_LATITUDE", null);
-            }
-            String longitude = access.getProperty(Config.CADI_LONGITUDE, null);
-            if (longitude==null) {
-                longitude = access.getProperty("AFT_LONGITUDE", null);
-            }
-            if (latitude==null || longitude==null) {
-                throw new CadiException(Config.CADI_LATITUDE + " and " + Config.CADI_LONGITUDE + " is required");
-            } else {
-                locate.latitude = Float.parseFloat(latitude);
-                locate.longitude = Float.parseFloat(longitude);
-            }
-            String split[] = Split.splitTrim('.', version);
-            locate.pkg = split.length>3?Integer.parseInt(split[3]):0;
-            locate.patch = split.length>2?Integer.parseInt(split[2]):0;
-            locate.minor = split.length>1?Integer.parseInt(split[1]):0;
-            locate.major = split.length>0?Integer.parseInt(split[0]):0;
-            locate.hostname = access.getProperty(Config.AAF_REGISTER_AS, null);
-            if (locate.hostname==null) {
-                locate.hostname = access.getProperty(Config.HOSTNAME, null);
-            }
-            if (locate.hostname==null) {
-                locate.hostname = Inet4Address.getLocalHost().getHostName();
-            }
-            String subprotocols = access.getProperty(Config.CADI_PROTOCOLS, null);
-            if (subprotocols==null) {
-                locate.protocol="http";
-            } else {
-                locate.protocol="https";
-                for (String s : Split.split(',', subprotocols)) {
-                    locate.subprotocol(true).add(s);
-                }
-            }
-        } catch (NumberFormatException | UnknownHostException e) {
-            throw new CadiException("Error extracting Data from Properties for Registrar",e);
+    private List<LocateDAO.Data> ldd; 
+    public DirectRegistrar(Access access, LocateDAO ldao, int port) throws CadiException {
+       this.ldao = ldao;
+        ldd = new ArrayList<>();
+        RegistrationCreator rc = new RegistrationCreator(access);
+        MgmtEndpoints mes = rc.create(port);
+        for(MgmtEndpoint me : mes.getMgmtEndpoint()) {
+               ldd.add(convert(me));
         }
     }
     
-    @Override
+    private LocateDAO.Data convert(MgmtEndpoint me) {
+       LocateDAO.Data out = new LocateDAO.Data();
+       out.name=me.getName();
+               out.hostname=me.getHostname();
+               out.latitude=me.getLatitude();
+               out.longitude=me.getLongitude();
+               out.major=me.getMajor();
+               out.minor=me.getMinor();
+               out.pkg=me.getPkg();
+               out.patch=me.getPatch();
+               out.port=me.getPort();
+               out.protocol=me.getProtocol();
+               out.subprotocol(true).addAll(me.getSubprotocol());
+//             out.port_key = UUID.randomUUID();
+               return out;
+       }
+
+       @Override
+
     public Result<Void> update(AuthzEnv env) {
-        org.onap.aaf.auth.layer.Result<Void> dr = ldao.update(env.newTransNoAvg(), locate);
-        if (dr.isOK()) {
-            return Result.ok(200, null);
-        } else {
-            return Result.err(503, dr.errorString());
-        }
+       AuthzTrans trans = env.newTransNoAvg(); 
+       StringBuilder sb = null;
+       for(LocateDAO.Data ld : ldd) {
+               org.onap.aaf.auth.layer.Result<Void> dr = ldao.update(trans, ld);
+               if (dr.notOK()) {
+                       if(sb == null) {
+                               sb = new StringBuilder(dr.errorString());
+                       } else {
+                               sb.append(';');
+                               sb.append(dr.errorString());
+                       }
+               }
+       }
+       
+       if(sb==null) {
+               return Result.ok(200, null);
+       } else {
+               return Result.err(503, sb.toString());
+       }
     }
 
     /* (non-Javadoc)
@@ -99,13 +96,25 @@ public class DirectRegistrar implements Registrant<AuthzEnv> {
      */
     @Override
     public Result<Void> cancel(AuthzEnv env) {
-        org.onap.aaf.auth.layer.Result<Void> dr = ldao.delete(env.newTransNoAvg(), locate, false);
-        if (dr.isOK()) {
-            return Result.ok(200, null);
-        } else {
-            return Result.err(503, dr.errorString());
-        }
-
+       AuthzTrans trans = env.newTransNoAvg(); 
+       StringBuilder sb = null;
+       for(LocateDAO.Data ld : ldd) {
+            org.onap.aaf.auth.layer.Result<Void> dr = ldao.delete(trans, ld, false);
+               if (dr.notOK()) {
+                       if(sb == null) {
+                               sb = new StringBuilder(dr.errorString());
+                       } else {
+                               sb.append(';');
+                               sb.append(dr.errorString());
+                       }
+               }
+       }
+       
+       if(sb==null) {
+               return Result.ok(200, null);
+       } else {
+               return Result.err(503, sb.toString());
+       }
     }
 
 }
index 76f2622..ba346e6 100644 (file)
@@ -20,7 +20,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index bfdb977..3727e34 100644 (file)
@@ -23,6 +23,7 @@
 package org.onap.aaf.auth.cm;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
@@ -139,8 +140,12 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
                         pinst[1]= key.substring(idx+1);
                         pinst[2]= aafEnv;
                         pinst[3] = multiParams; 
-                        CA ca = cons.newInstance(pinst);
-                        certAuths.put(ca.getName(),ca);
+                        try {
+                               CA ca = cons.newInstance(pinst);
+                            certAuths.put(ca.getName(),ca);
+                        } catch (InvocationTargetException e) {
+                               access.log(e, "Loading", segs[0]);
+                        }
                     }
                 }
             }
@@ -225,7 +230,7 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
     @Override
     public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException, LocatorException {
         return new Registrant[] {
-            new DirectRegistrar(access,locateDAO,app_name,app_version,port)
+            new DirectRegistrar(access,locateDAO,port)
         };
     }
 
@@ -236,16 +241,19 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
     }
 
     public static void main(final String[] args) {
-      
         try {
             Log4JLogIt logIt = new Log4JLogIt(args, "cm");
             PropAccess propAccess = new PropAccess(logIt,args);
 
-             AAF_CM service = new AAF_CM(new AuthzEnv(propAccess));
-            JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
-            jss.start();
-        } catch (Exception e) {
-            envLog.error().log(e);
+            try {
+                   AAF_CM service = new AAF_CM(new AuthzEnv(propAccess));
+                   JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
+                   jss.start();
+               } catch (Exception e) {
+                   propAccess.log(e);
+               }
+        } catch (APIException e) {
+               e.printStackTrace(System.err);
         }
     }
 }
index da63486..08c9685 100644 (file)
@@ -150,7 +150,7 @@ public class LocalCA extends CA {
 
                     try {
                         String pass = access.decrypt(params[0][2]/*encrypted passcode*/, true);
-                        if (pass==null) {
+                        if (pass==null || pass.isEmpty()) {
                             throw new CertException("Passcode for " + fileName + " cannot be decrypted.");
                         }
                         char[] ksPass = pass.toCharArray();
@@ -159,8 +159,9 @@ public class LocalCA extends CA {
 
                         keyStore.load(fis,ksPass);
                     } finally {
-                        if (fis != null)
+                        if (fis != null) {
                             fis.close();
+                        }
                     }
                     Entry entry;
                     if (fileName.endsWith(".pkcs11")) {
index e770fec..58efa2a 100644 (file)
@@ -86,7 +86,7 @@ public class JU_AAF_CM {
                        Properties props=new Properties();
                        Mockito.doReturn(props).when(access).getProperties();
                        props.setProperty("cm_ca.props", "test");
-                       Mockito.doReturn("test:2.1").when(access).getProperty(Config.AAF_COMPONENT, null);
+                       Mockito.doReturn("test:2.1").when(access).getProperty(Config.AAF_LOCATOR_NAMES, null);
                        Mockito.doReturn("test").when(access).getProperty("https.protocols","TLSv1.1,TLSv1.2");
                        Mockito.doReturn("test").when(env).getProperty("cm_ca.props.perm_type",null);
                        Mockito.doReturn("test").when(env).getProperty("cm_ca.props.baseSubject",null);
index ff281d2..c0169e5 100644 (file)
@@ -18,7 +18,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 9615381..a4b01cd 100644 (file)
@@ -25,7 +25,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 56db6f6..497c13d 100644 (file)
@@ -102,7 +102,10 @@ public class AuthzEnv extends RosettaEnv implements Access {
 
         @Override
         public void log(Throwable e, Object... msgs) {
-            access.log(Level.ERROR, msgs);
+               Object[] nm = new Object[msgs.length+1];
+               System.arraycopy(msgs, 0, nm, 1, msgs.length);
+               nm[0]=e;
+            access.log(Level.ERROR, nm);
         }
 
         @Override
index 3e68e3a..e064ade 100644 (file)
@@ -275,8 +275,6 @@ public class Result<RV> {
      * @return
      */
     public boolean isOKhasData() {
-       System.out.println("specialCondition:"+specialCondition);
-       System.out.println("specialCondition:"+(specialCondition & EMPTY_LIST));
         return status == OK && (specialCondition & EMPTY_LIST) != EMPTY_LIST;
     }
 
index 435b884..9ece484 100644 (file)
@@ -54,42 +54,30 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
 
     public final String app_name;
     public final String app_version;
-    public final String app_interface_version;
     public final String ROOT_NS;
-
+    
     public AbsService(final Access access, final ENV env) throws CadiException {
-            Define.set(access);
-            ROOT_NS = Define.ROOT_NS();
+        Define.set(access);
+        ROOT_NS = Define.ROOT_NS();
         this.access = access;
         this.env = env;
 
-        String component = access.getProperty(Config.AAF_COMPONENT, null);
-        final String[] locator_deploy;
-        
-        if (component == null) {
-            locator_deploy = null;
+        String str = access.getProperty(Config.AAF_LOCATOR_NAMES, null);
+        String[] scomp = Split.splitTrim(',', str);
+        if(scomp.length==0) {
+               throw new CadiException(Config.AAF_LOCATOR_NAMES + " must be defined.");
         } else {
-            locator_deploy = Split.splitTrim(':', component);
-            if(locator_deploy.length>1 && "AAF_RELEASE".equals(locator_deploy[1])) {
-               locator_deploy[1]=access.getProperty(Config.AAF_RELEASE, Defaults.AAF_VERSION);
-               int snapshot = locator_deploy[1].indexOf("-SNAPSHOT");
-               if(snapshot>0) {
-                       locator_deploy[1]=locator_deploy[1].substring(0, snapshot);
-               }
-            }
-        }
-            
-        if (component == null || locator_deploy==null || locator_deploy.length<2) {
-            throw new CadiException("AAF Component must include the " + Config.AAF_COMPONENT + " property, <fully qualified service name>:<full deployed version (i.e. 2.1.3.13)");
+               str = ROOT_NS + '.' + scomp[0];
         }
-        final String[] version = Split.splitTrim('.', locator_deploy[1]);
-        if (version==null || version.length<2) {
-            throw new CadiException("AAF Component Version must have at least Major.Minor version");
+        app_name = str;
+        
+        str = access.getProperty(Config.AAF_LOCATOR_VERSION, null);
+        if(str==null) {
+               str = Defaults.AAF_VERSION;
+               env.setProperty(Config.AAF_LOCATOR_VERSION, str);
         }
-            app_name = Define.varReplace(locator_deploy[0]);
-            app_version = locator_deploy[1];
-            app_interface_version = version[0]+'.'+version[1];
-            
+        app_version = str;
+        
         // Print Cipher Suites Available
         if (access.willLog(Level.DEBUG)) {
             SSLContext context;
@@ -111,7 +99,15 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
             access.log(Level.DEBUG,sb);
         }
     }
+    
+    public void setProtocol(String proto) {
+       env.setProperty(Config.AAF_LOCATOR_PROTOCOL, proto);
+    }
 
+    public void setSubprotocol(String subproto) {
+       env.setProperty(Config.AAF_LOCATOR_SUBPROTOCOL, subproto);
+    }
+    
     protected abstract Filter[] _filters(Object ... additionalTafLurs) throws CadiException,  LocatorException;
     
     /**
@@ -125,7 +121,7 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
         return _filters();
     }
 
-    public abstract Registrant<ENV>[] registrants(final int port) throws CadiException, LocatorException;
+    public abstract Registrant<ENV>[] registrants(final int actualPort) throws CadiException, LocatorException;
 
     // Lazy Instantiation
     public synchronized AAFConHttp aafCon() throws CadiException, LocatorException {
index 29166b0..8f0eb8a 100644 (file)
  *
  */
 package org.onap.aaf.auth.server;
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
 import org.onap.aaf.auth.org.OrganizationException;
 import org.onap.aaf.auth.org.OrganizationFactory;
 import org.onap.aaf.auth.rserv.RServlet;
 import org.onap.aaf.cadi.Access;
+import org.onap.aaf.cadi.Access.Level;
 import org.onap.aaf.cadi.register.Registrant;
 import org.onap.aaf.cadi.register.Registrar;
 import org.onap.aaf.misc.env.Trans;
@@ -61,14 +68,30 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
 
     @Override
     public final void start() throws Exception {
-        _start(service);
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            @Override
-            public void run() {
-                shutdown();
-            }
-        });
+       ExecutorService es = Executors.newSingleThreadExecutor();
+       Future<?> app = es.submit(this);
+        final AbsServiceStarter<?,?> absSS = this;
+       Runtime.getRuntime().addShutdownHook(new Thread() {
+             @Override
+          public void run() {
+                 absSS.access().printf(Level.INIT, "Shutting down %s:%s\n",absSS.service.app_name, absSS.service.app_version);
+                 absSS.shutdown();
+                 app.cancel(true);
+             }
+       });
+               if(System.getProperty("ECLIPSE", null)!=null) {
+                       Thread.sleep(2000);
+               System.out.println("Service Started in Eclipse: ");
+               System.out.print("  Hit <enter> to end:");
+               try {
+                               System.in.read();
+                               System.exit(0);
+                       } catch (IOException e) {
+                       }
+               }
+
     }
+    
 
     @SafeVarargs
     public final synchronized void register(final Registrant<ENV> ... registrants) {
@@ -83,6 +106,15 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
     }
 
     @Override
+       public void run() {
+        try {
+                       _start(service);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       @Override
     public void shutdown() {
         if (registrar!=null) {
             registrar.close(env());
index c5849d0..d29b8f2 100644 (file)
@@ -56,7 +56,6 @@ import org.onap.aaf.misc.rosetta.env.RosettaEnv;
 
 
 public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> extends AbsServiceStarter<ENV,TRANS> {
-
     private boolean secure;
 
     public JettyServiceStarter(final AbsService<ENV,TRANS> service) throws OrganizationException {
@@ -73,24 +72,6 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
         return this;
     }
 
-//    @Override
-//    public void _propertyAdjustment() {
-//        Properties props = access().getProperties();
-//        Object temp = null;
-//        // Critical - if no Security Protocols set, then set it.  We'll just get messed up if not
-//        if ((temp=props.get(Config.CADI_PROTOCOLS))==null) {
-//            if ((temp=props.get(Config.HTTPS_PROTOCOLS))==null) {
-//                props.put(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT);
-//            } else {
-//                props.put(Config.CADI_PROTOCOLS, temp);
-//            }
-//        }
-//    
-//        if ("1.7".equals(System.getProperty("java.specification.version"))) {
-//            System.setProperty(Config.HTTPS_CIPHER_SUITES, Config.HTTPS_CIPHER_SUITES_DEFAULT);
-//        }
-//        System.setProperty(Config.HTTPS_CIPHER_SUITES, temp.toString());
-//    }
 
     @Override
     public void _propertyAdjustment() {
@@ -129,6 +110,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
             protocol = "http";
         } else {
             protocol = "https";
+            
 
             String keystorePassword = access().getProperty(Config.CADI_KEYSTORE_PASSWORD, null);
             if (keystorePassword==null) {
@@ -151,7 +133,9 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
                 sslContextFactory.setTrustStorePassword(access().decrypt(truststorePassword, true)); 
             }
             // Be able to accept only certain protocols, i.e. TLSv1.1+
-            final String[] protocols = Split.splitTrim(',', access().getProperty(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT));
+            String subprotocols = access().getProperty(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT);
+            service.setSubprotocol(subprotocols);
+            final String[] protocols = Split.splitTrim(',', subprotocols);
             sslContextFactory.setIncludeProtocols(protocols);
             
             // Want to use Client Certificates, if they exist.
@@ -178,6 +162,8 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
                     new HttpConnectionFactory(httpConfig)
                 );
         }
+        service.setProtocol(protocol);
+
         
         // Setup JMX 
         // TODO trying to figure out how to set up/log ports
@@ -220,7 +206,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
             server.start();
             access().log(Level.INIT,server.dump());
         } catch (Exception e) {
-            access().log(e,"Error starting " + service.app_name);
+            access().log(e,"Error starting " + hostname + ':' + port + ' ' + InetAddress.getLocalHost().getHostAddress());
             String doExit = access().getProperty("cadi_exitOnFailure", "true");
             if (doExit == "true") {
                 System.exit(1);
@@ -231,7 +217,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
         try {
             register(service.registrants(port));
             access().printf(Level.INIT, "Starting Jetty Service for %s, version %s, on %s://%s:%d", service.app_name,service.app_version,protocol,hostname,port);
-            server.join();
+            //server.join();
         } catch (Exception e) {
             access().log(e,"Error registering " + service.app_name);
             String doExit = access().getProperty("cadi_exitOnFailure", "true");
index 6f2d4cb..9004f76 100644 (file)
@@ -20,7 +20,7 @@
  */
 package org.onap.aaf.auth.server;
 
-public interface ServiceStarter {
+public interface ServiceStarter extends Runnable {
     public void start() throws Exception;
     public void shutdown();
 }
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java
new file mode 100644 (file)
index 0000000..78172a2
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+
+package org.onap.aaf.auth.server;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+public class TestKill implements Runnable {
+
+       public static void main(String[] args) {
+               ExecutorService es = Executors.newSingleThreadExecutor();
+               TestKill tk = new TestKill();
+               Future<?> app = es.submit(tk);
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            @Override
+            public void run() {
+               System.out.println("Shutdown Hook, thread: setting interrupt");
+                app.cancel(true);
+                tk.longProcess();
+                es.shutdown();
+            }
+        });
+        System.out.println("Service Start");
+        System.out.print("Hit <enter> to end:");
+        try {
+                       System.in.read();
+                       System.exit(0);
+               } catch (IOException e) {
+               }
+       }
+
+    @Override
+       public void run() {
+       }
+    
+    private void longProcess() {
+       System.out.println("Starting long cleanup process");
+       try {
+                       Thread.sleep(10000);
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+       System.out.println("Ending long cleanup process");
+    }
+}
index a0ee9ef..65f019f 100644 (file)
@@ -103,7 +103,8 @@ public class JU_AbsService {
         BasicEnv bEnv = new BasicEnv();
         PropAccess prop = new PropAccess();
         
-        prop.setProperty(Config.AAF_COMPONENT, "te.st:te.st");
+        prop.setProperty(Config.AAF_LOCATOR_NAMES, "te.st");
+        prop.setProperty(Config.AAF_LOCATOR_VERSION, "te.st");
         prop.setLogLevel(Level.DEBUG);
         AbsServiceStub absServiceStub = new AbsServiceStub(prop, bEnv);    //Testing other branches requires "fails" due to exception handling, will leave that off for now.
     }
index 1f5d70a..1fe98d8 100644 (file)
@@ -131,7 +131,8 @@ public class JU_AbsServiceStarter {
         BasicEnv bEnv = new BasicEnv();
         PropAccess prop = new PropAccess();
         
-        prop.setProperty(Config.AAF_COMPONENT, "te.st:te.st");
+        prop.setProperty(Config.AAF_LOCATOR_NAMES, "te.st");
+        prop.setProperty(Config.AAF_LOCATOR_VERSION, "te.st");
         prop.setLogLevel(Level.DEBUG);
         absServiceStub = new AbsServiceStub(prop, bEnv);
         
index 5275663..63bcb9b 100644 (file)
@@ -26,7 +26,7 @@
                <artifactId>authparent</artifactId>
                <relativePath>../pom.xml</relativePath>
                <groupId>org.onap.aaf.authz</groupId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
        </parent>
 
        <artifactId>aaf-auth-deforg</artifactId>
index 40df8a3..5b37469 100644 (file)
@@ -17,7 +17,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index e316e01..26e4929 100644 (file)
@@ -99,7 +99,7 @@ public class AAF_FS extends AbsService<AuthzEnv, AuthzTrans>  {
     @Override
     public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException, LocatorException {
         return new Registrant[] {
-            new RemoteRegistrant<AuthzEnv>(aafCon(),app_name,app_version,port)
+            new RemoteRegistrant<AuthzEnv>(aafCon(),port)
         };
     }
     
index eef1a87..e7e5543 100644 (file)
@@ -73,7 +73,8 @@ public class JU_AAF_FS {
                aEnv = new AuthzEnv();
                aEnv.staticSlot("test");
                aEnv.access().setProperty("aaf_public_dir", "test");
-               aEnv.access().setProperty(Config.AAF_COMPONENT, "aaf_com:1.1");
+               aEnv.access().setProperty(Config.AAF_LOCATOR_NAMES, "aaf_com");
+        aEnv.access().setProperty(Config.AAF_LOCATOR_VERSION, "1.1");
                Server serverMock = mock(Server.class);
                JettyServiceStarter<AuthzEnv, AuthzTrans> jssMock = mock(JettyServiceStarter.class);
                aafFs = new AAF_FS(aEnv);
index a0748a2..63a652b 100644 (file)
@@ -17,7 +17,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 2e7e5e5..d8e8914 100644 (file)
@@ -247,7 +247,7 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
     @Override
     public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException, LocatorException {
         return new Registrant[] {
-            new RemoteRegistrant<AuthzEnv>(aafCon(),app_name,app_version,port)
+            new RemoteRegistrant<AuthzEnv>(aafCon(),port)
         };
     }
 
index 7c0c38e..dfb77a3 100644 (file)
@@ -17,7 +17,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 9190c66..6aee85d 100644 (file)
@@ -113,7 +113,7 @@ public class AAF_Hello extends AbsService<AuthzEnv,AuthzTrans> {
     @Override
     public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException, LocatorException {
         return new Registrant[] {
-            new RemoteRegistrant<AuthzEnv>(aafCon(),app_name,app_version,port)
+            new RemoteRegistrant<AuthzEnv>(aafCon(),port)
         };
     }
 
index b076981..40457ca 100644 (file)
@@ -17,7 +17,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index c8294d1..2bc4447 100644 (file)
@@ -220,7 +220,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
     @Override
     public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException {
         return new Registrant[] {
-            new DirectRegistrar(access,locateDAO,app_name,app_version,port)
+            new DirectRegistrar(access,locateDAO,port)
         };
     }
 
index ef0740c..62fb3f7 100644 (file)
@@ -17,7 +17,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 4104c34..ef0c4da 100644 (file)
@@ -165,10 +165,7 @@ public class AAF_OAuth extends AbsService<AuthzEnv,AuthzTrans> {
     @Override
     public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException {
         return new Registrant[] {
-                new DirectRegistrar(access,question.locateDAO,app_name,app_version,port),
-                new DirectRegistrar(access,question.locateDAO,app_name.replace(DOT_OAUTH, ".token"),app_version,port),
-                new DirectRegistrar(access,question.locateDAO,app_name.replace(DOT_OAUTH, ".introspect"),app_version,port)
-
+            new DirectRegistrar(access,question.locateDAO,port)
         };
     }
 
index a0803b4..bc7d279 100644 (file)
@@ -17,7 +17,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>authparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>../pom.xml</relativePath>
        </parent>
 
index 4f34fd5..90d4744 100644 (file)
@@ -185,9 +185,9 @@ public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
 
     @SuppressWarnings("unchecked")
     @Override
-    public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException {
+    public Registrant<AuthzEnv>[] registrants(final int actualPort) throws CadiException {
         return new Registrant[] {
-            new DirectRegistrar(access,question.locateDAO,app_name,app_interface_version,port)
+            new DirectRegistrar(access,question.locateDAO, actualPort)
         };
     }
 
@@ -226,7 +226,7 @@ public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
             Log4JLogIt logIt = new Log4JLogIt(args, "authz");
             PropAccess propAccess = new PropAccess(logIt,args);
             
-             AbsService<AuthzEnv, AuthzTrans> service = new AAF_Service(new AuthzEnv(propAccess));
+            AbsService<AuthzEnv, AuthzTrans> service = new AAF_Service(new AuthzEnv(propAccess));
             JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
             jss.start();
         } catch (Exception e) {
index 9e4bcf5..1c98ea3 100644 (file)
@@ -6,3 +6,5 @@
 /policy*
 /*.yaml
 /*.orig
+/.curl_auth
+/test.sh
diff --git a/auth/docker/Dockerfile.base b/auth/docker/Dockerfile.base
new file mode 100644 (file)
index 0000000..623d18d
--- /dev/null
@@ -0,0 +1,26 @@
+#########
+#  ============LICENSE_START====================================================
+#  org.onap.aaf
+#  ===========================================================================
+#  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+#  ===========================================================================
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#  ============LICENSE_END====================================================
+#
+FROM nexus3.onap.org:10001/openjdk:8-jre-alpine
+MAINTAINER AAF Team, AT&T 2018
+
+LABEL description="aaf_base"
+RUN apk add --no-cache bash
+RUN apk add --no-cache openssl
+
index dab925b..c2e1d78 100644 (file)
@@ -17,7 +17,8 @@
 #  limitations under the License.
 #  ============LICENSE_END====================================================
 #
-FROM nexus3.onap.org:10001/onap/aaf/aaf-base-xenial:latest
+FROM ${DOCKER_REPOSITORY}/onap/aaf/aaf_base:${AAF_VERSION}
+#FROM nexus3.onap.org:10001/onap/aaf/aaf-base-xenial:latest
 MAINTAINER AAF Team, AT&T 2018
 ENV VERSION=${AAF_VERSION}
 
@@ -30,6 +31,4 @@ COPY bin/aaf-auth-cmd-${AAF_VERSION}-full.jar /opt/app/aaf_config/bin/
 COPY bin/aaf-cadi-servlet-sample-*-sample.jar /opt/app/aaf_config/bin/
 COPY cert/*trust*.b64 /opt/app/aaf_config/cert/
 
-ENTRYPOINT ["/bin/bash","/opt/app/aaf_config/bin/agent.sh"]
-CMD []
-
+CMD ["/bin/bash","-c","/opt/app/aaf_config/bin/agent.sh"]
index 44109d6..d1b6b23 100644 (file)
@@ -17,7 +17,8 @@
 #  limitations under the License.
 #  ============LICENSE_END====================================================
 #
-FROM nexus3.onap.org:10001/onap/aaf/aaf-base-xenial:latest
+FROM ${DOCKER_REPOSITORY}/onap/aaf/aaf_base:${AAF_VERSION}
+#FROM nexus3.onap.org:10001/onap/aaf/aaf-base-xenial:latest
 MAINTAINER AAF Team, AT&T 2018
 ENV VERSION=${AAF_VERSION}
 
@@ -34,7 +35,7 @@ COPY logs /opt/app/aaf_config/logs
 COPY bin/service.sh /opt/app/aaf_config/bin/agent.sh
 COPY bin/pod_wait.sh /opt/app/aaf_config/bin/
 COPY bin/aaf-auth-cmd-${AAF_VERSION}-full.jar /opt/app/aaf_config/bin/
-
-ENTRYPOINT ["/bin/bash","/opt/app/aaf_config/bin/agent.sh"]
+CMD ["/bin/bash","/opt/app/aaf_config/bin/agent.sh"]
+#CMD ["/bin/bash","/opt/app/aaf_config/bin/agent.sh"]
 CMD []
-
index 3431ee2..a15039a 100644 (file)
@@ -17,7 +17,9 @@
 #  limitations under the License.
 #  ============LICENSE_END====================================================
 #
-FROM nexus3.onap.org:10001/onap/aaf/aaf-base-xenial:latest
+FROM ${DOCKER_REPOSITORY}/onap/aaf/aaf_base:${AAF_VERSION}
+#FROM nexus3.onap.org:10001/onap/aaf/aaf_base:${AAF_VERSION}
+#FROM nexus3.onap.org:10001/onap/aaf/aaf-base-xenial:latest
 MAINTAINER AAF Team, AT&T 2018
 ENV VERSION=${AAF_VERSION}
 
index 9ae40c7..99ac5fc 100644 (file)
@@ -17,7 +17,7 @@
 #  limitations under the License.
 #  ============LICENSE_END====================================================
 #
-FROM onap/aaf/aaf_core:${AAF_VERSION}
+FROM ${DOCKER_REPOSITORY}/onap/aaf/aaf_core:${AAF_VERSION}
 MAINTAINER AAF Team, AT&T 2018
 ENV VERSION=${AAF_VERSION}
 
@@ -26,7 +26,8 @@ LABEL version=${AAF_VERSION}
 
 COPY pod/* /opt/app/aaf/pod/
 
-CMD ["/bin/bash","-c","cd /opt/app/aaf;bin/${AAF_COMPONENT}"]
+#CMD ["bash","-c","cd /opt/app/aaf;bin/${AAF_COMPONENT}"]
+CMD []
 
 # For Debugging installation
 # CMD ["/bin/bash","-c","pwd;cd /opt/app/osaaf;find /opt/app/osaaf -depth;df -k; cat /opt/app/aaf/${AAF_COMPONENT}/bin/${AAF_COMPONENT};cat /etc/hosts;/opt/app/aaf/${AAF_COMPONENT}/bin/${AAF_COMPONENT}"]
index 165b000..14166a3 100644 (file)
@@ -26,32 +26,28 @@ function run_it() {
   $DOCKER run $@ \
     -v "aaf_config:$CONF_ROOT_DIR" \
     -v "aaf_status:/opt/app/aaf/status" \
-    --add-host="$HOSTNAME:$HOST_IP" \
-    --add-host="aaf.osaaf.org:$HOST_IP" \
-    --env HOSTNAME=${HOSTNAME} \
+    --env aaf_locator_container=docker \
+    --env aaf_locator_fqdn=${HOSTNAME} \
+    --env aaf_locate_url=https://aaf-locate:8095 \
     --env AAF_ENV=${AAF_ENV} \
-    --env AAF_REGISTER_AS=${AAF_REGISTER_AS} \
-    --env AAF_LOCATOR_AS=${AAF_LOCATOR_AS} \
     --env LATITUDE=${LATITUDE} \
     --env LONGITUDE=${LONGITUDE} \
-    --env CASS_HOST=${CASS_HOST} \
     --env CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER} \
     --env CASSANDRA_USER=${CASSANDRA_USER} \
     --env CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD} \
     --env CASSANDRA_PORT=${CASSANDRA_PORT} \
     --name aaf_config_$USER \
     $PREFIX${ORG}/${PROJECT}/aaf_config:${VERSION} \
-    /bin/bash $PARAMS
+    bash -c "bash /opt/app/aaf_config/bin/agent.sh $PARAMS"
 }
 
-PARAMS="$@"
+PARAMS=$@
 case "$1" in 
   bash)
-    run_it -it --rm 
+    PARAMS="&& cd /opt/app/osaaf/local && exec bash"
+    run_it -it --rm  
     ;;
-  -it)
-    shift 
-    PARAMS="$@"
+  taillog)
     run_it -it --rm 
     ;;
   *)
index 88b8497..86fee5f 100644 (file)
@@ -28,9 +28,9 @@ fi
 . ./aaf.props
 
 DOCKER=${DOCKER:=docker}
-CADI_VERSION=${CADI_VERSION:=2.1.9-SNAPSHOT}
+CADI_VERSION=${CADI_VERSION:=2.1.10-SNAPSHOT}
 
-for V in VERSION DOCKER_REPOSITORY AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_FQI VOLUME DRIVER LATITUDE LONGITUDE; do
+for V in VERSION DOCKER_REPOSITORY HOSTNAME AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_FQI VOLUME DRIVER LATITUDE LONGITUDE; do
    if [ "$(grep $V ./aaf.props)" = "" ]; then
       unset DEF
       case $V in
@@ -38,6 +38,10 @@ for V in VERSION DOCKER_REPOSITORY AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_
                PROMPT="Docker Repo"
                DEF=""
                ;;
+        HOSTNAME) 
+               PROMPT="HOSTNAME (blank for Default)"
+               DEF=""
+               ;;
          AAF_FQDN)   PROMPT="AAF's FQDN";;
          DEPLOY_FQI) PROMPT="Deployer's FQI";;
          AAF_FQDN_IP)
@@ -61,8 +65,10 @@ for V in VERSION DOCKER_REPOSITORY AAF_FQDN AAF_FQDN_IP DEPLOY_FQI APP_FQDN APP_
       read -p "$PROMPT" VAR 
       if [ "$VAR" = "" ]; then
          if [ "$DEF" = "" ]; then
-            echo "agent.sh needs each value queried.  Please start again."
-            exit
+            if [ "$V" != "HOSTNAME" ]; then
+              echo "agent.sh needs each value queried.  Please start again."
+              exit
+            fi
          else
             VAR=$DEF
          fi
index 0a4a66a..7f58dc3 100644 (file)
@@ -1,7 +1,7 @@
 service
 locate
 oauth
-gui
-fs
 cm
+gui
 hello
+fs
index 2a871bd..c406b81 100644 (file)
 ORG=onap
 PROJECT=aaf
 DOCKER_REPOSITORY=nexus3.onap.org:10003
-VERSION=2.1.9-SNAPSHOT
+VERSION=2.1.10-SNAPSHOT
 CONF_ROOT_DIR=/opt/app/osaaf
 # For local builds, set PREFIX=   
 PREFIX="$DOCKER_REPOSITORY/"
+NAMESPACE=onap
 
-# Local Env info
-HOSTNAME=aaf.osaaf.org
-HOST_IP=
+# HOSTNAME=aaf.osaaf.org
 
 # AAF Machine info
 AAF_ENV=DEV
-AAF_REGISTER_AS=$HOSTNAME
-AAF_LOCATE_AS=$AAF_REGISTER_AS
 LATITUDE=
 LONGITUDE=
 
@@ -50,7 +47,8 @@ AAF_SIGNER_PASSWORD=
 AAF_SIGNER_ALIAS=
 
 # OPTIONALLY ADD THESE CASSANDRA PROPERTIES
-# CASS_HOST=
+# Note:  Setting "CASSANDRA_DOCKER" will setup the appropriate CASSANDRA_CLUSTER, etc in Docker Properties.
+CASSANDRA_DOCKER=aaf-cass
 # CASSANDRA_CLUSTER=
 # CASSANDRA_USER=
 # CASSANDRA_PASSWORD=
index c91c249..f3bb26a 100644 (file)
@@ -20,4 +20,4 @@
 #
 
 . ./d.props
-${DOCKER:=docker} exec -it aaf_$1 bash
+${DOCKER:=docker} exec -it aaf-$1 bash
index 627be95..4eb349b 100755 (executable)
@@ -32,24 +32,39 @@ DOCKER=${DOCKER:=docker}
 echo "Building Containers for aaf components, version $VERSION"
 
 # AAF_cass now needs a version...
-cd ../auth-cass/docker
-bash ./dbuild.sh
-cd -
+#cd ../auth-cass/docker
+#bash ./dbuild.sh
+#cd -
+
+# AAF Base version - set the core image, etc
+sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
+    Dockerfile.base > Dockerfile
+$DOCKER build -t ${ORG}/${PROJECT}/aaf_base:${VERSION} .
+$DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:${VERSION}
+$DOCKER tag ${ORG}/${PROJECT}/aaf_base:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_base:latest
+rm Dockerfile
 
 # Create the AAF Config (Security) Images
 cd ..
 cp auth-cmd/target/aaf-auth-cmd-$VERSION-full.jar sample/bin
 cp -Rf ../conf/CA sample
 
+
 # AAF Config image (for AAF itself)
-sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' docker/Dockerfile.config > sample/Dockerfile
+sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
+    -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
+    -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
+    docker/Dockerfile.config > sample/Dockerfile
 $DOCKER build -t ${ORG}/${PROJECT}/aaf_config:${VERSION} sample
 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_config:${VERSION}
 $DOCKER tag ${ORG}/${PROJECT}/aaf_config:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/latest
 
 cp ../cadi/servlet-sample/target/aaf-cadi-servlet-sample-${VERSION}-sample.jar sample/bin
 # AAF Agent Image (for Clients)
-sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' docker/Dockerfile.client > sample/Dockerfile
+sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
+    -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
+    -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
+    docker/Dockerfile.client > sample/Dockerfile
 $DOCKER build -t ${ORG}/${PROJECT}/aaf_agent:${VERSION} sample
 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:${VERSION}
 $DOCKER tag ${ORG}/${PROJECT}/aaf_agent:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_agent:latest
@@ -63,7 +78,10 @@ cd -
 # Second, build a core Docker Image
 echo Building aaf_$AAF_COMPONENT...
 # Apply currrent Properties to Docker file, and put in place.
-sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.core >../aaf_${VERSION}/Dockerfile
+sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
+    -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
+    -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
+    Dockerfile.core >../aaf_${VERSION}/Dockerfile
 cd ..
 $DOCKER build -t ${ORG}/${PROJECT}/aaf_core:${VERSION} aaf_${VERSION}
 $DOCKER tag ${ORG}/${PROJECT}/aaf_core:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_core:${VERSION}
@@ -80,11 +98,13 @@ else
     AAF_COMPONENTS=$1
 fi
 
-mkdir -p ../aaf_${VERSION}/pod
-cp ../sample/bin/pod_wait.sh  ../aaf_${VERSION}/pod
+cp ../sample/bin/pod_wait.sh  ../aaf_${VERSION}/bin
 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
     echo Building aaf_$AAF_COMPONENT...
-    sed -e 's/${AAF_VERSION}/'${VERSION}'/g' -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' Dockerfile.ms >../aaf_${VERSION}/Dockerfile
+    sed -e 's/${AAF_VERSION}/'${VERSION}'/g' \
+        -e 's/${AAF_COMPONENT}/'${AAF_COMPONENT}'/g' \
+        -e 's/${DOCKER_REPOSITORY}/'${DOCKER_REPOSITORY}'/g' \
+        Dockerfile.ms >../aaf_${VERSION}/Dockerfile
     cd ..
     $DOCKER build -t ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} aaf_${VERSION}
     $DOCKER tag ${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} ${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION}
@@ -93,5 +113,4 @@ for AAF_COMPONENT in ${AAF_COMPONENTS}; do
     cd -
 
 done
-rm ../aaf_${VERSION}/pod/*
-rmdir ../aaf_${VERSION}/pod
+rm ../aaf_${VERSION}/bin/pod_wait.sh
index 9f77005..ed62e57 100644 (file)
 #  limitations under the License.
 #  ============LICENSE_END====================================================
 #
-# Validate for realtime Cassandra info
-
-# check if outside Cluster defined... otherwise, set CASS_HOST for using expected Docker based Cass
-if [ -z "$(grep -e '^CASS_CLUSTER=.*' d.props)" ]; then
-  if [ "$(uname)" = "Darwin" ]; then
-    SED="sed -i .bak"
-  else
-    SED="sed -i"
-  fi
-
-  CASSANDRA_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aaf_cass)
-  if [ -z "$(grep -e '^CASS_HOST.*' d.props)" ]; then
-    $SED "s/# CASS_HOST=.*/CASS_HOST=cass.aaf.osaaf.org:$CASSANDRA_IP/"  d.props
-  else 
-    $SED "s/CASS_HOST=.*/CASS_HOST=cass.aaf.osaaf.org:$CASSANDRA_IP/"  d.props
-  fi
-  echo "Updated d.props for CASSANDRA Name/IP"
-  grep -e '^CASS_HOST.*' d.props
-fi
-
 # Pull in Variables from d.props
 . ./d.props
 
+CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER:=$CASSANDRA_DOCKER}
+
 DOCKER=${DOCKER:=docker}
 
 # Running without params keeps from being TTY
@@ -55,83 +37,77 @@ fi
 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
     LINKS=""
     CMD_LINE=""
-    PORTMAP=""
+    PUBLISH=""
     case "$AAF_COMPONENT" in
     "service")
-        PORTMAP="8100:8100"
-        LINKS="--link aaf_cass:cassandra "
-        # CASS_HOST is for Container based Cassadra
-        if [ -z "$CASS_HOST" ]; then
-         CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_service sleep 0 cd /opt/app/aaf;bin/service"
+        PUBLISH="--publish 8100:8100"
+        if [ -z "$CASSANDRA_DOCKER" ]; then
+         CMD_LINE="cd /opt/app/aaf && /bin/bash pod/pod_wait.sh aaf-service && exec bin/service"
         else
-         CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_service aaf_cass cd /opt/app/aaf;bin/service"
+         CMD_LINE="cd /opt/app/aaf && /bin/bash pod/pod_wait.sh aaf-service aaf-cass && exec bin/service"
+          LINKS="--link $CASSANDRA_DOCKER"
+         echo $CASSANDRA_CLUSTER
         fi
         ;;
     "locate")
-        PORTMAP="8095:8095"
-        LINKS="--link aaf_cass:cassandra "
-       CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_locate aaf_service cd /opt/app/aaf;bin/locate"
+        PUBLISH="--publish 8095:8095"
+        LINKS="--link aaf-cass --link aaf-service"
+       CMD_LINE="cd /opt/app/aaf && /bin/bash pod/pod_wait.sh aaf-locate aaf-service && exec bin/locate"
         ;;
     "oauth")
-        PORTMAP="8140:8140"
-        LINKS="--link aaf_cass:cassandra "
-       CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_oauth aaf_service cd /opt/app/aaf;bin/oauth"
-        ;;
-    "gui")
-        PORTMAP="8200:8200"
-        LINKS=""
-       CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_gui aaf_locate cd /opt/app/aaf;bin/gui"
+        PUBLISH="--publish 8140:8140"
+        LINKS="--link aaf-cass --link aaf-service --link aaf-locate"
+       CMD_LINE="cd /opt/app/aaf && /bin/bash pod/pod_wait.sh aaf-oauth aaf-service && exec bin/oauth"
         ;;
     "cm")
-        PORTMAP="8150:8150"
-        LINKS="--link aaf_cass:cassandra "
-       CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_cm aaf_locate cd /opt/app/aaf;bin/cm"
+        PUBLISH="--publish 8150:8150"
+        LINKS="--link aaf-cass --link aaf-service --link aaf-locate"
+       CMD_LINE="cd /opt/app/aaf && /bin/bash pod/pod_wait.sh aaf-cm aaf-locate && exec bin/cm"
         ;;
-    "hello")
-        PORTMAP="8130:8130"
-        LINKS=""
-       CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_hello aaf_locate cd /opt/app/aaf;bin/hello"
+    "gui")
+        PUBLISH="--publish 8200:8200"
+        LINKS="--link aaf-service --link aaf-locate --link aaf-oauth --link aaf-cm"
+       CMD_LINE="cd /opt/app/aaf && /bin/bash pod/pod_wait.sh aaf-gui aaf-locate && exec bin/gui"
         ;;
     "fs")
-        PORTMAP="80:8096"
+        PUBLISH="--publish 80:8096"
         LINKS=""
-       CMD_LINE="/bin/bash /opt/app/aaf/pod/pod_wait.sh aaf_fs aaf_locate cd /opt/app/aaf;bin/fs"
+       CMD_LINE="cd /opt/app/aaf && /bin/bash pod/pod_wait.sh aaf-fs aaf-locate && exec bin/fs"
+        ;;
+    "hello")
+        PUBLISH="--publish 8130:8130"
+        LINKS="--link aaf-service --link aaf-locate --link aaf-oauth --link aaf-cm"
+       CMD_LINE="cd /opt/app/aaf && /bin/bash pod/pod_wait.sh aaf-hello aaf-locate && exec bin/hello"
         ;;
     esac
 
-    echo Starting aaf_$AAF_COMPONENT...
-
-    if [ -n "$AAF_REGISTER_AS" ] && [ "$HOSTNAME" != "$AAF_REGISTER_AS" ]; then
-       AH_ROOT="$HOSTNAME $AAF_REGISTER_AS"
-    else
-       AH_ROOT="$HOSTNAME"
-    fi
+    echo Starting aaf-$AAF_COMPONENT...
 
-    for A in aaf.osaaf.org $AH_ROOT; do 
-       ADD_HOST="$ADD_HOST --add-host=$A:$HOST_IP"
-    done
+    #for A in aaf.osaaf.org $AH_ROOT; do 
+       #ADD_HOST="$ADD_HOST --add-host=$A:$HOST_IP"
+    #done
 
-    if [ ! -z "$LINKS" ] && [[ "$CASS_HOST" =~ ":" ]]; then
-       ADD_HOST="$ADD_HOST --add-host=$CASS_HOST"
-    fi
-    $DOCKER run \
+    #if [ ! -z "$LINKS" ] && [[ "$CASS_HOST" =~ ":" ]]; then
+       #ADD_HOST="$ADD_HOST --add-host=$CASS_HOST"
+    #fi
+    #--hostname="${AAF_COMPONENT}.${NAMESPACE}" \
+    #  $ADD_HOST \
+    $DOCKER run  \
         -d \
-        --name aaf_$AAF_COMPONENT \
-        --hostname="${AAF_COMPONENT}.aaf.osaaf.org" \
-       $ADD_HOST \
+        --name aaf-$AAF_COMPONENT \
         ${LINKS} \
         --env AAF_ENV=${AAF_ENV} \
-        --env AAF_REGISTER_AS=${AAF_REGISTER_AS} \
+        --env aaf_locator_container=docker \
+        --env aaf_locator_fqdn=$HOSTNAME \
         --env LATITUDE=${LATITUDE} \
         --env LONGITUDE=${LONGITUDE} \
-        --env CASS_HOST=${CASS_HOST} \
         --env CASSANDRA_CLUSTER=${CASSANDRA_CLUSTER} \
         --env CASSANDRA_USER=${CASSANDRA_USER} \
         --env CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD} \
         --env CASSANDRA_PORT=${CASSANDRA_PORT} \
-        --publish $PORTMAP \
+        $PUBLISH \
         -v "aaf_config:$CONF_ROOT_DIR" \
         -v "aaf_status:/opt/app/aaf/status" \
         ${PREFIX}${ORG}/${PROJECT}/aaf_${AAF_COMPONENT}:${VERSION} \
-       $CMD_LINE
+       /bin/bash -c "$CMD_LINE"
 done
index 9242e46..1bd90d5 100644 (file)
@@ -30,5 +30,5 @@ else
 fi
 
 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
-    $DOCKER start aaf_$AAF_COMPONENT
+    $DOCKER start aaf-$AAF_COMPONENT
 done
index cebf4eb..4d302bd 100644 (file)
@@ -29,5 +29,5 @@ else
 fi
 
 for AAF_COMPONENT in ${AAF_COMPONENTS}; do
-    $DOCKER stop aaf_$AAF_COMPONENT
+    $DOCKER stop aaf-$AAF_COMPONENT 
 done
index 4b9b611..f8b7c12 100644 (file)
@@ -26,7 +26,7 @@
        <parent>
         <groupId>org.onap.aaf.authz</groupId>
         <artifactId>parent</artifactId>
-        <version>2.1.9-SNAPSHOT</version>
+        <version>2.1.10-SNAPSHOT</version>
     </parent>
        <artifactId>authparent</artifactId>
        <name>AAF Auth Parent</name>
index b69646d..f4048f3 100755 (executable)
@@ -49,7 +49,8 @@ JAVA_AAFCLI="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$LO
 if [ ! -d $LOCAL ]; then
     mkdir -p $LOCAL
     for D in bin logs; do
-        rsync -avzh --exclude=.gitignore $CONFIG/$D/* /opt/app/osaaf/$D
+        mkdir -p $OSAAF/$D
+        cp $CONFIG/$D/*.* $OSAAF/$D
     done
 fi
 
@@ -152,11 +153,6 @@ else
             fi
         fi
         ;;
-    update)
-        for D in bin logs; do
-            rsync -uh --exclude=.gitignore $CONFIG/$D/* /opt/app/osaaf/$D
-        done
-        ;;
     showpass)
         echo "## Show Passwords"
         $JAVA_AGENT showpass ${APP_FQI} ${APP_FQDN}
@@ -171,7 +167,7 @@ else
     bash)
         shift
         cd $LOCAL || exit
-        /bin/bash "$@"
+        exec bash "$@"
         ;;
     setProp)
         cd $LOCAL || exit
index 732edff..07ff981 100644 (file)
@@ -102,4 +102,4 @@ case "$OTHER" in
   ;;
 esac  
 
-eval "$@"
+eval  "$@"
index 78f6693..20be29c 100644 (file)
@@ -34,7 +34,7 @@ JAVA_AGENT="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$LOC
 JAVA_AAFCLI="$JAVA -cp $CONFIG/bin/aaf-auth-cmd-*-full.jar -Dcadi_prop_files=$LOCAL/org.osaaf.aaf.props org.onap.aaf.auth.cmd.AAFcli" 
 
 # If doesn't exist... still create
-mkdir -p /opt/app/osaaf
+mkdir -p $OSAAF
 
 # Temp use for clarity of code
 FILE=
@@ -42,7 +42,7 @@ FILE=
 # Setup Bash, first time only
 if [ ! -e "$HOME/.bash_aliases" ] || [ -z "$(grep cadi $HOME/.bash_aliases)" ]; then
   echo "alias cadi='$JAVA_CADI \$*'" >>$HOME/.bash_aliases
-  echo "alias agent='$CONFIG/bin/agent.sh EMPTY \$*'" >>$HOME/.bash_aliases
+  echo "alias agent='$CONFIG/bin/agent.sh \$*'" >>$HOME/.bash_aliases
   echo "alias aafcli='$JAVA_AAFCLI \$*'" >>$HOME/.bash_aliases
   chmod a+x $CONFIG/bin/agent.sh
   . $HOME/.bash_aliases
@@ -114,9 +114,10 @@ fi
 
 # Only initialize once, automatically...
 if [ ! -e $LOCAL/org.osaaf.aaf.props ]; then
-    rsync -avzh --exclude=.gitignore $CONFIG/local/org.osaaf.aaf* $LOCAL
+    cp  $CONFIG/local/org.osaaf.aaf* $LOCAL
     for D in public etc logs; do
-        rsync -avzh --exclude=.gitignore $CONFIG/$D/* /opt/app/osaaf/$D
+        mkdir -p $OSAAF/$D
+        cp $CONFIG/$D/* $OSAAF/$D
     done
 
     TMP=$(mktemp)
@@ -125,9 +126,16 @@ if [ ! -e $LOCAL/org.osaaf.aaf.props ]; then
     echo cadi_latitude=${LATITUDE} >> ${TMP}
     echo cadi_longitude=${LONGITUDE} >> ${TMP}
     echo cadi_x509_issuers=${CADI_X509_ISSUERS} >> ${TMP}
-    echo aaf_register_as=${AAF_REGISTER_AS} >> ${TMP}
-    AAF_LOCATOR_AS=${AAF_LOCATOR_AS:=$AAF_REGISTER_AS}
-    echo aaf_locate_url=https://${AAF_LOCATOR_AS}:8095 >> ${TMP}
+    AAF_LOCATE_URL=${aaf_locate_url:="https://${HOSTNAME}:8095"}
+    echo aaf_locate_url=${AAF_LOCATE_URL} >> ${TMP}
+    for P in `env`; do
+      if [[ "$P" == aaf_locator* ]]; then
+       echo "$P" >> ${TMP}
+        if [[ "$P" == aaf_locator_container=* ]]; then
+           echo aaf_locator_container.hostname=${HOSTNAME} >> ${TMP}
+       fi
+      fi
+    done
 
     cat $TMP
 
@@ -139,7 +147,7 @@ if [ ! -e $LOCAL/org.osaaf.aaf.props ]; then
 
     # Cassandra Config stuff
     # Default is expect a Cassandra on same Node
-    CASS_HOST=${CASS_HOST:="aaf_cass"}
+    CASS_HOST=${CASS_HOST:="aaf-cass"}
     CASS_PASS=$($JAVA_CADI digest "${CASSANDRA_PASSWORD:-cassandra}" $LOCAL/org.osaaf.aaf.keyfile)
     CASS_NAME=${CASS_HOST/:*/}
     sed -i.backup -e "s/\\(cassandra.clusters=\\).*/\\1${CASSANDRA_CLUSTERS:=$CASS_HOST}/" \
@@ -165,7 +173,7 @@ fi
 
 
 # Now run a command
-CMD=$2
+CMD=$1
 if [ -z "$CMD"  ]; then
     if [ -n "$INITIALIZED" ]; then
         echo "Initialization Complete"
@@ -173,12 +181,11 @@ if [ -z "$CMD"  ]; then
         echo "No Additional Initialization required"
     fi
 else
-    shift
     shift
     case "$CMD" in
     ls)
         echo ls requested
-        find /opt/app/osaaf -depth
+        find $OSAAF -depth
         ;;
     cat)
         if [ "$1" = "" ]; then
@@ -195,12 +202,6 @@ else
             fi
         fi
         ;;
-    update)
-        rsync -uh --exclude=.gitignore $CONFIG/local/org.osaaf.aaf* $LOCAL
-        for D in public data etc logs; do
-            rsync -uh --exclude=.gitignore $CONFIG/$D/* /opt/app/osaaf/$D
-        done
-        ;;
     validate)
         echo "## validate requested"
         $JAVA_AAFCLI perm list user aaf@aaf.osaaf.org
@@ -211,7 +212,7 @@ else
     bash)
         shift
         cd $LOCAL || exit
-        /bin/bash "$@"
+        exec /bin/bash -c "$@"
         ;;
     setProp)
         cd $LOCAL || exit
@@ -226,11 +227,11 @@ else
        fi
         for F in $FILES; do
            if [ "$ADD" = "Y" ]; then
-                echo "Changing $1 to $F"
+                echo "Changing $1 for $F"
                echo "$1=$2" >> $F
            else 
                echo "Changing $1 in $F"
-               sed -i.backup -e "s/\\(${1}.*=\\).*/\\1${2}/" $F
+               sed -i.backup -e "s/\\(${1}=\\).*/\\1${2}/" $F
            fi
             cat $F
         done
@@ -265,7 +266,7 @@ else
         done
         ;;
     taillog) 
-       sh /opt/app/osaaf/logs/taillog
+       sh $OSAAF/logs/taillog
        ;;
     wait)
        bash $CONFIG/bin/pod_wait.sh wait $1
index c1593e5..dc43c28 100644 (file)
 ## Note: Link to CA Properties in "local" dir
 ##
 cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props:/opt/app/osaaf/local/org.osaaf.aaf.cm.ca.props
-aaf_component=AAF_NS.cm:AAF_RELEASE
-port=8150
+aaf_locator_names=cm
+port=8100
+aaf_locator_public_port.helm=30084
+# aaf_locator_public_port.oom=
 
 #Certman
 cm_public_dir=/opt/app/osaaf/public
index 7125e46..9de81af 100644 (file)
@@ -22,7 +22,9 @@
 ## AAF Fileserver Properties
 ##
 cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props
-aaf_component=AAF_NS.fs:AAF_RELEASE
+aaf_locator_names=fs
 port=8096
+aaf_locator_port.helm=30085
+# aaf_locator_port.oom=
 
 aaf_public_dir=/opt/app/osaaf/public
index 4228eb3..81d04ea 100644 (file)
 ## AAF GUI Properties
 ##
 cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props
-aaf_component=AAF_NS.gui:AAF_RELEASE
+aaf_locator_names=gui
 port=8200
+aaf_locator_port.helm=30083
+#aaf_locator_port.oom=
 
 aaf_gui_title=AAF
 aaf_gui_copyright=(c) 2018 AT&T Intellectual Property. All rights reserved.
index 4529914..5add301 100644 (file)
@@ -22,6 +22,8 @@
 ## AAF Hello Properties
 ##
 cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props
-aaf_component=AAF_NS.hello:AAF_RELEASE
+aaf_locator_names=hello
 port=8130
+aaf_locator_public_port.helm=30086
+#aaf_locator_public_port.oom=
 
index 41474d4..1b74f65 100644 (file)
@@ -22,6 +22,9 @@
 ## AAF Locator Properties
 ##
 cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props
-aaf_component=AAF_NS.locator:AAF_RELEASE
+aaf_locator_names=locator
 port=8095
+aaf_locator_public_port.helm=30081
+#aaf_locator_public_port.oom=
+
 
index 19b657d..a968b94 100644 (file)
 #  ============LICENSE_END====================================================
 #
 ##
-## org.osaaf.aaf.oauth
 ## AAF OAuth2 Properties
 ##
 cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props
-aaf_component=AAF_NS.oauth:AAF_RELEASE
+aaf_locator_names=oauth,token,introspect
 port=8140
+aaf_locator_public_port.helm=30082
+#aaf_locator_public_port.oom=
+
 
index 3f5e7c4..5c9714c 100644 (file)
@@ -22,6 +22,8 @@
 ## AAF Service Properties
 ##
 cadi_prop_files=/opt/app/osaaf/local/org.osaaf.aaf.props:/opt/app/osaaf/etc/org.osaaf.aaf.log4j.props:/opt/app/osaaf/local/org.osaaf.aaf.cassandra.props:/opt/app/osaaf/etc/org.osaaf.aaf.orgs.props
-aaf_component=AAF_NS.service:AAF_RELEASE
+aaf_locator_names=service
 port=8100
+aaf_locator_public_port.helm=30080
+#aaf_locator_public_port.oom=
 
index 4eb70a9..bae24d4 100644 (file)
@@ -35,6 +35,12 @@ cadi_truststore=/opt/app/osaaf/public/truststoreONAPall.jks
 cadi_truststore_password=changeit
 cadi_x509_issuers=
 
+# Locator info
+aaf_locator_ns=AAF_NS
+aaf_locator_fqdn.docker=aaf-%N
+aaf_locator_fqdn.oom=%CNS.aaf-%N
+aaf_locator_fqdn.helm=%CNS.aaf-%N
+
 # Other
 aaf_data_dir=/opt/app/osaaf/data
 cadi_token_dir=/opt/app/osaaf/tokens
index fa2bc17..9c7e3df 100644 (file)
 #  limitations under the License.\r
 #  ============LICENSE_END====================================================\r
 #\r
-aaf_locate_url=https://localhost:8095\r
-aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/AAF_NS.introspect:2.1/introspect\r
-aaf_oauth2_token_url=https://AAF_LOCATE_URL/AAF_NS.token:2.1/token\r
-aaf_url=https://AAF_LOCATE_URL/AAF_NS.service:2.1\r
 cadi_protocols=TLSv1.1,TLSv1.2\r
-cm_url=https://AAF_LOCATE_URL/AAF_NS.cm:2.1\r
-fs_url=https://AAF_LOCATE_URL/AAF_NS.fs.2.1\r
-gui_url=https://AAF_LOCATE_URL/AAF_NS.gui.2.1\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.introspect:2.1/introspect\r
+aaf_oauth2_token_url=https://AAF_LOCATE_URL/%C%AAF_NS.token: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
index 5ce0529..25a2d02 100644 (file)
@@ -24,7 +24,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>cadiparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
 
index 08ee900..30ea1c2 100644 (file)
@@ -47,6 +47,7 @@ import org.onap.aaf.cadi.http.HBasicAuthSS;
 import org.onap.aaf.cadi.http.HClient;
 import org.onap.aaf.cadi.http.HX509SS;
 import org.onap.aaf.cadi.oauth.HRenewingTokenSS;
+import org.onap.aaf.cadi.util.FixURIinfo;
 import org.onap.aaf.misc.env.APIException;
 
 public class TestConnectivity {
@@ -234,11 +235,12 @@ public class TestConnectivity {
             } else {
                 socket = new Socket();
                 try {
+                       FixURIinfo fui = new FixURIinfo(uri);
                     try {
-                        socket.connect(new InetSocketAddress(uri.getHost(),  uri.getPort()),3000);
-                        System.out.printf("Can Connect a Socket to %s %d\n",uri.getHost(),uri.getPort());
+                        socket.connect(new InetSocketAddress(fui.getHost(),  fui.getPort()),3000);
+                        System.out.printf("Can Connect a Socket to %s %d\n",fui.getHost(),fui.getPort());
                     } catch (IOException e) {
-                        System.out.printf("Cannot Connect a Socket to  %s %d: %s\n",uri.getHost(),uri.getPort(),e.getMessage());
+                        System.out.printf("Cannot Connect a Socket to  %s %d: %s\n",fui.getHost(),fui.getPort(),e.getMessage());
                     }
                 } finally {
                     try {
index 35ef999..16fdb79 100644 (file)
@@ -28,6 +28,7 @@ import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.onap.aaf.cadi.Access;
 import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.LocatorException;
 import org.onap.aaf.cadi.SecuritySetter;
@@ -35,6 +36,7 @@ import org.onap.aaf.cadi.client.Future;
 import org.onap.aaf.cadi.config.Config;
 import org.onap.aaf.cadi.config.SecurityInfoC;
 import org.onap.aaf.cadi.http.HClient;
+import org.onap.aaf.cadi.util.FixURIinfo;
 import org.onap.aaf.cadi.util.Split;
 import org.onap.aaf.misc.env.APIException;
 import org.onap.aaf.misc.env.Data.TYPE;
@@ -61,21 +63,9 @@ public class AAFLocator extends AbsAAFLocator<BasicTrans>  {
         int connectTimeout = Integer.parseInt(si.access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));
         try {
             String[] path = Split.split('/',locatorURI.getPath());
-            String host = locatorURI.getHost();
-            if (host==null) {
-                host = locatorURI.getAuthority(); // this happens when no port
-            }
-            if ("AAF_LOCATE_URL".equals(host)) {
-                URI uri = new URI(
-                        locatorURI.getScheme(),
-                        locatorURI.getUserInfo(),
-                        aaf_locator_uri.getHost(),
-                        aaf_locator_uri.getPort(),
-                        "/locate"+locatorURI.getPath(),
-                        null,
-                        null
-                        );
-                client = createClient(si.defSS, uri, connectTimeout);
+            FixURIinfo fui = new FixURIinfo(locatorURI);
+            if ("AAF_LOCATE_URL".equals(fui.getHost())) {
+                client = createClient(si.defSS, locatorURI, connectTimeout);
             } else if (path.length>1 && "locate".equals(path[1])) {
                 StringBuilder sb = new StringBuilder();
                 for (int i=3;i<path.length;++i) {
@@ -83,23 +73,26 @@ public class AAFLocator extends AbsAAFLocator<BasicTrans>  {
                     sb.append(path[i]);
                 }
                 setPathInfo(sb.toString());
-                URI uri = new URI(
-                            locatorURI.getScheme(),
-                            locatorURI.getUserInfo(),
-                            locatorURI.getHost(),
-                            locatorURI.getPort(),
-                            "/locate/"+name + ':' + version,
-                            null,
-                            null
-                            );
-                client = createClient(si.defSS, uri, connectTimeout);
+//                URI uri = new URI(
+//                            locatorURI.getScheme(),
+//                            locatorURI.getAuthority(),
+//                            locatorURI.getPath(),
+//                            null,
+//                            null
+//                            );
+                client = createClient(si.defSS, locatorURI, connectTimeout);
             } else {
                 client = new HClient(si.defSS, locatorURI, connectTimeout);
             }
             epsDF = env.newDataFactory(Endpoints.class);
-        } catch (APIException | URISyntaxException e) {
+            
+        } catch (APIException /*| URISyntaxException*/ e) {
             throw new LocatorException(e);
         }
+        
+        if(si.access.willLog(Access.Level.DEBUG)) {
+               si.access.log(Access.Level.DEBUG, "Root URI:",client.getURI());
+        }
     }
 
     @Override
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFSingleLocator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFSingleLocator.java
new file mode 100644 (file)
index 0000000..1e4e9c0
--- /dev/null
@@ -0,0 +1,93 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+
+package org.onap.aaf.cadi.aaf.v2_0;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.onap.aaf.cadi.Locator;
+import org.onap.aaf.cadi.LocatorException;
+import org.onap.aaf.misc.env.impl.BasicTrans;
+
+/**
+ * This Locator good for using Inside Docker or K8s, where there is no real lookup, 
+ * and there is conflict between external and internal host names, due to 
+ * Service abstraction.
+ * 
+ * @author Instrumental(Jonathan)
+ *
+ */
+public class AAFSingleLocator implements Locator<URI> {
+       
+       private final URI uri;
+
+       /**
+        * NS here is "container" ns.  AAF NS is assumed to be AAF_NS at this level of client code.
+        * @param cont_ns
+        * @param prefix
+        * @param version
+        * @throws URISyntaxException 
+        */
+       public AAFSingleLocator(final String uri) throws URISyntaxException {
+               this.uri = new URI(uri);
+       }
+       
+       @Override
+       public URI get(Item item) throws LocatorException {
+               return uri;
+       }
+
+       @Override
+       public boolean hasItems() {
+               return true;
+       }
+
+       @Override
+       public void invalidate(Item item) throws LocatorException {
+       }
+
+       @Override
+       public Item best() throws LocatorException {
+               return new SingleItem();
+       }
+
+       @Override
+       public Item first() throws LocatorException {
+               return new SingleItem();
+       }
+
+       @Override
+       public Item next(Item item) throws LocatorException {
+               return null; // only one item
+       }
+
+       @Override
+       public boolean refresh() {
+               return false;
+       }
+
+       @Override
+       public void destroy() {
+       }
+       
+       private class SingleItem implements Item {
+       }
+}
index 9f61713..9b630a7 100644 (file)
@@ -87,12 +87,14 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
             latitude = Double.parseDouble(lat);
             longitude = Double.parseDouble(lng);
         }
+
         if (name.startsWith(Defaults.AAF_NS)) {
             String root_ns = access.getProperty(Config.AAF_ROOT_NS, null);
-            if (root_ns!=null) {
-                name=name.replace(Defaults.AAF_NS, root_ns);
+            if(root_ns!=null) {
+               name=name.replace(Defaults.AAF_NS, root_ns);
             }
         }
+
         if (name.startsWith("http")) { // simple URL
             this.name = name;
             this.version = access.getProperty(Config.AAF_API_VERSION,Config.AAF_DEFAULT_API_VERSION);
@@ -111,52 +113,7 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
     public static void setCreator(LocatorCreator lc) {
         locatorCreator = lc; 
     }
-    
-    /*public static Locator<URI> create(String key) throws LocatorException {
-        String name = null;
-        String version = Config.AAF_DEFAULT_API_VERSION;
-        String pathInfo = null;
-        int prev = key.indexOf("/locate");
-        if (prev>0) {
-            prev = key.indexOf('/',prev+6);
-            if (prev>0) {
-                int next = key.indexOf('/',++prev);
-                if (next>0) {
-                    name = key.substring(prev, next);
-                    pathInfo=key.substring(next);
-                } else {
-                    name = key.substring(prev);
-                }
-                String[] split = Split.split(':', name);
-                switch(split.length) {
-                    case 3:
-                    case 2:
-                        version = split[1];
-                        name = split[0];
-                        break;
-                    default:
-                        break;
-                }
-            }
-        }
-
-        if (key.startsWith("http")) {
-            if (name!=null) {
-                if (locatorCreator != null) {
-                    AbsAAFLocator<?> aal = locatorCreator.create(name, version);
-                    if (pathInfo!=null) {
-                        aal.setPathInfo(pathInfo);
-                    }
-                    return aal;
-                }
-            } else {
-                return new PropertyLocator(key);
-            }
-        }
-        return null;
-    }
-    */
-    
+        
     public static Locator<URI> create(final String name, final String version) throws LocatorException {
         return locatorCreator.create(name, version);
     }
index 18430ef..aa4e574 100644 (file)
@@ -773,6 +773,13 @@ public class Agent {
             }
             
             app.add(Config.AAF_LOCATE_URL, propAccess, null);
+            for(Entry<Object, Object> aaf_loc_prop : propAccess.getProperties().entrySet()) {
+               String key = aaf_loc_prop.getKey().toString();
+               if(key.startsWith("aaf_locator")) {
+                       app.add(key, aaf_loc_prop.getValue().toString());
+               }
+            }
+            
             app.add(Config.AAF_APPID, fqi);
             app.add(Config.AAF_URL, propAccess, Defaults.AAF_URL);
 
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java
new file mode 100644 (file)
index 0000000..7e519c5
--- /dev/null
@@ -0,0 +1,264 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+
+package org.onap.aaf.cadi.register;
+
+import java.net.Inet4Address;
+import java.net.UnknownHostException;
+import java.util.List;
+
+import org.onap.aaf.cadi.Access;
+import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.aaf.Defaults;
+import org.onap.aaf.cadi.config.Config;
+import org.onap.aaf.cadi.util.Split;
+
+import locate.v1_0.MgmtEndpoint;
+import locate.v1_0.MgmtEndpoints;
+
+public class RegistrationCreator {
+    private static final String MUST_BE_DEFINED = " must be defined\n";
+       private Access access;
+    
+    public RegistrationCreator(Access access) {
+       this.access = access;
+    }
+    
+    public MgmtEndpoints create(final int port) throws CadiException {
+       MgmtEndpoints me = new MgmtEndpoints();
+       List<MgmtEndpoint> lme = me.getMgmtEndpoint();
+       MgmtEndpoint defData = null;
+       MgmtEndpoint locate = null;
+
+
+       StringBuilder errs = new StringBuilder();
+       try {
+               String hostname = access.getProperty(Config.HOSTNAME, null);
+               if (hostname==null) {
+                       hostname = Inet4Address.getLocalHost().getHostName();
+               }
+               if (hostname==null) {
+                       errs.append(Config.HOSTNAME);
+                       errs.append(MUST_BE_DEFINED);
+               }
+
+               Float latitude=null;
+               String slatitude = access.getProperty(Config.CADI_LATITUDE, null);
+               if(slatitude == null) {
+                       errs.append(Config.CADI_LATITUDE);
+                       errs.append(MUST_BE_DEFINED);
+               } else {
+                       latitude = Float.parseFloat(slatitude);
+               }
+
+               Float longitude=null;
+               String slongitude = access.getProperty(Config.CADI_LONGITUDE, null);
+               if(slongitude == null) {
+                       errs.append(Config.CADI_LONGITUDE);
+                       errs.append(MUST_BE_DEFINED);
+               } else {
+                       longitude = Float.parseFloat(slongitude);
+               }
+
+               if(errs.length()>0) {
+                       throw new CadiException(errs.toString());
+               }
+
+               String dot_le;
+               String ns;
+               String version=null;
+               String lentries = access.getProperty(Config.AAF_LOCATOR_CONTAINER, null);
+               if(lentries==null) {
+                       lentries="";
+               } else {
+                       lentries=',' + lentries; // "" makes a blank default Public Entry
+               }
+
+               String defaultName = null;
+               String str;
+               int public_port = port;
+               // Note: only one of the ports can be public...  Therefore, only the la
+               for(String le : Split.splitTrim(',', lentries)) {
+                       dot_le = le.isEmpty()?"":"."+le;
+                               str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT+dot_le, null);
+                               if(str!=null) { // Get Public Port
+                                       public_port = Integer.decode(str);
+                               }
+               }
+               
+               String public_hostname = hostname;
+               for(String le : Split.splitTrim(',', lentries)) {
+                       dot_le = le.isEmpty()?"":"."+le;
+                               String ph = access.getProperty(Config.AAF_LOCATOR_PUBLIC_HOSTNAME+dot_le,null);
+                               if( ph != null) {
+                                       public_hostname=ph;
+                               }
+               }
+               
+               String default_fqdn = access.getProperty(Config.AAF_LOCATOR_FQDN, public_hostname);
+               
+
+               // Now, loop through by Container
+               for(String le : Split.splitTrim(',', lentries)) {
+                       // Add variable entries
+                       String names;
+                       if(le.length()>0) {
+                               dot_le = '.' + le;
+                               names = access.getProperty(Config.AAF_LOCATOR_NAMES+dot_le,null);
+                               if(names==null) {
+                                       // Go for Default
+                                       names = access.getProperty(Config.AAF_LOCATOR_NAMES,"");
+                               }
+                       } else {
+                               dot_le = "";
+                               names=access.getProperty(Config.AAF_LOCATOR_NAMES,dot_le);
+                       }
+                       
+                       for(String name : Split.splitTrim(',', names)) {
+                               if(defData==null) {
+                                       defData = locate = new MgmtEndpoint();
+
+                                       defaultName = name;
+                                       version = access.getProperty(Config.AAF_LOCATOR_VERSION, Defaults.AAF_VERSION);
+                                       locate.setProtocol(access.getProperty(Config.AAF_LOCATOR_PROTOCOL,null));
+                                       List<String> ls = locate.getSubprotocol();
+                                       for(String sp : Split.splitTrim(',', access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL,""))) {
+                                               ls.add(sp);     
+                                       }
+                                       locate.setLatitude(latitude);
+                                       locate.setLongitude(longitude);
+
+                               } else {
+                                       locate = copy(defData);
+                               }
+                               
+                               str = access.getProperty(Config.HOSTNAME+dot_le, null);
+                               if(str==null) {
+                                       str = access.getProperty(Config.HOSTNAME, hostname);
+                               }
+                               locate.setHostname(hostname);
+                               
+                               ns = access.getProperty(Config.AAF_LOCATOR_NS+dot_le,null);
+                               if(ns==null) {
+                                       ns = access.getProperty(Config.AAF_LOCATOR_NS,"");
+                               }
+                               switch(ns) {
+                                       case Defaults.AAF_NS:
+                                               ns = access.getProperty(Config.AAF_ROOT_NS, "");
+                                               // Fallthrough on purpose.
+                               }
+
+                               String ns_dot;
+                               if(ns.isEmpty()) {
+                                       ns_dot = ns;
+                               } else {
+                                       ns_dot = ns + '.';
+                               }
+
+                               String container_id = access.getProperty(Config.AAF_LOCATOR_CONTAINER_ID+dot_le, "");
+                               if(!container_id.isEmpty()) {
+                                       ns_dot = container_id + '.' + ns_dot;
+                               }
+
+                               if(!le.isEmpty()) {
+                                       ns_dot = le + '.' + ns_dot;
+                               }
+
+                               if(name.isEmpty()) {
+                                               locate.setName(ns_dot + defaultName);
+                               } else {
+                                       locate.setName(ns_dot + name);
+                               }
+
+                               if(dot_le.isEmpty()) {
+                                       locate.setHostname(access.getProperty(Config.AAF_LOCATOR_FQDN, default_fqdn));
+                               } else {
+                                       str =  access.getProperty(Config.AAF_LOCATOR_FQDN+dot_le, null);
+                                       if(str==null) {
+                                               locate.setHostname(default_fqdn);
+                                       } else {
+                                               String container_ns = access.getProperty(Config.AAF_LOCATOR_CONTAINER_NS+dot_le, "");
+                                               str = str.replace("%CNS", container_ns);
+                                               String container = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le, "");
+                                               str = str.replace("%C", container);
+                                               str = str.replace("%NS", ns);
+                                               str = str.replace("%N", name);
+                                               str = str.replace("%DF", default_fqdn);
+                                               str = str.replace("%PH", public_hostname);
+                                               locate.setHostname(str);
+                                       }
+                               }
+                               
+                               if(le.isEmpty()) {
+                                       locate.setPort(public_port);
+                               } else {
+                                       locate.setPort(port);
+                               }
+
+                               String specificVersion = access.getProperty(Config.AAF_LOCATOR_VERSION + dot_le,null);
+                               if(specificVersion == null && locate == defData) {
+                                       specificVersion = version;
+                               }
+                               if(specificVersion!=null) {
+                                       String split[] = Split.splitTrim('.', specificVersion);
+                                       locate.setPkg(split.length>3?Integer.parseInt(split[3]):0);
+                                       locate.setPatch(split.length>2?Integer.parseInt(split[2]):0);
+                                       locate.setMinor(split.length>1?Integer.parseInt(split[1]):0);
+                                       locate.setMajor(split.length>0?Integer.parseInt(split[0]):0);
+                               }
+
+                               String protocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL + dot_le, null);
+                               if (protocol!=null) {
+                                       locate.setProtocol(protocol);
+                                       String subprotocols = access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL + dot_le, null);
+                                       if(subprotocols!=null) {
+                                               List<String> ls = locate.getSubprotocol();
+                                               for (String s : Split.split(',', subprotocols)) {
+                                                       ls.add(s);
+                                               }
+                                       }
+                               }
+                               lme.add(locate);
+                       }
+               }
+       } catch (NumberFormatException | UnknownHostException e) {
+               throw new CadiException("Error extracting Data from Properties for Registrar",e);
+       }
+
+       return me;
+    }
+       
+    private MgmtEndpoint copy(MgmtEndpoint mep) {
+               MgmtEndpoint out = new MgmtEndpoint();
+               out.setName(mep.getName());
+               out.setHostname(mep.getHostname());
+               out.setLatitude(mep.getLatitude());
+               out.setLongitude(mep.getLongitude());
+               out.setMajor(mep.getMajor());
+               out.setMinor(mep.getMinor());
+               out.setPkg(mep.getPkg());
+               out.setPatch(mep.getPatch());
+               out.setPort(mep.getPort());
+               out.setProtocol(mep.getProtocol());
+               out.getSpecialPorts().addAll(mep.getSpecialPorts());
+               out.getSubprotocol().addAll(mep.getSubprotocol());
+               return out;
+       }
+}
index 49d40ab..883410c 100644 (file)
 package org.onap.aaf.cadi.register;
 
 import java.net.HttpURLConnection;
-import java.net.Inet4Address;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.UnknownHostException;
 
 import org.onap.aaf.cadi.Access;
 import org.onap.aaf.cadi.Access.Level;
@@ -39,16 +37,13 @@ import org.onap.aaf.cadi.client.Result;
 import org.onap.aaf.cadi.config.Config;
 import org.onap.aaf.cadi.locator.PropertyLocator;
 import org.onap.aaf.cadi.locator.SingleEndpointLocator;
-import org.onap.aaf.cadi.util.Split;
 import org.onap.aaf.misc.env.APIException;
 import org.onap.aaf.misc.env.impl.BasicEnv;
 import org.onap.aaf.misc.rosetta.env.RosettaDF;
 
-import locate.v1_0.MgmtEndpoint;
 import locate.v1_0.MgmtEndpoints;
 
 public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> {
-    private final MgmtEndpoint mep;
     private final MgmtEndpoints meps;
     private final AAFCon<HttpURLConnection> aafcon;
     private final RosettaDF<MgmtEndpoints> mgmtEndpointsDF;
@@ -56,8 +51,7 @@ public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> {
     private final Access access;
     private final int timeout;
 
-    @SafeVarargs
-    public RemoteRegistrant(AAFCon<HttpURLConnection> aafcon, String name, String version, int port, RemoteRegistrant<ENV> ... others) throws CadiException, LocatorException {
+    public RemoteRegistrant(AAFCon<HttpURLConnection> aafcon, int port) throws CadiException, LocatorException {
         this.aafcon = aafcon;
         access = aafcon.access;
         try {
@@ -82,60 +76,13 @@ public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> {
             }
         }
         
-        mep = new MgmtEndpoint();
-        mep.setName(name);
-        mep.setPort(port);
-
-        try {
-            String hostnameToRegister = access.getProperty(Config.AAF_REGISTER_AS, null);
-            if (hostnameToRegister==null) {
-                hostnameToRegister = access.getProperty(Config.HOSTNAME, null);
-            }
-            if (hostnameToRegister==null) {
-                hostnameToRegister = Inet4Address.getLocalHost().getHostName();
-            }
-            mep.setHostname(hostnameToRegister);
-            
-            String latitude = access.getProperty(Config.CADI_LATITUDE, null);
-            if (latitude==null) {
-                latitude = access.getProperty("AFT_LATITUDE", null);
-            }
-            String longitude = access.getProperty(Config.CADI_LONGITUDE, null);
-            if (longitude==null) {
-                longitude = access.getProperty("AFT_LONGITUDE", null);
-            }
-            if (latitude==null || longitude==null) {
-                throw new CadiException(Config.CADI_LATITUDE + " and " + Config.CADI_LONGITUDE + " is required");
-            } else {
-                mep.setLatitude(Float.parseFloat(latitude));
-                mep.setLongitude(Float.parseFloat(longitude));
-            }
-            String split[] = Split.split('.', version);
-            mep.setPkg(split.length>3?Integer.parseInt(split[3]):0);
-            mep.setPatch(split.length>2?Integer.parseInt(split[2]):0);
-            mep.setMinor(split.length>1?Integer.parseInt(split[1]):0);
-            mep.setMajor(split.length>0?Integer.parseInt(split[0]):0);
-            
-            String subprotocols = access.getProperty(Config.CADI_PROTOCOLS, null);
-            if (subprotocols==null) {
-                mep.setProtocol("http");
-            } else {
-                mep.setProtocol("https");
-                for (String s : Split.split(',', subprotocols)) {
-                    mep.getSubprotocol().add(s);
-                }
-            }
-        } catch (NumberFormatException | UnknownHostException e) {
-            throw new CadiException("Error extracting Data from Properties for Registrar",e);
-        }
-        meps = new MgmtEndpoints();
-        meps.getMgmtEndpoint().add(mep);
-        for (RemoteRegistrant<ENV> rr : others) {
-            meps.getMgmtEndpoint().add(rr.mep);
-        }
+        RegistrationCreator rcreator = new RegistrationCreator(access);
+        meps = rcreator.create(port);
     }
     
-    @Override
+
+
+       @Override
     public Result<Void> update(ENV env) {
         try {
             Rcli<?> client = aafcon.client(locator);
index 3563be7..b27d37c 100644 (file)
@@ -22,7 +22,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>cadiparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
 
index d885283..daca47d 100644 (file)
@@ -40,6 +40,7 @@ import org.onap.aaf.cadi.SecuritySetter;
 import org.onap.aaf.cadi.client.EClient;
 import org.onap.aaf.cadi.client.Future;
 import org.onap.aaf.cadi.client.Rcli;
+import org.onap.aaf.cadi.util.FixURIinfo;
 import org.onap.aaf.misc.env.APIException;
 import org.onap.aaf.misc.env.Data;
 import org.onap.aaf.misc.env.Data.TYPE;
@@ -109,24 +110,23 @@ public class HClient implements EClient<HttpURLConnection> {
 
     @Override
     public void send() throws APIException {
-        try {
-            // Build URL from given URI plus current Settings
-            if (uri.getPath()==null) {
-                throw new APIException("Invalid URL entered for HClient");
-            }
-            StringBuilder pi=null;
-            if (pathinfo!=null) { // additional pathinfo
-                pi = new StringBuilder(uri.getPath());
-                if (!pathinfo.startsWith("/")) {
-                    pi.append('/');
-                }
-                pi.append(pathinfo);
+        // Build URL from given URI plus current Settings
+        if (uri.getPath()==null) {
+            throw new APIException("Invalid URL entered for HClient");
+        }
+        StringBuilder pi=null;
+        if (pathinfo!=null) { // additional pathinfo
+            pi = new StringBuilder(uri.getPath());
+            if (!pathinfo.startsWith("/")) {
+                pi.append('/');
             }
-            URI sendURI = new URI(
+            pi.append(pathinfo);
+        }
+               URI sendURI = null;
+        try {
+            sendURI = new URI(
                     uri.getScheme(),
-                    uri.getUserInfo(),
-                    uri.getHost(),
-                    uri.getPort(),
+                    uri.getAuthority(),
                     pi==null?uri.getPath():pi.toString(),
                     query==null?uri.getQuery():query,
                     fragment==null?uri.getFragment():fragment
@@ -149,8 +149,14 @@ public class HClient implements EClient<HttpURLConnection> {
                 transfer.transfer(huc.getOutputStream());
             }
             // TODO other settings? There's a bunch here.
+        } catch (APIException e) {
+               throw e;
         } catch (Exception e) {
-            throw new APIException(e);
+               if(sendURI==null) {
+                       throw new APIException("Cannot connect to Root URI: " + uri.toString(),e);
+               } else {
+                       throw new APIException("Cannot connect to " + sendURI.toString() + "(Root URI: " + uri.toString() +')',e);
+               }
         } finally { // ensure all these are reset after sends
             meth=pathinfo=null;
             if (headers!=null) {
@@ -171,9 +177,7 @@ public class HClient implements EClient<HttpURLConnection> {
     protected HttpURLConnection getConnection(URI uri, StringBuilder pi) throws IOException, URISyntaxException {
         URL url = new URI(
                 uri.getScheme(), 
-                uri.getUserInfo(),
-                uri.getHost(), 
-                uri.getPort(), 
+                uri.getAuthority(),
                 pi==null?uri.getPath():pi.toString(), 
                 query,
                 fragment).toURL();
index 8e3138a..1e5c521 100644 (file)
@@ -30,14 +30,15 @@ import java.net.URISyntaxException;
 import javax.net.ssl.SSLHandshakeException;
 
 import org.onap.aaf.cadi.Access;
+import org.onap.aaf.cadi.Access.Level;
 import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.Locator;
+import org.onap.aaf.cadi.Locator.Item;
 import org.onap.aaf.cadi.LocatorException;
 import org.onap.aaf.cadi.SecuritySetter;
-import org.onap.aaf.cadi.Access.Level;
-import org.onap.aaf.cadi.Locator.Item;
 import org.onap.aaf.cadi.client.Rcli;
 import org.onap.aaf.cadi.client.Retryable;
+import org.onap.aaf.cadi.util.FixURIinfo;
 import org.onap.aaf.misc.env.APIException;
 
 public class HMangr {
@@ -174,7 +175,8 @@ public class HMangr {
         loc.refresh();
         for (Item li=loc.first();li!=null;li=loc.next(li)) {
             URI uri=loc.get(li);
-            if (host!=null && !host.equals(uri.getHost())) {
+            FixURIinfo fui = new FixURIinfo(uri);
+            if (host!=null && !host.equals(fui.getHost())) {
                 break;
             }
             try {
index eb0ecf1..bccb811 100644 (file)
@@ -36,6 +36,7 @@ import java.util.TimerTask;
 
 import org.onap.aaf.cadi.Locator;
 import org.onap.aaf.cadi.LocatorException;
+import org.onap.aaf.cadi.util.FixURIinfo;
 import org.onap.aaf.misc.env.util.Split;
 
 public class PropertyLocator implements Locator<URI> {
@@ -181,7 +182,8 @@ public class PropertyLocator implements Locator<URI> {
             String realname;
             for (int i = 0; i < orig.length ; ++i) {
                 try {
-                    InetAddress ia[] = InetAddress.getAllByName(orig[i].getHost());
+                       FixURIinfo fui = new FixURIinfo(orig[i]);
+                    InetAddress ia[] = InetAddress.getAllByName(fui.getHost());
 
                     URI o,n;
                     for (int j=0;j<ia.length;++j) {
index 51a0d09..c02d0f8 100644 (file)
@@ -16,7 +16,7 @@
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>cadiparent</artifactId>
                <relativePath>..</relativePath>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
        </parent>
 
        <modelVersion>4.0.0</modelVersion>
index a9d671c..599bb98 100644 (file)
@@ -26,6 +26,8 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -106,7 +108,7 @@ public class PropAccess implements Access {
         // First, load related System Properties
         for (Entry<Object,Object> es : System.getProperties().entrySet()) {
             String key = es.getKey().toString();
-            for (String start : new String[] {"cadi_","aaf_","cm_"}) {
+            for (String start : new String[] {"HOSTNAME","cadi_","aaf_","cm_"}) {
                 if (key.startsWith(start)) {
                     props.put(key, es.getValue());
                 }
@@ -274,41 +276,53 @@ public class PropAccess implements Access {
             sb.append("] ");
         } else {
             int idx = 0;
-            if (elements[idx] instanceof Integer) {
+            if(elements[idx]!=null  && 
+               elements[idx] instanceof Integer) {
                 sb.append('-');
                 sb.append(elements[idx]);
                 ++idx;
             }
             sb.append("] ");
-            String s;
-            boolean first = true;
-            for (Object o : elements) {
-                if (o!=null) {
-                    s=o.toString();
-                    if (first) {
-                        first = false;
-                    } else {
-                        int l = s.length();
-                        if (l>0)    {
-                            switch(s.charAt(l-1)) {
-                                case ' ':
-                                    break;
-                                default:
-                                    sb.append(' ');
-                            }
-                        }
-                    }
-                    sb.append(s);
-                }
-            }
+            write(true,sb,elements);
         }
         return sb;
     }
+    
+    private static boolean write(boolean first, StringBuilder sb, Object[] elements) {
+       String s;
+        for (Object o : elements) {
+            if (o!=null) {
+               if(o.getClass().isArray()) {
+                       first = write(first,sb,(Object[])o);
+               } else {
+                       s=o.toString();
+                       if (first) {
+                           first = false;
+                       } else {
+                           int l = s.length();
+                           if (l>0)    {
+                               switch(s.charAt(l-1)) {
+                                   case ' ':
+                                       break;
+                                   default:
+                                       sb.append(' ');
+                               }
+                           }
+                       }
+                       sb.append(s);
+               }
+            }
+        }
+        return first;
+    }
 
     @Override
     public void log(Exception e, Object... elements) {
-        log(Level.ERROR,e.getMessage(),elements);
-        e.printStackTrace(System.err);
+       StringWriter sw = new StringWriter();
+       PrintWriter pw = new PrintWriter(sw);
+       pw.println();
+       e.printStackTrace(pw);
+        log(Level.ERROR,elements,sw.toString());
     }
 
     @Override
index 353e8e3..245b653 100644 (file)
@@ -58,6 +58,7 @@ import org.onap.aaf.cadi.taf.HttpTaf;
 import org.onap.aaf.cadi.taf.basic.BasicHttpTaf;
 import org.onap.aaf.cadi.taf.cert.X509Taf;
 import org.onap.aaf.cadi.taf.dos.DenialOfServiceTaf;
+import org.onap.aaf.cadi.util.FixURIinfo;
 import org.onap.aaf.cadi.util.Split;
 
 /**
@@ -158,13 +159,31 @@ public class Config {
     public static final String OAUTH2_TOKEN_URL = "https://AAF_LOCATE_URL/AAF_NS.token:" + AAF_DEFAULT_API_VERSION;
     public static final String OAUTH2_INTROSPECT_URL = "https://AAF_LOCATE_URL/AAF_NS.introspect:" + AAF_DEFAULT_API_VERSION;
 
-    public static final String AAF_REGISTER_AS = "aaf_register_as";
+    public static final String AAF_LOCATOR_CLASS = "aaf_locator_class";
+    // AAF Locator Entries are ADDITIONAL entries, which also gives the Property ability
+    // to set these entries manually
+    // example: adding a K8S name like "oom"
+    // this will allow Registrations to pick up 
+    // locator_ns.oom for onap's "OOM" based k8s entries, etc.
+    public static final String AAF_LOCATOR_CONTAINER="aaf_locator_container";
+    // An ID for another Container, to be used to avoid picking up the wrong internal info 
+    // for another container.
+    public static final String AAF_LOCATOR_CONTAINER_ID = "aaf_locator_container_id";
+    public static final String AAF_LOCATOR_CONTAINER_NS = "aaf_locator_container_ns";
+    public static final String AAF_LOCATOR_VERSION = "aaf_locator_version";
+    public static final String AAF_LOCATOR_PROTOCOL = "aaf_locator_protocol";
+    public static final String AAF_LOCATOR_SUBPROTOCOL = "aaf_locator_subprotocol";
+    public static final String AAF_LOCATOR_NS = "aaf_locator_ns";
+    public static final String AAF_LOCATOR_NAMES = "aaf_locator_names";
+    public static final String AAF_LOCATOR_FQDN = "aaf_locator_fqdn";
+    public static final String AAF_LOCATOR_PUBLIC_PORT = "aaf_locator_public_port";
+    public static final String AAF_LOCATOR_PUBLIC_HOSTNAME = "aaf_locator_public_hostname";
+
     public static final String AAF_APPID = "aaf_id";
     public static final String AAF_APPPASS = "aaf_password";
     public static final String AAF_LUR_CLASS = "aaf_lur_class";
     public static final String AAF_TAF_CLASS = "aaf_taf_class";
     public static final String AAF_CONNECTOR_CLASS = "aaf_connector_class";
-    public static final String AAF_LOCATOR_CLASS = "aaf_locator_class";
     public static final String AAF_CONN_TIMEOUT = "aaf_conn_timeout";
     public static final String AAF_CONN_TIMEOUT_DEF = "3000";
     public static final String AAF_CONN_IDLE_TIMEOUT = "aaf_conn_idle_timeout"; // only for Direct Jetty Access.
@@ -189,7 +208,7 @@ public class Config {
     public static final String AAF_HIGH_COUNT = "aaf_high_count";
     public static final String AAF_HIGH_COUNT_DEF = "1000"; // Default is 1000 entries
     public static final String AAF_PERM_MAP = "aaf_perm_map";
-    public static final String AAF_COMPONENT = "aaf_component";
+//    public static final String AAF_COMPONENT = "aaf_component";
     public static final String AAF_CERT_IDS = "aaf_cert_ids";
     public static final String AAF_DEBUG_IDS = "aaf_debug_ids"; // comma delimited
     public static final String AAF_DATA_DIR = "aaf_data_dir"; // AAF processes and Components only.
@@ -795,18 +814,39 @@ public class Config {
         if (_url==null) {
             access.log(Level.INIT,"No URL passed to 'loadLocator'. Disabled");
         } else {
-            String url = _url;
+            String url = _url.replace("/AAF_NS.", "/%C%CID%AAF_NS.");
+            String root_ns = access.getProperty(Config.AAF_ROOT_NS, null);
+            if(url.indexOf('%')>=0) {
+                   String str = access.getProperty(Config.AAF_LOCATOR_CONTAINER_ID, null);
+                   if(str==null) {
+                       url = url.replace("%CID","");
+                   } else {
+                       url = url.replace("%CID",str+'.');
+                   }
+                   str = access.getProperty(Config.AAF_LOCATOR_CONTAINER, null);
+                   if(str==null) {
+                       url = url.replace("%C","");
+                   } else {
+                       url = url.replace("%C",str+'.');
+                   }
+       
+                   if (root_ns==null) {
+                       url = url.replace("%AAF_NS","");
+                   } else {
+                       url = url.replace("%AAF_NS",root_ns);
+                   }
+            }
             String replacement;
             int idxAAFLocateUrl;
-            if ((idxAAFLocateUrl=_url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) {
+            if ((idxAAFLocateUrl=url.indexOf(AAF_LOCATE_URL_TAG))>0 && ((replacement=access.getProperty(AAF_LOCATE_URL, null))!=null)) {
                 StringBuilder sb = new StringBuilder(replacement);
                 if (!replacement.endsWith("/locate")) {
                     sb.append("/locate");
                 } 
-                sb.append(_url,idxAAFLocateUrl+AAF_LOCATE_URL_TAG.length(),_url.length());
+                sb.append(url,idxAAFLocateUrl+AAF_LOCATE_URL_TAG.length(),url.length());
                 url = sb.toString();
             }
-    
+            
             try {
                 Class<?> lcls = loadClass(access,AAF_LOCATOR_CLASS_DEF);
                 if (lcls==null) {
@@ -821,12 +861,13 @@ public class Config {
                 }
                 if (locator==null) {
                     URI locatorURI = new URI(url);
+                    FixURIinfo fui = new FixURIinfo(locatorURI);
                     Constructor<?> cnst = lcls.getConstructor(SecurityInfoC.class,URI.class);
                     locator = (Locator<URI>)cnst.newInstance(new Object[] {si,locatorURI});
-                    int port = locatorURI.getPort();
-                    String portS = port<0?"":(":"+locatorURI.getPort());
+                    int port = fui.getPort();
+                    String portS = port<0?"":(":"+port);
                     
-                    access.log(Level.INFO, "AAFLocator enabled using " + locatorURI.getScheme() +"://"+locatorURI.getHost() + portS);
+                    access.log(Level.INFO, "AAFLocator enabled using " + locatorURI.getScheme() +"://"+fui.getHost() + portS);
                 } else {
                     access.log(Level.INFO, "AAFLocator enabled using preloaded " + locator.getClass().getSimpleName());
                 }
index 2305eac..cd8eff4 100644 (file)
@@ -139,7 +139,7 @@ public class CadiFilter implements Filter {
     
 
     @SuppressWarnings("unchecked")
-    private void init(Get getter) throws ServletException {
+    protected void init(Get getter) throws ServletException {
        sideChain = new SideChain();
         // Start with the assumption of "Don't trust anyone".
        TrustChecker tc = TrustChecker.NOTRUST; // default position
index cf7c922..1805c78 100644 (file)
@@ -32,7 +32,7 @@ import org.onap.aaf.cadi.config.Get;
  * A private method to query the Filter config and if not exists, return the default.  This
  * cleans up the initialization code.
  */
-class FCGet implements Get {
+public class FCGet implements Get {
     /**
      * 
      */
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/FixURIinfo.java
new file mode 100644 (file)
index 0000000..7e3a239
--- /dev/null
@@ -0,0 +1,66 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+
+package org.onap.aaf.cadi.util;
+
+import java.net.URI;
+
+/**
+ * URI and URL, if the host does not have "dots", will interpret Host:port as Authority
+ * 
+ * This is very problematic for Containers, which like single name entries.
+ * @author Instrumental(Jonathan)
+ *
+ */
+public class FixURIinfo {
+       private String auth;
+       private String host;
+       private int port;
+       
+       public FixURIinfo(URI uri) {
+               auth = uri.getAuthority();
+               host = uri.getHost();
+               if(host==null) {
+                       if(auth!=null) {
+                               int colon = auth.indexOf(':');
+                               if(colon >= 0 ) {
+                                       host = auth.substring(0, colon);
+                                       port = Integer.parseInt(auth.substring(colon+1));
+                               } else {
+                                       host = auth;
+                                       port = uri.getPort();
+                               }
+                               auth=null;
+                       }
+               }
+       }
+       
+       public String getHost() {
+               return host;
+       }
+       
+       public int getPort() {
+               return port;
+       }
+
+       public String getUserInfo() {
+               return auth;
+       }
+}
index 4bb1d3b..97afa65 100644 (file)
@@ -31,84 +31,93 @@ package org.onap.aaf.cadi.util;
  */
 
 public class Split {
-      public static String[] split(char c, String value) {
-          return split(c,value,0,value.length());
-      }
+       private static final String[] EMPTY = new String[0];
 
-      public static String[] split(char c, String value, int start, int end) {
-          if (value==null) {
-              return new String[0];
-          }
+       public static String[] split(char c, String value) {
+               if (value==null) {
+                       return EMPTY;
+               }
 
-          // Count items to preallocate Array (memory alloc is more expensive than counting twice)
-          int count,idx;
-          for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
-          String[] rv = new String[count];
-          if (count==1) {
-              rv[0]=value.substring(start,end);
-          } else {
-              int last=0;
-              count=-1;
-              for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
-                  rv[++count]=value.substring(last,idx);
-                  last = ++idx;
-              }
-              rv[++count]=value.substring(last,end);
-          }
-          return rv;
-    }
+               return split(c,value,0,value.length());
+       }
 
-      public static String[] splitTrim(char c, String value, int start, int end) {
-          if (value==null) {
-              return new String[0];
-          }
+       public static String[] split(char c, String value, int start, int end) {
+               if (value==null) {
+                       return EMPTY;
+               }
 
-          // Count items to preallocate Array (memory alloc is more expensive than counting twice)
-          int count,idx;
-          for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
-          String[] rv = new String[count];
-          if (count==1) {
-              rv[0]=value.substring(start,end).trim();
-          } else {
-              int last=0;
-              count=-1;
-              for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
-                  rv[++count]=value.substring(last,idx).trim();
-                  last = ++idx;
-              }
-              rv[++count]=value.substring(last,end).trim();
-          }
-          return rv;
-    }
+               // Count items to preallocate Array (memory alloc is more expensive than counting twice)
+               int count,idx;
+               for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
+               String[] rv = new String[count];
+               if (count==1) {
+                       rv[0]=value.substring(start,end);
+               } else {
+                       int last=0;
+                       count=-1;
+                       for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
+                               rv[++count]=value.substring(last,idx);
+                               last = ++idx;
+                       }
+                       rv[++count]=value.substring(last,end);
+               }
+               return rv;
+       }
 
-      public static String[] splitTrim(char c, String value) {
-          return splitTrim(c,value,0,value.length());
-      }
+       public static String[] splitTrim(char c, String value, int start, int end) {
+               if (value==null) {
+                       return EMPTY;
+               }
 
-      public static String[] splitTrim(char c, String value, int size) {
-          if (value==null) {
-              return new String[0];
-          }
+               // Count items to preallocate Array (memory alloc is more expensive than counting twice)
+               int count,idx;
+               for (count=1,idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,++idx),++count);
+               String[] rv = new String[count];
+               if (count==1) {
+                       rv[0]=value.substring(start,end).trim();
+               } else {
+                       int last=0;
+                       count=-1;
+                       for (idx=value.indexOf(c,start);idx>=0 && idx<end;idx=value.indexOf(c,idx)) {
+                               rv[++count]=value.substring(last,idx).trim();
+                               last = ++idx;
+                       }
+                       rv[++count]=value.substring(last,end).trim();
+               }
+               return rv;
+       }
 
-          int idx;
-          String[] rv = new String[size];
-          if (size==1) {
-              rv[0]=value.trim();
-          } else {
-              int last=0;
-              int count=-1;
-              size-=2;
-              for (idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {
-                  rv[++count]=value.substring(last,idx).trim();
-                  last = ++idx;
-              }
-              if (idx>0) {
-                rv[++count]=value.substring(last,idx).trim();
-              } else {
-                rv[++count]=value.substring(last).trim();
-              }
-          }
-          return rv;
-      }
+       public static String[] splitTrim(char c, String value) {
+               if (value==null) {
+                       return EMPTY;
+               }
+               return splitTrim(c,value,0,value.length());
+       }
+
+       public static String[] splitTrim(char c, String value, int size) {
+               if (value==null) {
+                       return EMPTY;
+               }
+
+               int idx;
+               String[] rv = new String[size];
+               if (size==1) {
+                       rv[0]=value.trim();
+               } else {
+                       int last=0;
+                       int count=-1;
+                       size-=2;
+                       for (idx=value.indexOf(c);idx>=0 && count<size;idx=value.indexOf(c,idx)) {
+                               rv[++count]=value.substring(last,idx).trim();
+                               last = ++idx;
+                       }
+                       if (idx>0) {
+                               rv[++count]=value.substring(last,idx).trim();
+                       } else {
+                               rv[++count]=value.substring(last).trim();
+                       }
+               }
+               return rv;
+       }
 
 }
index d9d5214..d04e12b 100644 (file)
@@ -25,7 +25,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>cadiparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        
index 4b02ebe..7e7458a 100644 (file)
@@ -24,7 +24,7 @@
        <parent>
            <groupId>org.onap.aaf.authz</groupId>
            <artifactId>parent</artifactId>
-           <version>2.1.9-SNAPSHOT</version>
+           <version>2.1.10-SNAPSHOT</version>
     </parent>
        <artifactId>cadiparent</artifactId>
        <name>AAF CADI Parent (Code, Access, Data, Identity)</name>
index ec73e2f..ca44107 100644 (file)
@@ -4,7 +4,7 @@
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>cadiparent</artifactId>
                <relativePath>..</relativePath>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
        <name>CADI Servlet Sample (Test Only)</name>
index e753493..bf94678 100644 (file)
@@ -90,12 +90,12 @@ fi
 
 for ROOT in $(cat san_root.aaf); do
    SANS="$SANS $ROOT"
-   for C in service locate oauth gui cm hello; do
+   for C in service locate oauth token introspect gui cm hello; do
      SANS="$SANS $C.$ROOT"
    done
 done
 
-for C in service locate oauth gui cm hello; do
+for C in service locate oauth token introspect gui cm hello; do
    SANS="$SANS aaf-$C"
    SANS="$SANS aaf-$C.onap"
 done
index cd3a3f3..a77b62d 100644 (file)
@@ -1 +1 @@
-aaf.osaaf.org aaf.api.simpledemo.onap.org 
+aaf.osaaf.org 
index 85bcdf9..2c8d420 100644 (file)
@@ -24,7 +24,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>miscparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
 
index 0bff6a0..61d10ae 100644 (file)
@@ -59,7 +59,7 @@ public final class StaticSlot {
      * @param name\r
      *             The name of the StaticSlot's key.\r
      */\r
-    StaticSlot(int index, String name) {\r
+    public StaticSlot(int index, String name) {\r
         slot = index;\r
         key = name;\r
     }\r
index 2617559..d76d882 100644 (file)
@@ -19,7 +19,7 @@
  *
  */
 
-package org.onap.aaf.misc.env.impl;
+package org.onap.aaf.misc.env;
 
 import static org.junit.Assert.assertFalse;
 import static org.mockito.MockitoAnnotations.initMocks;
@@ -31,6 +31,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.onap.aaf.misc.env.impl.JavaUtilLogTarget;
 
 public class JU_JavaUtilLogTarget {
 
index e685dfe..d8e843b 100644 (file)
  *
  */
 
-package org.onap.aaf.misc.env.impl;
+package org.onap.aaf.misc.env;
 
 import org.junit.Test;
-import org.onap.aaf.misc.env.APIException;
+import org.onap.aaf.misc.env.impl.NullLifeCycle;
 
 public class JU_NullLifeCycle {
 
  * ============LICENSE_END====================================================
  *
  */
-package org.onap.aaf.misc.env;
+package org.onap.aaf.misc.env.jaxb;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.MockitoAnnotations.initMocks;
 
-import java.io.File;
 import java.util.List;
 import java.util.Properties;
 
@@ -38,6 +36,12 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.Slot;
+import org.onap.aaf.misc.env.StaticSlot;
+import org.onap.aaf.misc.env.StoreImpl;
+import org.onap.aaf.misc.env.TimeTaken;
 
 @RunWith(MockitoJUnitRunner.class) 
 public class JU_StoreImplTest {
index 51073c0..0621305 100644 (file)
@@ -24,7 +24,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>miscparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
 
index 13f3aa7..89e7e2b 100644 (file)
@@ -25,7 +25,7 @@
        <parent>
        <groupId>org.onap.aaf.authz</groupId>
        <artifactId>parent</artifactId>
-       <version>2.1.9-SNAPSHOT</version>
+       <version>2.1.10-SNAPSHOT</version>
     </parent>
        <artifactId>miscparent</artifactId>
        <name>AAF Misc Parent</name>
index acf7c3d..2cf38a3 100644 (file)
@@ -24,7 +24,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>miscparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
 
index 355a712..c2042cf 100644 (file)
@@ -24,7 +24,7 @@
        <parent>
                <groupId>org.onap.aaf.authz</groupId>
                <artifactId>miscparent</artifactId>
-               <version>2.1.9-SNAPSHOT</version>
+               <version>2.1.10-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
 
diff --git a/pom.xml b/pom.xml
index 2ccb428..67b1e21 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.onap.aaf.authz</groupId>
     <artifactId>parent</artifactId>
-    <version>2.1.9-SNAPSHOT</version>
+    <version>2.1.10-SNAPSHOT</version>
     <name>aaf-authz</name>
     <packaging>pom</packaging>