summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-09-16 09:22:24 -0500
committerInstrumental <jonathan.gathman@att.com>2019-09-16 16:16:51 -0500
commit07fb3ece74a9aa1fad8e2a9fab73b4de3e36853b (patch)
tree058001a686d135d76713b22db74e817f2084622a /cadi
parent7afca63faf20cf6ee680f80e08d4cfebecbab9c8 (diff)
Improved multi Proxy DNSLocator based
Issue-ID: AAF-961 Change-Id: I21d4a8013ca6f65306e32c5a2e2fa4ba230df2b7 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthn.java19
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java6
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java5
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/User.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java12
5 files changed, 33 insertions, 11 deletions
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthn.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthn.java
index ec0875c1..216468c2 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthn.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFAuthn.java
@@ -29,9 +29,10 @@ import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.User;
import org.onap.aaf.cadi.aaf.AAFPermission;
import org.onap.aaf.cadi.client.Future;
-import org.onap.aaf.cadi.client.Rcli;
import org.onap.aaf.cadi.lur.ConfigPrincipal;
+import aaf.v2_0.CredRequest;
+
public class AAFAuthn<CLIENT> extends AbsUserCache<AAFPermission> {
private AAFCon<CLIENT> con;
private String realm;
@@ -139,12 +140,16 @@ public class AAFAuthn<CLIENT> extends AbsUserCache<AAFPermission> {
try {
Miss missed = missed(getName(),getCred());
if (missed==null || missed.mayContinue()) {
- Rcli<CLIENT> client = con.client().forUser(con.basicAuth(getName(), new String(getCred())));
- Future<String> fp = client.read(
- "/authn/basicAuth",
- "text/plain"
- );
- if (fp.get(con.timeout)) {
+ CredRequest cr = new CredRequest();
+ cr.setId(getName());
+ cr.setPassword(new String(getCred()));
+ Future<String> fp = con.client().readPost("/authn/validate", con.credReqDF, cr);
+ //Rcli<CLIENT> client = con.client().forUser(con.basicAuth(getName(), new String(getCred())));
+ //Future<String> fp = client.read(
+ // "/authn/basicAuth",
+ // "text/plain"
+ // );
+ if (fp.get(con.timeout)) {
expires = System.currentTimeMillis() + timeToLive;
addUser(new User<AAFPermission>(this, expires));
return Resp.REVALIDATED;
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java
index 40684057..3b97883b 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AAFCon.java
@@ -28,6 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.onap.aaf.cadi.AbsUserCache;
import org.onap.aaf.cadi.Access;
+import org.onap.aaf.cadi.Access.Level;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.CadiWrap;
import org.onap.aaf.cadi.Connector;
@@ -36,7 +37,6 @@ import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.Lur;
import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.SecuritySetter;
-import org.onap.aaf.cadi.Access.Level;
import org.onap.aaf.cadi.aaf.AAFPermission;
import org.onap.aaf.cadi.aaf.marshal.CertsMarshal;
import org.onap.aaf.cadi.client.Future;
@@ -56,6 +56,7 @@ import org.onap.aaf.misc.rosetta.env.RosettaDF;
import org.onap.aaf.misc.rosetta.env.RosettaEnv;
import aaf.v2_0.Certs;
+import aaf.v2_0.CredRequest;
import aaf.v2_0.Error;
import aaf.v2_0.Perms;
import aaf.v2_0.Users;
@@ -69,6 +70,7 @@ public abstract class AAFCon<CLIENT> implements Connector {
final public RosettaDF<Perms> permsDF;
final public RosettaDF<Certs> certsDF;
final public RosettaDF<Users> usersDF;
+ final public RosettaDF<CredRequest> credReqDF;
final public RosettaDF<Error> errDF;
private String realm;
public final String app;
@@ -90,6 +92,7 @@ public abstract class AAFCon<CLIENT> implements Connector {
permsDF = copy.permsDF;
certsDF = copy.certsDF;
usersDF = copy.usersDF;
+ credReqDF = copy.credReqDF;
errDF = copy.errDF;
app = copy.app;
si = copy.si;
@@ -186,6 +189,7 @@ public abstract class AAFCon<CLIENT> implements Connector {
usersDF = env.newDataFactory(Users.class);
certsDF = env.newDataFactory(Certs.class);
certsDF.rootMarshal(new CertsMarshal()); // Speedier Marshaling
+ credReqDF = env.newDataFactory(CredRequest.class);
errDF = env.newDataFactory(Error.class);
} catch (APIException e) {
throw new CadiException("AAFCon cannot be configured",e);
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
index 5ef25bcd..a654e6f6 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
@@ -236,7 +236,10 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
@Override
public Item best() throws LocatorException {
if (!hasItems()) {
- throw new LocatorException("No Entries found for '" + aaf_locator_uri.toString() + '/' + name + ':' + version + '\'');
+ throw new LocatorException(String.format("No Entries found for '%s/%s:%s'",
+ (aaf_locator_uri==null?aaf_locator_host:aaf_locator_uri.toString()),
+ name,
+ version));
}
List<EP> lep = new ArrayList<>();
EP first = null;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/User.java b/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
index 4848e504..cb3b4e8f 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/User.java
@@ -40,7 +40,7 @@ public final class User<PERM extends Permission> {
public String name;
private byte[] cred;
public Principal principal;
- Map<String, Permission> perms ;
+ Map<String, Permission> perms;
long permExpires;
private final long interval;
int count;
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
index fbaa4a5a..2c9bb8c4 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
@@ -45,17 +45,20 @@ public class CSV {
private Access access;
private boolean processAll;
private char delimiter = ',';
+ private boolean go;
public CSV(Access access, File file) {
this.access = access;
csv = file;
processAll = false;
+ go = true;
}
public CSV(Access access, String csvFilename) {
this.access = access;
csv = new File(csvFilename);
processAll = false;
+ go = true;
}
public CSV setDelimiter(char delimiter) {
@@ -88,7 +91,7 @@ public class CSV {
try {
String line;
StringBuilder sb = new StringBuilder();
- while((line = br.readLine())!=null) {
+ while(go && (line = br.readLine())!=null) {
line=line.trim();
if(!line.startsWith("#") && line.length()>0) {
// System.out.println(line); uncomment to debug
@@ -268,6 +271,13 @@ public class CSV {
return csv.getAbsolutePath();
}
}
+
+ /**
+ * Provides a way to stop processing records from inside a Visit
+ */
+ public void stop() {
+ go = false;
+ }
public void delete() {
csv.delete();