diff options
Diffstat (limited to 'auth/auth-core')
81 files changed, 975 insertions, 975 deletions
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 <TRANS> @@ -58,7 +58,7 @@ public class Cache<TRANS extends Trans, DATA> { /** * Dated Class - store any Data with timestamp - * + * * @author Jonathan * */ @@ -66,7 +66,7 @@ public class Cache<TRANS extends Trans, DATA> { 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<TRANS extends Trans, DATA> { timestamp = new Date(System.currentTimeMillis()+expireIn); } } - + public static Map<String,Dated> obtain(String key) { Map<String, Dated> m = cacheMap.get(key); if (m==null) { @@ -99,24 +99,24 @@ public class Cache<TRANS extends Trans, DATA> { /** * 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<String> 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<TRANS extends Trans, DATA> { advance = 0; set = new HashSet<>(); } - + public synchronized void add(String key) { set.add(key); } @@ -134,8 +134,8 @@ public class Cache<TRANS extends Trans, DATA> { 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<String,Dated> map = cacheMap.get(name); if (map==null) { @@ -150,7 +150,7 @@ public class Cache<TRANS extends Trans, DATA> { } } } - + if (count>0) { env.debug().log("Cache removed",count,"expired Cached Elements out of", total); } @@ -170,11 +170,11 @@ public class Cache<TRANS extends Trans, DATA> { 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<TRANS extends Trans, DATA> { 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<Object, Object> 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<idx;++i) { @@ -155,13 +155,13 @@ public class AuthzEnv extends RosettaEnv implements Access { ++count; pot += times[i]-prev; } - prev = times[i]; + prev = times[i]; } } return count==0?300000L:pot/count; // Return Weighted Avg, or 5 mins, if none avail. } - + @Override public ClassLoader classLoader() { return getClass().getClassLoader(); @@ -199,7 +199,7 @@ public class AuthzEnv extends RosettaEnv implements Access { public void setLogLevel(Level level) { access.setLogLevel(level); } - + private static final byte[] ENC="enc:".getBytes(); public String decrypt(String encrypted, final boolean anytext) throws IOException { if (encrypted==null) { @@ -237,7 +237,7 @@ public class AuthzEnv extends RosettaEnv implements Access { return ""; } } - + }; } return decryptor.decrypt(encrypted); @@ -290,5 +290,5 @@ public class AuthzEnv extends RosettaEnv implements Access { public Properties getProperties() { return access.getProperties(); }; - + } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTrans.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTrans.java index ac16833d..934b8417 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTrans.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTrans.java @@ -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. @@ -45,13 +45,13 @@ public interface AuthzTrans extends TransStore { public abstract AuthzTrans set(HttpServletRequest req, HttpServletResponse resp); public abstract HttpServletRequest hreq(); - + public abstract HttpServletResponse hresp(); public abstract String user(); public abstract void setUser(TaggedPrincipal p); - + public abstract TaggedPrincipal getUserPrincipal(); public abstract String ip(); @@ -63,27 +63,27 @@ public interface AuthzTrans extends TransStore { public abstract String path(); public abstract String agent(); - + public abstract AuthzEnv env(); public abstract void setLur(Lur lur); - + public abstract Lur getLur(); public abstract boolean fish(Permission ... p); - + public abstract Organization org(); public abstract boolean requested(REQD_TYPE requested); - + public void requested(REQD_TYPE requested, boolean b); - + public abstract void logAuditTrail(LogTarget lt); - + public abstract Date now(); - + public abstract void setTag(String tag); - + public abstract String getTag(); public abstract void clearCache(); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java index bd9f8875..e78a4889 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransFilter.java @@ -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. @@ -48,7 +48,7 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { 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<AuthzTrans> { 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<AuthzTrans> { 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<AuthzTrans> { for (int i=0;i<serviceMetric.buckets.length;++i) { serviceMetric.buckets[i]+=m.buckets[i]; } - + Long tsi; if ((tsi=trans.get(transIDslot, null))!=null) { sb.append(" TraceID="); @@ -118,14 +118,14 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { } else { // Single Line entry // IMPORTANT!!! if you add more entries here, change "BUCKETSIZE"!!! - StringBuilder content = new StringBuilder(); + StringBuilder content = new StringBuilder(); Metric m = trans.auditTrail(lt,1, content, Env.REMOTE,Env.JSON); // Add current Metrics to total metrics serviceMetric.total+= m.total; for (int i=0;i<serviceMetric.buckets.length;++i) { serviceMetric.buckets[i]+=m.buckets[i]; } - + StringBuilder sb = new StringBuilder(); sb.append("user="); Principal p = trans.getUserPrincipal(); @@ -140,7 +140,7 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { sb.append('('); sb.append(((TrustPrincipal)p).personalName()); // UserChain sb.append(')'); - } else { + } else { sb.append('['); if (p instanceof TaggedPrincipal) { sb.append(((TaggedPrincipal)p).tag()); @@ -184,7 +184,7 @@ public class AuthzTransFilter extends TransFilter<AuthzTrans> { } sb.append('"'); } - + lt.log(sb); } } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java index 037ce4ee..c3d0298d 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransImpl.java @@ -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. @@ -60,7 +60,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { hreq = req; hresp = resp; user = (TaggedPrincipal)req.getUserPrincipal(); - + for (REQD_TYPE rt : REQD_TYPE.values()) { requested(rt,req); } @@ -73,7 +73,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { org=null; return this; } - + @Override public HttpServletRequest hreq() { return hreq; @@ -96,7 +96,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { public String user() { return user==null?N_A:user.getName(); } - + /** * @see org.onap.aaf.auth.env.test.AuthTrans#getUserPrincipal() */ @@ -150,12 +150,12 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { public AuthzEnv env() { return (AuthzEnv)delegate; } - + @Override public boolean requested(REQD_TYPE requested) { return (mask&requested.bit)==requested.bit; } - + public void requested(REQD_TYPE requested, boolean b) { if (b) { mask|=requested.bit; @@ -163,7 +163,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { mask&=~requested.bit; } } - + private void requested(REQD_TYPE reqtype, HttpServletRequest req) { String p = req.getParameter(reqtype.name()); if (p!=null) { @@ -175,12 +175,12 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { public void setLur(Lur lur) { this.lur = lur; } - + @Override public Lur getLur() { - return lur; + return lur; } - + @Override public boolean fish(Permission ... pond) { if (lur!=null) { @@ -188,7 +188,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { } return false; } - + /* (non-Javadoc) * @see org.onap.aaf.auth.env.test.AuthzTrans#org() */ @@ -200,10 +200,10 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { org = Organization.NULL; } } catch (Exception e) { - + org = Organization.NULL; } - } + } return org; } @@ -229,7 +229,7 @@ public class AuthzTransImpl extends BasicTrans implements AuthzTrans { } return now; } - + /* * (non-Javadoc) * @see org.onap.aaf.auth.env.AuthzTrans#setTag(java.lang.String) diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransOnlyFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransOnlyFilter.java index 5545c7da..396f0d11 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransOnlyFilter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzTransOnlyFilter.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,9 +39,9 @@ public class AuthzTransOnlyFilter extends TransOnlyFilter<AuthzTrans> { 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<RV> { 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<RV> { 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<RV> { } /** - * 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<RV> { // public static<R> Result<R> err(int status, String details) { // return new Result<R>(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<RV> { } /** - * 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<RV> { } /** - * 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<RV> { 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<RV> { /** * 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<RV> { /** * 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<RV> { 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<RV> { 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<RV> { 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<RV> { } - /** + /** * 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<RV> { 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<String> { 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<String> { 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<String> { 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<String> { ti.close(); data.close(); } - + public class Reuse { public Token tokenData; private Field fieldData; @@ -138,7 +138,7 @@ public abstract class AbsData implements Iterable<String> { 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<String> { 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<String> { return fieldData; } } - + public Reuse reuse() { return new Reuse(maxLineSize,delim); } @@ -172,7 +172,7 @@ public abstract class AbsData implements Iterable<String> { public Iter iterator() { return new Iter(); } - + public class Iter implements Iterator<String> { 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<end && idx<buff.length && (c=buff[idx])!='\n'; ++idx) { ++idx; } @@ -186,5 +186,5 @@ public class DataFile { public File file() { return file; } - + } diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java index 73ad07c7..b36ed4b9 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/local/TextIndex.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,19 +40,19 @@ import org.onap.aaf.misc.env.Trans; public class TextIndex { private static final int REC_SIZE=8; - + private File file; private DataFile dataFile=null; - + public TextIndex(File theFile) { file = theFile; } - + public void open() throws IOException { dataFile = new DataFile(file,"r"); dataFile.open(); } - + public void close() throws IOException { if (dataFile!=null) { dataFile.close(); @@ -63,7 +63,7 @@ public class TextIndex { public int find(Object key, AbsData.Reuse reuse, int offset) throws IOException { return find(key,reuse.tokenData,reuse.getFieldData(),offset); } - + public int find(Object key, DataFile.Token dtok, Field df, int offset) throws IOException { if (dataFile==null) { throw new IOException("File not opened"); @@ -88,7 +88,7 @@ public class TextIndex { break; } } - + List<Integer> 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<Idx> 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<end; } } - + private static class Idx implements Comparable<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<String> toList, - List<String> ccList, - String subject, + List<String> toList, + List<String> 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<String> 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<Identity> 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<User> 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<Identity> 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<String> 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<String> 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<String> toList, List<String> 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<Identity> 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<Object, Object> 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<TRANS extends Trans> { private List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> types; List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> acceptable; - + public Acceptor(List<Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>>> types) { this.types = types; acceptable = new ArrayList<>(); } - + private boolean eval(HttpCode<TRANS,?> code, String str, List<String> props) { // int plus = str.indexOf('+'); // if (plus<0) { @@ -67,7 +67,7 @@ class Acceptor<TRANS extends Trans> { // String nstr; // while (prev!=0) { // nstr = first + (plus<0?str.substring(prev):str.substring(prev,plus)); -// +// // for (Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> type : types) { // if (type.x.equals(nstr)) { // acceptable.add(type); @@ -114,17 +114,17 @@ class Acceptor<TRANS extends Trans> { } /** - * 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<TRANS, ?> code, String cntnt) { byte bytes[] = cntnt.getBytes(); - + int cis,cie=-1,cend; int sis,sie,send; String name; @@ -133,17 +133,17 @@ class Acceptor<TRANS extends Trans> { // 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 (cis<bytes.length && Character.isSpaceChar(bytes[cis]))++cis; cie = cntnt.indexOf(',',cis); // find comma end cend = cie<0?bytes.length:cie; // If no comma, set comma end to full length, else cie while (cend>cis && 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 (sis<bytes.length && Character.isSpaceChar(bytes[sis]))++sis; + while (sis<bytes.length && Character.isSpaceChar(bytes[sis]))++sis; sie = cntnt.indexOf(';',sis); send = sie>cend || 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<TRANS extends Trans> { } 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<TRANS extends Trans> extends HttpCode<TRANS, Void> { public static void setEnv(Store store, String[] args) { - for (int i=0;i<args.length-1;i+=2) { // cover two parms required for each + for (int i=0;i<args.length-1;i+=2) { // cover two parms required for each if (CFA_WEB_PATH.equals(args[i])) { - store.put(store.staticSlot(CFA_WEB_PATH), args[i+1]); + store.put(store.staticSlot(CFA_WEB_PATH), args[i+1]); } else if (CFA_CACHE_CHECK_INTERVAL.equals(args[i])) { store.put(store.staticSlot(CFA_CACHE_CHECK_INTERVAL), Long.parseLong(args[i+1])); } else if (CFA_MAX_SIZE.equals(args[i])) { @@ -71,7 +71,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void } } } - + private static String MAX_AGE = "max-age=3600"; // 1 hour Caching private final Map<String,String> typeMap; private final NavigableMap<String,Content> content; @@ -79,7 +79,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void public final static String CFA_WEB_PATH = "aaf_cfa_web_path"; // when to re-validate from file // Re validating means comparing the Timestamp on the disk, and seeing it has changed. Cache is not marked - // dirty unless file has changed, but it still makes File IO, which for some kinds of cached data, i.e. + // dirty unless file has changed, but it still makes File IO, which for some kinds of cached data, i.e. // deployed GUI elements is unnecessary, and wastes time. // This parameter exists to cover the cases where data can be more volatile, so the user can choose how often the // File IO will be accessed, based on probability of change. "0", of course, means, check every time. @@ -96,10 +96,10 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void private String web_path; // A command key is set in the Properties, preferably changed on deployment. // it is compared at the beginning of the path, and if so, it is assumed to issue certain commands - // It's purpose is to protect, to some degree the command, even though it is HTTP, allowing + // It's purpose is to protect, to some degree the command, even though it is HTTP, allowing // local batch files to, for instance, clear caches on resetting of files. private String clear_command; - + public CachingFileAccess(EnvJAXB env, String ... args) throws IOException { super(null,"Caching File Access"); setEnv(env,args); @@ -130,16 +130,16 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void typeMap.put("class", "application/java"); typeMap.put("props", "text/plain"); typeMap.put("jks", "application/octet-stream"); - + // Fonts typeMap.put("ttf","font/ttf"); typeMap.put("woff","font/woff"); typeMap.put("woff2","font/woff2"); - + timer = new Timer("Caching Cleanup",true); timer.schedule(new Cleanup(content,500),60000,60000); - + // Property params web_path = env.get(env.staticSlot(CFA_WEB_PATH)); env.init().log("CachingFileAccess path: " + new File(web_path).getCanonicalPath()); @@ -150,18 +150,18 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void } else { checkInterval=Long.parseLong((String)obj); } - + obj = env.get(env.staticSlot(CFA_MAX_SIZE), 512000); // Default is max file 500k if (obj instanceof Integer) { maxItemSize=(Integer)obj; } else { maxItemSize =Integer.parseInt((String)obj); } - + clear_command = env.getProperty(CFA_CLEAR_COMMAND,null); } - + @Override public void handle(TRANS trans, HttpServletRequest req, HttpServletResponse resp) throws IOException { @@ -190,12 +190,12 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void public String webPath() { return web_path; } - + /** * Reset the Cleanup size and interval - * + * * The size and interval when started are 500 items (memory size unknown) checked every minute in a background thread. - * + * * @param size * @param interval */ @@ -204,13 +204,13 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void timer = new Timer(); timer.schedule(new Cleanup(content,size), interval, interval); } - - + + /** * Load a file, first checking cache - * - * + * + * * @param logTarget - logTarget can be null (won't log) * @param dataRoot - data root storage directory * @param key - relative File Path @@ -234,7 +234,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void isRoot = false; } Content c = content.get(key); - long systime = System.currentTimeMillis(); + long systime = System.currentTimeMillis(); File f=null; if (c!=null) { // Don't check every hit... only after certain time value @@ -245,11 +245,11 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void } } } - if (c==null) { + if (c==null) { if (logTarget!=null) { logTarget.log("File Read: ",key); } - + if (f==null){ f = new File(fileName); } @@ -266,7 +266,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void c = new CachedContent(f); cacheMe = checkInterval>0; } - + if (mediaType==null) { // determine from file Ending int idx = key.lastIndexOf('.'); String subkey = key.substring(++idx); @@ -279,9 +279,9 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void c.contentType=mediaType; c.attachmentOnly = false; } - + c.date = f.lastModified(); - + if (cacheMe) { content.put(key, c); } @@ -297,14 +297,14 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void c.access = systime; return c; } - + public void invalidate(String key) { content.remove(key); } - + private static final Content NULL=new Content() { - + @Override public void setHeader(HttpServletResponse resp) { resp.setStatus(404/*NOT_FOUND_404*/); @@ -318,37 +318,37 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void @Override public void write(OutputStream os) throws IOException { } - + }; private static abstract class Content { private long date; // date of the actual artifact (i.e. File modified date) private long access; // last accessed - + protected String contentType; protected boolean attachmentOnly; - + public void setHeader(HttpServletResponse resp) { resp.setStatus(200/*OK_200*/); resp.setHeader("Content-Type",contentType); resp.setHeader("Cache-Control", MAX_AGE); } - + public abstract void write(Writer writer) throws IOException; public abstract void write(OutputStream os) throws IOException; } private static class DirectFileContent extends Content { - private File file; + private File file; public DirectFileContent(File f) { file = f; } - + public String toString() { return file.getName(); } - + public void write(Writer writer) throws IOException { FileReader fr = new FileReader(file); char[] buff = new char[1024]; @@ -387,7 +387,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void public DirectoryContent(File directory, boolean isRoot) { notRoot = !isRoot; - + files = directory.listFiles(); Arrays.sort(files,new Comparator<File>() { @Override @@ -399,7 +399,7 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void // if numbers, are the numbers in the same start position int i1 = m1.start(); int i2 = m2.start(); - + // If same start position and the text is the same, then reverse sort if (i1==i2 && f1.getName().startsWith(f2.getName().substring(0,i1))) { // reverse sort files that start similarly, but have numbers in them @@ -408,14 +408,14 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void } return f1.compareTo(f2); } - + }); name = directory.getName(); attachmentOnly = false; contentType = "text/html"; } - - + + @Override public void write(Writer w) throws IOException { w.append(H1); @@ -435,19 +435,19 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void w.append(F); w.flush(); } - + @Override public void write(OutputStream os) throws IOException { write(new OutputStreamWriter(os)); } - + } private static class CachedContent extends Content { private byte[] data; private int end; - private char[] cdata; - + private char[] cdata; + public CachedContent(File f) throws IOException { // Read and Cache ByteBuffer bb = ByteBuffer.allocate((int)f.length()); @@ -462,11 +462,11 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void end = bb.position(); cdata=null; } - + public String toString() { return Arrays.toString(data); } - + public void write(Writer writer) throws IOException { synchronized(this) { // do the String Transformation once, and only if actually used @@ -495,24 +495,24 @@ public class CachingFileAccess<TRANS extends Trans> extends HttpCode<TRANS, Void private static class Cleanup extends TimerTask { private int maxSize; private NavigableMap<String, Content> content; - + public Cleanup(NavigableMap<String, Content> content, int size) { maxSize = size; this.content = content; } - + private class Comp implements Comparable<Comp> { public Map.Entry<String, Content> entry; - + public Comp(Map.Entry<String, Content> 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<TRANS extends Trans> { this.trans = trans; this.req = req; this.resp = resp; - + } public boolean matches(Route<TRANS> 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<TRANS,?> 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<TRANS extends Trans> { /** * 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<TRANS extends Trans> { } 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 <TRANS> @@ -45,14 +45,14 @@ public abstract class HttpCode<TRANS extends Trans, CONTEXT> { 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<TRANS extends Trans, CONTEXT> { } 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<TRANS extends Trans, CONTEXT> { } // 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<TRANS extends Trans, CONTEXT> { } 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;i<pa.length && !wildcard;++i) { @@ -69,7 +69,7 @@ public class Match { val = i; key = pa[i]; } - params.put(key,val); //put in :key + params.put(key,val); //put in :key params.put(key.substring(1,key.length()), val); // put in just key, better than adding a missing one, like Spark // values[i]=null; // null stands for Variable vars[i]=val; @@ -96,14 +96,14 @@ public class Match { /* * This is the second of the param evaluation functions. First, we look up to see if there is * any reference by key in the params Map created by the above. - * + * * The resulting Integer, if not null, is split high/low order into start and end. * We evaluate the string for '/', rather than splitting into String[] to avoid the time/mem needed - * We traverse to the proper field number for slash, evaluate the end (whether wild card or no), - * and return the substring. - * + * We traverse to the proper field number for slash, evaluate the end (whether wild card or no), + * and return the substring. + * * The result is something less than .003 milliseconds per evaluation - * + * */ public String param(String path,String key) { Integer val = params.get(key); // :key or key @@ -116,7 +116,7 @@ public class Match { idx = path.indexOf('/',idx+1); if (idx<0)break; } - if (i==start) { + if (i==start) { ++idx; if (end==0) { end = path.indexOf('/',idx); @@ -131,7 +131,7 @@ public class Match { } return null; } - + public boolean match(String path) { if (path==null|| path.length()==0 || "/".equals(path) ) { if (values==null)return true; @@ -140,7 +140,7 @@ public class Match { case 1: return values[0].length==0; default: return false; } - } + } boolean rv = true; byte[] pabytes = path.getBytes(); int field=0; @@ -169,7 +169,7 @@ public class Match { ++j; } } - + if (k==lastByte && pabytes[k-1]!='/')++field; if (k>i)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<lastField; // reset - fieldMatched = false; + fieldMatched = false; fieldIdx = 0; } else if (values[field].length==0) { - // double slash in path, but content in field. We check specially here to avoid + // double slash in path, but content in field. We check specially here to avoid // Array out of bounds issues. rv = false; } else { @@ -204,7 +204,7 @@ public class Match { if (field!=lastField || pabytes.length!=lastByte) rv = false; // have we matched all the fields and all the bytes? return rv; } - + public Set<String> 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 <X> @@ -32,12 +32,12 @@ package org.onap.aaf.auth.rserv; public class Pair<X,Y> { 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<TRANS extends Trans> 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<TRANS> route; HttpCode<TRANS,?> code=null; String ct = req.getContentType(); @@ -93,7 +93,7 @@ public abstract class RServlet<TRANS extends Trans> 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<TRANS extends Trans> implements Servlet { } } } - + @Override public String getServletInfo() { return "RServlet for Jetty"; @@ -127,9 +127,9 @@ public abstract class RServlet<TRANS extends Trans> 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<TRANS extends Trans> { public final String auditText; public final HttpMethods meth; public final String path; - + private Match match; // package on purpose private final TypedCode<TRANS> 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<TRANS extends Trans> { match = new Match(path); content = new TypedCode<TRANS>(); } - + public void add(HttpCode<TRANS,?> code, String ... others) { code.match = match; content.add(code, others); } - + public HttpCode<TRANS,?> 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<TRANS extends Trans> { } return null; } - + public Route<TRANS> matches(String method, String path) { return meth.name().equalsIgnoreCase(method) && match.match(path)?this:null; } - + public TimeTaken start(Trans trans, String auditText, HttpCode<TRANS,?> code, String type) { StringBuilder sb = new StringBuilder(auditText); sb.append(", "); @@ -100,9 +100,9 @@ public class Route<TRANS extends Trans> { 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<TRANS, ?> 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<TRANS extends Trans> { // Since this must be very, very fast, and only needs one creation, we'll use just an array. private Route<TRANS>[] 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<TRANS> findOrCreate(HttpMethods meth, String path) { @@ -50,7 +50,7 @@ public class Routes<TRANS extends Trans> { for (int i=0;i<end;++i) { if (routes[i].resolvesTo(meth,path))rv = routes[i]; } - + if (rv==null) { if (end>=routes.length) { @SuppressWarnings("unchecked") @@ -58,12 +58,12 @@ public class Routes<TRANS extends Trans> { System.arraycopy(routes, 0, temp, 0, routes.length); routes = temp; } - + routes[end++]=rv=new Route<TRANS>(meth,path); } return rv; } - + public Route<TRANS> derive(HttpServletRequest req, CodeSetter<TRANS> codeSetter) throws IOException, ServletException { Route<TRANS> rv = null; String path = req.getPathInfo(); @@ -71,13 +71,13 @@ public class Routes<TRANS extends Trans> { //TODO a TREE would be better for (int i=0;rv==null && i<end; ++i) { rv = routes[i].matches(meth,path); - if (rv!=null && !codeSetter.matches(rv)) { // potential match, check if has Code + if (rv!=null && !codeSetter.matches(rv)) { // potential match, check if has Code rv = null; // not quite, keep going } } return rv; } - + public List<RouteReport> routeReport() { ArrayList<RouteReport> ltr = new ArrayList<>(); for (int i=0;i<end;++i) { diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java index 2acfbe34..5b856935 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/rserv/TransFilter.java @@ -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. @@ -52,22 +52,22 @@ import org.onap.aaf.misc.env.util.Split; /** * 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 * */ public abstract class TransFilter<TRANS extends TransStore> 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<TRANS extends TransStore> implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } - + protected Lur getLur() { return cadi.getLur(); } @@ -90,19 +90,19 @@ public abstract class TransFilter<TRANS extends TransStore> 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<TRANS extends TransStore> 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<TRANS extends TransStore> 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<TRANS extends TransStore> 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 <TRANS> @@ -61,10 +61,10 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { 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<TRANS extends Trans> extends Content<TRANS> { 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<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> types(HttpCode<TRANS,?> code, String str) { Pair<String, Pair<HttpCode<TRANS,?>,List<Pair<String, Object>>>> type = null; @@ -127,7 +127,7 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { } return type.y.y.add(new Pair<String,Object>(tag,"version".equals(tag)?new Version(value):value)); } - + public Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> prep(TRANS trans, String compare){ Pair<String, Pair<HttpCode<TRANS,?>, List<Pair<String, Object>>>> 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<TRANS extends Trans> extends Content<TRANS> { } 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<TRANS extends Trans> extends Content<TRANS> { } 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<TRANS extends Trans> extends Content<TRANS> { } return sb; } - + public List<Pair<String, Object>> getContent(HttpCode<TRANS,?> code) { for (Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> pair : types) { if (pair.y.x == code) { @@ -220,17 +220,17 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { } 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<HttpCode<?,?>,StringBuilder> psb = new HashMap<>(); StringBuilder temp; tr.desc = null; - + // Read through Code/TypeCode trees for all accepted Typecodes for (Pair<String, Pair<HttpCode<TRANS, ?>, List<Pair<String, Object>>>> tc : types) { // If new, then it's new Code set, create prefix content @@ -253,7 +253,7 @@ public class TypedCode<TRANS extends Trans> extends Content<TRANS> { } } // 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<TRANS extends Trans> extends Content<TRANS> { } 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<ENV extends BasicEnv, TRANS extends Trans> 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<ENV extends BasicEnv, TRANS extends Trans> 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<ENV extends BasicEnv, TRANS extends Trans> 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<ENV extends BasicEnv, TRANS extends Trans> 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<ENV extends BasicEnv, TRANS extends Trans> 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<ENV extends BasicEnv, TRANS extends Trans> 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<ENV extends BasicEnv, TRANS extends Trans> exte public<RET> RET clientAsUser(TaggedPrincipal p,Retryable<RET> retryable) throws APIException, LocatorException, CadiException { return aafCon.hman().best(new HTransferSS(p,app_name, aafCon.securityInfo()), retryable); } - + 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<ENV extends BasicEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Tr } _propertyAdjustment(); } - - + + protected abstract void _start(RServlet<TRANS> 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<ENV extends RosettaEnv, TRANS extends Tr ExecutorService es = Executors.newSingleThreadExecutor(); Future<?> app = es.submit(this); final AbsServiceStarter<?,?> absSS = this; - // Docker/K8 may separately create startup Status in this dir for startup - // sequencing. If so, delete ON EXIT + // 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<ENV extends RosettaEnv, TRANS extends Tr } } } - + @SafeVarargs public final synchronized void register(final Registrant<ENV> ... registrants) { if (do_register) { @@ -137,7 +137,7 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr if (registrar!=null) { registrar.close(env()); registrar=null; - } + } if (service!=null) { File status = new File("/opt/app/aaf/status/"); boolean deleted = false; @@ -147,7 +147,7 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr if(lastdot<0) { fname = service.app_name + '-' + hostname; } else { - fname = service.app_name.substring(lastdot).replace('.', '-') + fname = service.app_name.substring(lastdot).replace('.', '-') + '-' + hostname; } status = new File(status, fname); diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java index 78a7702b..3f0d2ebb 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java @@ -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. @@ -58,7 +58,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex public JettyServiceStarter(final AbsService<ENV,TRANS> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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<ENV extends RosettaEnv, TRANS extends Trans> 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"); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java index a94d82da..f572af35 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/common/test/JU_Define.java @@ -50,7 +50,7 @@ public class JU_Define { public void setUp() throws CadiException{ acc = mock(Access.class); } - + @Test public void testSet() throws CadiException { PropAccess prop = new PropAccess(); @@ -60,7 +60,7 @@ public class JU_Define { Define.set(prop); Define.ROOT_NS(); Define.ROOT_COMPANY(); - + PropAccess prop1 = new PropAccess(); prop1.setProperty(AAF_NS_DOT, AAF_NS_DOT); prop1.setProperty(Config.AAF_ROOT_NS, ".ns_Test"); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java index 817ec984..80d85fce 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java @@ -146,7 +146,7 @@ public class JU_AuthzEnv { @Test public void testLog1() { - + Exception e = new Exception(); Object msgs = null; authzEnv.log(e, msgs); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.java index ddb2d8c1..7ed2ba69 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransFilter.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 class JU_AuthzTransFilter { @Mock private TrustChecker tcMock; @Mock private AuthzTrans authzTransMock; @Mock private Object additionalTafLurs; - + private PropAccess access; @Before @@ -66,7 +66,7 @@ public class JU_AuthzTransFilter { when(envMock.access()).thenReturn(access); } - + // TODO: These tests only work on the AT&T network. Fix them - Ian @Test public void testAuthenticated() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, CadiException { @@ -80,7 +80,7 @@ public class JU_AuthzTransFilter { // authenticatedMethod.setAccessible(true); // authenticatedMethod.invoke(aTF, authzTransMock, null); } - + @Test public void testTallyHo() throws CadiException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Slot specialLogSlot = authzEnvMock.slot("SPECIAL_LOG_SLOT"); @@ -107,5 +107,5 @@ public class JU_AuthzTransFilter { // when(authzTransMock.getUserPrincipal()).thenReturn(tPrin); // tallyHoMethod.invoke(aTF, authzTransMock); } - + } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.java index af92e372..0c697bea 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzTransImpl.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,13 +55,13 @@ public class JU_AuthzTransImpl { @Mock AuthzEnv authzEnvMock; AuthzTransImpl trans1; - + private Organization org=null; private AuthzTransImpl mockAuthzTransImpl; private static HttpServletRequest req; private static HttpServletResponse res; private Lur lur1 = mock(Lur.class); - + @Before public void setUp(){ authzTransImpl = new AuthzTransImpl(authzEnvMock); @@ -71,9 +71,9 @@ public class JU_AuthzTransImpl { when(req.getParameter("request")).thenReturn("NotNull"); authzTransImpl.set(req,res); when(req.getParameter("request")).thenReturn(""); - authzTransImpl.set(req,res); + authzTransImpl.set(req,res); } - + @Test public void testOrg() { Organization result=null; @@ -82,15 +82,15 @@ public class JU_AuthzTransImpl { //result = OrganizationFactory.obtain(authzTransImpl.env(), authzTransImpl.user()); authzTransImpl.org(); //when(test).thenReturn(null); - //assertTrue(true); + //assertTrue(true); } - + @Mock LogTarget logTargetMock; - + @Test public void testLogAuditTrail(){ - + when(logTargetMock.isLoggable()).thenReturn(false); authzTransImpl.logAuditTrail(logTargetMock); when(logTargetMock.isLoggable()).thenReturn(true); @@ -98,7 +98,7 @@ public class JU_AuthzTransImpl { //when(logTargetMock.isLoggable()).thenReturn(true);//TODO: Figure this out //authzTransImpl.logAuditTrail(logTargetMock); } - + // @Test //TODO:Fix this AAF-111 // public void testSetUser() { // Principal user = mock(Principal.class); @@ -107,7 +107,7 @@ public class JU_AuthzTransImpl { // String username = user1.getName(); // Assert.assertNotNull(user1); // } - + // @Test //TODO:Fix this AAF-111 // public void testUser() { // Assert.assertEquals("n/a", authzTransImpl.user()); @@ -117,7 +117,7 @@ public class JU_AuthzTransImpl { // authzTransImpl.setUser(user); // Assert.assertEquals("name", authzTransImpl.user()); // } -// +// @Test public void testRequested() { REQD_TYPE user = REQD_TYPE.move; @@ -134,10 +134,10 @@ public class JU_AuthzTransImpl { when(req.getParameter(user1.name())).thenReturn("test"); authzTransImpl.requested(user,false); */ - - + + } - + @Test public void testFish() { mockAuthzTransImpl = mock(AuthzTransImpl.class); @@ -149,7 +149,7 @@ public class JU_AuthzTransImpl { authzTransImpl.setLur(lur1); authzTransImpl.fish(p); } - + @Test public void testSetVariables() { //TODO: refactor this better Assert.assertNull(authzTransImpl.agent()); @@ -160,12 +160,12 @@ public class JU_AuthzTransImpl { Assert.assertNull(authzTransImpl.getUserPrincipal()); Assert.assertNotNull(authzTransImpl.user()); } - + @Test public void testNow() { Date date = authzTransImpl.now(); Assert.assertEquals(date,authzTransImpl.now()); when(authzTransImpl.now()).thenReturn(null); } - + } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_NullTrans.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_NullTrans.java index 9c7212c2..142317d1 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_NullTrans.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_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. @@ -48,65 +48,65 @@ import org.onap.aaf.misc.env.TimeTaken; @RunWith(MockitoJUnitRunner.class) public class JU_NullTrans { NullTrans nullTrans; - + @Before public void setUp(){ nullTrans = new NullTrans(); } - + @Test public void testAuditTrail() { Assert.assertNull(nullTrans.auditTrail(0, null, 0)); } - + @Test public void testSingleton() { AuthzTrans single = nullTrans.singleton(); Assert.assertTrue(single instanceof AuthzTrans); } - + @Test public void testCheckpoints() { nullTrans.checkpoint("Test"); nullTrans.checkpoint(null, 0); } - + @Test public void testFatal() { LogTarget log = nullTrans.fatal(); Assert.assertEquals(LogTarget.NULL, log); } - + @Test public void testError() { LogTarget log = nullTrans.error(); Assert.assertEquals(LogTarget.NULL, log); } - + @Test public void testAudit() { LogTarget log = nullTrans.audit(); Assert.assertEquals(LogTarget.NULL, log); } - + @Test public void testInit() { LogTarget log = nullTrans.init(); Assert.assertEquals(LogTarget.NULL, log); } - + @Test public void testWarn() { LogTarget log = nullTrans.warn(); Assert.assertEquals(LogTarget.NULL, log); } - + @Test public void testInfo() { LogTarget log = nullTrans.info(); Assert.assertEquals(LogTarget.NULL, log); } - + @Test public void testDebug() { LogTarget log = nullTrans.debug(); @@ -118,7 +118,7 @@ public class JU_NullTrans { LogTarget log = nullTrans.trace(); Assert.assertEquals(LogTarget.NULL, log); } - + @Test public void testStart() { TimeTaken test = nullTrans.start("test", 1); @@ -131,7 +131,7 @@ public class JU_NullTrans { s1 = s1.trim(); Assert.assertEquals(s,s1); } - + @Test public void testSetProperty() { String tag = "tag"; @@ -142,19 +142,19 @@ public class JU_NullTrans { String expectedTag = nullTrans.getProperty(tag); Assert.assertEquals(expectedTag, tag); } - + @Test public void testDecryptor() { Decryptor decry = nullTrans.decryptor(); Assert.assertNull(decry); } - + @Test public void testEncryptor() { Encryptor encry = nullTrans.encryptor(); Assert.assertNull(encry); } - + @Test public void testSet() { HttpServletRequest req = mock(HttpServletRequest.class); @@ -162,96 +162,96 @@ public class JU_NullTrans { AuthzTrans set = nullTrans.set(req,res); Assert.assertNull(set); } - + @Test public void testUser() { String user = nullTrans.user(); Assert.assertNull(user); } - + @Test public void testGetUserPrincipal() { Principal principal = nullTrans.getUserPrincipal(); Assert.assertNull(principal); } - + @Test public void testIp() { String ip = nullTrans.ip(); Assert.assertNull(ip); } - + @Test public void testMeth() { String meth = nullTrans.meth(); Assert.assertNull(meth); } - + @Test public void testPort() { int port = nullTrans.port(); Assert.assertEquals(port,0); } - + @Test public void testPath() { String path = nullTrans.path(); Assert.assertNull(path); } - + @Test public void testPut() { nullTrans.put(null, nullTrans); } - + @Test public void testSetUser() { Principal principal = mock(Principal.class); //nullTrans.setUser(principal); } - + @Test public void testSlot() { Slot slot = nullTrans.slot(null); Assert.assertNull(slot); } - + @Test public void testEnv() { AuthzEnv env = nullTrans.env(); Assert.assertNull(env); } - + @Test public void testAgent() { String agent = nullTrans.agent(); Assert.assertNull(agent); } - + @Test public void testSetLur() { nullTrans.setLur(null); } - + @Test public void testFish() { Permission perm = mock(Permission.class); Boolean fish = nullTrans.fish(perm); Assert.assertFalse(fish); } - + @Test public void testOrg() { Organization org = nullTrans.org(); Assert.assertEquals(Organization.NULL, org); } - + @Test public void testLogAuditTrail() { LogTarget lt = mock(LogTarget.class); nullTrans.logAuditTrail(lt); } - + @Test public void testRequested() { Boolean reqd = nullTrans.requested(null); @@ -266,7 +266,7 @@ public class JU_NullTrans { // Assert.assertEquals(date,nullTrans.now()); // //when(nullTrans.now()).thenReturn(null); // } - - - + + + } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java index 2bc7dfa0..86cb04bd 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_AbsData.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_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. @@ -54,16 +54,16 @@ public class JU_AbsData { String filePath = "test/output_.key"; File keyfile = new File(filePath); AuthzTrans trans = mock(AuthzTrans.class); - + private class AbsDataStub extends AbsData { - + public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) { super(dataf, sepChar, maxLineSize, fieldOffset); // TODO Auto-generated constructor stub - + } - + } @Test @@ -81,18 +81,18 @@ public class JU_AbsData { AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0); ads.skipLines(0); ads.name(); - + long lng = 1823286886660L; //ads.open(trans, lng); keyfile.delete(); } - + @Test public void testClose() throws IOException { AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0); ads.close(trans); } - + @Test public void testReuse() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { char character = 'x'; @@ -105,7 +105,7 @@ public class JU_AbsData { //reuse.pos(10); keyfile.delete(); } - + @Test public void testIter() throws IOException { AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java index b0af89ce..8f0ff022 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_DataFile.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_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. @@ -41,7 +41,7 @@ public class JU_DataFile { // public void netYetTested() { // fail("Tests not yet implemented"); // } - + // @Test // public void test() throws Exception { // File file = new File("../authz-batch/data/v1.dat"); @@ -52,7 +52,7 @@ public class JU_DataFile { // df.open(); // Token tok = df.new Token(1024000); // Field fld = tok.new Field('|'); -// +// // while (tok.nextLine()) { // ++count; // fld.reset(); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java index d4330296..30149cf4 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/local/test/JU_TextIndex.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. @@ -63,20 +63,20 @@ public class JU_TextIndex { DataFile datafile; @Mock File file; - + private class AbsDataStub extends AbsData { - + public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) { super(dataf, sepChar, maxLineSize, fieldOffset); // TODO Auto-generated constructor stub - + } - + } - + @Before - public void setUp() throws IOException{ + public void setUp() throws IOException{ char character = 'x'; String filePath = "test/output_key"; File keyfile = new File(filePath); @@ -87,31 +87,31 @@ public class JU_TextIndex { w.write("a\nsdfasdfxasdf" + i + "\n"); } w.close(); - + datafile = new DataFile(keyfile, "r"); datafile.open(); datafile = new DataFile(keyfile, "rws");// "S" for synchronized datafile.open(); - + trans = mock(Trans.class); TimeTaken ttMock = mock(TimeTaken.class); TimeTaken ttMock1 = mock(TimeTaken.class); when(trans.start("Open Files", Env.SUB)).thenReturn(ttMock); when(trans.start("Read", Env.SUB)).thenReturn(ttMock); - textIndex = new TextIndex(keyfile); + textIndex = new TextIndex(keyfile); textIndex.close(); textIndex.open(); //textIndex.create(trans, datafile, 4, character, 2, 0); //TODO: AAF-111 once actual input is aquired keyfile.delete(); - + iter = textIndex.new Iter(); } - + @Test public void testClose() throws IOException { textIndex.close(); } - + @Test public void testFind() throws IOException { char character = 'x'; @@ -121,13 +121,13 @@ public class JU_TextIndex { Reuse reuse = ads.reuse(); textIndex.find("a", reuse , 0); } - + @Test public void testIterNext() { iter.next(); iter.hasNext(); } - + @Test public void testIdx() throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { TextIndex outerObject = new TextIndex(file); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/log4j/test/JU_Log4jAccessAppender.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/log4j/test/JU_Log4jAccessAppender.java index 8123a82d..551ff0df 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/log4j/test/JU_Log4jAccessAppender.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/log4j/test/JU_Log4jAccessAppender.java @@ -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,26 +40,26 @@ public class JU_Log4jAccessAppender { @Mock Access access; - + @Before public void setUp() { initMocks(this); } - + @Test public void testRequiresLayout() { Log4JAccessAppender log4jObj = new Log4JAccessAppender(access); boolean retObj = log4jObj.requiresLayout(); assertFalse(retObj); } - + @Test public void testClose() { Log4JAccessAppender log4jObj = new Log4JAccessAppender(access); log4jObj.close(); - + } - + @Test public void testAppend() { Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); @@ -71,7 +71,7 @@ public class JU_Log4jAccessAppender { event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.ALL,"test",Thread.currentThread().getName(),null,null,null,null); log4jObj.append(event); } - + @Test public void testAppendWARN() { Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); @@ -79,7 +79,7 @@ public class JU_Log4jAccessAppender { LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.WARN,"test",Thread.currentThread().getName(),null,null,null,null); log4jObj.append(event); } - + @Test public void testAppendINFO() { Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); @@ -87,7 +87,7 @@ public class JU_Log4jAccessAppender { LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.INFO,"test",Thread.currentThread().getName(),null,null,null,null); log4jObj.append(event); } - + @Test public void testAppendWTrace() { Log4jAccessAppenderImpl log4jObj = new Log4jAccessAppenderImpl(access); @@ -95,18 +95,18 @@ public class JU_Log4jAccessAppender { LoggingEvent event=new LoggingEvent("com.chililog.server.engine",Logger.getLogger(Log4JAccessAppender.class),(new Date()).getTime(),Level.TRACE,"test",Thread.currentThread().getName(),null,null,null,null); log4jObj.append(event); } - + class Log4jAccessAppenderImpl extends Log4JAccessAppender{ public Log4jAccessAppenderImpl(Access access) { super(access); // TODO Auto-generated constructor stub } - + @Override protected void append(LoggingEvent event) { super.append(event); } - + } } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_Organization.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_Organization.java index 3d2153e6..8302cad7 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_Organization.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_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. @@ -51,9 +51,9 @@ public class JU_Organization { gc = new GregorianCalendar(1900, 1, 1); trans = mock(AuthzTrans.class); } - + @Test - public void test() throws OrganizationException { + public void test() throws OrganizationException { //tests for Org null Assert.assertEquals("n/a",Organization.NULL.getName()); Assert.assertEquals("n/a",Organization.NULL.getDomain()); @@ -74,9 +74,9 @@ public class JU_Organization { Assert.assertEquals("Null Organization rejects all Policies",Organization.NULL.validate(trans, Policy.CHANGE_JOB, null, null)); Assert.assertFalse(Organization.NULL.isTestEnv()); Organization.NULL.setTestMode(true); - + //tests for org emailWarnings - Assert.assertTrue(Organization.NULL.emailWarningPolicy() instanceof EmailWarnings); + Assert.assertTrue(Organization.NULL.emailWarningPolicy() instanceof EmailWarnings); Assert.assertEquals(604800000L, Organization.NULL.emailWarningPolicy().credEmailInterval()); Assert.assertEquals(604800000L, Organization.NULL.emailWarningPolicy().roleEmailInterval()); Assert.assertEquals(259200000L, Organization.NULL.emailWarningPolicy().apprEmailInterval()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.java index 87a86d7c..ad11ae69 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/CredCompare.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. @@ -33,7 +33,7 @@ public class CredCompare extends RosettaCompare<CredRequest> { public CredCompare() { super(CredRequest.class); } - + public static CredRequest create() { CredRequest rr = new CredRequest(); String in = instance(); @@ -46,7 +46,7 @@ public class CredCompare extends RosettaCompare<CredRequest> { rr.setEnd(Chrono.timeStamp(gc)); return rr; } - + @Override public void compare(CredRequest t1, CredRequest t2) { assertEquals(t1.getId(),t2.getId()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.java index 832f5188..02263a9d 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/JU_RequestCheck.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,7 +26,7 @@ import org.onap.aaf.misc.env.APIException; import org.onap.aaf.misc.rosetta.env.RosettaEnv; public class JU_RequestCheck { - + @Test public void testNSRequest() throws APIException { RosettaEnv env = new RosettaEnv(); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.java index 024a5237..803fff44 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/MultiCompare.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. @@ -33,7 +33,7 @@ public class MultiCompare extends RosettaCompare<MultiRequest> { public MultiCompare() { super(MultiRequest.class); } - + @Override public MultiRequest newOne() { MultiRequest multi = new MultiRequest(); @@ -50,19 +50,19 @@ public class MultiCompare extends RosettaCompare<MultiRequest> { multi.getUserRoleRequest().add(UserRoleCompare.create()); multi.getRolePermRequest().add(RolePermCompare.create()); multi.getRolePermRequest().add(RolePermCompare.create()); - - + + GregorianCalendar gc = new GregorianCalendar(); multi.setStart(Chrono.timeStamp(gc)); gc.add(GregorianCalendar.MONTH, 1); multi.setEnd(Chrono.timeStamp(gc)); return multi; } - + public void compare(MultiRequest t1, MultiRequest t2) { new NSCompare().compare(t1.getNsRequest(), t2.getNsRequest()); // Will have to find by key for others. - + assertEquals(t1.getStart(),t2.getStart()); assertEquals(t1.getEnd(),t2.getEnd()); } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java index 0786c134..7f7b09ce 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSAttribCompare.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,11 +35,11 @@ public class NSAttribCompare extends RosettaCompare<NsAttribRequest> { public NSAttribCompare() { super(NsAttribRequest.class); } - + public static NsAttribRequest create() { NsAttribRequest nar = new NsAttribRequest(); String in = instance(); - + nar.setNs("org.osaaf.ns"+in); Attrib attrib = new Attrib(); attrib.setKey("swm"); @@ -55,7 +55,7 @@ public class NSAttribCompare extends RosettaCompare<NsAttribRequest> { nar.setEnd(Chrono.timeStamp(gc)); return nar; } - + @Override public void compare(NsAttribRequest t1, NsAttribRequest t2) { assertEquals(t1.getNs(),t2.getNs()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java index c3504216..a6a3e428 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/NSCompare.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 class NSCompare extends RosettaCompare<NsRequest> { public NSCompare() { super(NsRequest.class); } - + public static NsRequest create() { NsRequest nsr = new NsRequest(); String in = instance(); @@ -51,7 +51,7 @@ public class NSCompare extends RosettaCompare<NsRequest> { nsr.setEnd(Chrono.timeStamp(gc)); return nsr; } - + @Override public void compare(NsRequest t1, NsRequest t2) { assertEquals(t1.getName(),t2.getName()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.java index 92e07655..f10c9013 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/PermCompare.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. @@ -33,7 +33,7 @@ public class PermCompare extends RosettaCompare<PermRequest> { public PermCompare() { super(PermRequest.class); } - + public static PermRequest create() { PermRequest pr = new PermRequest(); String in = instance(); @@ -47,7 +47,7 @@ public class PermCompare extends RosettaCompare<PermRequest> { pr.setEnd(Chrono.timeStamp(gc)); return pr; } - + @Override public void compare(PermRequest t1, PermRequest t2) { assertEquals(t1.getType(),t2.getType()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.java index 0a3a164c..b0c30e1c 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RoleCompare.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. @@ -33,7 +33,7 @@ public class RoleCompare extends RosettaCompare<RoleRequest> { public RoleCompare() { super(RoleRequest.class); } - + public static RoleRequest create() { RoleRequest rr = new RoleRequest(); String in = instance(); @@ -45,7 +45,7 @@ public class RoleCompare extends RosettaCompare<RoleRequest> { rr.setEnd(Chrono.timeStamp(gc)); return rr; } - + @Override public void compare(RoleRequest t1, RoleRequest t2) { assertEquals(t1.getName(),t2.getName()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.java index 24a84b53..73348d1b 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RolePermCompare.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 class RolePermCompare extends RosettaCompare<RolePermRequest> { public RolePermCompare() { super(RolePermRequest.class); } - + public static RolePermRequest create() { RolePermRequest urr = new RolePermRequest(); String in = instance(); @@ -50,7 +50,7 @@ public class RolePermCompare extends RosettaCompare<RolePermRequest> { urr.setEnd(Chrono.timeStamp(gc)); return urr; } - + @Override public void compare(RolePermRequest t1, RolePermRequest t2) { assertEquals(t1.getRole(),t2.getRole()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.java index 43703d29..c09ded28 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/RosettaCompare.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. @@ -31,36 +31,36 @@ import org.onap.aaf.misc.rosetta.env.RosettaEnv; public abstract class RosettaCompare<T> { protected Class<T> cls; private static int count = 0; - + public RosettaCompare(Class<T> cls) { this.cls = cls; } - + public void run(RosettaEnv env) throws APIException { RosettaDF<T> nsrDF = env.newDataFactory(cls); compare(nsrDF.newData().option(Data.PRETTY),newOne(),this); } - + private void compare(RosettaData<T> rdt, T t, RosettaCompare<T> comp) throws APIException { //System.out.println("########### Testing " + cls.getName() + " ##############"); String s = rdt.load(t).out(TYPE.JSON).asString(); //System.out.println(s); T t2 = rdt.in(TYPE.JSON).load(s).asObject(); comp.compare(t, t2); - + //System.out.println(); - + s = rdt.load(t).out(TYPE.XML).asString(); //System.out.println(s); t2 = rdt.in(TYPE.XML).load(s).asObject(); comp.compare(t, t2); } - + public synchronized static String instance() { return "_"+ ++count; } - + public abstract void compare(T t1, T t2); public abstract T newOne(); - + }
\ No newline at end of file diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.java index af61e639..258c6568 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/request/test/UserRoleCompare.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. @@ -33,7 +33,7 @@ public class UserRoleCompare extends RosettaCompare<UserRoleRequest> { public UserRoleCompare() { super(UserRoleRequest.class); } - + public static UserRoleRequest create() { UserRoleRequest urr = new UserRoleRequest(); String in = instance(); @@ -45,7 +45,7 @@ public class UserRoleCompare extends RosettaCompare<UserRoleRequest> { urr.setEnd(Chrono.timeStamp(gc)); return urr; } - + @Override public void compare(UserRoleRequest t1, UserRoleRequest t2) { assertEquals(t1.getUser(),t2.getUser()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.java index 031da2fa..98a213de 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch.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. @@ -51,7 +51,7 @@ public class JU_BetterMatch { assertFalse(bm.match("/req/1.0.0/wilma/bambam")); assertFalse(bm.match("/not/valid/234")); assertFalse(bm.match("")); - + TimeTaken tt = trans.start("A", Env.SUB); TimeTaken tt2; int i = 0; @@ -66,8 +66,8 @@ public class JU_BetterMatch { } finally { tt.done(); } - - + + tt = trans.start("B", Env.SUB); i = 0; try { @@ -88,9 +88,9 @@ public class JU_BetterMatch { assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/xyx")); } finally { tt2.done(); - tt.done(); + tt.done(); } - + tt = trans.start("C", Env.SUB); i = 0; try { @@ -98,12 +98,12 @@ public class JU_BetterMatch { bm = new Match(url+":urn*"); tt2 = trans.start(Integer.toString(++i), Env.SUB); String value = "urn:fsdb,1.0,req,newreq/0x12345"; - + assertTrue(bm.match(url+value)); assertEquals("urn:fsdb,1.0,req,newreq/0x12345",bm.param(url+value, ":urn")); } finally { tt2.done(); - tt.done(); + tt.done(); } tt = trans.start("D", Env.SUB); @@ -117,7 +117,7 @@ public class JU_BetterMatch { assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/")); } finally { tt2.done(); - tt.done(); + tt.done(); } tt = trans.start("E", Env.SUB); @@ -134,7 +134,7 @@ public class JU_BetterMatch { assertTrue(bm.match("this/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/")); } finally { tt2.done(); - tt.done(); + tt.done(); } tt = trans.start("F", Env.SUB); @@ -145,20 +145,20 @@ public class JU_BetterMatch { assertTrue(bm.match("<pass>/this")); } finally { tt2.done(); - tt.done(); + tt.done(); } - + StringBuilder sb = new StringBuilder(); trans.auditTrail(0, sb); //System.out.println(sb); - + } - + @Test public void specialTest() { Match match = new Match("/sample"); assertTrue(match.match("/sample")); - + match = new Match("/lpeer//lpeer/:key/:item*"); assertTrue(match.match("/lpeer//lpeer/x/y")); assertFalse(match.match("/lpeer/x/lpeer/x/y")); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.java index 2287889b..e95d626b 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterMatch1.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. @@ -47,7 +47,7 @@ public class JU_BetterMatch1 { assertFalse(bm.match("/req/1.0.0/wilma/bambam")); assertFalse(bm.match("/not/valid/234")); assertFalse(bm.match("")); - + TimeTaken tt = trans.start("A", Env.SUB); TimeTaken tt2; int i = 0; @@ -62,8 +62,8 @@ public class JU_BetterMatch1 { } finally { tt.done(); } - - + + tt = trans.start("B", Env.SUB); i = 0; try { @@ -84,9 +84,9 @@ public class JU_BetterMatch1 { assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/xyx")); } finally { tt2.done(); - tt.done(); + tt.done(); } - + tt = trans.start("C", Env.SUB); i = 0; try { @@ -94,12 +94,12 @@ public class JU_BetterMatch1 { bm = new Match(url+":urn*"); tt2 = trans.start(Integer.toString(++i), Env.SUB); String value = "urn:fsdb,1.0,req,newreq/0x12345"; - + assertTrue(bm.match(url+value)); assertEquals("urn:fsdb,1.0,req,newreq/0x12345",bm.param(url+value, ":urn")); } finally { tt2.done(); - tt.done(); + tt.done(); } tt = trans.start("D", Env.SUB); @@ -113,7 +113,7 @@ public class JU_BetterMatch1 { assertFalse(bm.match("/req/1.0.0/urn:fsdb,1.0,req,newreq/")); } finally { tt2.done(); - tt.done(); + tt.done(); } tt = trans.start("E", Env.SUB); @@ -130,7 +130,7 @@ public class JU_BetterMatch1 { assertTrue(bm.match("this/1.0.0/urn:fsdb,1.0,req,newreq/0x12345/")); } finally { tt2.done(); - tt.done(); + tt.done(); } tt = trans.start("F", Env.SUB); @@ -141,20 +141,20 @@ public class JU_BetterMatch1 { assertTrue(bm.match("whatever/this")); } finally { tt2.done(); - tt.done(); + tt.done(); } - + StringBuilder sb = new StringBuilder(); trans.auditTrail(0, sb); //System.out.println(sb); - + } - + @Test public void specialTest() { Match match = new Match("/sample"); assertTrue(match.match("/sample")); - + match = new Match("/lpeer//lpeer/:key/:item*"); assertTrue(match.match("/lpeer//lpeer/x/y")); assertFalse(match.match("/lpeer/x/lpeer/x/y")); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.java index 2fa6b5f8..04ddca2a 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_BetterRoute.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,7 +27,7 @@ public class JU_BetterRoute { @Test public void test() { - + } } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content.java index 65cf9bc9..23c0ae80 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_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. @@ -41,7 +41,7 @@ import org.onap.aaf.misc.env.impl.EnvFactory; * Test the functioning of the "Content" class, which holds, and routes to the right code based on Accept values */ public class JU_Content { - + @Test public void test() throws Exception { @@ -78,7 +78,7 @@ public class JU_Content { //BogusReq req = new BogusReq(); //expected = (expected); //HttpServletResponse resp = new BogusResp(); - + assertNotNull("Same Content String and Accept String",ct.prep(trans,expected)); //expects Null (not run) @@ -103,35 +103,35 @@ public class JU_Content { expected = "application/java.lang.Boolean+xml;charset=UTF8;version=1.0"; assertNotNull("Minor Charset in Caps acceptable",ct.prep(trans,expected)); - // expects no run + // expects no run expected="application/java.lang.Boolean+xml;charset=MyType;version=1.0"; assertNull("Unknown Minor Charset",ct.prep(trans,expected)); expected=""; assertNotNull("Blank Acceptance",ct.prep(trans,expected)); - + expected=null; - assertNotNull("Null Acceptance",ct.prep(trans,expected)); + assertNotNull("Null Acceptance",ct.prep(trans,expected)); expected = ("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); assertNotNull("Matches application/xml, and other content not known",ct.prep(trans,expected)); - + // No SemiColon expected = ("i/am/bogus,application/xml"); assertNotNull("Match second entry, with no Semis",ct.prep(trans,expected)); - } finally { + } finally { StringBuilder sb = new StringBuilder(); trans.auditTrail(0, sb); //System.out.println(sb); } } -// +// // Original API used HTTPServletRequest and HTTPServletResponse. Due to the fact that sometimes we use Accept, and others Content-TYpe // I changed it to simply accept a string -// +// // Jonathan 3/8/2013 -// +// // @SuppressWarnings("rawtypes") // class BogusReq implements HttpServletRequest { // private String accept; @@ -159,175 +159,175 @@ public class JU_Content { // @Override // public void setCharacterEncoding(String env) // throws UnsupportedEncodingException { -// +// // // } // // @Override // public int getContentLength() { -// +// // return 0; // } // // @Override // public String getContentType() { -// +// // return null; // } // // @Override // public ServletInputStream getInputStream() throws IOException { -// +// // return null; // } // // @Override // public String getParameter(String name) { -// +// // return null; // } // // @Override // public Enumeration getParameterNames() { -// +// // return null; // } // // @Override // public String[] getParameterValues(String name) { -// +// // return null; // } // // @Override // public Map getParameterMap() { -// +// // return null; // } // // @Override // public String getProtocol() { -// +// // return null; // } // // @Override // public String getScheme() { -// +// // return null; // } // // @Override // public String getServerName() { -// +// // return null; // } // // @Override // public int getServerPort() { -// +// // return 0; // } // // @Override // public BufferedReader getReader() throws IOException { -// +// // return null; // } // // @Override // public String getRemoteAddr() { -// +// // return null; // } // // @Override // public String getRemoteHost() { -// +// // return null; // } // // @Override // public void setAttribute(String name, Object o) { -// +// // // } // // @Override // public void removeAttribute(String name) { -// +// // // } // // @Override // public Locale getLocale() { -// +// // return null; // } // // @Override // public Enumeration getLocales() { -// +// // return null; // } // // @Override // public boolean isSecure() { -// +// // return false; // } // // @Override // public RequestDispatcher getRequestDispatcher(String path) { -// +// // return null; // } // // @Override // public String getRealPath(String path) { -// +// // return null; // } // // @Override // public int getRemotePort() { -// +// // return 0; // } // // @Override // public String getLocalName() { -// +// // return null; // } // // @Override // public String getLocalAddr() { -// +// // return null; // } // // @Override // public int getLocalPort() { -// +// // return 0; // } // // @Override // public String getAuthType() { -// +// // return null; // } // // @Override // public Cookie[] getCookies() { -// +// // return null; // } // // @Override // public long getDateHeader(String name) { -// +// // return 0; // } // @@ -338,137 +338,137 @@ public class JU_Content { // // @Override // public Enumeration getHeaders(String name) { -// +// // return null; // } // // @Override // public Enumeration getHeaderNames() { -// +// // return null; // } // // @Override // public int getIntHeader(String name) { -// +// // return 0; // } // // @Override // public String getMethod() { -// +// // return null; // } // // @Override // public String getPathInfo() { -// +// // return null; // } // // @Override // public String getPathTranslated() { -// +// // return null; // } // // @Override // public String getContextPath() { -// +// // return null; // } // // @Override // public String getQueryString() { -// +// // return null; // } // // @Override // public String getRemoteUser() { -// +// // return null; // } // // @Override // public boolean isUserInRole(String role) { -// +// // return false; // } // // @Override // public Principal getUserPrincipal() { -// +// // return null; // } // // @Override // public String getRequestedSessionId() { -// +// // return null; // } // // @Override // public String getRequestURI() { -// +// // return null; // } // // @Override // public StringBuffer getRequestURL() { -// +// // return null; // } // // @Override // public String getServletPath() { -// +// // return null; // } // // @Override // public HttpSession getSession(boolean create) { -// +// // return null; // } // // @Override // public HttpSession getSession() { -// +// // return null; // } // // @Override // public boolean isRequestedSessionIdValid() { -// +// // return false; // } // // @Override // public boolean isRequestedSessionIdFromCookie() { -// +// // return false; // } // // @Override // public boolean isRequestedSessionIdFromURL() { -// +// // return false; // } // // @Override // public boolean isRequestedSessionIdFromUrl() { -// +// // return false; // } // } -// +// // public class BogusResp implements HttpServletResponse { // public String contentType; // // @Override // public String getCharacterEncoding() { -// +// // return null; // } // @@ -479,26 +479,26 @@ public class JU_Content { // // @Override // public ServletOutputStream getOutputStream() throws IOException { -// +// // return null; // } // // @Override // public PrintWriter getWriter() throws IOException { -// +// // return null; // } // // @Override // public void setCharacterEncoding(String charset) { -// -// +// +// // } // // @Override // public void setContentLength(int len) { -// -// +// +// // } // // @Override @@ -508,154 +508,154 @@ public class JU_Content { // // @Override // public void setBufferSize(int size) { -// -// +// +// // } // // @Override // public int getBufferSize() { -// +// // return 0; // } // // @Override // public void flushBuffer() throws IOException { -// -// +// +// // } // // @Override // public void resetBuffer() { -// -// +// +// // } // // @Override // public boolean isCommitted() { -// +// // return false; // } // // @Override // public void reset() { -// -// +// +// // } // // @Override // public void setLocale(Locale loc) { -// -// +// +// // } // // @Override // public Locale getLocale() { -// +// // return null; // } // // @Override // public void addCookie(Cookie cookie) { -// -// +// +// // } // // @Override // public boolean containsHeader(String name) { -// +// // return false; // } // // @Override // public String encodeURL(String url) { -// +// // return null; // } // // @Override // public String encodeRedirectURL(String url) { -// +// // return null; // } // // @Override // public String encodeUrl(String url) { -// +// // return null; // } // // @Override // public String encodeRedirectUrl(String url) { -// +// // return null; // } // // @Override // public void sendError(int sc, String msg) throws IOException { -// -// +// +// // } // // @Override // public void sendError(int sc) throws IOException { -// -// +// +// // } // // @Override // public void sendRedirect(String location) throws IOException { -// -// +// +// // } // // @Override // public void setDateHeader(String name, long date) { -// -// +// +// // } // // @Override // public void addDateHeader(String name, long date) { -// -// +// +// // } // // @Override // public void setHeader(String name, String value) { -// -// +// +// // } // // @Override // public void addHeader(String name, String value) { -// -// +// +// // } // // @Override // public void setIntHeader(String name, int value) { -// -// +// +// // } // // @Override // public void addIntHeader(String name, int value) { -// -// +// +// // } // // @Override // public void setStatus(int sc) { -// -// +// +// // } // // @Override // public void setStatus(int sc, String sm) { -// -// +// +// // } -// +// // } // } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.java index eb2fe359..b6f220c9 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Content1.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,7 +42,7 @@ import org.onap.aaf.misc.env.impl.EnvFactory; * Test the functioning of the "Content" class, which holds, and routes to the right code based on Accept values */ public class JU_Content1 { - + @Test public void test() throws Exception { @@ -79,7 +79,7 @@ public class JU_Content1 { //BogusReq req = new BogusReq(); //expected = (expected); //HttpServletResponse resp = new BogusResp(); - + assertNotNull("Same Content String and Accept String",ct.prep(trans,expected)); //expects Null (not run) @@ -104,24 +104,24 @@ public class JU_Content1 { expected = "application/java.lang.Boolean+xml;charset=UTF8;version=1.0"; assertNotNull("Minor Charset in Caps acceptable",ct.prep(trans,expected)); - // expects no run + // expects no run expected="application/java.lang.Boolean+xml;charset=MyType;version=1.0"; assertNull("Unknown Minor Charset",ct.prep(trans,expected)); expected=""; assertNotNull("Blank Acceptance",ct.prep(trans,expected)); - + expected=null; - assertNotNull("Null Acceptance",ct.prep(trans,expected)); + assertNotNull("Null Acceptance",ct.prep(trans,expected)); expected = ("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); assertNotNull("Matches application/xml, and other content not known",ct.prep(trans,expected)); - + // No SemiColon expected = ("i/am/bogus,application/xml"); assertNotNull("Match second entry, with no Semis",ct.prep(trans,expected)); - } finally { + } finally { StringBuilder sb = new StringBuilder(); trans.auditTrail(0, sb); //System.out.println(sb); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Pair.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Pair.java index b81966db..84383ce5 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Pair.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_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. @@ -34,7 +34,7 @@ public class JU_Pair { Pair<Integer, Integer> pair; Integer x; Integer y; - + @Before public void setUp(){ pair = new Pair<Integer, Integer>(1, 2); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Route.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Route.java index 26ec6abf..b8fd01c2 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Route.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_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. @@ -37,20 +37,20 @@ public class JU_Route { HttpCode httpCode; HttpMethods httpMethod; Trans trans; - + @Before public void setUp() { //TODO: AAF-111 complete when actual input is provided //httpMethod = Matchers.any(HttpMethods.class); //when(httpMethod.name()).thenReturn("test"); // route = new Route(null,"path/to/place"); } - - + + @Test public void testAdd() { // route.add(httpCode, "path/to/place"); } - + @Test public void testStart() { // trans = mock(Trans.class); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_RouteReport.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_RouteReport.java index fffd3944..12b00858 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_RouteReport.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_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/test/java/org/onap/aaf/auth/rserv/test/JU_Routes.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Routes.java index 9606d472..b5538b99 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Routes.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_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. @@ -49,25 +49,25 @@ public class JU_Routes { //TODO: Gabe [JUnit] Not visible to junit //CodeSetter<Trans> codeSetterMock; Route<Trans> routeObj; - + @Before public void setUp(){ routes = new Routes(); } - + @Test public void testRouteReport(){ - List listVal = routes.routeReport(); + List listVal = routes.routeReport(); assertNotNull(listVal); } - + @Test public void testDerive() throws IOException, ServletException{ routeObj = routes.derive(reqMock, null); - + } - - - + + + } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java index 76948ac6..60727b6a 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_TypedCode.java @@ -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. @@ -50,31 +50,31 @@ public class JU_TypedCode { TypedCode typedCode; @Mock RouteReport routeReportMock; - + @Before public void setUp(){ typedCode = new TypedCode(); } - + @Test public void testFirst(){ String returnVal = typedCode.first(); assertNull(returnVal); } - + @Test public void testAdd() { HttpCode<?, ?> code = mock(HttpCode.class); typedCode.add(code , "test", "test1", "test2"); } - + @Test public void testPrep() throws IOException, ServletException, ClassNotFoundException { Trans trans = mock(Trans.class); TimeTaken time = new TimeTaken("yell", 2) { @Override public void output(StringBuilder sb) { - // TODO Auto-generated method stub + // TODO Auto-generated method stub } }; when(trans.start(";na=me;,prop", 8)).thenReturn(time); @@ -83,20 +83,20 @@ public class JU_TypedCode { code.isAuthorized(null); //Testing httpcode, currently not working code.no_cache(); code.toString(); - + typedCode.add(code , ""); typedCode.prep(null , "q"); - + typedCode.add(code , "t"); typedCode.prep(trans , null); - + typedCode.add(code , "t"); typedCode.prep(trans , ""); - + typedCode.add(code, "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*"); - //typedCode.prep(trans , "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*"); + //typedCode.prep(trans , "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*"); } - + @Test public void testRelatedTo() { HttpCode<?, ?> code = mock(HttpCode.class); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Version.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Version.java index 47be1acb..a1bbef5a 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_Version.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/rserv/test/JU_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. @@ -38,7 +38,7 @@ public class JU_Version { Version version; Version versionTest; - + @Before public void setUp(){ version = new Version("first\\.123"); @@ -46,7 +46,7 @@ public class JU_Version { } @Test - public void testEquals(){ + public void testEquals(){ version.equals(versionTest); versionTest.equals(version); versionTest = new Version("fail\\.124"); @@ -54,16 +54,16 @@ public class JU_Version { version.equals("This is not an object of version"); versionTest = new Version("NoVersion\\.number"); version.equals(versionTest); - - + + } - + @Test public void testToString(){ String strVal = version.toString(); assertNotNull(strVal); } - + @Test public void testHashCode() { Assert.assertNotNull(version.hashCode()); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java index b89e2e5d..c80c8187 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_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. @@ -63,9 +63,9 @@ import java.security.Principal; import javax.servlet.Filter; public class JU_AbsService { - + ByteArrayOutputStream outStream; - + private class AbsServiceStub extends AbsService { public AbsServiceStub(Access access, BasicEnv env) throws CadiException { @@ -84,31 +84,31 @@ public class JU_AbsService { // TODO Auto-generated method stub return null; } - + } - + @Before public void setUp() { outStream = new ByteArrayOutputStream(); System.setOut(new PrintStream(outStream)); } - + @After public void tearDown() { System.setOut(System.out); } - + @Test public void testStub() throws CadiException { BasicEnv bEnv = new BasicEnv(); PropAccess prop = new PropAccess(); - + prop.setProperty(Config.AAF_LOCATOR_ENTRIES, "te.st"); prop.setProperty(Config.AAF_LOCATOR_VERSION, "te.st"); prop.setLogLevel(Level.DEBUG); AbsServiceStub absServiceStub = new AbsServiceStub(prop, bEnv); //Testing other branches requires "fails" due to exception handling, will leave that off for now. } - + } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java index 4972b572..9e0cd9af 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_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. @@ -42,11 +42,11 @@ import org.onap.aaf.cadi.register.Registrant; import org.onap.aaf.misc.env.impl.BasicEnv; public class JU_AbsServiceStarter { - + ByteArrayOutputStream outStream; AbsServiceStub absServiceStub; AbsServiceStarterStub absServiceStarterStub; - + private class AbsServiceStarterStub extends AbsServiceStarter { public AbsServiceStarterStub(AbsService service, boolean secure) { @@ -57,16 +57,16 @@ public class JU_AbsServiceStarter { @Override public void _start(RServlet rserv) throws Exception { // TODO Auto-generated method stub - + } @Override public void _propertyAdjustment() { // TODO Auto-generated method stub - + } } - + private class AbsServiceStub extends AbsService { public AbsServiceStub(Access access, BasicEnv env) throws CadiException { @@ -85,40 +85,40 @@ public class JU_AbsServiceStarter { // TODO Auto-generated method stub return null; } - + } - + @Before public void setUp() { outStream = new ByteArrayOutputStream(); System.setOut(new PrintStream(outStream)); } - + @After public void tearDown() { System.setOut(System.out); } - - + + @Test public void testStub() throws CadiException { BasicEnv bEnv = new BasicEnv(); PropAccess prop = new PropAccess(); - + prop.setProperty(Config.AAF_LOCATOR_ENTRIES, "te.st"); prop.setProperty(Config.AAF_LOCATOR_VERSION, "te.st"); prop.setLogLevel(Level.DEBUG); absServiceStub = new AbsServiceStub(prop, bEnv); - + absServiceStarterStub = new AbsServiceStarterStub(absServiceStub,true); } - + // @Test // public void testStart() throws Exception { // absServiceStarterStub.env(); // absServiceStarterStub.start(); // } - + } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java index ae76de0f..68077c7c 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.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. @@ -76,18 +76,18 @@ public class JU_JettyServiceStarter { @Before public void setUp() throws OrganizationException, CadiException { Access access = mock(Access.class); - + BasicEnv bEnv = mock(BasicEnv.class); Trans trans = mock(Trans.class); //TODO: Fix this once Gabe has services running to see correct output without mock //TestService testService = new TestService(access, bEnv); //jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(testService); } - + // @Test // public void netYetTested() { // fail("Tests not yet implemented"); // } - + @Test public void testPropertyAdjustment() { //jss._propertyAdjustment(); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.java index 5bc1b68d..f887ca40 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/JU_Mask.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,12 +40,12 @@ public class JU_Mask { InetAddress ia = InetAddress.getByName("192.168.0.0"); NetMask mask = new NetMask(ia.getAddress()); assertTrue(mask.isInNet(ia.getAddress())); - + mask = new NetMask("192.168.1/24"); assertTrue(mask.isInNet("192.168.1.20")); assertTrue(mask.isInNet("192.168.1.255")); assertFalse(mask.isInNet("192.168.2.20")); - + mask = new NetMask("192.168.1/31"); assertFalse(mask.isInNet("192.168.2.20")); assertFalse(mask.isInNet("192.168.1.20")); @@ -56,10 +56,10 @@ public class JU_Mask { assertTrue(mask.isInNet("192.168.1.1")); assertTrue(mask.isInNet("192.1.1.1")); assertFalse(mask.isInNet("193.168.1.1")); - + mask = new NetMask("/0"); assertTrue(mask.isInNet("193.168.1.1")); - + String msg = "Should throw " + MaskFormatException.class.getSimpleName(); try { mask = new NetMask("256.256.256.256"); diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java index 40e1886e..754d476f 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/util/test/TestKill.java @@ -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. @@ -52,7 +52,7 @@ public class TestKill implements Runnable { @Override public void run() { } - + private void longProcess() { System.out.println("Starting long cleanup process"); try { |