From 1296352d8eafee57f982a4342ad79ada4aa56d28 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Tue, 15 Oct 2019 08:19:50 -0500 Subject: Sonar Fixes, Formatting Issue-ID: AAF-1019 Change-Id: Ica49d9e7323aad9622ff9d95cc21b87430c22c54 Signed-off-by: Instrumental --- .../main/java/org/onap/aaf/auth/cache/Cache.java | 36 ++--- .../main/java/org/onap/aaf/auth/common/Define.java | 14 +- .../main/java/org/onap/aaf/auth/env/AuthzEnv.java | 34 ++-- .../java/org/onap/aaf/auth/env/AuthzTrans.java | 24 +-- .../org/onap/aaf/auth/env/AuthzTransFilter.java | 20 +-- .../java/org/onap/aaf/auth/env/AuthzTransImpl.java | 30 ++-- .../onap/aaf/auth/env/AuthzTransOnlyFilter.java | 8 +- .../main/java/org/onap/aaf/auth/env/NullTrans.java | 14 +- .../onap/aaf/auth/layer/DirectIntrospectImpl.java | 4 +- .../java/org/onap/aaf/auth/layer/FacadeImpl.java | 6 +- .../main/java/org/onap/aaf/auth/layer/Result.java | 46 +++--- .../main/java/org/onap/aaf/auth/local/AbsData.java | 30 ++-- .../java/org/onap/aaf/auth/local/DataFile.java | 30 ++-- .../java/org/onap/aaf/auth/local/TextIndex.java | 42 ++--- .../onap/aaf/auth/log4j/Log4JAccessAppender.java | 4 +- .../java/org/onap/aaf/auth/org/EmailWarnings.java | 4 +- .../main/java/org/onap/aaf/auth/org/Executor.java | 8 +- .../java/org/onap/aaf/auth/org/FileMailer.java | 18 +-- .../main/java/org/onap/aaf/auth/org/Mailer.java | 10 +- .../java/org/onap/aaf/auth/org/Organization.java | 176 ++++++++++----------- .../onap/aaf/auth/org/OrganizationException.java | 6 +- .../org/onap/aaf/auth/org/OrganizationFactory.java | 20 +-- .../java/org/onap/aaf/auth/rserv/Acceptor.java | 28 ++-- .../org/onap/aaf/auth/rserv/CachingFileAccess.java | 110 ++++++------- .../java/org/onap/aaf/auth/rserv/CodeSetter.java | 8 +- .../main/java/org/onap/aaf/auth/rserv/Content.java | 22 +-- .../java/org/onap/aaf/auth/rserv/HttpCode.java | 36 ++--- .../java/org/onap/aaf/auth/rserv/HttpMethods.java | 4 +- .../main/java/org/onap/aaf/auth/rserv/Match.java | 42 ++--- .../main/java/org/onap/aaf/auth/rserv/Pair.java | 12 +- .../java/org/onap/aaf/auth/rserv/RServlet.java | 20 +-- .../main/java/org/onap/aaf/auth/rserv/Route.java | 20 +-- .../java/org/onap/aaf/auth/rserv/RouteReport.java | 4 +- .../main/java/org/onap/aaf/auth/rserv/Routes.java | 18 +-- .../java/org/onap/aaf/auth/rserv/TransFilter.java | 28 ++-- .../org/onap/aaf/auth/rserv/TransOnlyFilter.java | 14 +- .../java/org/onap/aaf/auth/rserv/TypedCode.java | 48 +++--- .../main/java/org/onap/aaf/auth/rserv/Version.java | 10 +- .../java/org/onap/aaf/auth/rserv/doc/ApiDoc.java | 6 +- .../java/org/onap/aaf/auth/server/AbsService.java | 32 ++-- .../onap/aaf/auth/server/AbsServiceStarter.java | 22 +-- .../onap/aaf/auth/server/JettyServiceStarter.java | 46 +++--- .../java/org/onap/aaf/auth/server/Log4JLogIt.java | 16 +- .../org/onap/aaf/auth/server/ServiceStarter.java | 4 +- .../org/onap/aaf/auth/validation/Validator.java | 12 +- 45 files changed, 573 insertions(+), 573 deletions(-) (limited to 'auth/auth-core/src/main') diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/cache/Cache.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/cache/Cache.java index 6a8ccf1e..ca387dc5 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/cache/Cache.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/cache/Cache.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. @@ -37,7 +37,7 @@ import org.onap.aaf.misc.env.Trans; /** * Create and maintain a Map of Maps used for Caching - * + * * @author Jonathan * * @param @@ -58,7 +58,7 @@ public class Cache { /** * Dated Class - store any Data with timestamp - * + * * @author Jonathan * */ @@ -66,7 +66,7 @@ public class Cache { public Date timestamp; public List data; private long expireIn; - + public Dated(List data, long expireIn) { timestamp = new Date(System.currentTimeMillis()+expireIn); this.data = data; @@ -85,7 +85,7 @@ public class Cache { timestamp = new Date(System.currentTimeMillis()+expireIn); } } - + public static Map obtain(String key) { Map m = cacheMap.get(key); if (m==null) { @@ -99,24 +99,24 @@ public class Cache { /** * Clean will examine resources, and remove those that have expired. - * + * * If "highs" have been exceeded, then we'll expire 10% more the next time. This will adjust after each run * without checking contents more than once, making a good average "high" in the minimum speed. - * + * * @author Jonathan * */ private static final class Clean extends TimerTask { private final Env env; private Set set; - - // The idea here is to not be too restrictive on a high, but to Expire more items by + + // The idea here is to not be too restrictive on a high, but to Expire more items by // shortening the time to expire. This is done by judiciously incrementing "advance" // when the "highs" are exceeded. This effectively reduces numbers of cached items quickly. private final int high; private long advance; private final long timeInterval; - + public Clean(Env env, long cleanInterval, int highCount) { this.env = env; high = highCount; @@ -124,7 +124,7 @@ public class Cache { advance = 0; set = new HashSet<>(); } - + public synchronized void add(String key) { set.add(key); } @@ -134,8 +134,8 @@ public class Cache { int total = 0; // look at now. If we need to expire more by increasing "now" by "advance" Date now = new Date(System.currentTimeMillis() + advance); - - + + for (String name : set) { Map map = cacheMap.get(name); if (map==null) { @@ -150,7 +150,7 @@ public class Cache { } } } - + if (count>0) { env.debug().log("Cache removed",count,"expired Cached Elements out of", total); } @@ -170,11 +170,11 @@ public class Cache { public static synchronized void startCleansing(Env env, String ... keys) { if (cleanseTimer==null) { cleanseTimer = new Timer("Cache Cleanup Timer"); - int cleanInterval = Integer.parseInt(env.getProperty(CACHE_CLEAN_INTERVAL,"60000")); // 1 minute clean cycles + int cleanInterval = Integer.parseInt(env.getProperty(CACHE_CLEAN_INTERVAL,"60000")); // 1 minute clean cycles int highCount = Integer.parseInt(env.getProperty(CACHE_HIGH_COUNT,"5000")); cleanseTimer.schedule(clean = new Clean(env, cleanInterval, highCount), cleanInterval, cleanInterval); } - + for (String key : keys) { clean.add(key); } @@ -193,7 +193,7 @@ public class Cache { public void run() { Cache.stopTimer(); } - }); + }); } } 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 5fb590c1..77d9e8a0 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 @@ -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. @@ -44,14 +44,14 @@ public class Define { } return ROOT_NS; } - + public static String ROOT_COMPANY() { if (ROOT_NS==null) { throw new RuntimeException(Define.class.getName() + MSG); } return ROOT_COMPANY; } - + public static void set(Access access) throws CadiException { ROOT_NS = access.getProperty(Config.AAF_ROOT_NS,"org.osaaf.aaf"); ROOT_COMPANY = access.getProperty(Config.AAF_ROOT_COMPANY,null); @@ -63,7 +63,7 @@ public class Define { throw new CadiException(Config.AAF_ROOT_COMPANY + " or " + Config.AAF_ROOT_NS + " property with 3 positions is required."); } } - + for ( Entry es : access.getProperties().entrySet()) { if (es.getKey().toString().startsWith(ROOT_NS_TAG_DOT)) { access.getProperties().setProperty(es.getKey().toString(),varReplace(es.getValue().toString())); @@ -90,7 +90,7 @@ public class Define { public static boolean isInitialized() { return initialized; } - + public static String getCredType(int type) { switch(type) { case 0: return "NoCrd"; @@ -102,5 +102,5 @@ public class Define { return "n/a"; } } - + } 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 a46be8ef..0e2d4145 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 @@ -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. @@ -39,10 +39,10 @@ import org.onap.aaf.misc.rosetta.env.RosettaEnv; /** * AuthzEnv is the Env tailored to Authz Service - * + * * Most of it is derived from RosettaEnv, but it also implements Access, which * is an Interface that Allows CADI to interact with Container Logging - * + * * @author Jonathan * */ @@ -65,14 +65,14 @@ public class AuthzEnv extends RosettaEnv implements Access { super(); _init(new PropAccess(props)); } - + public AuthzEnv(PropAccess pa) { super(); _init(pa); } - - private final void _init(PropAccess pa) { + + private final void _init(PropAccess pa) { access = pa; times = new long[20]; idx = 0; @@ -85,16 +85,16 @@ public class AuthzEnv extends RosettaEnv implements Access { debug = new AccessLogTarget(access, Level.DEBUG); trace = new AccessLogTarget(access, Level.TRACE); } - + private class AccessLogTarget implements LogTarget { private final Level level; private final Access access; - + public AccessLogTarget(final Access access, final Level level) { this.level = level; this.access = access; } - + @Override public void log(Object... msgs) { access.log(level, msgs); @@ -117,7 +117,7 @@ public class AuthzEnv extends RosettaEnv implements Access { public void printf(String fmt, Object... vars) { access.printf(level, fmt, vars); } - + } @Override public AuthzTransImpl newTrans() { @@ -146,7 +146,7 @@ public class AuthzEnv extends RosettaEnv implements Access { ++count; pot += times[i]-prev; } - prev = times[i]; + prev = times[i]; } } for (int i=0;i { public static final String SPECIAL_LOG_SLOT = "SPECIAL_LOG_SLOT"; public static final int BUCKETSIZE = 2; - + public AuthzTransFilter(AuthzEnv env, Connector con, TrustChecker tc, Object ... additionalTafLurs) throws CadiException, LocatorException { super(env.access(),con, tc, additionalTafLurs); this.env = env; @@ -61,7 +61,7 @@ public class AuthzTransFilter extends TransFilter { specialLogSlot = env.slot(SPECIAL_LOG_SLOT); } } - + @Override protected AuthzTrans newTrans(HttpServletRequest req, HttpServletResponse resp) { AuthzTrans at = env.newTrans(); @@ -87,7 +87,7 @@ public class AuthzTransFilter extends TransFilter { protected void tallyHo(AuthzTrans trans, String target) { Boolean b = trans.get(specialLogSlot, false); LogTarget lt = b?trans.warn():trans.debug(); - + if (lt.isLoggable()) { // Transaction is done, now post full Audit Trail StringBuilder sb = new StringBuilder("AuditTrail\n"); @@ -100,7 +100,7 @@ public class AuthzTransFilter extends TransFilter { for (int i=0;i { public AuthzTransOnlyFilter(AuthzEnv env) { this.env = env; serviceMetric = new Metric(); - serviceMetric.buckets = new float[BUCKETSIZE]; + serviceMetric.buckets = new float[BUCKETSIZE]; } - + @Override protected AuthzTrans newTrans(HttpServletRequest req, HttpServletResponse resp) { AuthzTrans trans = env.newTrans(); 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 df086cda..a10cae9c 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 @@ -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. @@ -42,13 +42,13 @@ import org.onap.aaf.misc.env.TimeTaken; */ public class NullTrans implements AuthzTrans { private static final AuthzTrans singleton = new NullTrans(); - + public static final AuthzTrans singleton() { return singleton; } private Date now; - + public void checkpoint(String text) {} public void checkpoint(String text, int additionalFlag) {} public Metric auditTrail(int indent, StringBuilder sb, int... flag) {return null;} @@ -144,7 +144,7 @@ public class NullTrans implements AuthzTrans { public HttpServletResponse hresp() { return null; } - + @Override public String user() { @@ -159,7 +159,7 @@ public class NullTrans implements AuthzTrans { @Override public void setUser(TaggedPrincipal p) { } - + @Override public String ip() { return null; @@ -209,7 +209,7 @@ public class NullTrans implements AuthzTrans { @Override public Lur getLur() { - return null; + return null; } @Override diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/DirectIntrospectImpl.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/DirectIntrospectImpl.java index 41f0e74a..dd3a14d9 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/DirectIntrospectImpl.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/DirectIntrospectImpl.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. diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/FacadeImpl.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/FacadeImpl.java index c81504b6..a80ad26f 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/FacadeImpl.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/FacadeImpl.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. @@ -34,7 +34,7 @@ public abstract class FacadeImpl { protected void setContentType(HttpServletResponse response, TYPE type) { response.setContentType(type==Data.TYPE.JSON?"application/json":"text.xml"); } - + protected void setCacheControlOff(HttpServletResponse response) { response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java index 9d7347ac..9050553c 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.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. @@ -28,7 +28,7 @@ import java.util.Set; /** * It would be nice if Java Enums were extensible, but they're not. - * + * * @author Jonathan * */ @@ -47,12 +47,12 @@ public class Result { ERR_ActionNotCompleted = 8, ERR_Backend = 9, ERR_General = 20; - + public RV value; public final int status; public final String details; public final Object[] variables; - + public Result(RV value, int status, String details, Object ... variables) { this.value = value; if (value==null) { @@ -66,12 +66,12 @@ public class Result { this.variables=variables; } } - + /** * Create a Result class with "OK" status and "Success" for details - * + * * This is the easiest to use - * + * * @param value * @param status * @return @@ -126,7 +126,7 @@ public class Result { } /** - * Create a Status (usually non OK, with a details statement + * Create a Status (usually non OK, with a details statement * @param value * @param status * @param details @@ -135,7 +135,7 @@ public class Result { // public static Result err(int status, String details) { // return new Result(null,status,details,null); // } - + /** * Create a Status (usually non OK, with a details statement and variables supported * @param status @@ -166,7 +166,7 @@ public class Result { } /** - * Create a Status (usually non OK, with a details statement + * Create a Status (usually non OK, with a details statement * @param value * @param status * @param details @@ -177,7 +177,7 @@ public class Result { } /** - * Create a Status from a previous status' result/details + * Create a Status from a previous status' result/details * @param value * @param status * @param details @@ -189,10 +189,10 @@ public class Result { private static final int PARTIAL_CONTENT = 0x001; private static final int EMPTY_LIST = 0x002; - + /** - * AAF Specific problems, etc - * + * AAF Specific problems, etc + * * @author Jonathan * */ @@ -227,7 +227,7 @@ public class Result { /** * When Result is a List, you can check here to see if it's empty instead of looping - * + * * @return */ public boolean isEmpty() { @@ -237,7 +237,7 @@ public class Result { /** * A common occurrence is that data comes back, but list is empty. If set, you can skip looking * at list at the outset. - * + * * @param emptyList * @return */ @@ -250,8 +250,8 @@ public class Result { return this; } - - /** + + /** * Convenience function. Checks OK, and also if List is not Empty * Not valid if Data is not a List * @return @@ -260,7 +260,7 @@ public class Result { return status == OK; } - /** + /** * Convenience function. Checks OK, and also if List is not Empty * Not valid if Data is not a List * @return @@ -269,7 +269,7 @@ public class Result { return status != OK; } - /** + /** * Convenience function. Checks OK, and also if List is not Empty * Not valid if Data is not a List * @return @@ -279,7 +279,7 @@ public class Result { } - /** + /** * Convenience function. Checks OK, and also if List is not Empty * Not valid if Data is not a List * @return @@ -307,7 +307,7 @@ public class Result { return sb.toString(); } } - + public String errorString() { StringBuilder sb = new StringBuilder(); switch(status) { diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java index 6f644bd4..cdc0e486 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/AbsData.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. @@ -55,21 +55,21 @@ public abstract class AbsData implements Iterable { this.fieldOffset = fieldOffset; idxf = new File(dir,name.concat(".idx")); lockf = new File(dir,name.concat(".lock")); - - + + data = new DataFile(dataf,"r"); ti = new TextIndex(idxf); skipLines=0; } - + public void skipLines(int lines) { skipLines=lines; } - + public String name() { return name; } - + public void open(AuthzTrans trans, long timeout) throws IOException { TimeTaken tt = trans.start("Open Data File", Env.SUB); boolean first = true; @@ -84,7 +84,7 @@ public abstract class AbsData implements Iterable { if (first) { trans.warn().log("Waiting for",lockf.getCanonicalPath(),"to close"); first = false; - } + } try { Thread.sleep(200); } catch (InterruptedException e) { @@ -103,12 +103,12 @@ public abstract class AbsData implements Iterable { throw e; } ti.open(); - + } finally { tt.done(); } } - + private synchronized void ensureIdxGood(AuthzTrans trans) throws IOException { if (!idxf.exists() || idxf.length()==0 || dataf.lastModified()>idxf.lastModified()) { trans.warn().log(idxf.getAbsolutePath(),"is missing, empty or out of date, creating"); @@ -129,7 +129,7 @@ public abstract class AbsData implements Iterable { ti.close(); data.close(); } - + public class Reuse { public Token tokenData; private Field fieldData; @@ -138,7 +138,7 @@ public abstract class AbsData implements Iterable { tokenData = data.new Token(size); fieldData = tokenData.new Field(delim); } - + public void reset() { getFieldData().reset(); } @@ -151,7 +151,7 @@ public abstract class AbsData implements Iterable { public String next() { return getFieldData().next(); } - + public String at(int field) { return getFieldData().at(field); } @@ -164,7 +164,7 @@ public abstract class AbsData implements Iterable { return fieldData; } } - + public Reuse reuse() { return new Reuse(maxLineSize,delim); } @@ -172,7 +172,7 @@ public abstract class AbsData implements Iterable { public Iter iterator() { return new Iter(); } - + public class Iter implements Iterator { private Reuse reuse; private org.onap.aaf.auth.local.TextIndex.Iter tii; diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/DataFile.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/DataFile.java index a65c13db..2ca6e1f9 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/DataFile.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/DataFile.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. @@ -37,7 +37,7 @@ public class DataFile { public MappedByteBuffer mapBuff; private final File file; private final String access; - + public DataFile(File file, String access) { this.file = file; this.access = access; @@ -73,21 +73,21 @@ public class DataFile { } return len<0?0:len; } - + public class Token { private byte[] buff; int pos, next, end; - + public Token(int size) { buff = new byte[size]; pos = next = end = 0; } - + public boolean pos(int to) { pos = next = to; return (end=load(this))>0; } - + public boolean nextLine() { end = load(this); pos = next; @@ -100,7 +100,7 @@ public class DataFile { } return false; } - + public IntBuffer getIntBuffer() { return ByteBuffer.wrap(buff).asIntBuffer(); } @@ -108,7 +108,7 @@ public class DataFile { public String toString() { return new String(buff,0,end); } - + public class Field { char delim; int idx; @@ -119,12 +119,12 @@ public class DataFile { idx = 0; bb = null; } - + public Field reset() { idx = 0; return this; } - + public String next() { if (idx>=end)return null; int start = idx; @@ -134,7 +134,7 @@ public class DataFile { if (c=='\r')endStr=idx; ++idx; } - + if (endStr<0) { endStr=idx-start; } else { @@ -157,7 +157,7 @@ public class DataFile { } return new String(buff,start,(idx-start-(c=='\r'?1:0))); } - + public String atToEnd(int fieldOffset) { int start; byte c=0; @@ -169,7 +169,7 @@ public class DataFile { start = idx+1; } } - + for (; idx entries = new ArrayList<>(); for (int i=min;i<=max;++i) { ttok.pos(i*REC_SIZE); @@ -100,7 +100,7 @@ public class TextIndex { break; } } - + for (Integer i : entries) { dtok.pos(i); if (df.at(offset).equals(key)) { @@ -109,7 +109,7 @@ public class TextIndex { } return -1; } - + /* * Have to change Bytes into a Long, to avoid the inevitable signs in the Hash @@ -123,10 +123,10 @@ public class TextIndex { } return rv; } - + public void create(final Trans trans,final DataFile data, int maxLine, char delim, int fieldOffset, int skipLines) throws IOException { FileChannel fos; - + List list = new LinkedList<>(); // Some hashcodes will double... DO NOT make a set TimeTaken tt2 = trans.start("Open Files", Env.SUB); RandomAccessFile raf=null; @@ -138,12 +138,12 @@ public class TextIndex { } finally { tt2.done(); } - + try { - - Token t = data.new Token(maxLine); + + Token t = data.new Token(maxLine); Field f = t.new Field(delim); - + int count = 0; if (skipLines>0) { trans.info().log("Skipping",skipLines,"line"+(skipLines==1?" in":"s in"),data.file().getName()); @@ -184,14 +184,14 @@ public class TextIndex { } } finally { fos.close(); - } + } } finally { if (raf!=null) { raf.close(); // closed by fos } } } - + public class Iter { private int idx; private Token t; @@ -210,7 +210,7 @@ public class TextIndex { end = -1L; } } - + public int next() { t.pos(idx); ib.clear(); @@ -224,14 +224,14 @@ public class TextIndex { return idx { public int hash, pos; public Idx(Object obj, int pos) { hash = obj.hashCode(); this.pos = pos; } - + @Override public int compareTo(Idx ib) { long a = hashToLong(hash); 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 165295d9..7cb25c73 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 @@ -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. diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/EmailWarnings.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/EmailWarnings.java index 7084fbd8..be5d6e0e 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/EmailWarnings.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/EmailWarnings.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. diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Executor.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Executor.java index 48ac9dce..bfe588f3 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Executor.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/Executor.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,9 +26,9 @@ public interface Executor { // remove user from Admins // if # of Owners > 1, remove User from Owner // if # of Owners = 1, changeOwner to X Remove Owner???? - boolean hasPermission(String user, String ns, String type, String instance, String action); + boolean hasPermission(String user, String ns, String type, String instance, String action); boolean inRole(String name); - + public String namespace() throws Exception; public String id(); } 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 9478832b..8896ca87 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 @@ -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. @@ -41,7 +41,7 @@ public class FileMailer implements Mailer { 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"); @@ -59,7 +59,7 @@ public class FileMailer implements Mailer { 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); @@ -94,7 +94,7 @@ public class FileMailer implements Mailer { bw.write(to); } bw.newLine(); - + bw.write("CC: "); first = true; for(String cc : ccList) { @@ -106,17 +106,17 @@ public class FileMailer implements Mailer { 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.write("Importance: High"); bw.newLine(); } 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 64a2e8dd..ad1d5a23 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 @@ -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. @@ -28,9 +28,9 @@ public interface Mailer { public boolean sendEmail( AuthzTrans trans, String test, - List toList, - List ccList, - String subject, + List toList, + List ccList, + String subject, String body, Boolean urgent) throws OrganizationException; 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 75669632..288d79d3 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 @@ -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. @@ -32,13 +32,13 @@ import org.onap.aaf.auth.env.AuthzTrans; /** * Organization - * + * * There is Organizational specific information required which we have extracted to a plugin - * + * * It supports using Company Specific User Directory lookups, as well as supporting an * Approval/Validation Process to simplify control of Roles and Permissions for large organizations - * in lieu of direct manipulation by a set of Admins. - * + * in lieu of direct manipulation by a set of Admins. + * * @author Jonathan * */ @@ -55,7 +55,7 @@ public interface Organization { public String fullName(); public String firstName(); /** - * If Responsible entity, then String returned is "null" meaning "no Objection". + * If Responsible entity, then String returned is "null" meaning "no Objection". * If String exists, it is the Policy objection text setup by the entity. * @return */ @@ -90,7 +90,7 @@ public interface Organization { * @return */ public String getRealm(); - + public boolean supportsRealm(String user); public void addSupportedRealm(String r); @@ -99,44 +99,44 @@ public interface Organization { /** * Get Identity information based on userID - * + * * @param id * @return */ public Identity getIdentity(AuthzTrans trans, String id) throws OrganizationException; - + /** * Is Revoked - * - * Deletion of an Identity that has been removed from an Organization can be dangerous. Mistakes may have been made - * in the Organization side, a Feed might be corrupted, an API might not be quite right. - * + * + * Deletion of an Identity that has been removed from an Organization can be dangerous. Mistakes may have been made + * in the Organization side, a Feed might be corrupted, an API might not be quite right. + * * The implementation of this method can use a double check of some sort, such as comparison of missing ID in Organization - * feed with a "Deleted ID" feed. - * + * feed with a "Deleted ID" feed. + * */ public boolean isRevoked(AuthzTrans trans, String id); /** * Does the ID pass Organization Standards - * - * Return a Blank (empty) String if empty, otherwise, return a "\n" separated list of + * + * Return a Blank (empty) String if empty, otherwise, return a "\n" separated list of * reasons why it fails - * + * * @param id * @return */ public String isValidID(AuthzTrans trans, String id); /** - * Return a Blank (empty) String if empty, otherwise, return a "\n" separated list of + * Return a Blank (empty) String if empty, otherwise, return a "\n" separated list of * reasons why it fails - * + * * Identity is passed in to allow policies regarding passwords that are the same as user ID - * + * * any entries for "prev" imply a reset - * + * * @param id * @param password * @return @@ -149,7 +149,7 @@ public interface Organization { public String[] getPasswordRules(); /** - * + * * @param id * @return */ @@ -157,7 +157,7 @@ public interface Organization { /** * If response is Null, then it is valid. Otherwise, the Organization specific reason is returned. - * + * * @param trans * @param policy * @param executor @@ -169,7 +169,7 @@ public interface Organization { /** * Does your Company distinguish essential permission structures by kind of Identity? - * i.e. Employee, Contractor, Vendor + * i.e. Employee, Contractor, Vendor * @return */ public Set getIdentityTypes(); @@ -198,30 +198,30 @@ public interface Organization { ERR_UserNotExist, ERR_NotificationFailure, }; - + public enum Expiration { Password, - TempPassword, + TempPassword, Future, UserInRole, - UserDelegate, + UserDelegate, ExtendPassword } - + public enum Policy { - CHANGE_JOB, - LEFT_COMPANY, - CREATE_MECHID, + CHANGE_JOB, + LEFT_COMPANY, + CREATE_MECHID, CREATE_MECHID_BY_PERM_ONLY, OWNS_MECHID, - AS_RESPONSIBLE, + AS_RESPONSIBLE, MAY_EXTEND_CRED_EXPIRES, MAY_APPLY_DEFAULT_REALM } - + /** * Notify a User of Action or Info - * + * * @param type * @param url * @param users (separated by commas) @@ -233,7 +233,7 @@ public interface Organization { /** * (more) generic way to send an email - * + * * @param toList * @param ccList * @param subject @@ -245,36 +245,36 @@ public interface Organization { /** * whenToValidate - * + * * Authz support services will ask the Organization Object at startup when it should - * kickoff Validation processes given particular types. - * + * kickoff Validation processes given particular types. + * * This allows the Organization to express Policy - * + * * Turn off Validation behavior by returning "null" - * + * */ public Date whenToValidate(Notify type, Date lastValidated); - + /** * Expiration - * + * * Given a Calendar item of Start (or now), set the Expiration Date based on the Policy * based on type. - * + * * For instance, "Passwords expire in 3 months" - * + * * The Extra Parameter is used by certain Orgs. - * + * * For Password, the extra is UserID, so it can check the User Type - * + * * @param gc * @param exp * @return */ public GregorianCalendar expiration(GregorianCalendar gc, Expiration exp, String ... extra); - + /** * Get Email Warning timing policies * @return @@ -282,7 +282,7 @@ public interface Organization { public EmailWarnings emailWarningPolicy(); /** - * + * * @param trans * @param user * @return @@ -295,23 +295,23 @@ public interface Organization { * 2 = expects both self and immediate responsible party * 3 = expects self, immediate report and any higher that the Organization wants to escalate to in the * hierarchy. - * + * * Note: this is used to notify of imminent danger of Application's Cred or Role expirations. */ public List getIDs(AuthzTrans trans, String user, int escalate) throws OrganizationException ; - + /* - * + * * @param user * @param type * @param users * @return public Response notifyRequest(AuthzTrans trans, String user, Approval type, List approvers); */ - + /** - * + * * @return */ public String getApproverType(); @@ -319,7 +319,7 @@ public interface Organization { /* * startOfDay - define for company what hour of day business starts (specifically for password and other expiration which * were set by Date only.) - * + * * @return */ public int startOfDay(); @@ -333,12 +333,12 @@ public interface Organization { * @return */ public boolean canHaveMultipleCreds(String id); - + boolean isTestEnv(); public void setTestMode(boolean dryRun); - public static final Organization NULL = new Organization() + public static final Organization NULL = new Organization() { private final GregorianCalendar gc = new GregorianCalendar(1900, 1, 1); private final List nullList = new ArrayList<>(); @@ -355,27 +355,27 @@ public interface Organization { public String mayOwn() { return N_A; // negative case } - + @Override public boolean isFound() { return false; } - + @Override public String id() { return N_A; } - + @Override public String fullID() { return N_A; } - + @Override public String email() { return N_A; } - + @Override public List delegate() { return nullUser; @@ -406,12 +406,12 @@ public interface Organization { public String getName() { return N_A; } - + @Override public String getRealm() { return N_A; } - + @Override public boolean supportsRealm(String r) { return false; @@ -425,87 +425,87 @@ public interface Organization { public String getDomain() { return N_A; } - + @Override public Identity getIdentity(AuthzTrans trans, String id) { return nullIdentity; } - + @Override public String isValidID(final AuthzTrans trans, String id) { return N_A; } - + @Override public String isValidPassword(final AuthzTrans trans, final String user, final String password, final String... prev) { return N_A; } - + @Override public Set getIdentityTypes() { return nullStringSet; } - + @Override public Response notify(AuthzTrans trans, Notify type, String url, String[] users, String[] ccs, String summary, Boolean urgent) { return Response.ERR_NotImplemented; } - + @Override public int sendEmail(AuthzTrans trans, List toList, List ccList, String subject, String body, Boolean urgent) throws OrganizationException { return 0; } - + @Override public Date whenToValidate(Notify type, Date lastValidated) { return gc.getTime(); } - + @Override public GregorianCalendar expiration(GregorianCalendar gc, Expiration exp, String... extra) { return gc; } - + @Override public List getApprovers(AuthzTrans trans, String user) throws OrganizationException { return nullList; } - + @Override public String getApproverType() { return ""; } - + @Override public int startOfDay() { return 0; } - + @Override public boolean canHaveMultipleCreds(String id) { return false; } - + @Override public boolean isValidCred(final AuthzTrans trans, final String id) { return false; } - + @Override public String validate(AuthzTrans trans, Policy policy, Executor executor, String ... vars) throws OrganizationException { return "Null Organization rejects all Policies"; } - + @Override public boolean isTestEnv() { return false; } - + @Override public void setTestMode(boolean dryRun) { } @@ -519,24 +519,24 @@ public interface Organization { { return 604800000L; // 7 days in millis 1000 * 86400 * 7 } - + @Override public long roleEmailInterval() { return 604800000L; // 7 days in millis 1000 * 86400 * 7 } - + @Override public long apprEmailInterval() { return 259200000L; // 3 days in millis 1000 * 86400 * 3 } - + @Override public long credExpirationWarning() { return( 2592000000L ); // One month, in milliseconds 1000 * 86400 * 30 in milliseconds } - + @Override public long roleExpirationWarning() { @@ -550,15 +550,15 @@ public interface Organization { } }; - + } @Override public String[] getPasswordRules() { - return nullStringArray; + 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. diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationException.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationException.java index 347e2d35..c291c65b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationException.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationException.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. @@ -24,7 +24,7 @@ package org.onap.aaf.auth.org; public class OrganizationException extends Exception { /** - * + * */ private static final long serialVersionUID = 1L; 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 2ada75d2..867d2984 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 @@ -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. @@ -36,10 +36,10 @@ import org.onap.aaf.misc.env.impl.BasicEnv; /** * Organization Plugin Mechanism - * - * Define a NameSpace for the company (i.e. com.att), and put in Properties as - * "Organization.[your NS" and assign the supporting Class. - * + * + * Define a NameSpace for the company (i.e. com.att), and put in Properties as + * "Organization.[your NS" and assign the supporting Class. + * * Example: * Organization.com.att=org.onap.aaf.auth.org.test.att.ATT * @@ -53,7 +53,7 @@ public class OrganizationFactory { public static Organization init(BasicEnv env) throws OrganizationException { int idx = ORGANIZATION_DOT.length(); Organization org,firstOrg = null; - + for (Entry es : env.getProperties().entrySet()) { String key = es.getKey().toString(); if (key.startsWith(ORGANIZATION_DOT)) { @@ -117,8 +117,8 @@ public class OrganizationFactory { org.addSupportedRealm(r); } } - } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | - InstantiationException | IllegalAccessException | IllegalArgumentException | + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | + InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { env.error().log(e, "Error on Organization Construction"); throw new OrganizationException(e); @@ -138,7 +138,7 @@ public class OrganizationFactory { } } } - + return org; } 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 0e70e25e..bd718e46 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 @@ -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. @@ -29,7 +29,7 @@ import org.onap.aaf.misc.env.Trans; /** * Find Acceptable Paths and place them where TypeCode can evaluate. - * + * * If there are more than one, TypeCode will choose based on "q" value * @author Jonathan * @@ -38,12 +38,12 @@ import org.onap.aaf.misc.env.Trans; class Acceptor { private List, List>>>> types; List, List>>>> acceptable; - + public Acceptor(List, List>>>> types) { this.types = types; acceptable = new ArrayList<>(); } - + private boolean eval(HttpCode code, String str, List props) { // int plus = str.indexOf('+'); // if (plus<0) { @@ -67,7 +67,7 @@ class Acceptor { // String nstr; // while (prev!=0) { // nstr = first + (plus<0?str.substring(prev):str.substring(prev,plus)); -// +// // for (Pair, List>>> type : types) { // if (type.x.equals(nstr)) { // acceptable.add(type); @@ -114,17 +114,17 @@ class Acceptor { } /** - * parse - * + * parse + * * Note: I'm processing by index to avoid lots of memory creation, which speeds things - * up for this time critical section of code. + * up for this time critical section of code. * @param code * @param cntnt * @return */ protected boolean parse(HttpCode code, String cntnt) { byte bytes[] = cntnt.getBytes(); - + int cis,cie=-1,cend; int sis,sie,send; String name; @@ -133,17 +133,17 @@ class Acceptor { // Clear these in case more than one Semi props.clear(); // on loop, do not want mixed properties name=null; - + cis = cie+1; // find comma start while (ciscis && Character.isSpaceChar(bytes[cend-1]))--cend; // Start SEMIS - sie=cis-1; + sie=cis-1; do { sis = sie+1; // semi start is one after previous end - while (siscend || sie<0?cend:sie; // if the Semicolon is after the comma, or non-existent, use comma end, else keep while (send>sis && Character.isSpaceChar(bytes[send-1]))--send; @@ -165,5 +165,5 @@ class Acceptor { } while (cie>=0); // loop to next comma return false; // didn't get even one match } - + } \ No newline at end of file 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 ac87d80e..3c76e928 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 @@ -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. @@ -55,15 +55,15 @@ import org.onap.aaf.misc.env.Store; import org.onap.aaf.misc.env.Trans; /* * CachingFileAccess - * + * * Author: Jonathan Gathman, Gathsys 2010 - * + * */ public class CachingFileAccess extends HttpCode { public static void setEnv(Store store, String[] args) { - for (int i=0;i extends HttpCode typeMap; private final NavigableMap content; @@ -79,7 +79,7 @@ public class CachingFileAccess extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode0; } - + if (mediaType==null) { // determine from file Ending int idx = key.lastIndexOf('.'); String subkey = key.substring(++idx); @@ -279,9 +279,9 @@ public class CachingFileAccess extends HttpCode extends HttpCode extends HttpCode extends HttpCode() { @Override @@ -399,7 +399,7 @@ public class CachingFileAccess extends HttpCode extends HttpCode extends HttpCode extends HttpCode extends HttpCode content; - + public Cleanup(NavigableMap content, int size) { maxSize = size; this.content = content; } - + private class Comp implements Comparable { public Map.Entry entry; - + public Comp(Map.Entry en) { entry = en; } - + @Override public int compareTo(Comp o) { return (int)(entry.getValue().access-o.entry.getValue().access); } - + } @SuppressWarnings("unchecked") @Override 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 1c171fd7..761fd8cc 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 @@ -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. @@ -39,13 +39,13 @@ class CodeSetter { this.trans = trans; this.req = req; this.resp = resp; - + } public boolean matches(Route route) throws IOException, ServletException { // Find best Code in Route based on "Accepts (Get) or Content-Type" (if exists) return (code = route.getCode(trans, req, resp))!=null; } - + public HttpCode code() { return code; } 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 63a2eeaa..e9c8adb0 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 @@ -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. @@ -29,14 +29,14 @@ import org.onap.aaf.misc.env.Trans; /** * A Class to hold Service "ContentTypes", and to match incoming "Accept" types from HTTP. - * + * * This is a multi-use class built to use the same Parser for ContentTypes and Accept. - * + * * Thus, you would create and use "Content.Type" within your service, and use it to match * Accept Strings. What is returned is an Integer (for faster processing), which can be * used in a switch statement to act on match different Actions. The server should * know which behaviors match. - * + * * "bestMatch" returns an integer for the best match, or -1 if no matches. * * @author Jonathan @@ -49,16 +49,16 @@ public abstract class Content { /** * Parse a Content-Type/Accept. As found, call "types" and "props", which do different - * things depending on if it's a Content-Type or Accepts. - * + * things depending on if it's a Content-Type or Accepts. + * * For Content-Type, it builds a tree suitable for Comparison * For Accepts, it compares against the tree, and builds an acceptable type list - * + * * Since this parse code is used for every incoming HTTP transaction, I have removed the implementation * that uses String.split, and replaced with integers evaluating the Byte array. This results - * in only the necessary strings created, resulting in 1/3 better speed, and less + * in only the necessary strings created, resulting in 1/3 better speed, and less * Garbage collection. - * + * * @param trans * @param code * @param cntnt @@ -111,5 +111,5 @@ public abstract class Content { } while (cie>=0); return contType && contProp; // for use in finds, True if a type found AND all props matched } - + } 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 0768145f..8c533f6e 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 @@ -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. @@ -28,13 +28,13 @@ import org.onap.aaf.misc.env.Trans; /** * HTTP Code element, which responds to the essential "handle Method". - * + * * Use Native HttpServletRe[quest|sponse] calls for questions like QueryParameters (getParameter, etc) - * + * * Use local "pathParam" method to obtain in an optimized manner the path parameter, which must be interpreted by originating string - * + * * i.e. my/path/:id/:other/* - * + * * @author Jonathan * * @param @@ -45,14 +45,14 @@ public abstract class HttpCode { private String desc; protected String [] roles; private boolean all; - + // Package by design... Set by Route when linked Match match; - + public HttpCode(CONTEXT context, String description, String ... roles) { this.context = context; desc = description; - + // Evaluate for "*" once... all = false; for (String srole : roles) { @@ -63,16 +63,16 @@ public abstract class HttpCode { } this.roles = all?null:roles; } - + public abstract void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws Exception; - + public String desc() { return desc; } - + /** * Get the variable element out of the Path Parameter, as set by initial Code - * + * * @param req * @param key * @return @@ -92,12 +92,12 @@ public abstract class HttpCode { } // Note: get Query Params from Request - + /** * Check for Authorization when set. - * + * * If no Roles set, then accepts all users - * + * * @param req * @return */ @@ -110,11 +110,11 @@ public abstract class HttpCode { } return false; } - + public boolean no_cache() { return false; } - + public String toString() { return desc; } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpMethods.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpMethods.java index 3f7f93c7..2ea340e3 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpMethods.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/HttpMethods.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. 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 599e45b2..8f47126f 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 @@ -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. @@ -27,9 +27,9 @@ import java.util.Set; /** * This path matching algorithm avoids using split strings during the critical transactional run-time. By pre-analyzing the - * content at "set Param" time, and storing data in an array-index model which presumably is done once and at the beginning, + * content at "set Param" time, and storing data in an array-index model which presumably is done once and at the beginning, * we can match in much less time when it actually counts. - * + * * @author Jonathan * */ @@ -39,14 +39,14 @@ public class Match { private Integer vars[]; private boolean wildcard; - + /* * These two methods are pairs of searching performance for variables Spark Style. * setParams evaluates the target path, and sets a HashMap that will return an Integer. * the Keys are both :key and key so that there will be no string operations during * a transaction - * - * For the Integer, if the High Order is 0, then it is just one value. If High Order >0, then it is + * + * For the Integer, if the High Order is 0, then it is just one value. If High Order >0, then it is * a multi-field option, i.e. ending with a wild-card. */ public Match(String path) { @@ -56,7 +56,7 @@ public class Match { String[] pa = path.split("/"); values = new byte[pa.length][]; vars = new Integer[pa.length]; - + int val = 0; String key; for (int i=0;ii)i=k-1; // if we've incremented, have to accommodate the outer for loop incrementing as well fieldMatched = false; // reset @@ -183,10 +183,10 @@ public class Match { } rv = fieldMatched && ++field getParamNames() { return params.keySet(); } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Pair.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Pair.java index f4d1394b..54b2e59e 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Pair.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Pair.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. @@ -22,8 +22,8 @@ package org.onap.aaf.auth.rserv; /** - * A pair of generic Objects. - * + * A pair of generic Objects. + * * @author Jonathan * * @param @@ -32,12 +32,12 @@ package org.onap.aaf.auth.rserv; public class Pair { public X x; public Y y; - + public Pair(X x, Y y) { this.x = x; this.y = y; } - + public String toString() { return "X: " + x.toString() + "-->" + y.toString(); } 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 9dec87db..7f94acba 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 @@ -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. @@ -59,19 +59,19 @@ public abstract class RServlet implements Servlet { r.add(code,moreTypes); env.init().log(r.report(code),code); } - + @Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { HttpServletRequest request = (HttpServletRequest)req; HttpServletResponse response = (HttpServletResponse)res; - + @SuppressWarnings("unchecked") TRANS trans = (TRANS)req.getAttribute(TransFilter.TRANS_TAG); if (trans==null) { response.setStatus(404); // Not Found, because it didn't go through TransFilter return; } - + Route route; HttpCode code=null; String ct = req.getContentType(); @@ -93,7 +93,7 @@ public abstract class RServlet implements Servlet { } finally { tt.done(); } - + if (route!=null && code!=null) { StringBuilder sb = new StringBuilder(72); sb.append(route.auditText); @@ -119,7 +119,7 @@ public abstract class RServlet implements Servlet { } } } - + @Override public String getServletInfo() { return "RServlet for Jetty"; @@ -127,9 +127,9 @@ public abstract class RServlet implements Servlet { /** * 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/Route.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.java index 46a3a955..a3282849 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Route.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. @@ -36,12 +36,12 @@ public class Route { public final String auditText; public final HttpMethods meth; public final String path; - + private Match match; // package on purpose private final TypedCode content; private final boolean isContentType; - + public Route(HttpMethods meth, String path) { this.path = path; auditText = meth.name() + ' ' + path; @@ -50,12 +50,12 @@ public class Route { match = new Match(path); content = new TypedCode(); } - + public void add(HttpCode code, String ... others) { code.match = match; content.add(code, others); } - + public HttpCode getCode(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { // Type is associated with Accept for GET (since it is what is being returned // We associate the rest with ContentType. @@ -82,11 +82,11 @@ public class Route { } return null; } - + public Route matches(String method, String path) { return meth.name().equalsIgnoreCase(method) && match.match(path)?this:null; } - + public TimeTaken start(Trans trans, String auditText, HttpCode code, String type) { StringBuilder sb = new StringBuilder(auditText); sb.append(", "); @@ -100,9 +100,9 @@ public class Route { boolean resolvesTo(HttpMethods hm, String p) { return(path.equals(p) && hm.equals(meth)); } - + public String toString() { - return auditText + ' ' + content; + return auditText + ' ' + content; } public String report(HttpCode code) { diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RouteReport.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RouteReport.java index cb7c48bc..4e4cdb5b 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RouteReport.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/RouteReport.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. diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.java index ed6326a8..3afe223f 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/Routes.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. @@ -35,14 +35,14 @@ public class Routes { // Since this must be very, very fast, and only needs one creation, we'll use just an array. private Route[] routes; private int end; - + @SuppressWarnings("unchecked") public Routes() { routes = new Route[10]; end = 0; } - + // This method for setup of Routes only... // Package on purpose synchronized Route findOrCreate(HttpMethods meth, String path) { @@ -50,7 +50,7 @@ public class Routes { for (int i=0;i=routes.length) { @SuppressWarnings("unchecked") @@ -58,12 +58,12 @@ public class Routes { System.arraycopy(routes, 0, temp, 0, routes.length); routes = temp; } - + routes[end++]=rv=new Route(meth,path); } return rv; } - + public Route derive(HttpServletRequest req, CodeSetter codeSetter) throws IOException, ServletException { Route rv = null; String path = req.getPathInfo(); @@ -71,13 +71,13 @@ public class Routes { //TODO a TREE would be better for (int i=0;rv==null && i routeReport() { ArrayList ltr = new ArrayList<>(); for (int i=0;i implements Filter { public static final String TRANS_TAG = "__TRANS__"; - + private CadiHTTPManip cadi; private final String[] no_authn; - + 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); @@ -81,7 +81,7 @@ public abstract class TransFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } - + protected Lur getLur() { return cadi.getLur(); } @@ -90,19 +90,19 @@ public abstract class TransFilter implements Filter { protected abstract TimeTaken start(TRANS trans); protected abstract void authenticated(TRANS trans, Principal p); protected abstract void tallyHo(TRANS trans, String target); - + @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest)request; HttpServletResponse res = (HttpServletResponse)response; - + TRANS trans = newTrans(req,res); - + TimeTaken overall = start(trans); String target = "n/a"; try { request.setAttribute(TRANS_TAG, trans); - + if (no_authn!=null) { for (String prefix : no_authn) { if (req.getPathInfo().startsWith(prefix)) { @@ -133,7 +133,7 @@ public abstract class TransFilter implements Filter { } finally { security.done(); } - + if (r==RESP.IS_AUTHENTICATED) { trans.checkpoint(resp.desc()); if (cadi.notCadi(cw, res)) { @@ -141,7 +141,7 @@ public abstract class TransFilter implements Filter { } } else { //TODO this is a good place to check if too many checks recently - // Would need Cached Counter objects that are cleaned up on + // Would need Cached Counter objects that are cleaned up on // use trans.checkpoint(resp.desc(),Env.ALWAYS); if (resp.isFailedAttempt()) { diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransOnlyFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransOnlyFilter.java index ef91e485..0cf4b83e 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransOnlyFilter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransOnlyFilter.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. @@ -38,12 +38,12 @@ import org.onap.aaf.misc.env.TransStore; /** * Create a new Transaction Object for each and every incoming Transaction - * + * * Attach to Request. User "FilterHolder" mechanism to retain single instance. - * + * * TransFilter includes CADIFilter as part of the package, so that it can * set User Data, etc, as necessary. - * + * * @author Jonathan * */ @@ -51,14 +51,14 @@ public abstract class TransOnlyFilter implements Filte @Override public void init(FilterConfig filterConfig) throws ServletException { } - + protected abstract TRANS newTrans(HttpServletRequest req, HttpServletResponse resp); protected abstract TimeTaken start(TRANS trans); protected abstract void authenticated(TRANS trans, TaggedPrincipal p); protected abstract void tallyHo(TRANS trans); - + @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { TRANS trans = newTrans((HttpServletRequest)request,(HttpServletResponse)response); 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 6f1372f3..c292fae3 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 @@ -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. @@ -40,17 +40,17 @@ import org.onap.aaf.misc.env.Trans; * FYI: For those in the future wondering why I would create a specialized set of "Pair" for the data content: * 1) TypeCode is used in Route, and this code is used for every transaction... it needs to be blazingly fast * 2) The actual number of objects accessed is quite small and built at startup. Arrays are best - * 3) I needed a small, well defined tree where each level is a different Type. Using a "Pair" Generic definitions, + * 3) I needed a small, well defined tree where each level is a different Type. Using a "Pair" Generic definitions, * I created type-safety at each level, which you can't get from a TreeSet, etc. * 4) Chaining through the Network is simply object dereferencing, which is as fast as Java can go. * 5) The drawback is that in your code is that all the variables are named "x" and "y", which can be a bit hard to - * read both in code, and in the debugger. However, TypeSafety allows your IDE (Eclipse) to help you make the + * read both in code, and in the debugger. However, TypeSafety allows your IDE (Eclipse) to help you make the * choices. Also, make sure you have a good "toString()" method on each object so you can see what's happening * in the IDE Debugger. - * + * * Empirically, this method of obtaining routes proved to be much faster than the HashSet implementations available in otherwise * competent Open Source. - * + * * @author Jonathan * * @param @@ -61,10 +61,10 @@ public class TypedCode extends Content { public TypedCode() { types = new ArrayList<>(); } - + /** * Construct Typed Code based on ContentType parameters passed in - * + * * @param code * @param others * @return @@ -74,17 +74,17 @@ public class TypedCode extends Content { boolean first = true; for (String str : others) { if (first) { - first = false; + first = false; } else { sb.append(','); } sb.append(str); } parse(code, sb.toString()); - + return this; } - + @Override protected Pair, List>>> types(HttpCode code, String str) { Pair,List>>> type = null; @@ -127,7 +127,7 @@ public class TypedCode extends Content { } return type.y.y.add(new Pair(tag,"version".equals(tag)?new Version(value):value)); } - + public Pair, List>>> prep(TRANS trans, String compare){ Pair, List>>> c,rv=null; if (types.size()==1 && "".equals((c=types.get(0)).x)) { // if there are no checks for type, skip @@ -146,11 +146,11 @@ public class TypedCode extends Content { } if (accepted) { switch(acc.acceptable.size()) { - case 0: + case 0: // // TODO best Status Code? // resp.setStatus(HttpStatus.NOT_ACCEPTABLE_406); break; - case 1: + case 1: rv = acc.acceptable.get(0); break; default: // compare Q values to get Best Match @@ -177,14 +177,14 @@ public class TypedCode extends Content { } return rv; } - + /** * Print on String Builder content related to specific Code - * + * * This is for Reporting and Debugging purposes, so the content is not cached. - * + * * If code is "null", then all content is matched - * + * * @param code * @return */ @@ -211,7 +211,7 @@ public class TypedCode extends Content { } return sb; } - + public List> getContent(HttpCode code) { for (Pair, List>>> pair : types) { if (pair.y.x == code) { @@ -220,17 +220,17 @@ public class TypedCode extends Content { } return null; } - + public String toString() { return relatedTo(null,new StringBuilder()).toString(); } - + public void api(RouteReport tr) { // Need to build up a map, because Prop entries can be in several places. HashMap,StringBuilder> psb = new HashMap<>(); StringBuilder temp; tr.desc = null; - + // Read through Code/TypeCode trees for all accepted Typecodes for (Pair, List>>> tc : types) { // If new, then it's new Code set, create prefix content @@ -253,7 +253,7 @@ public class TypedCode extends Content { } } // Gather all ContentType possibilities for the same code together - + for (StringBuilder sb : psb.values()) { tr.contextTypes.add(sb.toString()); } @@ -265,5 +265,5 @@ public class TypedCode extends Content { } return null; } - + } \ No newline at end of file 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 adf05380..37c26fc5 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 @@ -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. @@ -24,7 +24,7 @@ package org.onap.aaf.auth.rserv; /** * Analyze and hold Version information for Code - * + * * @author Jonathan * */ @@ -67,8 +67,8 @@ public class Version { } return false; } - - + + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/doc/ApiDoc.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/doc/ApiDoc.java index 684976b9..ab766a6c 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/doc/ApiDoc.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/doc/ApiDoc.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. @@ -36,5 +36,5 @@ public @interface ApiDoc { String[] text(); /** Format with name|type|[true|false] */ String[] params(); - + } 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 4fb81d73..31131314 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 @@ -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. @@ -55,7 +55,7 @@ public abstract class AbsService exte public final String app_name; public final String app_version; public final String ROOT_NS; - + public AbsService(final Access access, final ENV env) throws CadiException { Define.set(access); ROOT_NS = Define.ROOT_NS(); @@ -70,14 +70,14 @@ public abstract class AbsService exte 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); } app_version = access.getProperty(Config.AAF_DEPLOYED_VERSION, str); - + // Print Cipher Suites Available if (access.willLog(Level.DEBUG)) { SSLContext context; @@ -99,7 +99,7 @@ public abstract class AbsService exte access.log(Level.DEBUG,sb); } } - + public void setProtocol(String proto) { env.setProperty(Config.AAF_LOCATOR_PROTOCOL, proto); } @@ -107,12 +107,12 @@ public abstract class AbsService exte public void setSubprotocol(String subproto) { env.setProperty(Config.AAF_LOCATOR_SUBPROTOCOL, subproto); } - + protected abstract Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException; - + /** * Overload this method to add new TAF or LURs - * + * * @return * @throws CadiException * @throws LocatorException @@ -134,11 +134,11 @@ public abstract class AbsService exte } return aafCon; } - + /** * Allow to be over ridden for special cases * @return - * @throws LocatorException + * @throws LocatorException */ protected synchronized AAFConHttp _newAAFConHttp() throws CadiException, LocatorException { if (aafCon==null) { @@ -147,12 +147,12 @@ public abstract class AbsService exte return aafCon; } - + // This is a method, so we can overload for AAFAPI public String aaf_url() { return access.getProperty(Config.AAF_URL, null); } - + public Rcli client() throws CadiException { return aafCon.client(); } @@ -165,7 +165,7 @@ public abstract class AbsService exte public RET clientAsUser(TaggedPrincipal p,Retryable retryable) throws APIException, LocatorException, CadiException { return aafCon.hman().best(new HTransferSS(p,app_name, aafCon.securityInfo()), retryable); } - + protected static final String loadFromArgOrSystem(final Properties props, final String tag, final String args[], final String def) { String tagEQ = tag + '='; String value; @@ -177,11 +177,11 @@ public abstract class AbsService exte } // check System.properties value = System.getProperty(tag); - if (value!=null) { + if (value!=null) { props.put(tag, value); return value; } - + if (def!=null) { props.put(tag,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 90f4158f..f09a4ff3 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 @@ -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. @@ -68,15 +68,15 @@ public abstract class AbsServiceStarter rserv) throws Exception; protected abstract void _propertyAdjustment(); - + public ENV env() { return service.env; } - + public Access access() { return service.access; } @@ -86,8 +86,8 @@ public abstract class AbsServiceStarter 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 + // Docker/K8 may separately create startup Status in this dir for startup + // sequencing. If so, delete ON EXIT Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { @@ -109,7 +109,7 @@ public abstract class AbsServiceStarter ... registrants) { if (do_register) { @@ -137,7 +137,7 @@ public abstract class AbsServiceStarter ex public JettyServiceStarter(final AbsService service, boolean secure) throws OrganizationException { super(service, secure); } - + @Override public void _propertyAdjustment() { // System.setProperty("com.sun.management.jmxremote.port", "8081"); @@ -72,7 +72,7 @@ public class JettyServiceStarter ex props.put(Config.CADI_PROTOCOLS, httpproto); } } - + if ("1.7".equals(System.getProperty("java.specification.version")) && (httpproto==null || (httpproto instanceof String && ((String)httpproto).contains("TLSv1.2")))) { System.setProperty(Config.HTTPS_CIPHER_SUITES, Config.HTTPS_CIPHER_SUITES_DEFAULT); } @@ -84,7 +84,7 @@ public class JettyServiceStarter ex final String keystore = access().getProperty(Config.CADI_KEYSTORE, null); final int IDLE_TIMEOUT = Integer.parseInt(access().getProperty(Config.AAF_CONN_IDLE_TIMEOUT, Config.AAF_CONN_IDLE_TIMEOUT_DEF)); Server server = new Server(); - + ServerConnector conn; String protocol; if (!secure || keystore==null) { @@ -92,7 +92,7 @@ public class JettyServiceStarter ex protocol = "http"; } else { protocol = "https"; - + String keystorePassword = access().getProperty(Config.CADI_KEYSTORE_PASSWORD, null); if (keystorePassword==null) { @@ -104,7 +104,7 @@ public class JettyServiceStarter ex sslContextFactory.setKeyStorePassword(temp=access().decrypt(keystorePassword, true)); // don't allow unencrypted sslContextFactory.setKeyManagerPassword(temp); temp=null; // don't leave lying around - + String truststore = access().getProperty(Config.CADI_TRUSTSTORE, null); if (truststore!=null) { String truststorePassword = access().getProperty(Config.CADI_TRUSTSTORE_PASSWORD, null); @@ -112,17 +112,17 @@ public class JettyServiceStarter ex throw new CadiException("No Truststore Password configured for " + truststore); } sslContextFactory.setTrustStorePath(truststore); - sslContextFactory.setTrustStorePassword(access().decrypt(truststorePassword, false)); + sslContextFactory.setTrustStorePassword(access().decrypt(truststorePassword, false)); } // Be able to accept only certain protocols, i.e. TLSv1.1+ String subprotocols = access().getProperty(Config.CADI_PROTOCOLS, Config.HTTPS_PROTOCOLS_DEFAULT); service.setSubprotocol(subprotocols); final String[] protocols = Split.splitTrim(',', subprotocols); sslContextFactory.setIncludeProtocols(protocols); - + // Want to use Client Certificates, if they exist. sslContextFactory.setWantClientAuth(true); - + // Optional future checks. // sslContextFactory.setValidateCerts(true); // sslContextFactory.setValidatePeerCerts(true); @@ -132,13 +132,13 @@ public class JettyServiceStarter ex if (certAlias!=null) { sslContextFactory.setCertAlias(certAlias); } - + HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setSecureScheme(protocol); httpConfig.setSecurePort(port); httpConfig.addCustomizer(new SecureRequestCustomizer()); // httpConfig.setOutputBufferSize(32768); Not sure why take this setting - + conn = new ServerConnector(server, new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpConfig) @@ -146,22 +146,22 @@ public class JettyServiceStarter ex } service.setProtocol(protocol); - - // Setup JMX + + // 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); server.addConnector(conn); - + server.setHandler(new AbstractHandler() { private FilterChain fc = buildFilterChain(service,new FilterChain() { @Override @@ -169,7 +169,7 @@ public class JettyServiceStarter ex rserv.service(req, resp); } }); - + @Override public void handle(String target, Request baseRequest, HttpServletRequest hreq, HttpServletResponse hresp) throws IOException, ServletException { try { @@ -182,7 +182,7 @@ public class JettyServiceStarter ex } } ); - + try { access().printf(Level.INIT, "Starting service on %s:%d (%s)",hostname,port,InetAddress.getByName(hostname).getHostAddress()); server.start(); @@ -204,7 +204,7 @@ public class JettyServiceStarter ex 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); } catch (Exception e) { access().log(e,"Error registering " + service.app_name); @@ -225,15 +225,15 @@ public class JettyServiceStarter ex } return fc; } - + private class FCImpl implements FilterChain { private Filter f; private FilterChain next; - + public FCImpl(final Filter f, final FilterChain fc) { this.f=f; next = fc; - + } @Override public void doFilter(ServletRequest req, ServletResponse resp) throws IOException, ServletException { 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 894f571d..aa7d14cc 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 @@ -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. @@ -35,7 +35,7 @@ import org.onap.aaf.misc.env.util.Chrono; public class Log4JLogIt implements LogIt { protected static final String AAF_LOG4J_PREFIX = "aaf_log4j_prefix"; // Log4j does it's own date. Can't apparently turn it off. - + private final String service; private final String audit; private final String init; @@ -74,13 +74,13 @@ public class Log4JLogIt implements LogIt { laudit = Logger.getLogger(audit); linit = Logger.getLogger(init); ltrace = Logger.getLogger(trace); - + lfn.configure(etc_dir,propsFile, log_level); } catch (IOException e) { throw new APIException(e); } } - + private static final String getArgOrVM(final String tag, final String args[], final String def) { String tagEQ = tag + '='; String value; @@ -91,10 +91,10 @@ public class Log4JLogIt implements LogIt { } // check System.properties value = System.getProperty(tag); - if (value!=null) { + if (value!=null) { return value; } - + return def; } @@ -127,7 +127,7 @@ public class Log4JLogIt implements LogIt { default: lservice.info(PropAccess.buildMsg(service, Chrono.utcFmt, level, elements)); break; - + } } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java index 9004f76b..17aeafa1 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.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. 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 052f21bf..fcbccb12 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 @@ -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. @@ -64,7 +64,7 @@ public class Validator { actionChars = ACTION_CHARS; instChars = INST_CHARS; } - + public final String errs() { return msgs.toString(); } @@ -96,7 +96,7 @@ public class Validator { } protected final boolean nob(String str, Pattern p) { - return str==null || !p.matcher(str).matches(); + return str==null || !p.matcher(str).matches(); } protected final void msg(String ... strs) { @@ -164,7 +164,7 @@ public class Validator { } return this; } - + public final Validator permType(String type, String ns) { if (type==null) { msg("Perm Type is null"); @@ -227,7 +227,7 @@ public class Validator { return this; } else if (nob(ns,NAME_CHARS)) { msg("NS [" + ns + "] is invalid."); - } + } for (String s : nsKeywords) { if (ns.endsWith(s)) { msg("NS [" + ns + "] may not be named with NS keywords"); -- cgit 1.2.3-korg