List of usage examples for org.apache.commons.lang StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(String str, String searchStr)
Checks if String contains a search String irrespective of case, handling null
.
From source file:org.zanata.action.LanguageManagerAction.java
@Override public List<HLocale> suggest() { if (StringUtils.isEmpty(getQuery())) { return Collections.EMPTY_LIST; }/*from w w w. jav a 2 s . c o m*/ Collection<HLocale> locales = Collections2.transform(allLocales, new Function<LocaleId, HLocale>() { @Override public HLocale apply(@Nullable LocaleId from) { return new HLocale(from); } }); Collection<HLocale> filtered = Collections2.filter(locales, new Predicate<HLocale>() { @Override public boolean apply(HLocale input) { return StringUtils.containsIgnoreCase(input.getLocaleId().getId(), getQuery()); } }); if (filtered.isEmpty()) { updateLanguage(getQuery()); } return Lists.newArrayList(filtered); }
From source file:org.zanata.action.LanguagesAction.java
@Override protected boolean include(HLocale elem, String filter) { return StringUtils.containsIgnoreCase(elem.retrieveDisplayName(), filter) || StringUtils.containsIgnoreCase(elem.getLocaleId().getId(), filter); }
From source file:org.zaproxy.zap.extension.ascanrules.TestCrossSiteScriptV2.java
@Override public void scan(HttpMessage msg, String param, String value) { if (!AlertThreshold.LOW.equals(getAlertThreshold()) && HttpRequestHeader.PUT.equals(msg.getRequestHeader().getMethod())) { return;//from w w w. j a v a 2 s. c o m } try { // Inject the 'safe' eyecatcher and see where it appears boolean attackWorked = false; HttpMessage msg2 = getNewMsg(); setParameter(msg2, param, Constant.getEyeCatcher()); try { sendAndReceive(msg2); } catch (URIException e) { if (log.isDebugEnabled()) { log.debug("Failed to send HTTP message, cause: " + e.getMessage()); } return; } catch (InvalidRedirectLocationException | UnknownHostException e) { // Not an error, just means we probably attacked the redirect // location // Try the second eye catcher } if (isStop()) { return; } HtmlContextAnalyser hca = new HtmlContextAnalyser(msg2); List<HtmlContext> contexts = hca.getHtmlContexts(Constant.getEyeCatcher(), null, 0); if (contexts.size() == 0) { // Lower case? contexts = hca.getHtmlContexts(Constant.getEyeCatcher().toLowerCase(), null, 0); } if (contexts.size() == 0) { // Upper case? contexts = hca.getHtmlContexts(Constant.getEyeCatcher().toUpperCase(), null, 0); } if (contexts.size() == 0) { // No luck - try again, appending the eyecatcher to the original // value msg2 = getNewMsg(); setParameter(msg2, param, value + Constant.getEyeCatcher()); try { sendAndReceive(msg2); } catch (URIException e) { if (log.isDebugEnabled()) { log.debug("Failed to send HTTP message, cause: " + e.getMessage()); } return; } catch (InvalidRedirectLocationException | UnknownHostException e) { // Second eyecatcher failed for some reason, no need to // continue return; } hca = new HtmlContextAnalyser(msg2); contexts = hca.getHtmlContexts(value + Constant.getEyeCatcher(), null, 0); } if (contexts.size() == 0) { // No luck - lets just try a direct attack List<HtmlContext> contexts2 = performAttack(msg, param, "'\"" + GENERIC_SCRIPT_ALERT, null, 0); if (contexts2 == null) { return; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_LOW, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } } for (HtmlContext context : contexts) { // Loop through the returned contexts and launch targeted // attacks if (attackWorked || isStop()) { break; } if (context.getTagAttribute() != null) { // its in a tag attribute - lots of attack vectors possible if (context.isInScriptAttribute()) { // Good chance this will be vulnerable // Try a simple alert attack List<HtmlContext> contexts2 = performAttack(msg, param, ";alert(1)", context, 0); if (contexts2 == null) { break; } for (HtmlContext context2 : contexts2) { if (context2.getTagAttribute() != null && context2.isInScriptAttribute()) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, context2.getTarget(), "", contexts2.get(0).getTarget(), context2.getMsg()); attackWorked = true; break; } } if (!attackWorked) { log.debug("Failed to find vuln in script attribute on " + msg.getRequestHeader().getURI()); } } else if (context.isInUrlAttribute()) { // Its a url attribute List<HtmlContext> contexts2 = performAttack(msg, param, "javascript:alert(1);", context, 0); if (contexts2 == null) { break; } for (HtmlContext ctx : contexts2) { if (ctx.isInUrlAttribute()) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, ctx.getTarget(), "", ctx.getTarget(), ctx.getMsg()); attackWorked = true; break; } } if (!attackWorked) { log.debug("Failed to find vuln in url attribute on " + msg.getRequestHeader().getURI()); } } if (!attackWorked && context.isInTagWithSrc()) { // Its in an attribute in a tag which supports src // attributes List<HtmlContext> contexts2 = performAttack(msg, param, context.getSurroundingQuote() + " src=http://badsite.com", context, HtmlContext.IGNORE_TAG); if (contexts2 == null) { break; } if (contexts2.size() > 0) { bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } if (!attackWorked) { log.debug("Failed to find vuln in tag with src attribute on " + msg.getRequestHeader().getURI()); } } if (!attackWorked) { // Try a simple alert attack List<HtmlContext> contexts2 = performAttack(msg, param, context.getSurroundingQuote() + ">" + GENERIC_SCRIPT_ALERT, context, HtmlContext.IGNORE_TAG); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } if (!attackWorked) { log.debug("Failed to find vuln with simple script attack " + msg.getRequestHeader().getURI()); } } if (!attackWorked) { // Try adding an onMouseOver List<HtmlContext> contexts2 = performAttack( msg, param, context.getSurroundingQuote() + " onMouseOver=" + context.getSurroundingQuote() + "alert(1);", context, HtmlContext.IGNORE_TAG); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } if (!attackWorked) { log.debug("Failed to find vuln in with simple onmounseover " + msg.getRequestHeader().getURI()); } } } else if (context.isHtmlComment()) { // Try breaking out of the comment List<HtmlContext> contexts2 = performAttack(msg, param, "-->" + GENERIC_SCRIPT_ALERT + "<!--", context, HtmlContext.IGNORE_HTML_COMMENT); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } else { // Maybe they're blocking script tags contexts2 = performAttack(msg, param, "--><b onMouseOver=alert(1);>test</b><!--", context, HtmlContext.IGNORE_HTML_COMMENT); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } } } else { // its not in a tag attribute if ("body".equalsIgnoreCase(context.getParentTag())) { // Immediately under a body tag // Try a simple alert attack List<HtmlContext> contexts2 = performAttack(msg, param, GENERIC_SCRIPT_ALERT, null, HtmlContext.IGNORE_PARENT); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } else { // Maybe they're blocking script tags contexts2 = performAttack(msg, param, "<b onMouseOver=alert(1);>test</b>", context, HtmlContext.IGNORE_PARENT); if (contexts2 != null) { for (HtmlContext context2 : contexts2) { if ("body".equalsIgnoreCase(context2.getParentTag()) || "b".equalsIgnoreCase(context2.getParentTag())) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; break; } } } if (!attackWorked) { if (GET_POST_TYPES.contains(currentParamType)) { // Try double encoded List<HtmlContext> contexts3 = performAttack(msg, param, getURLEncode(GENERIC_SCRIPT_ALERT), null, 0, true); if (contexts3 != null && contexts3.size() > 0) { attackWorked = true; bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, getURLEncode(getURLEncode(contexts3.get(0).getTarget())), "", GENERIC_SCRIPT_ALERT, contexts3.get(0).getMsg()); } break; } } } } else if (context.getParentTag() != null) { // Its not immediately under a body tag, try to close // the tag List<HtmlContext> contexts2 = performAttack(msg, param, "</" + context.getParentTag() + ">" + GENERIC_SCRIPT_ALERT + "<" + context.getParentTag() + ">", context, HtmlContext.IGNORE_IN_SCRIPT); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } else if ("script".equalsIgnoreCase(context.getParentTag())) { // its in a script tag... contexts2 = performAttack(msg, param, context.getSurroundingQuote() + ";alert(1);" + context.getSurroundingQuote(), context, 0); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; } } else { // Try an img tag List<HtmlContext> contextsA = performAttack(msg, param, "<img src=x onerror=alert(1);>", context, HtmlContext.IGNORE_IN_SCRIPT); if (contextsA != null && contextsA.size() > 0) { bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contextsA.get(0).getTarget(), "", contextsA.get(0).getTarget(), contextsA.get(0).getMsg()); attackWorked = true; break; } } } else { // Last chance - is the payload reflected outside of any // tags if (context.getMsg().getResponseBody().toString().contains(context.getTarget())) { List<HtmlContext> contexts2 = performAttack(msg, param, GENERIC_SCRIPT_ALERT, null, 0); if (contexts2 == null) { break; } for (HtmlContext ctx : contexts2) { if (ctx.getParentTag() != null) { // Yep, its vulnerable if (ctx.getMsg().getResponseHeader().isHtml()) { bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, ctx.getTarget(), "", ctx.getTarget(), contexts2.get(0).getMsg()); } else { HttpMessage ctx2Message = contexts2.get(0).getMsg(); if (StringUtils.containsIgnoreCase( ctx.getMsg().getResponseHeader().getHeader(HttpHeader.CONTENT_TYPE), "json")) { bingo(Alert.RISK_LOW, Alert.CONFIDENCE_LOW, Constant.messages.getString(MESSAGE_PREFIX + "json.name"), Constant.messages.getString(MESSAGE_PREFIX + "json.desc"), ctx2Message.getRequestHeader().getURI().toString(), param, GENERIC_SCRIPT_ALERT, Constant.messages .getString(MESSAGE_PREFIX + "otherinfo.nothtml"), getSolution(), "", ctx2Message); } else { bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_LOW, null, param, ctx.getTarget(), Constant.messages .getString(MESSAGE_PREFIX + "otherinfo.nothtml"), ctx.getTarget(), ctx2Message); } } attackWorked = true; break; } } } } } } } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:org.zaproxy.zap.extension.ascanrules.TestPersistentXSSAttack.java
@Override public void scan(HttpMessage sourceMsg, String param, String value) { if (!AlertThreshold.LOW.equals(getAlertThreshold()) && HttpRequestHeader.PUT.equals(sourceMsg.getRequestHeader().getMethod())) { return;/*from w ww.j a v a2 s. com*/ } String otherInfo = Constant.messages.getString(MESSAGE_PREFIX + "otherinfo", sourceMsg.getRequestHeader().getURI().toString()); try { Set<Integer> sinks = PersistentXSSUtils.getSinksIdsForSource(sourceMsg, param); if (sinks != null) { // Loop through each one // Inject the 'safe' eyecatcher boolean attackWorked = false; setParameter(sourceMsg, param, Constant.getEyeCatcher()); sendAndReceive(sourceMsg); // Check each sink for (Integer sinkMsgId : sinks) { if (isStop()) { break; } HttpMessage sinkMsg = PersistentXSSUtils.getMessage(sinkMsgId); if (sinkMsg == null) { continue; } sinkMsg = sinkMsg.cloneRequest(); sendAndReceive(sinkMsg); HtmlContextAnalyser hca = new HtmlContextAnalyser(sinkMsg); List<HtmlContext> contexts = hca.getHtmlContexts(Constant.getEyeCatcher(), null, 0); for (HtmlContext context : contexts) { // Loop through the returned contexts and lauch targetted attacks if (attackWorked || isStop()) { break; } if (context.getTagAttribute() != null) { // its in a tag attribute - lots of attack vectors possible if (context.isInScriptAttribute()) { // Good chance this will be vulnerable // Try a simple alert attack List<HtmlContext> contexts2 = performAttack(sourceMsg, param, ";alert(1)", sinkMsg, context, 0); if (contexts2 == null) { break; } for (HtmlContext context2 : contexts2) { if (context2.getTagAttribute() != null && context2.isInScriptAttribute()) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, context2.getTarget(), otherInfo, context2.getMsg()); attackWorked = true; break; } } if (!attackWorked) { log.debug("Failed to find vuln in script attribute on " + sourceMsg.getRequestHeader().getURI()); } } else if (context.isInUrlAttribute()) { // Its a url attribute List<HtmlContext> contexts2 = performAttack(sourceMsg, param, "javascript:alert(1);", sinkMsg, context, 0); if (contexts2 == null) { break; } for (HtmlContext ctx : contexts2) { if (ctx.isInUrlAttribute()) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, ctx.getTarget(), "", ctx.getTarget(), ctx.getMsg()); attackWorked = true; break; } } if (!attackWorked) { log.debug("Failed to find vuln in url attribute on " + sourceMsg.getRequestHeader().getURI()); } } if (!attackWorked && context.isInTagWithSrc()) { // Its in an attribute in a tag which supports src attributes List<HtmlContext> contexts2 = performAttack(sourceMsg, param, context.getSurroundingQuote() + " src=http://badsite.com", sinkMsg, context, HtmlContext.IGNORE_TAG); if (contexts2 == null) { break; } if (contexts2.size() > 0) { bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), otherInfo, contexts2.get(0).getMsg()); attackWorked = true; } if (!attackWorked) { log.debug("Failed to find vuln in tag with src attribute on " + sourceMsg.getRequestHeader().getURI()); } } if (!attackWorked) { // Try a simple alert attack List<HtmlContext> contexts2 = performAttack(sourceMsg, param, context.getSurroundingQuote() + ">" + GENERIC_SCRIPT_ALERT, sinkMsg, context, HtmlContext.IGNORE_TAG); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), otherInfo, contexts2.get(0).getMsg()); attackWorked = true; } if (!attackWorked) { log.debug("Failed to find vuln with simple script attack " + sourceMsg.getRequestHeader().getURI()); } } if (!attackWorked) { // Try adding an onMouseOver List<HtmlContext> contexts2 = performAttack(sourceMsg, param, context.getSurroundingQuote() + " onMouseOver=" + context.getSurroundingQuote() + "alert(1);", sinkMsg, context, HtmlContext.IGNORE_TAG); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), otherInfo, contexts2.get(0).getMsg()); attackWorked = true; } if (!attackWorked) { log.debug("Failed to find vuln in with simple onmounseover " + sourceMsg.getRequestHeader().getURI()); } } } else if (context.isHtmlComment()) { // Try breaking out of the comment List<HtmlContext> contexts2 = performAttack(sourceMsg, param, "-->" + GENERIC_SCRIPT_ALERT + "<!--", sinkMsg, context, HtmlContext.IGNORE_HTML_COMMENT); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), otherInfo, contexts2.get(0).getMsg()); attackWorked = true; } else { // Maybe they're blocking script tags contexts2 = performAttack(sourceMsg, param, "--><b onMouseOver=alert(1);>test</b><!--", sinkMsg, context, HtmlContext.IGNORE_HTML_COMMENT); if (contexts2 != null && contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), otherInfo, contexts2.get(0).getMsg()); attackWorked = true; } } } else { // its not in a tag attribute if ("body".equalsIgnoreCase(context.getParentTag())) { // Immediately under a body tag // Try a simple alert attack List<HtmlContext> contexts2 = performAttack(sourceMsg, param, GENERIC_SCRIPT_ALERT, sinkMsg, null, HtmlContext.IGNORE_PARENT); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), otherInfo, contexts2.get(0).getMsg()); attackWorked = true; } else { // Maybe they're blocking script tags contexts2 = performAttack(sourceMsg, param, "<b onMouseOver=alert(1);>test</b>", sinkMsg, context, HtmlContext.IGNORE_PARENT); if (contexts2 != null) { for (HtmlContext context2 : contexts2) { if ("body".equalsIgnoreCase(context2.getParentTag()) || "b".equalsIgnoreCase(context2.getParentTag()) || "script".equalsIgnoreCase(context2.getParentTag())) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), "", contexts2.get(0).getTarget(), contexts2.get(0).getMsg()); attackWorked = true; break; } } } if (!attackWorked) { if (GET_POST_TYPES.contains(currentParamType)) { // Try double encoded List<HtmlContext> contexts3 = performAttack(sourceMsg, param, getURLEncode(GENERIC_SCRIPT_ALERT), sinkMsg, null, 0, true); if (contexts3 != null && contexts3.size() > 0) { attackWorked = true; bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, getURLEncode(getURLEncode(contexts3.get(0).getTarget())), "", GENERIC_SCRIPT_ALERT, contexts3.get(0).getMsg()); } break; } } } } else if (context.getParentTag() != null) { // Its not immediately under a body tag, try to close the tag List<HtmlContext> contexts2 = performAttack(sourceMsg, param, "</" + context.getParentTag() + ">" + GENERIC_SCRIPT_ALERT + "<" + context.getParentTag() + ">", sinkMsg, context, HtmlContext.IGNORE_IN_SCRIPT); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), otherInfo, contexts2.get(0).getMsg()); attackWorked = true; } else if ("script".equalsIgnoreCase(context.getParentTag())) { // its in a script tag... contexts2 = performAttack(sourceMsg, param, context.getSurroundingQuote() + ";alert(1);" + context.getSurroundingQuote(), sinkMsg, context, 0); if (contexts2 == null) { break; } if (contexts2.size() > 0) { // Yep, its vulnerable bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contexts2.get(0).getTarget(), otherInfo, contexts2.get(0).getMsg()); attackWorked = true; } } else { // Try an img tag List<HtmlContext> contextsA = performAttack(sourceMsg, param, "<img src=x onerror=alert(1);>", sinkMsg, context, 0); if (contextsA != null && contextsA.size() > 0) { bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, contextsA.get(0).getTarget(), "", contextsA.get(0).getTarget(), contextsA.get(0).getMsg()); attackWorked = true; break; } } } else { // Last chance - is the payload outside of any tags if (context.getMsg().getResponseBody().toString().contains(context.getTarget())) { List<HtmlContext> contexts2 = performAttack(sourceMsg, param, GENERIC_SCRIPT_ALERT, sinkMsg, null, 0); if (contexts2 == null) { break; } for (HtmlContext ctx : contexts2) { if (ctx.getParentTag() != null) { // Yep, its vulnerable if (ctx.getMsg().getResponseHeader().isHtml()) { bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_MEDIUM, null, param, ctx.getTarget(), "", ctx.getTarget(), contexts2.get(0).getMsg()); } else { HttpMessage ctx2Message = contexts2.get(0).getMsg(); if (StringUtils.containsIgnoreCase(ctx.getMsg().getResponseHeader() .getHeader(HttpHeader.CONTENT_TYPE), "json")) { bingo(Alert.RISK_LOW, Alert.CONFIDENCE_LOW, Constant.messages .getString(MESSAGE_PREFIX + "json.name"), Constant.messages .getString(MESSAGE_PREFIX + "json.desc"), ctx2Message.getRequestHeader().getURI().toString(), param, GENERIC_SCRIPT_ALERT, Constant.messages.getString( MESSAGE_PREFIX + "otherinfo.nothtml"), getSolution(), "", ctx2Message); } else { bingo(Alert.RISK_HIGH, Alert.CONFIDENCE_LOW, null, param, ctx.getTarget(), Constant.messages.getString( MESSAGE_PREFIX + "otherinfo.nothtml"), ctx.getTarget(), ctx2Message); } } attackWorked = true; break; } } } } } } } } } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:pl.otros.logview.filter.PropertyFilter.java
protected boolean contains(String string, String searchStr, boolean ignoreCase) { if (ignoreCase) { return StringUtils.containsIgnoreCase(string, searchStr); } else {//w w w .j ava2 s . c o m return StringUtils.contains(string, searchStr); } }
From source file:pl.otros.logview.gui.message.SearchResultColorizer.java
@Override public boolean colorizingNeeded(String message) { if (StringUtils.isBlank(searchString)) { return false; }// w ww . ja v a 2 s .c o m if (searchMode.equals(SearchMode.STRING_CONTAINS)) { return StringUtils.containsIgnoreCase(message, searchString); } else if (searchMode.equals(SearchMode.REGEX)) { try { Pattern p = Pattern.compile(searchString, Pattern.CASE_INSENSITIVE); return (p.matcher(message).find()); } catch (Exception e) { return false; } } //TODO QUERY MODE? return false; }
From source file:pl.otros.vfs.browser.table.VfsTableModelFileNameRowFilter.java
boolean checkIfInclude(String baseName, String patternText) { Pattern pattern = null;//from w w w. jav a 2 s . co m try { String patternString = preparePatternString(patternText); pattern = Pattern.compile(patternString); } catch (PatternSyntaxException pse) { LOGGER.error(pse.getMessage()); //if pattern can't be compiled we will use String contains test } LOGGER.debug(String.format("pattern=(%s)", pattern)); return StringUtils.containsIgnoreCase(baseName, patternText) || (pattern == null) ? true : pattern.matcher(baseName).matches(); }
From source file:pt.webdetails.cda.utils.DataTableFilter.java
public boolean rowContainsSearchTerms(TableModel table, int rowIndex) { String[] columnValues = getRelevantColumns(table, rowIndex); for (String searchTerm : searchTerms) { boolean containsTerm = false; for (String value : columnValues) { if (StringUtils.containsIgnoreCase(value, searchTerm)) { containsTerm = true;//from w ww . j a v a 2s. co m continue; } } if (!containsTerm) return false; } return true; }
From source file:radiotimesdataservice.RadioTimesDataService.java
public Channel[] checkForAvailableChannels(ChannelGroup group, ProgressMonitor monitor) throws TvBrowserException { try {// w w w .j a va2s.com ArrayList<Channel> channels = new ArrayList<Channel>(); monitor.setMessage(mLocalizer.msg("loadingChannels", "Loading Radio Times Channel List")); // Do the parsing... BufferedReader reader = new BufferedReader( new InputStreamReader(IOUtilities.getStream(new URL(BASEURL + "channels.dat")))); String line; while ((line = reader.readLine()) != null) { String[] channel = line.split("\\|"); // format of a line in this file: // 92|BBC1 if (channel.length == 2) { String channelId = channel[0].trim(); String channelName = channel[1].trim(); int categories = Channel.CATEGORY_NONE; if (StringUtils.containsIgnoreCase(channelName, "TV") || StringUtils.containsIgnoreCase(channelName, "HD")) { categories = Channel.CATEGORY_TV; } Channel ch = new Channel(this, channelName, RADIOTIMES + channelId, TimeZone.getTimeZone("GMT+0:00"), "gb", "(c) Radio Times", "http://www.radiotimes.co.uk", mRadioTimesChannelGroup, null, categories); channels.add(ch); mLog.fine("Channel : " + ch.getName() + "{" + ch.getId() + "}"); } } reader.close(); mChannels = channels; monitor.setMessage(mLocalizer.msg("done", "Done with Radio Times data")); return channels.toArray(new Channel[channels.size()]); } catch (Exception e) { throw new TvBrowserException(getClass(), "error.1", "Downloading Channellist failed", e); } }
From source file:raptor.chess.pgn.LenientPgnParserListener.java
public Game createGameFromDescription() { String fen = null;/*from ww w. ja v a2 s. co m*/ Variant variant = null; Game result = null; if (currentHeaders.get(PgnHeader.FEN.name()) != null) { fen = currentHeaders.get(PgnHeader.FEN.name()); } // Check for the Variant header. if (currentHeaders.get(PgnHeader.Variant.name()) != null) { try { variant = Variant.valueOf(currentHeaders.get(PgnHeader.Variant.name())); } catch (IllegalArgumentException iae) { } } // Couldn't find it now check for keywords in event. if (variant == null && currentHeaders.get(PgnHeader.Event.name()) != null) { if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "crazyhouse")) { variant = Variant.crazyhouse; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "standard")) { variant = Variant.standard; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "blitz")) { variant = Variant.blitz; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "lightning")) { variant = Variant.lightning; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "bullet")) { variant = Variant.lightning; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "atomic")) { variant = Variant.atomic; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "suicide")) { variant = Variant.suicide; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "losers")) { variant = Variant.losers; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "wild/fr")) { variant = Variant.fischerRandom; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "bughouse")) { variant = Variant.bughouse; } else if (StringUtils.containsIgnoreCase(currentHeaders.get(PgnHeader.Event.name()), "wild")) { variant = Variant.wild; } } // No variant detected, set it to classic. if (variant == null) { variant = Variant.classic; } if (fen != null) { result = GameFactory.createFromFen(fen, variant); result.setHeader(PgnHeader.FEN, fen); } else { result = GameFactory.createStartingPosition(variant); } if (variant != Variant.classic) { result.setHeader(PgnHeader.Variant, variant.toString()); } return result; }