X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Frserv%2FAcceptor.java;h=bf9f57e3acd95e1f437beea50dba25a7ff711b66;hb=c4679e1c9264eb4f105bf458ee16a0353b87b7e0;hp=0e70e25e7a2a820d7b5fe956b07fd0744c3a2957;hpb=7e966914050e66219689001ff4ab601a49eef0ac;p=aaf%2Fauthz.git 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..bf9f57e3 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,15 +38,14 @@ import org.onap.aaf.misc.env.Trans; class Acceptor { private List, List>>>> types; List, List>>>> acceptable; - + public Acceptor(List, List>>>> types) { this.types = types; acceptable = new ArrayList<>(); } - + private boolean eval(HttpCode code, String str, List props) { -// int plus = str.indexOf('+'); -// if (plus<0) { + boolean ok = false; boolean any = false; for (Pair, List>>> type : types) { @@ -61,23 +60,7 @@ class Acceptor { } } } -// } else { // Handle Accepts with "+" as in application/xaml+xml -// int prev = str.indexOf('/')+1; -// String first = str.substring(0,prev); -// String nstr; -// while (prev!=0) { -// nstr = first + (plus<0?str.substring(prev):str.substring(prev,plus)); -// -// for (Pair, List>>> type : types) { -// if (type.x.equals(nstr)) { -// acceptable.add(type); -// return type; -// } -// } -// prev = plus+1; -// plus=str.indexOf('+', prev); -// }; -// } + return any; } @@ -93,9 +76,9 @@ class Acceptor { if (type.y!=null) { for (Pair prop : type.y.y){ if (tag.equals(prop.x)) { - if (tag.equals("charset")) { + if ( "charset".equals(tag)) { return prop.x==null?false:prop.y.equals(value.toLowerCase()); // return True if Matched - } else if (tag.equals("version")) { + } else if ("version".equals(tag)) { return prop.y.equals(new Version(value)); // Note: Version Class knows Minor Version encoding } else if (tag.equals(Content.Q)) { // replace Q value try { @@ -114,17 +97,17 @@ class Acceptor { } /** - * parse - * + * parse + * * Note: I'm processing by index to avoid lots of memory creation, which speeds things - * up for this time critical section of code. + * up for this time critical section of code. * @param code * @param cntnt * @return */ protected boolean parse(HttpCode code, String cntnt) { byte bytes[] = cntnt.getBytes(); - + int cis,cie=-1,cend; int sis,sie,send; String name; @@ -133,17 +116,17 @@ class Acceptor { // Clear these in case more than one Semi props.clear(); // on loop, do not want mixed properties name=null; - + cis = cie+1; // find comma start while (ciscis && Character.isSpaceChar(bytes[cend-1]))--cend; // Start SEMIS - sie=cis-1; + sie=cis-1; do { sis = sie+1; // semi start is one after previous end - while (siscend || sie<0?cend:sie; // if the Semicolon is after the comma, or non-existent, use comma end, else keep while (send>sis && Character.isSpaceChar(bytes[send-1]))--send; @@ -165,5 +148,5 @@ class Acceptor { } while (cie>=0); // loop to next comma return false; // didn't get even one match } - + } \ No newline at end of file