summaryrefslogtreecommitdiffstats
path: root/auth/auth-core
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-core')
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java10
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java44
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CodeSetter.java3
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java15
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java2
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java11
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java2
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java10
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java21
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java2
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java18
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java14
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java27
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java14
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/validation/Validator.java22
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java2
16 files changed, 88 insertions, 129 deletions
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java
index bf9f57e3..52b86ccb 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Acceptor.java
@@ -106,10 +106,14 @@ class Acceptor<TRANS extends Trans> {
* @return
*/
protected boolean parse(HttpCode<TRANS, ?> code, String cntnt) {
- byte bytes[] = cntnt.getBytes();
+ byte[] bytes = cntnt.getBytes();
- int cis,cie=-1,cend;
- int sis,sie,send;
+ int cis;
+ int cie=-1;
+ int cend;
+ int sis;
+ int sie;
+ int send;
String name;
ArrayList<String> props = new ArrayList<>();
do {
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java
index 3c76e928..cdda50db 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CachingFileAccess.java
@@ -72,20 +72,20 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
}
}
- private static String MAX_AGE = "max-age=3600"; // 1 hour Caching
+ private static String maxAge = "max-age=3600"; // 1 hour Caching
private final Map<String,String> typeMap;
private final NavigableMap<String,Content> content;
private final Set<String> attachOnly;
- public final static String CFA_WEB_PATH = "aaf_cfa_web_path";
+ public static final String CFA_WEB_PATH = "aaf_cfa_web_path";
// when to re-validate from file
// Re validating means comparing the Timestamp on the disk, and seeing it has changed. Cache is not marked
// dirty unless file has changed, but it still makes File IO, which for some kinds of cached data, i.e.
// deployed GUI elements is unnecessary, and wastes time.
// This parameter exists to cover the cases where data can be more volatile, so the user can choose how often the
// File IO will be accessed, based on probability of change. "0", of course, means, check every time.
- private final static String CFA_CACHE_CHECK_INTERVAL = "aaf_cfa_cache_check_interval";
- private final static String CFA_MAX_SIZE = "aaf_cfa_max_size"; // Cache size limit
- private final static String CFA_CLEAR_COMMAND = "aaf_cfa_clear_command";
+ private static final String CFA_CACHE_CHECK_INTERVAL = "aaf_cfa_cache_check_interval";
+ private static final String CFA_MAX_SIZE = "aaf_cfa_max_size"; // Cache size limit
+ private static final String CFA_CLEAR_COMMAND = "aaf_cfa_clear_command";
// Note: can be null without a problem, but included
// to tie in with existing Logging.
@@ -93,12 +93,14 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
public long checkInterval; // = 600000L; // only check if not hit in 10 mins by default
public int maxItemSize; // = 512000; // max file 500k
private Timer timer;
- private String web_path;
+ private String webPath;
// A command key is set in the Properties, preferably changed on deployment.
// it is compared at the beginning of the path, and if so, it is assumed to issue certain commands
// It's purpose is to protect, to some degree the command, even though it is HTTP, allowing
// local batch files to, for instance, clear caches on resetting of files.
- private String clear_command;
+ private String clearCommand;
+
+ public static final String TEXT_PLAIN = "text/plain";
public CachingFileAccess(EnvJAXB env, String ... args) throws IOException {
super(null,"Caching File Access");
@@ -112,7 +114,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
typeMap.put("html","text/html");
typeMap.put("css","text/css");
typeMap.put("js","text/javascript");
- typeMap.put("txt","text/plain");
+ typeMap.put("txt", TEXT_PLAIN);
typeMap.put("xml","text/xml");
typeMap.put("xsd","text/xml");
attachOnly.add("xsd");
@@ -128,7 +130,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
typeMap.put("jar","application/x-java-applet");
typeMap.put("jnlp", "application/x-java-jnlp-file");
typeMap.put("class", "application/java");
- typeMap.put("props", "text/plain");
+ typeMap.put("props", TEXT_PLAIN);
typeMap.put("jks", "application/octet-stream");
// Fonts
@@ -141,8 +143,8 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
timer.schedule(new Cleanup(content,500),60000,60000);
// Property params
- web_path = env.get(env.staticSlot(CFA_WEB_PATH));
- env.init().log("CachingFileAccess path: " + new File(web_path).getCanonicalPath());
+ webPath = env.get(env.staticSlot(CFA_WEB_PATH));
+ env.init().log("CachingFileAccess path: " + new File(webPath).getCanonicalPath());
Object obj;
obj = env.get(env.staticSlot(CFA_CACHE_CHECK_INTERVAL),600000L); // Default is 10 mins
if (obj instanceof Long) {
@@ -158,7 +160,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
maxItemSize =Integer.parseInt((String)obj);
}
- clear_command = env.getProperty(CFA_CLEAR_COMMAND,null);
+ clearCommand = env.getProperty(CFA_CLEAR_COMMAND,null);
}
@@ -167,7 +169,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
public void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException {
String key = pathParam(req, ":key");
int slash = key.indexOf('/');
- if(key.length()>2 && slash>=0 && key.substring(0,slash).equals(clear_command)) {
+ if(key.length()>2 && slash>=0 && key.substring(0,slash).equals(clearCommand)) {
resp.setHeader("Content-Type",typeMap.get("txt"));
if ("clear".equals(key.substring(slash+1))) {
content.clear();
@@ -177,7 +179,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
}
return;
}
- Content c = load(logT , web_path,key, null, checkInterval);
+ Content c = load(logT , webPath,key, null, checkInterval);
if (c.attachmentOnly) {
resp.setHeader("Content-disposition", "attachment");
}
@@ -188,7 +190,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
public String webPath() {
- return web_path;
+ return webPath;
}
/**
@@ -308,7 +310,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
@Override
public void setHeader(HttpServletResponse resp) {
resp.setStatus(404/*NOT_FOUND_404*/);
- resp.setHeader("Content-type","text/plain");
+ resp.setHeader("Content-type",TEXT_PLAIN);
}
@Override
@@ -321,7 +323,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
};
- private static abstract class Content {
+ private abstract static class Content {
private long date; // date of the actual artifact (i.e. File modified date)
private long access; // last accessed
@@ -331,7 +333,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
public void setHeader(HttpServletResponse resp) {
resp.setStatus(200/*OK_200*/);
resp.setHeader("Content-Type",contentType);
- resp.setHeader("Cache-Control", MAX_AGE);
+ resp.setHeader("Cache-Control", maxAge);
}
public abstract void write(Writer writer) throws IOException;
@@ -526,16 +528,10 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void
}
Collections.sort(scont);
int end = size - ((maxSize/4)*3); // reduce to 3/4 of max size
- //System.out.println("------ Cleanup Cycle ------ " + new Date().toString() + " -------");
for (int i=0;i<end;++i) {
Entry<String, Content> entry = scont.get(i).entry;
content.remove(entry.getKey());
- //System.out.println("removed Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString());
}
-// for (int i=end;i<size;++i) {
-// Entry<String, Content> entry = scont.get(i).entry;
-// //System.out.println("remaining Cache Item " + entry.getKey() + "/" + new Date(entry.getValue().access).toString());
-// }
}
}
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CodeSetter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CodeSetter.java
index 172f386e..44cca872 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CodeSetter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/CodeSetter.java
@@ -21,9 +21,6 @@
package org.onap.aaf.auth.rserv;
-import java.io.IOException;
-
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java
index e9c8adb0..f4f0e665 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Content.java
@@ -65,10 +65,15 @@ public abstract class Content<TRANS extends Trans> {
* @return
*/
protected boolean parse(HttpCode<TRANS,?> code, String cntnt) {
- byte bytes[] = cntnt.getBytes();
- boolean contType=false,contProp=true;
- int cis,cie=-1,cend;
- int sis,sie,send;
+ byte[] bytes = cntnt.getBytes();
+ boolean contType=false;
+ boolean contProp=true;
+ int cis;
+ int cie=-1;
+ int cend;
+ int sis;
+ int sie;
+ int send;
do {
cis = cie+1;
cie = cntnt.indexOf(',',cis);
@@ -82,7 +87,6 @@ public abstract class Content<TRANS extends Trans> {
send = sie>cend || sie<0?cend:sie;
if (me==null) {
String semi = new String(bytes,sis,send-sis);
- // trans.checkpoint(semi);
// Look at first entity within comma group
// Is this an acceptable Type?
me=types(code, semi);
@@ -98,7 +102,6 @@ public abstract class Content<TRANS extends Trans> {
if (eq>sis && eq<send) {
String tag = new String(bytes,sis,eq-sis);
String value = new String(bytes,eq+1,send-(eq+1));
- // trans.checkpoint(" Prop " + tag + "=" + value);
boolean bool = props(me,tag,value);
if (!bool) {
contProp=false;
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java
index 8c533f6e..e23a6169 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpCode.java
@@ -111,7 +111,7 @@ public abstract class HttpCode<TRANS extends Trans, CONTEXT> {
return false;
}
- public boolean no_cache() {
+ public boolean noCache() {
return false;
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java
index 8f47126f..41e3c5db 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Match.java
@@ -35,8 +35,8 @@ import java.util.Set;
*/
public class Match {
private Map<String, Integer> params;
- private byte[] values[];
- private Integer vars[];
+ private byte[][] values;
+ private Integer[] vars;
private boolean wildcard;
@@ -50,7 +50,6 @@ public class Match {
* a multi-field option, i.e. ending with a wild-card.
*/
public Match(String path) {
- // IF DEBUG: System.out.print("\n[" + path + "]");
params = new HashMap<>();
if (path!=null) {
String[] pa = path.split("/");
@@ -87,7 +86,6 @@ public class Match {
vars[i]=0; // this is actually a variable, if it only contains a "*"
}
}
- // vars[i]=null;
}
}
}
@@ -148,8 +146,7 @@ public class Match {
int lastField = values.length;
int lastByte = pabytes.length;
- boolean fieldMatched = false; // = lastByte>0?(pabytes[0]=='/'):false;
- // IF DEBUG: System.out.println("\n -- " + path + " --");
+ boolean fieldMatched = false;
for (int i=0;rv && i<lastByte;++i) {
if (field>=lastField) { // checking here allows there to be a non-functional ending /
rv = false;
@@ -163,7 +160,6 @@ public class Match {
if (end==0)end=start+1;
int k = i;
for (int j=start; j<end && k<lastByte; ++k) {
- // IF DEBUG: System.out.print((char)pabytes[k]);
if (pabytes[k]=='/') {
++field;
++j;
@@ -175,7 +171,6 @@ public class Match {
fieldMatched = false; // reset
fieldIdx = 0;
} else {
- // IF DEBUG: System.out.print((char)pabytes[i]);
if (pabytes[i]=='/') { // end of field, eval if Field is matched
// if double slash, check if supposed to be empty
if (fieldIdx==0 && values[field].length==0) {
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java
index 7f94acba..db39be4e 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RServlet.java
@@ -88,7 +88,7 @@ public abstract class RServlet<TRANS extends Trans> implements Servlet {
response.setStatus(404); // Not Found
} else {
// Find best Code in Route based on "Accepts (Get) or Content-Type" (if exists)
- code = codesetter.code();// route.getCode(trans, request, response);
+ code = codesetter.code();
}
} finally {
tt.done();
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java
index 5b856935..aaf75fd7 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java
@@ -66,15 +66,15 @@ public abstract class TransFilter<TRANS extends TransStore> implements Filter {
private CadiHTTPManip cadi;
- private final String[] no_authn;
+ private final String[] noAuthn;
public TransFilter(Access access, Connector con, TrustChecker tc, Object ... additionalTafLurs) throws CadiException, LocatorException {
cadi = new CadiHTTPManip(access, con, tc, additionalTafLurs);
String no = access.getProperty(Config.CADI_NOAUTHN, null);
if (no!=null) {
- no_authn = Split.split(':', no);
+ noAuthn = Split.split(':', no);
} else {
- no_authn=null;
+ noAuthn =null;
}
}
@@ -103,8 +103,8 @@ public abstract class TransFilter<TRANS extends TransStore> implements Filter {
try {
request.setAttribute(TRANS_TAG, trans);
- if (no_authn!=null) {
- for (String prefix : no_authn) {
+ if (noAuthn !=null) {
+ for (String prefix : noAuthn) {
if (req.getPathInfo().startsWith(prefix)) {
chain.doFilter(request, response);
return;
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java
index 6af28356..f0ff9c5c 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TypedCode.java
@@ -91,25 +91,9 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> {
// Want Q percentage is to be first in the array everytime. If not listed, 1.0 is default
props.add(new Pair<String,Object>(Q,1f));
Pair<HttpCode<TRANS,?>, List<Pair<String,Object>>> cl = new Pair<HttpCode<TRANS,?>, List<Pair<String,Object>>>(code, props);
-// // breakup "plus" stuff, i.e. application/xaml+xml
-// int plus = str.indexOf('+');
-// if (plus<0) {
type = new Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>(str, cl);
types.add(type);
return type;
-// } else {
-// int prev = str.indexOf('/')+1;
-// String first = str.substring(0,prev);
-// String nstr;
-// while (prev!=0) {
-// nstr = first + (plus>-1?str.substring(prev,plus):str.substring(prev));
-// type = new Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String,Object>>>>(nstr, cl);
-// types.add(type);
-// prev = plus+1;
-// plus = str.indexOf('+',prev);
-// }
-// return type;
-// }
}
@Override
@@ -146,8 +130,6 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> {
if (accepted) {
switch(acc.acceptable.size()) {
case 0:
-// // TODO best Status Code?
-// resp.setStatus(HttpStatus.NOT_ACCEPTABLE_406);
break;
case 1:
rv = acc.acceptable.get(0);
@@ -163,9 +145,6 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> {
}
}
if (bestT!=null) {
- // When it is a GET, the matched type is what is returned, so set ContentType
-// if (isGet)resp.setContentType(bestT.x); // set ContentType of Code<TRANS,?>
-// rv = bestT.y.x;
rv = bestT;
}
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java
index 37c26fc5..c2ffea6b 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Version.java
@@ -32,7 +32,7 @@ public class Version {
private Object[] parts;
public Version(String v) {
- String sparts[] = v.split("\\.");
+ String[] sparts = v.split("\\.");
parts = new Object[sparts.length];
System.arraycopy(sparts, 0, parts, 0, sparts.length);
if (parts.length>1) { // has at least a minor
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
index 31131314..678fb28e 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
@@ -52,13 +52,13 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
public final ENV env;
private AAFConHttp aafCon;
- public final String app_name;
- public final String app_version;
- public final String ROOT_NS;
+ public final String appName;
+ public final String appVersion;
+ public final String rootNs;
public AbsService(final Access access, final ENV env) throws CadiException {
Define.set(access);
- ROOT_NS = Define.ROOT_NS();
+ rootNs = Define.ROOT_NS();
this.access = access;
this.env = env;
@@ -67,16 +67,16 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
if(scomp.length==0) {
throw new CadiException(Config.AAF_LOCATOR_ENTRIES + " must be defined.");
} else {
- str = ROOT_NS + '.' + scomp[0];
+ str = rootNs + '.' + scomp[0];
}
- app_name = str;
+ appName = str;
str = access.getProperty(Config.AAF_LOCATOR_VERSION, null);
if(str==null) {
str = Defaults.AAF_VERSION;
env.setProperty(Config.AAF_LOCATOR_VERSION, str);
}
- app_version = access.getProperty(Config.AAF_DEPLOYED_VERSION, str);
+ appVersion = access.getProperty(Config.AAF_DEPLOYED_VERSION, str);
// Print Cipher Suites Available
if (access.willLog(Level.DEBUG)) {
@@ -159,11 +159,11 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
public Rcli<?> clientAsUser(TaggedPrincipal p) throws CadiException {
return aafCon.client().forUser(
- new HTransferSS(p,app_name, aafCon.securityInfo()));
+ new HTransferSS(p, appName, aafCon.securityInfo()));
}
public<RET> RET clientAsUser(TaggedPrincipal p,Retryable<RET> retryable) throws APIException, LocatorException, CadiException {
- return aafCon.hman().best(new HTransferSS(p,app_name, aafCon.securityInfo()), retryable);
+ return aafCon.hman().best(new HTransferSS(p, appName, aafCon.securityInfo()), retryable);
}
protected static final String loadFromArgOrSystem(final Properties props, final String tag, final String args[], final String def) {
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
index f09a4ff3..fcdcf878 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
@@ -40,7 +40,7 @@ import org.onap.aaf.misc.rosetta.env.RosettaEnv;
public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> implements ServiceStarter {
private Registrar<ENV> registrar;
- private boolean do_register;
+ private boolean doRegister;
protected AbsService<ENV,TRANS> service;
protected String hostname;
protected final boolean secure;
@@ -57,7 +57,7 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
}
// do_register - this is used for specialty Debug Situations. Developer can create an Instance for a remote system
// for Debugging purposes without fear that real clients will start to call your debug instance
- do_register = !"TRUE".equalsIgnoreCase(access().getProperty("aaf_locate_no_register",null));
+ doRegister = !"TRUE".equalsIgnoreCase(access().getProperty("aaf_locate_no_register",null));
hostname = access().getProperty(Config.HOSTNAME, null);
if (hostname==null) {
try {
@@ -91,7 +91,7 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
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.access().printf(Level.INIT, "Shutting down %s:%s\n",absSS.service.appName, absSS.service.appVersion);
absSS.shutdown();
app.cancel(true);
}
@@ -112,7 +112,7 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
@SafeVarargs
public final synchronized void register(final Registrant<ENV> ... registrants) {
- if (do_register) {
+ if (doRegister) {
if (registrar==null) {
registrar = new Registrar<ENV>(env(),false);
}
@@ -142,12 +142,12 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
File status = new File("/opt/app/aaf/status/");
boolean deleted = false;
if(status.exists()) {
- int lastdot = service.app_name.lastIndexOf("aaf.");
+ int lastdot = service.appName.lastIndexOf("aaf.");
String fname;
if(lastdot<0) {
- fname = service.app_name + '-' + hostname;
+ fname = service.appName + '-' + hostname;
} else {
- fname = service.app_name.substring(lastdot).replace('.', '-')
+ fname = service.appName.substring(lastdot).replace('.', '-')
+ '-' + hostname;
}
status = new File(status, fname);
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
index 3f0d2ebb..5ebdc9e9 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
@@ -61,7 +61,6 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
@Override
public void _propertyAdjustment() {
-// System.setProperty("com.sun.management.jmxremote.port", "8081");
Properties props = access().getProperties();
Object httpproto = null;
// Critical - if no Security Protocols set, then set it. We'll just get messed up if not
@@ -123,11 +122,6 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
// Want to use Client Certificates, if they exist.
sslContextFactory.setWantClientAuth(true);
- // Optional future checks.
- // sslContextFactory.setValidateCerts(true);
- // sslContextFactory.setValidatePeerCerts(true);
- // sslContextFactory.setEnableCRLDP(false);
- // sslContextFactory.setEnableOCSP(false);
String certAlias = access().getProperty(Config.CADI_ALIAS, null);
if (certAlias!=null) {
sslContextFactory.setCertAlias(certAlias);
@@ -146,17 +140,6 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
}
service.setProtocol(protocol);
-
- // Setup JMX
- // TODO trying to figure out how to set up/log ports
-// MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
-// MBeanContainer mbContainer=new MBeanContainer(mbeanServer);
-// server.addEventListener(mbContainer);
-// server.addBean(mbContainer);
-
- // Add loggers MBean to server (will be picked up by MBeanContainer above)
-// server.addBean(Log.getLog());
-
conn.setHost(hostname);
conn.setPort(port);
conn.setIdleTimeout(IDLE_TIMEOUT);
@@ -197,17 +180,17 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
}
}
try {
- String no_register = env().getProperty("aaf_no_register",null);
- if(no_register==null) {
+ String noRegister = env().getProperty("aaf_no_register",null);
+ if(noRegister==null) {
register(service.registrants(port));
} else {
- access().printf(Level.INIT,"'aaf_no_register' is set. %s will not be registered with Locator", service.app_name);
+ access().printf(Level.INIT,"'aaf_no_register' is set. %s will not be registered with Locator", service.appName);
}
- access().printf(Level.INIT, "Starting Jetty Service for %s, version %s, on %s://%s:%d", service.app_name,service.app_version,protocol,hostname,port);
+ access().printf(Level.INIT, "Starting Jetty Service for %s, version %s, on %s://%s:%d", service.appName,service.appVersion,protocol,hostname,port);
rserv.postStartup(hostname, port);
} catch (Exception e) {
- access().log(e,"Error registering " + service.app_name);
+ access().log(e,"Error registering " + service.appName);
String doExit = access().getProperty("cadi_exitOnFailure", "true");
if (doExit == "true") {
System.exit(1);
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java
index aa7d14cc..284a7dec 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java
@@ -49,10 +49,10 @@ public class Log4JLogIt implements LogIt {
public Log4JLogIt(final String[] args, final String root) throws APIException {
String propsFile = getArgOrVM(AAF_LOG4J_PREFIX, args, "org.osaaf.aaf")+".log4j.props";
- String log_dir = getArgOrVM(Config.CADI_LOGDIR,args,"/opt/app/osaaf/logs");
- String etc_dir = getArgOrVM(Config.CADI_ETCDIR,args,"/opt/app/osaaf/etc");
- String log_level = getArgOrVM(Config.CADI_LOGLEVEL,args,"INFO");
- File logs = new File(log_dir);
+ String logDir = getArgOrVM(Config.CADI_LOGDIR,args,"/opt/app/osaaf/logs");
+ String etcDir = getArgOrVM(Config.CADI_ETCDIR,args,"/opt/app/osaaf/etc");
+ String logLevel = getArgOrVM(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(logDir);
if (!logs.isDirectory()) {
logs.delete();
}
@@ -61,9 +61,9 @@ public class Log4JLogIt implements LogIt {
}
if (System.getProperty("log4j.configuration")==null) {
- System.setProperty("log4j.configuration", etc_dir+'/'+propsFile);
+ System.setProperty("log4j.configuration", etcDir+'/'+propsFile);
}
- LogFileNamer lfn = new LogFileNamer(log_dir,root);
+ LogFileNamer lfn = new LogFileNamer(logDir,root);
try {
service=lfn.setAppender("service"); // when name is split, i.e. authz|service, the Appender is "authz", and "service"
audit=lfn.setAppender("audit"); // is part of the log-file name
@@ -75,7 +75,7 @@ public class Log4JLogIt implements LogIt {
linit = Logger.getLogger(init);
ltrace = Logger.getLogger(trace);
- lfn.configure(etc_dir,propsFile, log_level);
+ lfn.configure(etcDir,propsFile, logLevel);
} catch (IOException e) {
throw new APIException(e);
}
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 fcbccb12..1e406043 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
@@ -47,7 +47,9 @@ public class Validator {
private final Pattern actionChars;
private final Pattern instChars;
private StringBuilder msgs;
-
+ public static final String PERM_TYPE = "Perm Type [";
+ public static final String IS_INVALID = "] is invalid.";
+ public static final String ROLE_STR = "Role [";
static {
nsKeywords = new ArrayList<>();
nsKeywords.add(".access");
@@ -145,7 +147,7 @@ public class Validator {
public final Validator permType(String type) {
if (nob(type,NAME_CHARS)) {
- msg("Perm Type [" +type + "] is invalid.");
+ msg(PERM_TYPE +type + IS_INVALID);
}
return this;
}
@@ -158,7 +160,7 @@ public class Validator {
} else {
if(!(type.startsWith(user) && type.endsWith(":id"))) {
if(nob(type,NAME_CHARS)) {
- msg("Perm Type [" + type + "] is invalid.");
+ msg(PERM_TYPE + type + IS_INVALID);
}
}
}
@@ -171,14 +173,14 @@ 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;
}
public final Validator permInstance(String instance) {
if(!"/".equals(instance) && nob(instance,instChars)) {
- msg("Perm Instance [" + instance + "] is invalid.");
+ msg("Perm Instance [" + instance + IS_INVALID);
}
return this;
}
@@ -186,7 +188,7 @@ public class Validator {
public final Validator permAction(String action) {
// TODO check for correct Splits? Type|Instance|Action ?
if (nob(action, actionChars)) {
- msg("Perm Action [" + action + "] is invalid.");
+ msg("Perm Action [" + action + IS_INVALID);
}
return this;
}
@@ -204,10 +206,10 @@ public class Validator {
if(!quit) {
if(role.startsWith(user) && role.endsWith(":user")) {
if(!(role.length() == user.length() + 5)) {
- msg("Role [" + role + "] is invalid.");
+ msg(ROLE_STR + role + IS_INVALID);
}
} else if (nob(role, NAME_CHARS)) {
- msg("Role [" + role + "] is invalid.");
+ msg(ROLE_STR + role + IS_INVALID);
}
}
return this;
@@ -216,7 +218,7 @@ public class Validator {
public final Validator role(String role) {
if (nob(role, NAME_CHARS)) {
- msg("Role [" + role + "] is invalid.");
+ msg(ROLE_STR + role + IS_INVALID);
}
return this;
}
@@ -226,7 +228,7 @@ public class Validator {
msg("NS is null");
return this;
} else if (nob(ns,NAME_CHARS)) {
- msg("NS [" + ns + "] is invalid.");
+ msg("NS [" + ns + IS_INVALID);
}
for (String s : nsKeywords) {
if (ns.endsWith(s)) {
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java
index 60727b6a..83c8a820 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java
@@ -81,7 +81,7 @@ public class JU_TypedCode {
HttpCode<?, ?> code = mock(HttpCode.class);
code.pathParam(null, null);
code.isAuthorized(null); //Testing httpcode, currently not working
- code.no_cache();
+ code.noCache();
code.toString();
typedCode.add(code , "");