diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-01-22 10:27:32 -0600 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-01-22 10:32:14 -0600 |
commit | 12414fe43077e12d7ef711951b1633ad31d73573 (patch) | |
tree | 475166cee68c104b2f36625ef864a912aab50fa4 /auth | |
parent | a5bcce655e339151445fbce2c129687e3bc8610a (diff) |
Public and Private Locate entries
Issue-ID: AAF-723
Change-Id: I9dcd2e732ce64b39aaa57a6e9404f275f7ad540c
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth')
73 files changed, 742 insertions, 462 deletions
diff --git a/auth/auth-batch/pom.xml b/auth/auth-batch/pom.xml index c30a32af..1994d9e8 100644 --- a/auth/auth-batch/pom.xml +++ b/auth/auth-batch/pom.xml @@ -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> diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java index ff605203..d49f4faf 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java @@ -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()) { diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java index 7ed26ce5..e171d174 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Expiring.java @@ -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>>(); diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java index 2ba5d022..fe754c10 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NotInOrg.java @@ -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); diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java index daf51925..547b657f 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/Notify.java @@ -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 index 00000000..8281e747 --- /dev/null +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/NsRoleUserReport.java @@ -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(); + } + +} diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/NotifyCredExpiring.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/NotifyCredExpiring.java index ce008164..4288b2e7 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/NotifyCredExpiring.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/NotifyCredExpiring.java @@ -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; diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java index 5f6021b3..f2425f4a 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/update/Remove.java @@ -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) { diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/creators/RowCreator.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/creators/RowCreator.java index 661105d3..6902a426 100644 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/creators/RowCreator.java +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/creators/RowCreator.java @@ -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; } diff --git a/auth/auth-cass/cass_init/cmd.sh b/auth/auth-cass/cass_init/cmd.sh index 98194e08..ffaf182d 100644 --- a/auth/auth-cass/cass_init/cmd.sh +++ b/auth/auth-cass/cass_init/cmd.sh @@ -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" diff --git a/auth/auth-cass/docker/dinstall.sh b/auth/auth-cass/docker/dinstall.sh index 83fb060e..e6da5e4b 100644 --- a/auth/auth-cass/docker/dinstall.sh +++ b/auth/auth-cass/docker/dinstall.sh @@ -24,12 +24,12 @@ 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 diff --git a/auth/auth-cass/docker/drun.sh b/auth/auth-cass/docker/drun.sh index a412296b..778947eb 100644 --- a/auth/auth-cass/docker/drun.sh +++ b/auth/auth-cass/docker/drun.sh @@ -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 diff --git a/auth/auth-cass/pom.xml b/auth/auth-cass/pom.xml index cfff8f7c..c43a6965 100644 --- a/auth/auth-cass/pom.xml +++ b/auth/auth-cass/pom.xml @@ -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> diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java index 48131860..6fe9bde5 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/CassAccess.java @@ -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"); } diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java index 757efa5f..085f4199 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/LocateDAO.java @@ -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>{ diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java index 9eea77e3..ec5449df 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectRegistrar.java @@ -21,77 +21,74 @@ 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()); + } } } diff --git a/auth/auth-certman/pom.xml b/auth/auth-certman/pom.xml index 76f26222..ba346e6f 100644 --- a/auth/auth-certman/pom.xml +++ b/auth/auth-certman/pom.xml @@ -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> diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java index bfdb977d..3727e34d 100644 --- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java +++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java @@ -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); } } } diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java index da634868..08c96853 100644 --- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java +++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/ca/LocalCA.java @@ -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")) { diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java index e770fec7..58efa2a0 100644 --- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java +++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/JU_AAF_CM.java @@ -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); diff --git a/auth/auth-cmd/pom.xml b/auth/auth-cmd/pom.xml index ff281d28..c0169e57 100644 --- a/auth/auth-cmd/pom.xml +++ b/auth/auth-cmd/pom.xml @@ -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> diff --git a/auth/auth-core/pom.xml b/auth/auth-core/pom.xml index 96153818..a4b01cd9 100644 --- a/auth/auth-core/pom.xml +++ b/auth/auth-core/pom.xml @@ -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> diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java index 56db6f60..497c13d6 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java @@ -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 diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java index 3e68e3ab..e064ade3 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java @@ -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; } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java index 435b8845..9ece4847 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java @@ -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 { diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java index 29166b0b..8f0eb8aa 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java @@ -19,10 +19,17 @@ * */ 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()); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java index c5849d05..d29b8f26 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java @@ -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"); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java index 6f2d4cb9..9004f76b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java @@ -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 index 00000000..78172a22 --- /dev/null +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java @@ -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"); + } +} diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java index a0ee9ef9..65f019f0 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java @@ -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. } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java index 1f5d70ae..1fe98d84 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java @@ -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); diff --git a/auth/auth-deforg/pom.xml b/auth/auth-deforg/pom.xml index 52756638..63bcb9b5 100644 --- a/auth/auth-deforg/pom.xml +++ b/auth/auth-deforg/pom.xml @@ -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> diff --git a/auth/auth-fs/pom.xml b/auth/auth-fs/pom.xml index 40df8a38..5b37469a 100644 --- a/auth/auth-fs/pom.xml +++ b/auth/auth-fs/pom.xml @@ -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> diff --git a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java index e316e015..26e49290 100644 --- a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java +++ b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java @@ -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) }; } diff --git a/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java b/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java index eef1a87b..e7e5543a 100644 --- a/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java +++ b/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_AAF_FS.java @@ -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); diff --git a/auth/auth-gui/pom.xml b/auth/auth-gui/pom.xml index a0748a2f..63a652b1 100644 --- a/auth/auth-gui/pom.xml +++ b/auth/auth-gui/pom.xml @@ -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> diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java index 2e7e5e59..d8e8914e 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java @@ -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) }; } diff --git a/auth/auth-hello/pom.xml b/auth/auth-hello/pom.xml index 7c0c38eb..dfb77a39 100644 --- a/auth/auth-hello/pom.xml +++ b/auth/auth-hello/pom.xml @@ -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> diff --git a/auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java b/auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java index 9190c665..6aee85d3 100644 --- a/auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java +++ b/auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java @@ -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) }; } diff --git a/auth/auth-locate/pom.xml b/auth/auth-locate/pom.xml index b076981b..40457cab 100644 --- a/auth/auth-locate/pom.xml +++ b/auth/auth-locate/pom.xml @@ -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> diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java index c8294d1f..2bc4447f 100644 --- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java +++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java @@ -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) }; } diff --git a/auth/auth-oauth/pom.xml b/auth/auth-oauth/pom.xml index ef0740c1..62fb3f76 100644 --- a/auth/auth-oauth/pom.xml +++ b/auth/auth-oauth/pom.xml @@ -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> diff --git a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java index 4104c34b..ef0c4da5 100644 --- a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java +++ b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java @@ -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) }; } diff --git a/auth/auth-service/pom.xml b/auth/auth-service/pom.xml index a0803b4e..bc7d2794 100644 --- a/auth/auth-service/pom.xml +++ b/auth/auth-service/pom.xml @@ -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> diff --git a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java index 4f34fd56..90d4744a 100644 --- a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java +++ b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java @@ -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) { diff --git a/auth/docker/.gitignore b/auth/docker/.gitignore index 9e4bcf51..1c98ea37 100644 --- a/auth/docker/.gitignore +++ b/auth/docker/.gitignore @@ -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 index 00000000..623d18d4 --- /dev/null +++ b/auth/docker/Dockerfile.base @@ -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 + diff --git a/auth/docker/Dockerfile.client b/auth/docker/Dockerfile.client index dab925b0..c2e1d787 100644 --- a/auth/docker/Dockerfile.client +++ b/auth/docker/Dockerfile.client @@ -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"] diff --git a/auth/docker/Dockerfile.config b/auth/docker/Dockerfile.config index 44109d65..d1b6b237 100644 --- a/auth/docker/Dockerfile.config +++ b/auth/docker/Dockerfile.config @@ -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 [] - diff --git a/auth/docker/Dockerfile.core b/auth/docker/Dockerfile.core index 3431ee25..a15039aa 100644 --- a/auth/docker/Dockerfile.core +++ b/auth/docker/Dockerfile.core @@ -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} diff --git a/auth/docker/Dockerfile.ms b/auth/docker/Dockerfile.ms index 9ae40c74..99ac5fca 100644 --- a/auth/docker/Dockerfile.ms +++ b/auth/docker/Dockerfile.ms @@ -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}"] diff --git a/auth/docker/aaf.sh b/auth/docker/aaf.sh index 165b0007..14166a3e 100644 --- a/auth/docker/aaf.sh +++ b/auth/docker/aaf.sh @@ -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 ;; *) diff --git a/auth/docker/agent.sh b/auth/docker/agent.sh index 88b8497e..86fee5f6 100644 --- a/auth/docker/agent.sh +++ b/auth/docker/agent.sh @@ -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 diff --git a/auth/docker/components b/auth/docker/components index 0a4a66ad..7f58dc33 100644 --- a/auth/docker/components +++ b/auth/docker/components @@ -1,7 +1,7 @@ service locate oauth -gui -fs cm +gui hello +fs diff --git a/auth/docker/d.props.init b/auth/docker/d.props.init index 2a871bd8..c406b81c 100644 --- a/auth/docker/d.props.init +++ b/auth/docker/d.props.init @@ -21,19 +21,16 @@ 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= diff --git a/auth/docker/dbash.sh b/auth/docker/dbash.sh index c91c2494..f3bb26a0 100644 --- a/auth/docker/dbash.sh +++ b/auth/docker/dbash.sh @@ -20,4 +20,4 @@ # . ./d.props -${DOCKER:=docker} exec -it aaf_$1 bash +${DOCKER:=docker} exec -it aaf-$1 bash diff --git a/auth/docker/dbuild.sh b/auth/docker/dbuild.sh index 627be95d..4eb349b9 100755 --- a/auth/docker/dbuild.sh +++ b/auth/docker/dbuild.sh @@ -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 diff --git a/auth/docker/drun.sh b/auth/docker/drun.sh index 9f770055..ed62e573 100644 --- a/auth/docker/drun.sh +++ b/auth/docker/drun.sh @@ -18,29 +18,11 @@ # 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 diff --git a/auth/docker/dstart.sh b/auth/docker/dstart.sh index 9242e46a..1bd90d5e 100644 --- a/auth/docker/dstart.sh +++ b/auth/docker/dstart.sh @@ -30,5 +30,5 @@ else fi for AAF_COMPONENT in ${AAF_COMPONENTS}; do - $DOCKER start aaf_$AAF_COMPONENT + $DOCKER start aaf-$AAF_COMPONENT done diff --git a/auth/docker/dstop.sh b/auth/docker/dstop.sh index cebf4ebf..4d302bd1 100644 --- a/auth/docker/dstop.sh +++ b/auth/docker/dstop.sh @@ -29,5 +29,5 @@ else fi for AAF_COMPONENT in ${AAF_COMPONENTS}; do - $DOCKER stop aaf_$AAF_COMPONENT + $DOCKER stop aaf-$AAF_COMPONENT done diff --git a/auth/pom.xml b/auth/pom.xml index 4b9b6112..f8b7c122 100644 --- a/auth/pom.xml +++ b/auth/pom.xml @@ -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> diff --git a/auth/sample/bin/client.sh b/auth/sample/bin/client.sh index b69646df..f4048f30 100755 --- a/auth/sample/bin/client.sh +++ b/auth/sample/bin/client.sh @@ -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 diff --git a/auth/sample/bin/pod_wait.sh b/auth/sample/bin/pod_wait.sh index 732edffc..07ff9814 100644 --- a/auth/sample/bin/pod_wait.sh +++ b/auth/sample/bin/pod_wait.sh @@ -102,4 +102,4 @@ case "$OTHER" in ;; esac -eval "$@" +eval "$@" diff --git a/auth/sample/bin/service.sh b/auth/sample/bin/service.sh index 78f6693b..20be29c4 100644 --- a/auth/sample/bin/service.sh +++ b/auth/sample/bin/service.sh @@ -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" @@ -174,11 +182,10 @@ if [ -z "$CMD" ]; then 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 diff --git a/auth/sample/etc/org.osaaf.aaf.cm.props b/auth/sample/etc/org.osaaf.aaf.cm.props index c1593e58..dc43c282 100644 --- a/auth/sample/etc/org.osaaf.aaf.cm.props +++ b/auth/sample/etc/org.osaaf.aaf.cm.props @@ -23,8 +23,10 @@ ## 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 diff --git a/auth/sample/etc/org.osaaf.aaf.fs.props b/auth/sample/etc/org.osaaf.aaf.fs.props index 7125e466..9de81af6 100644 --- a/auth/sample/etc/org.osaaf.aaf.fs.props +++ b/auth/sample/etc/org.osaaf.aaf.fs.props @@ -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 diff --git a/auth/sample/etc/org.osaaf.aaf.gui.props b/auth/sample/etc/org.osaaf.aaf.gui.props index 4228eb30..81d04ea0 100644 --- a/auth/sample/etc/org.osaaf.aaf.gui.props +++ b/auth/sample/etc/org.osaaf.aaf.gui.props @@ -22,8 +22,10 @@ ## 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. diff --git a/auth/sample/etc/org.osaaf.aaf.hello.props b/auth/sample/etc/org.osaaf.aaf.hello.props index 45299140..5add3014 100644 --- a/auth/sample/etc/org.osaaf.aaf.hello.props +++ b/auth/sample/etc/org.osaaf.aaf.hello.props @@ -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= diff --git a/auth/sample/etc/org.osaaf.aaf.locate.props b/auth/sample/etc/org.osaaf.aaf.locate.props index 41474d40..1b74f654 100644 --- a/auth/sample/etc/org.osaaf.aaf.locate.props +++ b/auth/sample/etc/org.osaaf.aaf.locate.props @@ -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= + diff --git a/auth/sample/etc/org.osaaf.aaf.oauth.props b/auth/sample/etc/org.osaaf.aaf.oauth.props index 19b657d5..a968b949 100644 --- a/auth/sample/etc/org.osaaf.aaf.oauth.props +++ b/auth/sample/etc/org.osaaf.aaf.oauth.props @@ -18,10 +18,12 @@ # ============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= + diff --git a/auth/sample/etc/org.osaaf.aaf.service.props b/auth/sample/etc/org.osaaf.aaf.service.props index 3f5e7c4a..5c9714c4 100644 --- a/auth/sample/etc/org.osaaf.aaf.service.props +++ b/auth/sample/etc/org.osaaf.aaf.service.props @@ -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= diff --git a/auth/sample/local/aaf.props b/auth/sample/local/aaf.props index 4eb70a9b..bae24d42 100644 --- a/auth/sample/local/aaf.props +++ b/auth/sample/local/aaf.props @@ -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 diff --git a/auth/sample/local/initialConfig.props b/auth/sample/local/initialConfig.props index fa2bc174..9c7e3df0 100644 --- a/auth/sample/local/initialConfig.props +++ b/auth/sample/local/initialConfig.props @@ -17,11 +17,12 @@ # limitations under the License.
# ============LICENSE_END====================================================
#
-aaf_locate_url=https://localhost:8095
-aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/AAF_NS.introspect:2.1/introspect
-aaf_oauth2_token_url=https://AAF_LOCATE_URL/AAF_NS.token:2.1/token
-aaf_url=https://AAF_LOCATE_URL/AAF_NS.service:2.1
cadi_protocols=TLSv1.1,TLSv1.2
-cm_url=https://AAF_LOCATE_URL/AAF_NS.cm:2.1
-fs_url=https://AAF_LOCATE_URL/AAF_NS.fs.2.1
-gui_url=https://AAF_LOCATE_URL/AAF_NS.gui.2.1
+
+aaf_locate_url=https://localhost:8095
+aaf_url=https://AAF_LOCATE_URL/%C%AAF_NS.service:2.1
+aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/%C%AAF_NS.introspect:2.1/introspect
+aaf_oauth2_token_url=https://AAF_LOCATE_URL/%C%AAF_NS.token:2.1/token
+cm_url=https://AAF_LOCATE_URL/%C%AAF_NS.cm:2.1
+gui_url=https://AAF_LOCATE_URL/%C%AAF_NS.gui.2.1
+fs_url=https://AAF_LOCATE_URL/%C%AAF_NS.fs.2.1
|