diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-08-07 13:40:39 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-08-07 13:40:42 -0500 |
commit | 3d1706fcbe7f95830ff6fd23cf679ee55c6d0595 (patch) | |
tree | ff97f10380a44d9f81d536c066782af10f728687 /auth/auth-core | |
parent | 321dce367d74092a0ba09930c3aa526abdbd5da8 (diff) |
Remove Tabs, per Jococo
Issue-ID: AAF-932
Change-Id: I3ab0ebcc082048d2d1424a58a90ea479fb005ee6
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'auth/auth-core')
20 files changed, 424 insertions, 424 deletions
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java index 800a8472..5fb590c1 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/common/Define.java @@ -75,15 +75,15 @@ public class Define { } public static String varReplace(final String potential) { - int idx = potential.indexOf(ROOT_NS_TAG_DOT); - if(idx<0) { - return potential; - } else if(idx==0) { - return ROOT_NS + potential.substring(ROOT_NS_TAG_LEN); + int idx = potential.indexOf(ROOT_NS_TAG_DOT); + if(idx<0) { + return potential; + } else if(idx==0) { + return ROOT_NS + potential.substring(ROOT_NS_TAG_LEN); } else if('.'==potential.charAt(idx)) { return potential.replace(ROOT_NS_TAG, ROOT_NS); } else { - return potential; + return potential; } } @@ -93,7 +93,7 @@ public class Define { public static String getCredType(int type) { switch(type) { - case 0: return "NoCrd"; + case 0: return "NoCrd"; case 1: return "U/P"; case 2: return "U/P2"; case 10: return "FQI"; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java index 497c13d6..a46be8ef 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java @@ -102,9 +102,9 @@ public class AuthzEnv extends RosettaEnv implements Access { @Override public void log(Throwable e, Object... msgs) { - Object[] nm = new Object[msgs.length+1]; - System.arraycopy(msgs, 0, nm, 1, msgs.length); - nm[0]=e; + Object[] nm = new Object[msgs.length+1]; + System.arraycopy(msgs, 0, nm, 1, msgs.length); + nm[0]=e; access.log(Level.ERROR, nm); } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTrans.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTrans.java index 1a1e7f24..454d46d2 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTrans.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTrans.java @@ -44,8 +44,8 @@ public interface AuthzTrans extends TransStore { public abstract AuthzTrans set(HttpServletRequest req, HttpServletResponse resp); - public abstract HttpServletRequest hreq(); - + public abstract HttpServletRequest hreq(); + public abstract HttpServletResponse hresp(); public abstract String user(); @@ -84,7 +84,7 @@ public interface AuthzTrans extends TransStore { public abstract String getTag(); - public abstract void clearCache(); + public abstract void clearCache(); }
\ No newline at end of file diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java index bda23e13..e4420ab1 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java @@ -130,11 +130,11 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { sb.append("user="); Principal p = trans.getUserPrincipal(); if (p==null) { - lt=trans.warn(); + lt=trans.warn(); sb.append(target); sb.append("[None]"); } else { - lt=trans.info(); + lt=trans.info(); sb.append(p.getName()); if (p instanceof TrustPrincipal) { sb.append('('); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java index 0af760b8..c68f71ab 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java @@ -35,10 +35,10 @@ import org.onap.aaf.misc.env.LogTarget; import org.onap.aaf.misc.env.impl.BasicTrans; public class AuthzTransImpl extends BasicTrans implements AuthzTrans { - private static final String N_A = "n/a"; - private static final String BLANK = ""; - private HttpServletRequest hreq; - private HttpServletResponse hresp; + private static final String N_A = "n/a"; + private static final String BLANK = ""; + private HttpServletRequest hreq; + private HttpServletResponse hresp; private TaggedPrincipal user; private Lur lur; private Organization org; @@ -57,8 +57,8 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { */ @Override public AuthzTrans set(HttpServletRequest req, HttpServletResponse resp) { - hreq = req; - hresp = resp; + hreq = req; + hresp = resp; user = (TaggedPrincipal)req.getUserPrincipal(); for (REQD_TYPE rt : REQD_TYPE.values()) { @@ -76,12 +76,12 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { @Override public HttpServletRequest hreq() { - return hreq; + return hreq; } @Override public HttpServletResponse hresp() { - return hresp; + return hresp; } @Override @@ -135,7 +135,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { */ @Override public String path() { - return hreq==null?"":hreq.getPathInfo(); + return hreq==null?"":hreq.getPathInfo(); } /** @@ -231,20 +231,20 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { */ @Override public void setTag(String tag) { - this.tag = tag; + this.tag = tag; } @Override public String getTag() { - return tag; + return tag; } - @Override - public void clearCache() { + @Override + public void clearCache() { if (lur!=null) { - StringBuilder report = new StringBuilder(); + StringBuilder report = new StringBuilder(); lur.clear(user, report); info().log(report); } - } + } } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/NullTrans.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/NullTrans.java index f0052e5a..9189cc30 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/NullTrans.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/NullTrans.java @@ -136,17 +136,17 @@ public class NullTrans implements AuthzTrans { } @Override - public HttpServletRequest hreq() { - return null; - } + public HttpServletRequest hreq() { + return null; + } @Override - public HttpServletResponse hresp() { - return null; - } + public HttpServletResponse hresp() { + return null; + } - @Override + @Override public String user() { return null; } @@ -243,15 +243,15 @@ public class NullTrans implements AuthzTrans { } return now; } - @Override - public void setTag(String tag) { - } - @Override - public String getTag() { - return null; - } - @Override - public void clearCache() { - } + @Override + public void setTag(String tag) { + } + @Override + public String getTag() { + return null; + } + @Override + public void clearCache() { + } } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/log4j/Log4JAccessAppender.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/log4j/Log4JAccessAppender.java index 7bda155c..165295d9 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/log4j/Log4JAccessAppender.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/log4j/Log4JAccessAppender.java @@ -27,52 +27,52 @@ import org.apache.log4j.spi.LoggingEvent; import org.onap.aaf.cadi.Access; public class Log4JAccessAppender extends AppenderSkeleton{ - private Access access; + private Access access; - public Log4JAccessAppender(Access access) { - this.access = access; - } + public Log4JAccessAppender(Access access) { + this.access = access; + } - @Override - public void close() { - } + @Override + public void close() { + } - @Override - public boolean requiresLayout() { - return false; - } + @Override + public boolean requiresLayout() { + return false; + } - @Override - protected void append(LoggingEvent event) { - Access.Level al = null; - switch(event.getLevel().toInt()) { - case Level.FATAL_INT: - case Level.ERROR_INT: - if(access.willLog(Access.Level.ERROR)) { - al=Access.Level.ERROR; - } - break; - case Level.WARN_INT: - if(!access.willLog(Access.Level.WARN)) { - al=Access.Level.WARN; - } - break; - case Level.ALL_INT: - case Level.INFO_INT: - if(!access.willLog(Access.Level.INFO)) { - al=Access.Level.INFO; - } - break; - case Level.TRACE_INT: - if(!access.willLog(Access.Level.TRACE)) { - al=Access.Level.TRACE; - } - break; - } - if(al!=null) { - access.log(al,"Log4J["+event.getLoggerName()+"]["+event.getLevel()+']',event.getMessage()); - } - } + @Override + protected void append(LoggingEvent event) { + Access.Level al = null; + switch(event.getLevel().toInt()) { + case Level.FATAL_INT: + case Level.ERROR_INT: + if(access.willLog(Access.Level.ERROR)) { + al=Access.Level.ERROR; + } + break; + case Level.WARN_INT: + if(!access.willLog(Access.Level.WARN)) { + al=Access.Level.WARN; + } + break; + case Level.ALL_INT: + case Level.INFO_INT: + if(!access.willLog(Access.Level.INFO)) { + al=Access.Level.INFO; + } + break; + case Level.TRACE_INT: + if(!access.willLog(Access.Level.TRACE)) { + al=Access.Level.TRACE; + } + break; + } + if(al!=null) { + access.log(al,"Log4J["+event.getLoggerName()+"]["+event.getLevel()+']',event.getMessage()); + } + } } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/FileMailer.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/FileMailer.java index 6a648a8a..9478832b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/FileMailer.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/FileMailer.java @@ -33,120 +33,120 @@ import org.onap.aaf.misc.env.APIException; import org.onap.aaf.misc.env.util.Chrono; public class FileMailer implements Mailer { - private Path dir; - private String mail_from; - private String testName; - private int count; + private Path dir; + private String mail_from; + private String testName; + private int count; - public FileMailer(Access access) throws APIException { - count = 0; - - mail_from = access.getProperty("MAIL_FROM", null); - if(mail_from==null) { - throw new APIException("MAIL_FROM property is required for Email Notifications"); - } - String env = access.getProperty("CASS_ENV", "UNKNOWN"); - String logdir = access.getProperty("LOG_DIR",null); - if(logdir==null) { - logdir=access.getProperty(env+".LOG_DIR", "logs/"+env); - } - dir = Paths.get(logdir+"/email/"+Chrono.dateOnlyStamp()); - if(!Files.exists(dir)) { - try { - Files.createDirectories(dir); - } catch (IOException e) { - throw new APIException("Cannot create directory: " + dir.toString(),e); - } - } - - boolean dryrun = Boolean.parseBoolean(access.getProperty("DRY_RUN","false")); - String str = access.getProperty("MAX_EMAIL", null); - int maxEmail = str==null || str.isEmpty()?Integer.MAX_VALUE:Integer.parseInt(str); - if(dryrun && maxEmail==1) { - testName = "email_test"; - } else { - testName = null; - } - } + public FileMailer(Access access) throws APIException { + count = 0; + + mail_from = access.getProperty("MAIL_FROM", null); + if(mail_from==null) { + throw new APIException("MAIL_FROM property is required for Email Notifications"); + } + String env = access.getProperty("CASS_ENV", "UNKNOWN"); + String logdir = access.getProperty("LOG_DIR",null); + if(logdir==null) { + logdir=access.getProperty(env+".LOG_DIR", "logs/"+env); + } + dir = Paths.get(logdir+"/email/"+Chrono.dateOnlyStamp()); + if(!Files.exists(dir)) { + try { + Files.createDirectories(dir); + } catch (IOException e) { + throw new APIException("Cannot create directory: " + dir.toString(),e); + } + } + + boolean dryrun = Boolean.parseBoolean(access.getProperty("DRY_RUN","false")); + String str = access.getProperty("MAX_EMAIL", null); + int maxEmail = str==null || str.isEmpty()?Integer.MAX_VALUE:Integer.parseInt(str); + if(dryrun && maxEmail==1) { + testName = "email_test"; + } else { + testName = null; + } + } - @Override - public boolean sendEmail(AuthzTrans trans, String test, List<String> toList, List<String> ccList, - String subject, String body, Boolean urgent) throws OrganizationException { - boolean status = false; - try { - Path path; - if(testName==null) { - path = Files.createTempFile(dir, "email", ".hdr"); - } else { - path = Paths.get(dir.toString(), "emailTEST"+test+".hdr"); - } - BufferedWriter bw = Files.newBufferedWriter(path); - try { - bw.write("TO: "); - boolean first = true; - for(String to : toList) { - if(first) { - first = false; - } else { - bw.write(','); - } - bw.write(to); - } - bw.newLine(); - - bw.write("CC: "); - first = true; - for(String cc : ccList) { - if(first) { - first = false; - } else { - bw.write(','); - } - bw.write(cc); - } - bw.newLine(); - - bw.write("FROM: "); - bw.write(mail_from); - bw.newLine(); - - bw.write("SUBJECT: "); - bw.write(subject); - bw.newLine(); - - if(urgent) { - bw.write("Importance: High"); - bw.newLine(); - } + @Override + public boolean sendEmail(AuthzTrans trans, String test, List<String> toList, List<String> ccList, + String subject, String body, Boolean urgent) throws OrganizationException { + boolean status = false; + try { + Path path; + if(testName==null) { + path = Files.createTempFile(dir, "email", ".hdr"); + } else { + path = Paths.get(dir.toString(), "emailTEST"+test+".hdr"); + } + BufferedWriter bw = Files.newBufferedWriter(path); + try { + bw.write("TO: "); + boolean first = true; + for(String to : toList) { + if(first) { + first = false; + } else { + bw.write(','); + } + bw.write(to); + } + bw.newLine(); + + bw.write("CC: "); + first = true; + for(String cc : ccList) { + if(first) { + first = false; + } else { + bw.write(','); + } + bw.write(cc); + } + bw.newLine(); + + bw.write("FROM: "); + bw.write(mail_from); + bw.newLine(); + + bw.write("SUBJECT: "); + bw.write(subject); + bw.newLine(); + + if(urgent) { + bw.write("Importance: High"); + bw.newLine(); + } - } finally { - bw.close(); - } + } finally { + bw.close(); + } - path = Paths.get(path.toString().replaceAll(".hdr", ".html")); - bw = Files.newBufferedWriter(path); - try { - bw.write(body); - bw.newLine(); - } finally { - bw.close(); - } - status = true; - } catch ( IOException e) { - throw new OrganizationException(e); - } - ++count; - return status; - } + path = Paths.get(path.toString().replaceAll(".hdr", ".html")); + bw = Files.newBufferedWriter(path); + try { + bw.write(body); + bw.newLine(); + } finally { + bw.close(); + } + status = true; + } catch ( IOException e) { + throw new OrganizationException(e); + } + ++count; + return status; + } - @Override - public String mailFrom() { - return mail_from; - } + @Override + public String mailFrom() { + return mail_from; + } - @Override - public int count() { - return count; - } + @Override + public int count() { + return count; + } } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Mailer.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Mailer.java index dd32c651..64a2e8dd 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Mailer.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Mailer.java @@ -34,8 +34,8 @@ public interface Mailer { String body, Boolean urgent) throws OrganizationException; - public String mailFrom(); + public String mailFrom(); - public int count(); + public int count(); } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Organization.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Organization.java index 539b9369..75669632 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Organization.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Organization.java @@ -65,17 +65,17 @@ public interface Organization { public Organization org(); // Organization of Identity - public static String mixedCase(String in) { - StringBuilder sb = new StringBuilder(); - for(int i=0;i<in.length();++i) { - if(i==0) { - sb.append(Character.toUpperCase(in.charAt(i))); - } else { - sb.append(Character.toLowerCase(in.charAt(i))); - } - } - return sb.toString(); - } + public static String mixedCase(String in) { + StringBuilder sb = new StringBuilder(); + for(int i=0;i<in.length();++i) { + if(i==0) { + sb.append(Character.toUpperCase(in.charAt(i))); + } else { + sb.append(Character.toLowerCase(in.charAt(i))); + } + } + return sb.toString(); + } } @@ -115,7 +115,7 @@ public interface Organization { * feed with a "Deleted ID" feed. * */ - public boolean isRevoked(AuthzTrans trans, String id); + public boolean isRevoked(AuthzTrans trans, String id); /** @@ -559,17 +559,17 @@ public interface Organization { return nullStringArray; } - @Override - public boolean isRevoked(AuthzTrans trans, String id) { - // provide a corresponding feed that indicates that an ID has been intentionally removed from identities.dat table. - return false; - } - - @Override - public List<Identity> getIDs(AuthzTrans trans, String user, int escalate) throws OrganizationException { - // TODO Auto-generated method stub - return null; - } + @Override + public boolean isRevoked(AuthzTrans trans, String id) { + // provide a corresponding feed that indicates that an ID has been intentionally removed from identities.dat table. + return false; + } + + @Override + public List<Identity> getIDs(AuthzTrans trans, String user, int escalate) throws OrganizationException { + // TODO Auto-generated method stub + return null; + } }; } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java index 098fb979..4f2ba4f2 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java @@ -64,15 +64,15 @@ public class OrganizationFactory { } } if(firstOrg==null) { // attempt to load DefaultOrg - try { - Class<?> cls = Class.forName("org.onap.aaf.org.DefaultOrg"); - @SuppressWarnings("unchecked") - Constructor<Organization> cnst = (Constructor<Organization>)cls.getConstructor(Env.class,String.class); - String realm = env.getProperty(Config.AAF_DEFAULT_REALM,"people.osaaf.org"); - defaultOrg = cnst.newInstance(env,realm); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException e) { - env.init().log("Default Organization Module not linked in",e); - } + try { + Class<?> cls = Class.forName("org.onap.aaf.org.DefaultOrg"); + @SuppressWarnings("unchecked") + Constructor<Organization> cnst = (Constructor<Organization>)cls.getConstructor(Env.class,String.class); + String realm = env.getProperty(Config.AAF_DEFAULT_REALM,"people.osaaf.org"); + defaultOrg = cnst.newInstance(env,realm); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException e) { + env.init().log("Default Organization Module not linked in",e); + } } if (defaultOrg == null) { defaultOrg = firstOrg; 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 acca80ba..9dec87db 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 @@ -125,11 +125,11 @@ public abstract class RServlet<TRANS extends Trans> implements Servlet { return "RServlet for Jetty"; } - /** + /** * Allow Service to instantiate certain actions after service starts up - * @throws LocatorException - * @throws CadiException - * @throws APIException + * @throws LocatorException + * @throws CadiException + * @throws APIException */ public void postStartup(String hostname, int port) throws APIException { } 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 81e2e619..2acfbe34 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 @@ -120,7 +120,7 @@ public abstract class TransFilter<TRANS extends TransStore> implements Filter { resp = cadi.validate(req,res,trans); Object tag = req.getAttribute("CRED_TAG"); if(tag!=null) { - ((AuthzTrans)trans).setTag(tag.toString()); + ((AuthzTrans)trans).setTag(tag.toString()); } switch(r=resp.isAuthenticated()) { case IS_AUTHENTICATED: @@ -145,7 +145,7 @@ public abstract class TransFilter<TRANS extends TransStore> implements Filter { // use trans.checkpoint(resp.desc(),Env.ALWAYS); if (resp.isFailedAttempt()) { - target = resp.getTarget(); + target = resp.getTarget(); } } } catch (Exception e) { 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 5fbb951b..4fb81d73 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 @@ -65,16 +65,16 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte String str = access.getProperty(Config.AAF_LOCATOR_ENTRIES, null); String[] scomp = Split.splitTrim(',', str); if(scomp.length==0) { - throw new CadiException(Config.AAF_LOCATOR_ENTRIES + " must be defined."); + throw new CadiException(Config.AAF_LOCATOR_ENTRIES + " must be defined."); } else { - str = ROOT_NS + '.' + scomp[0]; + str = ROOT_NS + '.' + scomp[0]; } 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); + str = Defaults.AAF_VERSION; + env.setProperty(Config.AAF_LOCATOR_VERSION, str); } app_version = access.getProperty(Config.AAF_DEPLOYED_VERSION, str); @@ -101,11 +101,11 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte } public void setProtocol(String proto) { - env.setProperty(Config.AAF_LOCATOR_PROTOCOL, proto); + env.setProperty(Config.AAF_LOCATOR_PROTOCOL, proto); } public void setSubprotocol(String subproto) { - env.setProperty(Config.AAF_LOCATOR_SUBPROTOCOL, subproto); + env.setProperty(Config.AAF_LOCATOR_SUBPROTOCOL, subproto); } protected abstract Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java index 11ba6562..90f4158f 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 @@ -42,18 +42,18 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr private Registrar<ENV> registrar; private boolean do_register; protected AbsService<ENV,TRANS> service; - protected String hostname; - protected final boolean secure; + protected String hostname; + protected final boolean secure; public AbsServiceStarter(final AbsService<ENV,TRANS> service, boolean secure) { - this.secure = secure; + this.secure = secure; this.service = service; try { OrganizationFactory.init(service.env); } catch (OrganizationException e) { service.access.log(e, "Missing defined Organization Plugins"); - System.exit(3); + System.exit(3); } // 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 @@ -61,10 +61,10 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr hostname = access().getProperty(Config.HOSTNAME, null); if (hostname==null) { try { - hostname = Inet4Address.getLocalHost().getHostName(); - } catch (UnknownHostException e) { - hostname= "cannotBeDetermined"; - } + hostname = Inet4Address.getLocalHost().getHostName(); + } catch (UnknownHostException e) { + hostname= "cannotBeDetermined"; + } } _propertyAdjustment(); } @@ -83,31 +83,31 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr @Override public final void start() throws Exception { - ExecutorService es = Executors.newSingleThreadExecutor(); - Future<?> app = es.submit(this); + ExecutorService es = Executors.newSingleThreadExecutor(); + Future<?> app = es.submit(this); final AbsServiceStarter<?,?> absSS = this; // Docker/K8 may separately create startup Status in this dir for startup // sequencing. If so, delete ON EXIT - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override + 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); - if(!app.isCancelled()) { - System.out.println("Service Started in Eclipse: "); - System.out.print(" Hit <enter> to end:\n"); - try { - System.in.read(); - System.exit(0); - } catch (IOException e) { - } - } - } + 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); + if(!app.isCancelled()) { + System.out.println("Service Started in Eclipse: "); + System.out.print(" Hit <enter> to end:\n"); + try { + System.in.read(); + System.exit(0); + } catch (IOException e) { + } + } + } } @SafeVarargs @@ -123,16 +123,16 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr } @Override - public void run() { + public void run() { try { - _start(service); - } catch (Exception e) { - e.printStackTrace(); - shutdown(); - } - } + _start(service); + } catch (Exception e) { + e.printStackTrace(); + shutdown(); + } + } - @Override + @Override public void shutdown() { if (registrar!=null) { registrar.close(env()); @@ -141,26 +141,26 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr if (service!=null) { File status = new File("/opt/app/aaf/status/"); boolean deleted = false; - if(status.exists()) { - int lastdot = service.app_name.lastIndexOf("aaf."); - String fname; - if(lastdot<0) { - fname = service.app_name + '-' + hostname; - } else { - fname = service.app_name.substring(lastdot).replace('.', '-') - + '-' + hostname; - } - status = new File(status, fname); - if(status.exists()) { - deleted=status.delete(); - } - } - if(deleted) { - service.access.log(Level.INIT, "Deleted Status",status.getAbsolutePath()); - } else { - service.access.log(Level.INIT, "Status not deleted: ",status.getAbsolutePath()); - } - service.destroy(); + if(status.exists()) { + int lastdot = service.app_name.lastIndexOf("aaf."); + String fname; + if(lastdot<0) { + fname = service.app_name + '-' + hostname; + } else { + fname = service.app_name.substring(lastdot).replace('.', '-') + + '-' + hostname; + } + status = new File(status, fname); + if(status.exists()) { + deleted=status.delete(); + } + } + if(deleted) { + service.access.log(Level.INIT, "Deleted Status",status.getAbsolutePath()); + } else { + service.access.log(Level.INIT, "Status not deleted: ",status.getAbsolutePath()); + } + service.destroy(); } } } 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 8d49720b..78a7702b 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 @@ -197,12 +197,12 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex } } try { - String no_register = env().getProperty("aaf_no_register",null); - if(no_register==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); - } + String no_register = env().getProperty("aaf_no_register",null); + if(no_register==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, "Starting Jetty Service for %s, version %s, on %s://%s:%d", service.app_name,service.app_version,protocol,hostname,port); rserv.postStartup(hostname, port); 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 6d519c64..052f21bf 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 @@ -90,9 +90,9 @@ public class Validator { } protected final void match(String text, String str, Pattern p) { - if(str==null || !p.matcher(str).matches()) { - msg(text); - } + if(str==null || !p.matcher(str).matches()) { + msg(text); + } } protected final boolean nob(String str, Pattern p) { @@ -156,11 +156,11 @@ public class Validator { } else if (user==null) { msg("User is null"); } else { - if(!(type.startsWith(user) && type.endsWith(":id"))) { - if(nob(type,NAME_CHARS)) { - msg("Perm Type [" + type + "] is invalid."); - } - } + if(!(type.startsWith(user) && type.endsWith(":id"))) { + if(nob(type,NAME_CHARS)) { + msg("Perm Type [" + type + "] is invalid."); + } + } } return this; } @@ -177,7 +177,7 @@ public class Validator { } public final Validator permInstance(String instance) { - if(!"/".equals(instance) && nob(instance,instChars)) { + if(!"/".equals(instance) && nob(instance,instChars)) { msg("Perm Instance [" + instance + "] is invalid."); } return this; @@ -192,24 +192,24 @@ public class Validator { } public final Validator role(String user, String role) { - boolean quit = false; - if(role==null) { - msg("Role is null"); - quit = true; - } - if(user==null) { - msg("User is null"); - quit = true; - } - if(!quit) { - if(role.startsWith(user) && role.endsWith(":user")) { - if(!(role.length() == user.length() + 5)) { - msg("Role [" + role + "] is invalid."); - } - } else if (nob(role, NAME_CHARS)) { - msg("Role [" + role + "] is invalid."); - } - } + boolean quit = false; + if(role==null) { + msg("Role is null"); + quit = true; + } + if(user==null) { + msg("User is null"); + quit = true; + } + if(!quit) { + if(role.startsWith(user) && role.endsWith(":user")) { + if(!(role.length() == user.length() + 5)) { + msg("Role [" + role + "] is invalid."); + } + } else if (nob(role, NAME_CHARS)) { + msg("Role [" + role + "] is invalid."); + } + } return this; } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/log4j/test/JU_Log4jAccessAppender.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/log4j/test/JU_Log4jAccessAppender.java index 2c5d86b4..8123a82d 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/log4j/test/JU_Log4jAccessAppender.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/log4j/test/JU_Log4jAccessAppender.java @@ -38,75 +38,75 @@ import org.onap.aaf.cadi.Access; public class JU_Log4jAccessAppender { - @Mock - Access access; - - @Before - public void setUp() { - initMocks(this); - } - - @Test - public void testRequiresLayout() { - Log4JAccessAppender log4jObj = new Log4JAccessAppender(access); - boolean retObj = log4jObj.requiresLayout(); - assertFalse(retObj); - } - - @Test - public void testClose() { - Log4JAccessAppender log4jObj = new Log4JAccessAppender(access); - log4jObj.close(); - - } - - @Test - public void testAppend() { - Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); - LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.FATAL,"test",Thread.currentThread().getName(),null,null,null,null); - log4jObj.append(event); - Mockito.doReturn(true).when(access).willLog(Access.Level.ERROR); - event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.ERROR,"test",Thread.currentThread().getName(),null,null,null,null); - log4jObj.append(event); - event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.ALL,"test",Thread.currentThread().getName(),null,null,null,null); - log4jObj.append(event); - } - - @Test - public void testAppendWARN() { - Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); - Mockito.doReturn(false).when(access).willLog(Access.Level.WARN); - LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.WARN,"test",Thread.currentThread().getName(),null,null,null,null); - log4jObj.append(event); - } - - @Test - public void testAppendINFO() { - Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); - Mockito.doReturn(true).when(access).willLog(Access.Level.INFO); - LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.INFO,"test",Thread.currentThread().getName(),null,null,null,null); - log4jObj.append(event); - } - - @Test - public void testAppendWTrace() { - Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); - Mockito.doReturn(false).when(access).willLog(Access.Level.TRACE); - LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.TRACE,"test",Thread.currentThread().getName(),null,null,null,null); - log4jObj.append(event); - } - - class Log4jAccessAppenderImpl extends Log4JAccessAppender{ + @Mock + Access access; + + @Before + public void setUp() { + initMocks(this); + } + + @Test + public void testRequiresLayout() { + Log4JAccessAppender log4jObj = new Log4JAccessAppender(access); + boolean retObj = log4jObj.requiresLayout(); + assertFalse(retObj); + } + + @Test + public void testClose() { + Log4JAccessAppender log4jObj = new Log4JAccessAppender(access); + log4jObj.close(); + + } + + @Test + public void testAppend() { + Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); + LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.FATAL,"test",Thread.currentThread().getName(),null,null,null,null); + log4jObj.append(event); + Mockito.doReturn(true).when(access).willLog(Access.Level.ERROR); + event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.ERROR,"test",Thread.currentThread().getName(),null,null,null,null); + log4jObj.append(event); + event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.ALL,"test",Thread.currentThread().getName(),null,null,null,null); + log4jObj.append(event); + } + + @Test + public void testAppendWARN() { + Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); + Mockito.doReturn(false).when(access).willLog(Access.Level.WARN); + LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.WARN,"test",Thread.currentThread().getName(),null,null,null,null); + log4jObj.append(event); + } + + @Test + public void testAppendINFO() { + Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); + Mockito.doReturn(true).when(access).willLog(Access.Level.INFO); + LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.INFO,"test",Thread.currentThread().getName(),null,null,null,null); + log4jObj.append(event); + } + + @Test + public void testAppendWTrace() { + Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); + Mockito.doReturn(false).when(access).willLog(Access.Level.TRACE); + LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.TRACE,"test",Thread.currentThread().getName(),null,null,null,null); + log4jObj.append(event); + } + + class Log4jAccessAppenderImpl extends Log4JAccessAppender{ - public Log4jAccessAppenderImpl(Access access) { - super(access); - // TODO Auto-generated constructor stub - } - - @Override - protected void append(LoggingEvent event) { - super.append(event); - } - - } + public Log4jAccessAppenderImpl(Access access) { + super(access); + // TODO Auto-generated constructor stub + } + + @Override + protected void append(LoggingEvent event) { + super.append(event); + } + + } } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java index 20b47331..14d702b3 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java @@ -56,7 +56,7 @@ public class JU_OrganizationFactory { @SuppressWarnings("static-access") @Test public void testInit() throws OrganizationException { - Assert.assertEquals(null, organizationFactory.init(bEnv)); + Assert.assertEquals(null, organizationFactory.init(bEnv)); } @SuppressWarnings("static-access") //TODO:Fix this once real input is available AAF-111 diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java index c6ddc79f..40e1886e 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java @@ -27,14 +27,14 @@ 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); + 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"); + System.out.println("Shutdown Hook, thread: setting interrupt"); app.cancel(true); tk.longProcess(); es.shutdown(); @@ -43,23 +43,23 @@ public class TestKill implements Runnable { System.out.println("Service Start"); System.out.print("Hit <enter> to end:"); try { - System.in.read(); - System.exit(0); - } catch (IOException e) { - } - } + System.in.read(); + System.exit(0); + } catch (IOException e) { + } + } @Override - public void run() { - } + 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"); + System.out.println("Starting long cleanup process"); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + System.out.println("Ending long cleanup process"); } } |