summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/URFutureApproveExec.java2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/UserRole.java143
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/reports/ExpiringNext.java2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/update/Expiring.java8
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/update/NotifyCredExpiring.java2
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java71
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java17
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/test/JU_ErrMessageTest.java2
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactOnStream.java2
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java4
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java6
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_GetAccess.java2
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java4
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java40
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_SubStandardConsole.java19
-rw-r--r--misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java182
17 files changed, 254 insertions, 254 deletions
diff --git a/.gitignore b/.gitignore
index 5ca6890c..b36780dc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
/.settings/
/.project
+.idea
+*.iml
/target/
/temp/
.metadata/
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/URFutureApproveExec.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/URFutureApproveExec.java
index 635efef0..acbadca7 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/URFutureApproveExec.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/actions/URFutureApproveExec.java
@@ -75,7 +75,7 @@ public class URFutureApproveExec extends ActionDAO<List<Approval>, OP_STATUS, Fu
new Lookup<UserRoleDAO.Data>() {
@Override
public UserRoleDAO.Data get(AuthzTrans trans, Object ... keys) {
- List<UserRole> lur = UserRole.byUser.get(keys[0]);
+ List<UserRole> lur = UserRole.getByUser().get(keys[0]);
if(lur!=null) {
for(UserRole ur : lur) {
if(ur.role().equals(keys[1])) {
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/UserRole.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/UserRole.java
index a289fe00..288211e6 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/UserRole.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/UserRole.java
@@ -7,9 +7,9 @@
* 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.
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import java.util.SortedMap;
import java.util.TreeMap;
import org.onap.aaf.auth.actions.URDelete;
@@ -44,16 +45,36 @@ import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.Statement;
public class UserRole implements Cloneable, CacheChange.Data {
- public static final List<UserRole> data = new ArrayList<>();
- public static final TreeMap<String,List<UserRole>> byUser = new TreeMap<>();
- public static final TreeMap<String,List<UserRole>> byRole = new TreeMap<>();
- private final static CacheChange<UserRole> cache = new CacheChange<>();
- private static PrintStream urDelete=System.out,urRecover=System.err;
+
+ private static final String SEPARATOR = "\",\"";
+
+ // CACHE Calling
+ private static final String LOG_FMT = "%s UserRole - %s: %s-%s (%s, %s) expiring %s";
+ private static final String REPLAY_FMT = "%s|%s|%s|%s|%s\n";
+ private static final String DELETE_FMT = "# %s\n"+ REPLAY_FMT;
+
+ private static final List<UserRole> data = new ArrayList<>();
+ private static final SortedMap<String,List<UserRole>> byUser = new TreeMap<>();
+ private static final SortedMap<String,List<UserRole>> byRole = new TreeMap<>();
+ private static final CacheChange<UserRole> cache = new CacheChange<>();
+ private static PrintStream urDelete = System.out;
+ private static PrintStream urRecover = System.err;
private static int totalLoaded;
- private static int deleted;
-
+ private int deleted;
private Data urdd;
+ public static final Creator<UserRole> v2_0_11 = new Creator<UserRole>() {
+ @Override
+ public UserRole create(Row row) {
+ return new UserRole(row.getString(0), row.getString(1), row.getString(2),row.getString(3),row.getTimestamp(4));
+ }
+
+ @Override
+ public String select() {
+ return "select user,role,ns,rname,expires from authz.user_role";
+ }
+ };
+
public UserRole(String user, String ns, String rname, Date expires) {
urdd = new UserRoleDAO.Data();
urdd.user = user;
@@ -72,6 +93,18 @@ public class UserRole implements Cloneable, CacheChange.Data {
urdd.expires = expires;
}
+ public static List<UserRole> getData() {
+ return data;
+ }
+
+ public static SortedMap<String, List<UserRole>> getByUser() {
+ return byUser;
+ }
+
+ public static SortedMap<String, List<UserRole>> getByRole() {
+ return byRole;
+ }
+
public static void load(Trans trans, Session session, Creator<UserRole> creator ) {
load(trans,session,creator,null);
}
@@ -87,9 +120,9 @@ public class UserRole implements Cloneable, CacheChange.Data {
private static void load(Trans trans, Session session, Creator<UserRole> creator, String where) {
String query = creator.query(where);
trans.info().log( "query: " + query );
- TimeTaken tt = trans.start("Read UserRoles", Env.REMOTE);
-
- ResultSet results;
+ TimeTaken tt = trans.start("Read UserRoles", Env.REMOTE);
+
+ ResultSet results;
try {
Statement stmt = new SimpleStatement( query );
results = session.execute(stmt);
@@ -97,30 +130,9 @@ public class UserRole implements Cloneable, CacheChange.Data {
tt.done();
}
try {
- Iterator<Row> iter = results.iterator();
- Row row;
tt = trans.start("Load UserRole", Env.SUB);
try {
- while(iter.hasNext()) {
- ++totalLoaded;
- row = iter.next();
- UserRole ur = creator.create(row);
- data.add(ur);
-
- List<UserRole> lur = byUser.get(ur.urdd.user);
- if(lur==null) {
- lur = new ArrayList<>();
- byUser.put(ur.urdd.user, lur);
- }
- lur.add(ur);
-
- lur = byRole.get(ur.urdd.role);
- if(lur==null) {
- lur = new ArrayList<>();
- byRole.put(ur.urdd.role, lur);
- }
- lur.add(ur);
- }
+ iterateResults(creator, results.iterator());
} finally {
tt.done();
}
@@ -128,7 +140,31 @@ public class UserRole implements Cloneable, CacheChange.Data {
trans.info().log("Loaded",totalLoaded,"UserRoles");
}
}
-
+
+ private static void iterateResults(Creator<UserRole> creator, Iterator<Row> iter ) {
+ Row row;
+ while(iter.hasNext()) {
+ ++totalLoaded;
+ row = iter.next();
+ UserRole ur = creator.create(row);
+ data.add(ur);
+
+ List<UserRole> lur = byUser.get(ur.urdd.user);
+ if(lur==null) {
+ lur = new ArrayList<>();
+ byUser.put(ur.urdd.user, lur);
+ }
+ lur.add(ur);
+
+ lur = byRole.get(ur.urdd.role);
+ if(lur==null) {
+ lur = new ArrayList<>();
+ byRole.put(ur.urdd.role, lur);
+ }
+ lur.add(ur);
+ }
+ }
+
public int totalLoaded() {
return totalLoaded;
}
@@ -174,26 +210,13 @@ public class UserRole implements Cloneable, CacheChange.Data {
}
}
-
- public static Creator<UserRole> v2_0_11 = new Creator<UserRole>() {
- @Override
- public UserRole create(Row row) {
- return new UserRole(row.getString(0), row.getString(1), row.getString(2),row.getString(3),row.getTimestamp(4));
- }
-
- @Override
- public String select() {
- return "select user,role,ns,rname,expires from authz.user_role";
- }
- };
-
public UserRoleDAO.Data urdd() {
return urdd;
}
public String user() {
return urdd.user;
- };
+ }
public String role() {
return urdd.role;
@@ -215,16 +238,16 @@ public class UserRole implements Cloneable, CacheChange.Data {
urdd.expires = time;
}
-
-
public String toString() {
- return "\"" + urdd.user + "\",\"" + urdd.role + "\",\"" + urdd.ns + "\",\"" + urdd.rname + "\",\""+ Chrono.dateOnlyStamp(urdd.expires);
+ return "\"" + urdd.user + SEPARATOR + urdd.role + SEPARATOR + urdd.ns + SEPARATOR + urdd.rname + SEPARATOR
+ + Chrono.dateOnlyStamp(urdd.expires);
}
public static UserRole get(String u, String r) {
List<UserRole> lur = byUser.get(u);
if(lur!=null) {
for(UserRole ur : lur) {
+
if(ur.urdd.role.equals(r)) {
return ur;
}
@@ -232,23 +255,18 @@ public class UserRole implements Cloneable, CacheChange.Data {
}
return null;
}
-
- // CACHE Calling
- private static final String logfmt = "%s UserRole - %s: %s-%s (%s, %s) expiring %s";
- private static final String replayfmt = "%s|%s|%s|%s|%s\n";
- private static final String deletefmt = "# %s\n"+replayfmt;
-
+
// SAFETY - DO NOT DELETE USER ROLES DIRECTLY FROM BATCH FILES!!!
// We write to a file, and validate. If the size is iffy, we email Support
public void delayDelete(AuthzTrans trans, String text, boolean dryRun) {
String dt = Chrono.dateTime(urdd.expires);
if(dryRun) {
- trans.info().printf(logfmt,text,"Would Delete",urdd.user,urdd.role,urdd.ns,urdd.rname,dt);
+ trans.info().printf(LOG_FMT,text,"Would Delete",urdd.user,urdd.role,urdd.ns,urdd.rname,dt);
} else {
- trans.info().printf(logfmt,text,"Staged Deletion",urdd.user,urdd.role,urdd.ns,urdd.rname,dt);
+ trans.info().printf(LOG_FMT,text,"Staged Deletion",urdd.user,urdd.role,urdd.ns,urdd.rname,dt);
}
- urDelete.printf(deletefmt,text,urdd.user,urdd.role,dt,urdd.ns,urdd.rname);
- urRecover.printf(replayfmt,urdd.user,urdd.role,dt,urdd.ns,urdd.rname);
+ urDelete.printf(DELETE_FMT,text,urdd.user,urdd.role,dt,urdd.ns,urdd.rname);
+ urRecover.printf(REPLAY_FMT,urdd.user,urdd.role,dt,urdd.ns,urdd.rname);
cache.delayedDelete(this);
++deleted;
@@ -278,5 +296,4 @@ public class UserRole implements Cloneable, CacheChange.Data {
cache.resetLocalData();
}
-
} \ No newline at end of file
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/reports/ExpiringNext.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/reports/ExpiringNext.java
index 8e0257fd..67282915 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/reports/ExpiringNext.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/reports/ExpiringNext.java
@@ -76,7 +76,7 @@ public class ExpiringNext extends Batch {
List<String> expiring = new ArrayList<>();
trans.info().log("Checking for Expired UserRoles");
- for(UserRole ur : UserRole.data) {
+ for(UserRole ur : UserRole.getData()) {
if(ur.expires().after(now)) {
if(ur.expires().before(twoWeeks)) {
expiring.add(Chrono.dateOnlyStamp(ur.expires()) + ":\t" + ur.user() + '\t' + ur.role());
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/update/Expiring.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/update/Expiring.java
index f3388326..e12a452a 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/update/Expiring.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/update/Expiring.java
@@ -305,7 +305,7 @@ public class Expiring extends Batch {
// Make sure Owner Role exists
String owner = role.ns + ".owner";
if(Role.byName.containsKey(owner)) {
- List<UserRole> lur = UserRole.byRole.get(owner);
+ List<UserRole> lur = UserRole.getByRole().get(owner);
if(lur != null) {
for(UserRole ur : lur) {
if(ur.user().equals(app.getApprover())) {
@@ -360,7 +360,7 @@ public class Expiring extends Batch {
// Run for User Roles
trans.info().log("Checking for Expired User Roles");
try {
- for(UserRole ur : UserRole.data) {
+ for(UserRole ur : UserRole.getData()) {
if(org.getIdentity(noAvg, ur.user())==null) { // if not part of Organization;
if(isSpecial(ur.user())) {
trans.info().log(ur.user(),"is not part of organization, but may not be deleted");
@@ -421,11 +421,11 @@ public class Expiring extends Batch {
if(UserRole.sizeForDeletion()>0) {
count+=UserRole.sizeForDeletion();
double onePercent = 0.01;
- if(((double)UserRole.sizeForDeletion())/UserRole.data.size() > onePercent) {
+ if(((double)UserRole.sizeForDeletion())/UserRole.getData().size() > onePercent) {
Message msg = new Message();
try {
msg.line("Found %d of %d UserRoles marked for Deletion in file %s",
- delayedURDeletes,UserRole.data.size(),deletesFile.getCanonicalPath());
+ delayedURDeletes,UserRole.getData().size(),deletesFile.getCanonicalPath());
} catch (IOException e) {
msg.line("Found %d of %d UserRoles marked for Deletion.\n",
delayedURDeletes);
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/update/NotifyCredExpiring.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/update/NotifyCredExpiring.java
index c9f04f73..fe8f16d9 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/update/NotifyCredExpiring.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/update/NotifyCredExpiring.java
@@ -142,7 +142,7 @@ public class NotifyCredExpiring extends Batch {
for(Cred c : es.getValue()) {
last = c.last(CredDAO.BASIC_AUTH,CredDAO.BASIC_AUTH_SHA256);
if(last!=null && last.after(tooLate) && last.before(early)) {
- List<UserRole> ownerURList = UserRole.byRole.get(es.getKey()+".owner");
+ List<UserRole> ownerURList = UserRole.getByRole().get(es.getKey()+".owner");
if(ownerURList!=null) {
for(UserRole ur:ownerURList) {
String owner = ur.user();
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java
index dee788e4..376ae1b1 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/service/CMService.java
@@ -74,15 +74,16 @@ public class CMService {
public static final String REQUEST = "request";
public static final String RENEW = "renew";
public static final String DROP = "drop";
-// public static final String SANS = "san";
public static final String IPS = "ips";
public static final String DOMAIN = "domain";
+
+ private static final String CERTMAN = ".certman";
+ private static final String ACCESS = ".access";
private static final String[] NO_NOTES = new String[0];
private final CertDAO certDAO;
private final CredDAO credDAO;
private final ArtiDAO artiDAO;
-// private DAO<AuthzTrans, ?>[] daos;
private AAF_CM certman;
// @SuppressWarnings("unchecked")
@@ -94,11 +95,7 @@ public class CMService {
certDAO = new CertDAO(trans, hd, cid);
credDAO = new CredDAO(trans, hd, cid);
artiDAO = new ArtiDAO(trans, hd, cid);
-
-// daos =(DAO<AuthzTrans, ?>[]) new DAO<?,?>[] {
-// hd,cid,certDAO,credDAO,artiDAO
-// };
-//
+
this.certman = certman;
}
@@ -119,7 +116,7 @@ public class CMService {
// Disallow non-AAF CA without special permission
- if(!ca.getName().equals("aaf") && !trans.fish( new AAFPermission(mechNS+".certman", ca.getName(), REQUEST))) {
+ if(!"aaf".equals(ca.getName()) && !trans.fish( new AAFPermission(mechNS+CERTMAN, ca.getName(), REQUEST))) {
return Result.err(Status.ERR_Denied, "'%s' does not have permission to request Certificates from Certificate Authority '%s'",
trans.user(),ca.getName());
}
@@ -135,7 +132,7 @@ public class CMService {
InetAddress primary = null;
// Organize incoming information to get to appropriate Artifact
- if(fqdns.size()>=1) {
+ if(!fqdns.isEmpty()) {
// Accept domain wild cards, but turn into real machines
// Need *domain.com:real.machine.domain.com:san.machine.domain.com:...
if(fqdns.get(0).startsWith("*")) { // Domain set
@@ -146,16 +143,16 @@ public class CMService {
//TODO check for Permission in Add Artifact?
String domain = fqdns.get(0).substring(1);
fqdns.remove(0);
- if(fqdns.size()>=1) {
- InetAddress ia = InetAddress.getByName(fqdns.get(0));
- if(ia==null) {
- return Result.err(Result.ERR_Denied, "Request not made from matching IP matching domain");
- } else if(ia.getHostName().endsWith(domain)) {
- primary = ia;
- }
- } else {
- return Result.err(Result.ERR_Denied, "Requests using domain require machine declaration");
- }
+ if(fqdns.isEmpty()) {
+ return Result.err(Result.ERR_Denied, "Requests using domain require machine declaration");
+ }
+
+ InetAddress ia = InetAddress.getByName(fqdns.get(0));
+ if(ia==null) {
+ return Result.err(Result.ERR_Denied, "Request not made from matching IP matching domain");
+ } else if(ia.getHostName().endsWith(domain)) {
+ primary = ia;
+ }
} else {
for(String cn : req.value.fqdns) {
@@ -180,7 +177,6 @@ public class CMService {
if(primary==null) {
return Result.err(Result.ERR_Denied, "Request not made from matching IP (%s)",trans.ip());
-// return Result.err(Result.ERR_BadData,"Calling Machine does not match DNS lookup for %s",req.value.fqdns.get(0));
}
ArtiDAO.Data add = null;
@@ -247,25 +243,10 @@ public class CMService {
}
// Policy 7: Caller must be the MechID or have specifically delegated permissions
- if(!(trans.user().equals(req.value.mechid) || trans.fish(new AAFPermission(mechNS + ".certman", ca.getName() , "request")))) {
+ if(!(trans.user().equals(req.value.mechid) || trans.fish(new AAFPermission(mechNS + CERTMAN, ca.getName() , REQUEST)))) {
return Result.err(Status.ERR_Denied, "%s must have access to modify x509 certs in NS %s",trans.user(),mechNS);
}
- // Policy 8: SANs only allowed by Exception... need permission
- // 7/25/2017 - SAN Permission no longer required. CSO
-// if(fqdns.size()>1 && !certman.aafLurPerm.fish(
-// new Principal() {
-// @Override
-// public String getName() {
-// return req.value.mechid;
-// }
-// },
-// new AAFPermission(ca.getPermType(), ca.getName(), SANS))) {
-// if(notes==null) {notes = new ArrayList<>();}
-// notes.add("Warning: Subject Alternative Names only allowed by Permission: Get CSO Exception.");
-// return Result.err(Status.ERR_Denied, "%s must have a CSO Exception to work with SAN",trans.user());
-// }
-
// Make sure Primary is the first in fqdns
if(fqdns.size()>1) {
for(int i=0;i<fqdns.size();++i) {
@@ -295,9 +276,6 @@ public class CMService {
return Result.err(Result.ERR_ActionNotCompleted,"x509 Certificate not signed by CA");
}
trans.info().printf("X509 Subject: %s", x509ac.getX509().getSubjectDN());
-// for(String s: x509ac.getTrustChain()) {
-// trans.warn().printf("Trust Cert: \n%s", s);
-// }
X509Certificate x509 = x509ac.getX509();
CertDAO.Data cdd = new CertDAO.Data();
@@ -349,7 +327,7 @@ public class CMService {
String ns = Question.domain2ns(mechID);
try {
if( trans.user().equals(mechID)
- || trans.fish(new AAFPermission(ns + ".access", "*", "read"))
+ || trans.fish(new AAFPermission(ns + ACCESS, "*", "read"))
|| (trans.org().validate(trans,Organization.Policy.OWNS_MECHID,null,mechID))==null) {
return certDAO.readID(trans, mechID);
} else {
@@ -496,9 +474,9 @@ public class CMService {
}
add = data.value.get(0);
if( trans.user().equals(add.mechid)
- || trans.fish(new AAFPermission(add.ns + ".access", "*", "read"))
- || trans.fish(new AAFPermission(add.ns+".certman",add.ca,"read"))
- || trans.fish(new AAFPermission(add.ns+".certman",add.ca,"request"))
+ || trans.fish(new AAFPermission(add.ns + ACCESS, "*", "read"))
+ || trans.fish(new AAFPermission(add.ns+CERTMAN,add.ca,"read"))
+ || trans.fish(new AAFPermission(add.ns+CERTMAN,add.ca,"request"))
|| (trans.org().validate(trans,Organization.Policy.OWNS_MECHID,null,add.mechid))==null) {
return data;
} else {
@@ -516,7 +494,7 @@ public class CMService {
String ns = FQI.reverseDomain(mechid);
String reason;
- if(trans.fish(new AAFPermission(ns + ".access", "*", "read"))
+ if(trans.fish(new AAFPermission(ns + ACCESS, "*", "read"))
|| (reason=trans.org().validate(trans,Organization.Policy.OWNS_MECHID,null,mechid))==null) {
return artiDAO.readByMechID(trans, mechid);
} else {
@@ -547,8 +525,7 @@ public class CMService {
// TODO do some checks?
- Result<List<ArtiDAO.Data>> rv = artiDAO.readByNs(trans, ns);
- return rv;
+ return artiDAO.readByNs(trans, ns);
}
@@ -646,7 +623,7 @@ public class CMService {
String ns = FQI.reverseDomain(add.mechid);
- if(trans.fish(new AAFPermission(ns + ".access", "*", "write"))
+ if(trans.fish(new AAFPermission(ns + ACCESS, "*", "write"))
|| trans.user().equals(sponsor)) {
return artiDAO.delete(trans, add, false);
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java
index de20e476..8302e771 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java
@@ -43,9 +43,9 @@ public class Validator {
public static final Pattern ID_CHARS = Pattern.compile("[\\w.-]+@[\\w.-]+");
public static final Pattern NAME_CHARS = Pattern.compile("[\\w.-]+");
public static final Pattern DESC_CHAR = Pattern.compile("["+ESSENTIAL+"\\x20]+");
- public static List<String> nsKeywords;
- protected final Pattern actionChars;
- protected final Pattern instChars;
+ protected static List<String> nsKeywords;
+ private final Pattern actionChars;
+ private final Pattern instChars;
private StringBuilder msgs;
static {
@@ -110,7 +110,7 @@ public class Validator {
if(res==null) {
msgs.append("Result object is blank");
} else if(res.notOK()) {
- msgs.append(res.getClass().getSimpleName() + " is not OK");
+ msgs.append(res.getClass().getSimpleName()).append(" is not OK");
}
return this;
}
@@ -130,10 +130,8 @@ public class Validator {
}
protected Validator description(String type, String description) {
- if(description!=null) {
- if(noMatch(description, DESC_CHAR)) {
- msg(type + " Description is invalid.");
- }
+ if (description != null && noMatch(description, DESC_CHAR)) {
+ msg(type + " Description is invalid.");
}
return this;
}
@@ -151,7 +149,7 @@ public class Validator {
} else if(ns==null) {
msg("Perm NS is null");
} else if(nob(type,NAME_CHARS)) {
- msg("Perm Type [" + (ns+(type.length()==0?"":'.'))+type + "] is invalid.");
+ msg("Perm Type [" + (ns+(type.length()==0?"":'.')) + type + "] is invalid.");
}
return this;
}
@@ -208,4 +206,5 @@ public class Validator {
return this;
}
+
}
diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/test/JU_ErrMessageTest.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/test/JU_ErrMessageTest.java
index 273affd3..bb2edfb8 100644
--- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/test/JU_ErrMessageTest.java
+++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/test/JU_ErrMessageTest.java
@@ -102,7 +102,7 @@ public class JU_ErrMessageTest {
when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error);
errMessage.printErr(new PrintStream(errStream), attErrJson);
- assertEquals("Error Message Id Error Text\n", errStream.toString());
+ assertEquals("Error Message Id Error Text" + System.lineSeparator(), errStream.toString());
}
@Test
diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactOnStream.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactOnStream.java
index 3d8f41c6..7f9cc765 100644
--- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactOnStream.java
+++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactOnStream.java
@@ -72,7 +72,7 @@ public class JU_PlaceArtifactOnStream {
PlaceArtifactOnStream placer = new PlaceArtifactOnStream(new PrintStream(outStream));
placer.place(transMock, certInfoMock, artiMock, "machine");
- String[] output = outStream.toString().split("\n", 0);
+ String[] output = outStream.toString().split(System.lineSeparator(), 0);
String[] expected = {
"Challenge: " + luggagePassword,
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java
index 1478cafe..81140d23 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java
@@ -64,7 +64,7 @@ public class JU_HClientHotPeerLocator {
loc = new HClientHotPeerLocator(access, urlStr, 0, "38.627", "-90.199", ssMock);
assertThat(loc.hasItems(), is(true));
- String[] messages = outStream.toString().split("\n");
+ String[] messages = outStream.toString().split(System.lineSeparator());
String preffered = messages[0].split(" ", 4)[3];
String alternate = messages[1].split(" ", 4)[3];
assertThat(preffered, is("Preferred Client is " + goodURL1));
@@ -97,7 +97,7 @@ public class JU_HClientHotPeerLocator {
HClientHotPeerLocator loc;
String urlStr = goodURL1 + ',' + goodURL2 + ',' + badURL;
loc = new HClientHotPeerLocator(access, urlStr, 1000000, "38.627", "-90.199", ssMock);
- String[] messages = outStream.toString().split("\n");
+ String[] messages = outStream.toString().split(System.lineSeparator());
String preffered = messages[0].split(" ", 4)[3];
String alternate1 = messages[1].split(" ", 4)[3];
String alternate2 = messages[2].split(" ", 4)[3];
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java
index 586c50c7..eaa3376d 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_Get.java
@@ -76,19 +76,19 @@ public class JU_Get {
assertThat(accessGet.get("tag", defaultVal, true), is("value"));
output = outStream.toString().split(" ", 2)[1];
- assertThat(output, is("INIT [cadi] tag is set to value\n"));
+ assertThat(output, is("INIT [cadi] tag is set to value" + System.lineSeparator()));
outStream.reset();
assertThat(accessGet.get("not a real tag", defaultVal, true), is(defaultVal));
output = outStream.toString().split(" ", 2)[1];
- assertThat(output, is("INIT [cadi] not a real tag is set to " + defaultVal + "\n"));
+ assertThat(output, is("INIT [cadi] not a real tag is set to " + defaultVal + System.lineSeparator()));
outStream.reset();
assertThat(accessGet.get("not a real tag", null, true), is(nullValue()));
output = outStream.toString().split(" ", 2)[1];
- assertThat(output, is("INIT [cadi] not a real tag is not set\n"));
+ assertThat(output, is("INIT [cadi] not a real tag is not set" + System.lineSeparator()));
outStream.reset();
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_GetAccess.java b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_GetAccess.java
index 36da3073..d50f9e8c 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_GetAccess.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/config/test/JU_GetAccess.java
@@ -72,7 +72,7 @@ public class JU_GetAccess {
@SuppressWarnings("unused")
GetAccess getAccess = new GetAccess(accessGet);
- String[] lines = outStream.toString().split("\n");
+ String[] lines = outStream.toString().split(System.lineSeparator());
assertThat(lines.length, is(2));
output = lines[0].split(" ", 2)[1];
assertThat(output, is("INIT [cadi] cadi_prop_files is set to " + filePath));
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java
index 11877dea..1737710a 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AbsUserCache.java
@@ -113,7 +113,7 @@ public class JU_AbsUserCache {
expected.append(String.valueOf(cleanInterval));
expected.append(" ms and max objects of ");
expected.append(String.valueOf(maxInterval));
- expected.append("\n");
+ expected.append(System.lineSeparator());
assertThat(output, is(expected.toString()));
outStream.reset();
@@ -124,7 +124,7 @@ public class JU_AbsUserCache {
expected.append(String.valueOf(cleanInterval));
expected.append(" ms and max objects of ");
expected.append(String.valueOf(maxInterval));
- expected.append("\n");
+ expected.append(System.lineSeparator());
assertThat(output, is(expected.toString()));
AbsUserCacheStub<Permission> aucs3 = new AbsUserCacheStub<Permission>(access, 0, 0, Integer.MAX_VALUE);
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java
index 76cd225d..bf4304d9 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CmdLine.java
@@ -111,7 +111,7 @@ public class JU_CmdLine {
public void decode64Test() throws Exception {
String encrypted = Symm.base64.encode(password);
CmdLine.main(new String[]{"decode64", encrypted});
- assertThat(outContent.toString(), is(password + "\n"));
+ assertThat(outContent.toString(), is(password + System.lineSeparator()));
}
@Test
@@ -125,19 +125,19 @@ public class JU_CmdLine {
public void decode64urlTest() throws Exception {
String encrypted = Symm.base64url.encode(password);
CmdLine.main(new String[]{"decode64url", encrypted});
- assertThat(outContent.toString(), is(password + "\n"));
+ assertThat(outContent.toString(), is(password + System.lineSeparator()));
}
@Test
public void md5Test() throws Exception {
CmdLine.main(new String[]{"md5", quickBrownFoxPlain});
- assertThat(outContent.toString(), is(quickBrownFoxMD5 + "\n"));
+ assertThat(outContent.toString(), is(quickBrownFoxMD5 + System.lineSeparator()));
}
@Test
public void sha256Test() throws Exception {
CmdLine.main(new String[]{"sha256", quickBrownFoxPlain});
- assertThat(outContent.toString(), is(quickBrownFoxSHA256 + "\n"));
+ assertThat(outContent.toString(), is(quickBrownFoxSHA256 + System.lineSeparator()));
outContent.reset();
CmdLine.main(new String[]{"sha256", quickBrownFoxPlain, "10"});
@@ -169,7 +169,7 @@ public class JU_CmdLine {
File keyfile = new File(filePath);
assertTrue(Files.isReadable(Paths.get(filePath)));
assertFalse(Files.isWritable(Paths.get(filePath)));
- assertFalse(Files.isExecutable(Paths.get(filePath)));
+ //assertFalse(Files.isExecutable(Paths.get(filePath)));
keyfile.delete();
}
@@ -227,21 +227,21 @@ public class JU_CmdLine {
@Test
public void showHelpTest() {
- String expected =
- "Usage: java -jar <this jar> ...\n" +
- " keygen [<keyfile>] (Generates Key on file, or Std Out)\n" +
- " digest [<passwd>|-i|] <keyfile> (Encrypts Password with \"keyfile\"\n" +
- " if passwd = -i, will read StdIn\n" +
- " if passwd is blank, will ask securely)\n" +
- " passgen <digits> (Generate Password of given size)\n" +
- " urlgen <digits> (Generate URL field of given size)\n" +
- " encode64 <your text> (Encodes to Base64)\n" +
- " decode64 <base64 encoded text> (Decodes from Base64)\n" +
- " encode64url <your text> (Encodes to Base64 URL charset)\n" +
- " decode64url <base64url encoded text> (Decodes from Base64 URL charset)\n" +
- " sha256 <text> <salts(s)> (Digest String into SHA256 Hash)\n" +
- " md5 <text> (Digest String into MD5 Hash)\n"
- ;
+ String lineSeparator = System.lineSeparator();
+ String expected =
+ "Usage: java -jar <this jar> ..." + lineSeparator +
+ " keygen [<keyfile>] (Generates Key on file, or Std Out)" + lineSeparator +
+ " digest [<passwd>|-i|] <keyfile> (Encrypts Password with \"keyfile\"" + lineSeparator +
+ " if passwd = -i, will read StdIn" + lineSeparator +
+ " if passwd is blank, will ask securely)" + lineSeparator +
+ " passgen <digits> (Generate Password of given size)" + lineSeparator +
+ " urlgen <digits> (Generate URL field of given size)" + lineSeparator +
+ " encode64 <your text> (Encodes to Base64)" + lineSeparator +
+ " decode64 <base64 encoded text> (Decodes from Base64)" + lineSeparator +
+ " encode64url <your text> (Encodes to Base64 URL charset)" + lineSeparator +
+ " decode64url <base64url encoded text> (Decodes from Base64 URL charset)" + lineSeparator +
+ " sha256 <text> <salts(s)> (Digest String into SHA256 Hash)" + lineSeparator +
+ " md5 <text> (Digest String into MD5 Hash)" + lineSeparator;
CmdLine.main(new String[]{});
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_SubStandardConsole.java b/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_SubStandardConsole.java
index 4d8e8f84..712b9891 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_SubStandardConsole.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/util/test/JU_SubStandardConsole.java
@@ -39,6 +39,7 @@ public class JU_SubStandardConsole {
private String inputString = "An input string";
private ByteArrayOutputStream outStream;
private ByteArrayOutputStream errStream;
+ private String lineSeparator = System.lineSeparator();
@Before
public void setup() {
@@ -59,9 +60,9 @@ public class JU_SubStandardConsole {
byte[] input = inputString.getBytes();
System.setIn(new ByteArrayInputStream(input));
SubStandardConsole ssc = new SubStandardConsole();
- String output = ssc.readLine("%s\n", ">>> ");
+ String output = ssc.readLine("%s" + lineSeparator, ">>> ");
assertThat(output, is(inputString));
- assertThat(outStream.toString(), is(">>> \n"));
+ assertThat(outStream.toString(), is(">>> " + lineSeparator));
}
@Test
@@ -69,7 +70,7 @@ public class JU_SubStandardConsole {
byte[] input = inputString.getBytes();
System.setIn(new ByteArrayInputStream(input));
SubStandardConsole ssc = new SubStandardConsole();
- String output = ssc.readLine("%s %s\n", ">>> ", "Another argument for coverage");
+ String output = ssc.readLine("%s %s" + lineSeparator, ">>> ", "Another argument for coverage");
assertThat(output, is(inputString));
}
@@ -78,9 +79,9 @@ public class JU_SubStandardConsole {
byte[] input = "\n".getBytes();
System.setIn(new ByteArrayInputStream(input));
SubStandardConsole ssc = new SubStandardConsole();
- String output = ssc.readLine("%s\n", ">>> ");
+ String output = ssc.readLine("%s" + lineSeparator, ">>> ");
assertThat(output, is(">>> "));
- assertThat(outStream.toString(), is(">>> \n"));
+ assertThat(outStream.toString(), is(">>> " + lineSeparator));
}
@Test
@@ -88,10 +89,10 @@ public class JU_SubStandardConsole {
byte[] input = inputString.getBytes();
System.setIn(new ByteArrayInputStream(input));
SubStandardConsole ssc = new SubStandardConsole();
- char[] output = ssc.readPassword("%s\n", ">>> ");
+ char[] output = ssc.readPassword("%s" + lineSeparator, ">>> ");
System.out.println(output);
assertThat(output, is(inputString.toCharArray()));
- assertThat(outStream.toString(), is(">>> \nAn input string\n"));
+ assertThat(outStream.toString(), is(">>> " + lineSeparator + "An input string" + lineSeparator));
}
@Test
@@ -115,10 +116,10 @@ public class JU_SubStandardConsole {
brField.set(ssc, brMock);
assertThat(ssc.readLine(""), is(""));
- assertThat(errStream.toString(), is("uh oh...\n"));
+ assertThat(errStream.toString(), is("uh oh..." + lineSeparator));
errStream.reset();
assertThat(ssc.readPassword("").length, is(0));
- assertThat(errStream.toString(), is("uh oh...\n"));
+ assertThat(errStream.toString(), is("uh oh..." + lineSeparator));
}
}
diff --git a/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java b/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java
index b96d6dd0..8c47a409 100644
--- a/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java
+++ b/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java
@@ -1,89 +1,93 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-package org.onap.aaf.misc.env.log4j;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JU_LogFileNamerTest {
- private File dir = new File(".");
-
- private String ending = new SimpleDateFormat("YYYYMMdd").format(new Date());
-
- @Before
- public void setUp() throws Exception {
- }
-
- @Test
- public void test() throws IOException {
- LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "log");
- assertEquals(logFileNamer, logFileNamer.noPID());
-
- logFileNamer.setAppender("Append");
- assertEquals(System.getProperty("LOG4J_FILENAME_Append"), dir.getCanonicalFile()+"/log-Append" + ending + "_0.log");
-
- logFileNamer.setAppender("Append");
- assertEquals(System.getProperty("LOG4J_FILENAME_Append"), dir.getCanonicalFile()+"/log-Append" + ending + "_1.log");
- }
-
- @Test
- public void testBlankRoot() throws IOException {
- LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "");
- assertEquals(logFileNamer, logFileNamer.noPID());
-
- logFileNamer.setAppender("Append");
- assertEquals(System.getProperty("LOG4J_FILENAME_Append"), dir.getCanonicalPath()+"/Append" + ending + "_0.log");
-
- logFileNamer.setAppender("Append");
- assertEquals(System.getProperty("LOG4J_FILENAME_Append"), dir.getCanonicalPath()+"/Append" + ending + "_1.log");
- }
-
- @After
- public void tearDown() throws IOException {
- File file = new File("./log-Append" + ending + "_0.log");
- if (file.exists()) {
- Files.delete(Paths.get(file.getAbsolutePath()));
- }
- file = new File("./log-Append" + ending + "_1.log");
- if (file.exists()) {
- Files.delete(Paths.get(file.getAbsolutePath()));
- }
- file = new File("./Append" + ending + "_0.log");
- if (file.exists()) {
- Files.delete(Paths.get(file.getAbsolutePath()));
- }
- file = new File("./Append" + ending + "_1.log");
- if (file.exists()) {
- Files.delete(Paths.get(file.getAbsolutePath()));
- }
- }
-
-}
+/**
+ * ============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.misc.env.log4j;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JU_LogFileNamerTest {
+ private File dir = new File(".");
+
+ private String ending = new SimpleDateFormat("YYYYMMdd").format(new Date());
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void test() throws IOException {
+ LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "log");
+ assertEquals(logFileNamer, logFileNamer.noPID());
+
+ logFileNamer.setAppender("Append");
+ assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
+ dir.getCanonicalFile() + File.separator + "log-Append" + ending + "_0.log");
+
+ logFileNamer.setAppender("Append");
+ assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
+ dir.getCanonicalFile() + File.separator + "log-Append" + ending + "_1.log");
+ }
+
+ @Test
+ public void testBlankRoot() throws IOException {
+ LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "");
+ assertEquals(logFileNamer, logFileNamer.noPID());
+
+ logFileNamer.setAppender("Append");
+ assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
+ dir.getCanonicalPath() + File.separator + "Append" + ending + "_0.log");
+
+ logFileNamer.setAppender("Append");
+ assertEquals(System.getProperty("LOG4J_FILENAME_Append"),
+ dir.getCanonicalPath() + File.separator + "Append" + ending + "_1.log");
+ }
+
+ @After
+ public void tearDown() throws IOException {
+ File file = new File("./log-Append" + ending + "_0.log");
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+ file = new File("./log-Append" + ending + "_1.log");
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+ file = new File("./Append" + ending + "_0.log");
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+ file = new File("./Append" + ending + "_1.log");
+ if (file.exists()) {
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+ }
+
+}