<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>
<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>
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";
}
}
- 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()) {
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;
// 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());
@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>>();
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;
// 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);
// 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);
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) {
--- /dev/null
+/**
+ * ============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();
+ }
+
+}
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;
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;
final int maxBatch = 25;
// Create Intermediate Output
- File logDir = new File(logDir());
+ File logDir = logDir();
List<File> remove = new ArrayList<>();
if(args().length>0) {
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;
}
}
@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;
}
function status {
echo "$@"
- echo "$@" > $DIR/aaf_cass
+ echo "$@" > $DIR/aaf-cass
}
function wait_start {
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
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"
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
# 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 \
$PUBLISH \
-d ${PREFIX}${ORG}/${PROJECT}/aaf_cass:${VERSION} "onap"
else
- $DOCKER start aaf_cass
+ $DOCKER start aaf-cass
fi
<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>
}
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");
}
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>{
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)
*/
@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());
+ }
}
}
<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>
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;
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]);
+ }
}
}
}
@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)
};
}
}
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);
}
}
}
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();
keyStore.load(fis,ksPass);
} finally {
- if (fis != null)
+ if (fis != null) {
fis.close();
+ }
}
Entry entry;
if (fileName.endsWith(".pkcs11")) {
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);
<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>
<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>
@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
* @return
*/
public boolean isOKhasData() {
- System.out.println("specialCondition:"+specialCondition);
- System.out.println("specialCondition:"+(specialCondition & EMPTY_LIST));
return status == OK && (specialCondition & EMPTY_LIST) != EMPTY_LIST;
}
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;
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;
/**
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 {
*
*/
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;
@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) {
}
@Override
+ public void run() {
+ try {
+ _start(service);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
public void shutdown() {
if (registrar!=null) {
registrar.close(env());
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 {
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() {
protocol = "http";
} else {
protocol = "https";
+
String keystorePassword = access().getProperty(Config.CADI_KEYSTORE_PASSWORD, null);
if (keystorePassword==null) {
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.
new HttpConnectionFactory(httpConfig)
);
}
+ service.setProtocol(protocol);
+
// Setup JMX
// TODO trying to figure out how to set up/log ports
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);
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");
*/
package org.onap.aaf.auth.server;
-public interface ServiceStarter {
+public interface ServiceStarter extends Runnable {
public void start() throws Exception;
public void shutdown();
}
--- /dev/null
+/**
+ * ============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");
+ }
+}
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.
}
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);
<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>
<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>
@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)
};
}
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);
<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>
@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)
};
}
<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>
@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)
};
}
<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>
@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)
};
}
<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>
@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)
};
}
<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>
@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)
};
}
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) {
/policy*
/*.yaml
/*.orig
+/.curl_auth
+/test.sh
--- /dev/null
+#########
+# ============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
+
# 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}
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"]
# 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}
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 []
-
# 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}
# 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}
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}"]
$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
;;
*)
. ./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
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)
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
service
locate
oauth
-gui
-fs
cm
+gui
hello
+fs
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=
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=
#
. ./d.props
-${DOCKER:=docker} exec -it aaf_$1 bash
+${DOCKER:=docker} exec -it aaf-$1 bash
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
# 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}
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}
cd -
done
-rm ../aaf_${VERSION}/pod/*
-rmdir ../aaf_${VERSION}/pod
+rm ../aaf_${VERSION}/bin/pod_wait.sh
# 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
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
fi
for AAF_COMPONENT in ${AAF_COMPONENTS}; do
- $DOCKER start aaf_$AAF_COMPONENT
+ $DOCKER start aaf-$AAF_COMPONENT
done
fi
for AAF_COMPONENT in ${AAF_COMPONENTS}; do
- $DOCKER stop aaf_$AAF_COMPONENT
+ $DOCKER stop aaf-$AAF_COMPONENT
done
<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>
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
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}
bash)
shift
cd $LOCAL || exit
- /bin/bash "$@"
+ exec bash "$@"
;;
setProp)
cd $LOCAL || exit
;;
esac
-eval "$@"
+eval "$@"
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=
# 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
# 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)
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
# 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}/" \
# Now run a command
-CMD=$2
+CMD=$1
if [ -z "$CMD" ]; then
if [ -n "$INITIALIZED" ]; then
echo "Initialization Complete"
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
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
bash)
shift
cd $LOCAL || exit
- /bin/bash "$@"
+ exec /bin/bash -c "$@"
;;
setProp)
cd $LOCAL || exit
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
done
;;
taillog)
- sh /opt/app/osaaf/logs/taillog
+ sh $OSAAF/logs/taillog
;;
wait)
bash $CONFIG/bin/pod_wait.sh wait $1
## 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
## 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
## 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.
## 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=
## 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=
+
# ============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=
+
## 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=
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
# 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
<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>
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 {
} 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 {
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;
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;
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) {
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
--- /dev/null
+/**
+ * ============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 {
+ }
+}
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);
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);
}
}
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);
--- /dev/null
+/**
+ * ============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;
+ }
+}
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;
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;
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 {
}
}
- 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);
<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>
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;
@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
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) {
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();
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 {
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 {
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> {
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) {
<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>
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;
// 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());
}
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
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;
/**
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.
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.
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) {
}
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());
}
@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
* 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 {
/**
*
*/
--- /dev/null
+/**
+ * ============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;
+ }
+}
*/
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;
+ }
}
<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>
<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>
<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>
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
-aaf.osaaf.org aaf.api.simpledemo.onap.org
+aaf.osaaf.org
<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>
* @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
*
*/
-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;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.onap.aaf.misc.env.impl.JavaUtilLogTarget;
public class JU_JavaUtilLogTarget {
*
*/
-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;
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 {
<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>
<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>
<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>
<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>
<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>