Java Code Examples for org.apache.commons.lang3.StringUtils#containsAny()

The following examples show how to use org.apache.commons.lang3.StringUtils#containsAny() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Terminal.java    From cyberduck with GNU General Public License v3.0 6 votes vote down vote up
protected Exit delete(final SessionPool session, final Path remote) {
    final List<Path> files = new ArrayList<Path>();
    for(TransferItem i : new DeletePathFinder().find(input, TerminalAction.delete, remote)) {
        files.add(i.remote);
    }
    final DeleteWorker worker;
    if(StringUtils.containsAny(remote.getName(), '*')) {
        worker = new DeleteWorker(new TerminalLoginCallback(reader), files, cache, new DownloadGlobFilter(remote.getName()), progress);
    }
    else {
        worker = new DeleteWorker(new TerminalLoginCallback(reader), files, cache, progress);
    }
    final SessionBackgroundAction<List<Path>> action = new TerminalBackgroundAction<List<Path>>(controller, session, worker);
    try {
        this.execute(action);
    }
    catch(TerminalBackgroundException e) {
        return Exit.failure;
    }
    return Exit.success;
}
 
Example 2
Source File: DownloadTransferItemFinder.java    From cyberduck with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) {
    final Local local = LocalFactory.get(input.getOptionValues(action.name())[1]);
    if(StringUtils.containsAny(remote.getName(), '*')) {
        // Treat asterisk as wildcard
        return Collections.singleton(new TransferItem(remote.getParent(), local));
    }
    if(remote.isDirectory()) {
        // Remote path resolves to directory
        if(local.exists()) {
            return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName())));
        }
        return Collections.singleton(new TransferItem(remote, local));
    }
    // Remote path resolves to file
    if(local.isDirectory()) {
        // Append remote filename to local target
        return Collections.singleton(new TransferItem(remote, LocalFactory.get(local, remote.getName())));
    }
    // Keep from input
    return Collections.singleton(new TransferItem(remote, local));
}
 
Example 3
Source File: DOMTokenList.java    From htmlunit with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if the specified token is contained in the underlying string.
 * @param token the token to add
 * @return true if the underlying string contains token, otherwise false
 */
@JsxFunction
public boolean contains(final String token) {
    if (getBrowserVersion().hasFeature(JS_DOMTOKENLIST_CONTAINS_RETURNS_FALSE_FOR_BLANK)
            && StringUtils.isBlank(token)) {
        return false;
    }

    if (StringUtils.isEmpty(token)) {
        throw Context.reportRuntimeError("Empty imput not allowed");
    }
    if (StringUtils.containsAny(token, whitespaceChars())) {
        throw Context.reportRuntimeError("Empty imput not allowed");
    }
    return position(getDefaultValue(null), token) > -1;
}
 
Example 4
Source File: UI.java    From MMDownloader with Apache License 2.0 5 votes vote down vote up
/**
 * 8-6 이미지 압축하기 모드
 *
 * @param in
 * @throws Exception
 */
private void compressImage(final BufferedReader in) throws Exception {
	boolean compress = Configuration.getBoolean("ZIP", false);
	print.info("다운받은 만화들을 압축할 것인지 설정합니다(현재: {})\n", compress);
	print.info("값 입력(true or false): ");

	String input = StringUtils.lowerCase(in.readLine());
	if (StringUtils.containsAny(input, "true", "false")) {
		Configuration.setProperty("ZIP", input);
		Configuration.refresh();
		print.info("변경 완료\n");
	} else {
		ErrorHandling.printError("잘못된 값입니다.", false);
	}
}
 
Example 5
Source File: Struts2Crawler.java    From TrackRay with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean check() {
    String path = target.getPath().toLowerCase();
    if (StringUtils.containsAny(path , ".do",".action",".jsp","shtml") || task.getResult().getSystemInfo().getLanguage() == Language.JAVA)
        return true;
    return false;
}
 
Example 6
Source File: UI.java    From MMDownloader with Apache License 2.0 5 votes vote down vote up
/**
 * 메뉴 8-3 이미지 합치기
 *
 * @param in
 * @throws Exception
 */
private void mergeImage(final BufferedReader in) throws Exception {
	boolean merge = Configuration.getBoolean("MERGE", false);
	print.info("true면 다운받은 만화를 하나의 긴 파일로 합친 파일을 추가로 생성합니다(현재: {})\n", merge);
	print.info("값 입력(true or false): ");

	String input = StringUtils.lowerCase(in.readLine());
	if (StringUtils.containsAny(input, "true", "false")) {
		Configuration.setProperty("MERGE", input);
		Configuration.refresh();
		System.out.println("변경 완료");
	} else {
		ErrorHandling.printError("잘못된 값입니다.", false);
	}
}
 
Example 7
Source File: UI.java    From MMDownloader with Apache License 2.0 5 votes vote down vote up
/**
 * 메뉴 8-4 디버깅 모드
 *
 * @param in
 * @throws Exception
 */
private void debugMode(final BufferedReader in) throws Exception {
	boolean debug = Configuration.getBoolean("DEBUG", false);
	print.info("true면 다운로드 과정에 파일의 용량과 메모리 사용량이 같이 출력됩니다(현재: {})\n", debug);
	print.info("값 입력(true or false): ");

	String input = StringUtils.lowerCase(in.readLine());
	if (StringUtils.containsAny(input, "true", "false")) {
		Configuration.setProperty("DEBUG", input);
		Configuration.refresh();
		print.info("변경 완료\n");
	} else {
		ErrorHandling.printError("잘못된 값입니다.", false);
	}
}
 
Example 8
Source File: WindowsRdp.java    From TrackRay with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Windows XP Service Pack 3
 Windows XP Professional x64 Edition Service Pack 2
 Windows Server 2003 Service Pack 2
 Windows Server 2003 x64 Edition Service Pack 2
 Windows Server 2003 SP2(用于基于 Itanium 的系统)
 Windows Vista Service Pack 2
 Windows Vista x64 Edition Service Pack 2
 Windows Server 2008(用于 32 位系统)Service Pack 2*
 Windows Server 2008(用于基于 x64 的系统)Service Pack 2*
 Windows Server 2008(用于基于 Itanium 的系统)Service Pack 2
 Windows 7(用于 32 位系统)和 Windows 7(用于 32 位系统)Service Pack 1
 Windows 7(用于基于 x64 的系统)和 Windows 7(用于基于 x64 的系统)Service Pack 1
 Windows Server 2008 R2(用于基于 x64 的系统)和 Windows Server 2008 R2(用于基于 x64 的系统)Service Pack 1*
 Windows Server 2008 R2(用于基于 Itanium 的系统)和 Windows Server 2008 R2(用于基于 Itanium 的系统)Service Pack 1
 */
private void rdpDOSms12020() {
    String realIP = getTask().getResult().getHostInfo().getRealIP();
    SystemEntity systemOS = getTask().getResult().getSystemInfo().getSystemOS();
    if (systemOS!=null && systemOS.getOs() == SystemOS.WINDOWS){
        String version = systemOS.getVersion();
        if (StringUtils.containsAny(version,
                "Windows XP",
                "Windows Server 2003",
                "Windows Vista",
                "Windows Server 2008",
                "Windows 7"))
        {
            Vulnerable vulnerable = Vulnerable.builder()
                    .level(Vulnerable.Level.MIDDLE.getLevel())
                    .level(Vulnerable.Type.CODE_EXECUTION.getType())
                    .title("该端口可能存在 MS12-020 拒绝服务漏洞")
                    .references(Arrays.asList("https://docs.microsoft.com/zh-cn/security-updates/Securitybulletins/2012/ms12-020"))
                    .address(realIP + ":" + port).build();
            this.addVulnerable(vulnerable);



        }

    }


}
 
Example 9
Source File: WeblogicFuzz.java    From TrackRay with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean check(Result result) {

    if (result.getSystemInfo().getWebServer() == WEBServer.WEBLOGIC)
        return true;

    String url404 = getTarget().concat("/asdasdsad");

    String[] flag = {"Hypertext Transfer Protocol","From RFC 2068","unavailable and has no forwarding address"};

    try {
        HttpURLRequest url = requests.url(url404);
        HttpResponse response = url.get();

        String body = response.body();

        if (StringUtils.containsAny(body , flag)){
            this.getTask().getResult().getAdditional()
                    .put("网站的WEB服务器","Weblogic");
            getTask().getResult().getSystemInfo().setWebServer(WEBServer.WEBLOGIC);
            return true;
        }

    } catch (MalformedURLException e) {
    }
    return false;
}
 
Example 10
Source File: PasswordValidator.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
private boolean validatePasswordHasDigit() {
   String DIGITS = "0123456789";
   if (!StringUtils.containsAny(firstPass.getText().toString(), DIGITS)) {
      setError(firstPassLayout, firstPass, R.string.account_registration_password_contains_no_num_error_msg);
      return false;
   }

   return true;
}
 
Example 11
Source File: ConcurrentTestExceptionHandler.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Some exceptions that happen off the test thread are not serious enough to fail the test.
 * For example, some exceptions happen on the headless test server due more to 
 * environmental issues rather than real problems.  This method is intended to ignore 
 * these less-than-serious issues.
 * 
 * @param throwable the throwable to examine
 * @return true if it should be ignored
 */
private static boolean isKnownTestMachineTimingBug(Throwable t) {

	String message = t.getMessage();
	if (message == null) {
		return false;
	}

	return StringUtils.containsAny(message, IGNORABLE_ERROR_MESSAGES);
}
 
Example 12
Source File: DOMTokenList.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the specified token to the underlying string.
 * @param token the token to add
 */
@JsxFunction
public void add(final String token) {
    if (StringUtils.isEmpty(token)) {
        throw Context.reportRuntimeError("Empty imput not allowed");
    }
    if (StringUtils.containsAny(token, whitespaceChars())) {
        throw Context.reportRuntimeError("Empty imput not allowed");
    }

    String value = getDefaultValue(null);
    boolean changed = false;
    if (position(value, token) < 0) {
        if (value.length() != 0 && !isWhitespache(value.charAt(value.length() - 1))) {
            value = value + " ";
        }
        value = value + token;
        changed = true;
    }
    else if (getBrowserVersion().hasFeature(JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_ADD)) {
        value = String.join(" ", StringUtils.split(value, whitespaceChars()));
        changed = true;
    }

    if (changed) {
        updateAttribute(value);
    }
}
 
Example 13
Source File: BaseAction.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
protected boolean checkNameInvalid(Business business, Unit unit) throws Exception {
	if (StringUtils.containsAny(unit.getName(), new String[] { "\\","/"})) {
		return true;
	}
	return false;

}
 
Example 14
Source File: FullTextSearchDescription.java    From timbuctoo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean test(Object o1, Object o2) {
  if (!(o1 instanceof String)) {
    return false;
  }

  String propertyValue = ((String) o1).toLowerCase();
  String[] matches = Arrays.stream(StringUtils.split((String) o2))
                           .map(String::toLowerCase)
                           .toArray(String[]::new);

  return StringUtils.containsAny(propertyValue, matches);
}
 
Example 15
Source File: DOMTokenList.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Removes the specified token from the underlying string.
 * @param token the token to remove
 */
@JsxFunction
public void remove(final String token) {
    if (StringUtils.isEmpty(token)) {
        throw Context.reportRuntimeError("Empty imput not allowed");
    }
    if (StringUtils.containsAny(token, whitespaceChars())) {
        throw Context.reportRuntimeError("Empty imput not allowed");
    }

    String value = getDefaultValue(null);
    boolean changed = false;
    int pos = position(value, token);
    while (pos != -1) {
        int from = pos;
        int to = pos + token.length();

        while (from > 0 && isWhitespache(value.charAt(from - 1))) {
            from = from - 1;
        }
        while (to < value.length() - 1 && isWhitespache(value.charAt(to))) {
            to = to + 1;
        }

        final StringBuilder result = new StringBuilder();
        if (from > 0) {
            result.append(value, 0, from);
            if (to < value.length()) {
                result.append(" ");
            }
        }
        result.append(value, to, value.length());
        value = result.toString();
        changed = true;

        pos = position(value, token);
    }

    if (getBrowserVersion().hasFeature(JS_DOMTOKENLIST_REMOVE_WHITESPACE_CHARS_ON_REMOVE)) {
        value = String.join(" ", StringUtils.split(value, whitespaceChars()));
        changed = true;
    }

    if (changed) {
        updateAttribute(value);
    }
}
 
Example 16
Source File: CronExpressionDescriptor.java    From quartz-glass with Apache License 2.0 4 votes vote down vote up
/**
 * @param options
 * @param expressionParts
 * @param expression
 * @return
 */
private static String getTimeOfDayDescription(String expression, String[] expressionParts, Options options) {
    String secondsExpression = expressionParts[0];
    String minutesExpression = expressionParts[1];
    String hoursExpression = expressionParts[2];
    StringBuffer description = new StringBuffer();
    // Handle special cases first
    if (!StringUtils.containsAny(minutesExpression, specialCharacters) && !StringUtils.containsAny(hoursExpression, specialCharacters) && !StringUtils.containsAny(secondsExpression, specialCharacters)) {
        description.append("At ").append(DateAndTimeUtils.formatTime(hoursExpression, minutesExpression, secondsExpression)); // Specific time of day (e.g. 10 14)
    } else if (minutesExpression.contains("-") && !StringUtils.containsAny(hoursExpression, specialCharacters)) {
        // Minute range in single hour (e.g. 0-10 11)
        String[] minuteParts = minutesExpression.split("-");
        description.append(MessageFormat.format("Every minute between {0} and {1}", DateAndTimeUtils.formatTime(hoursExpression, minuteParts[0]),
                DateAndTimeUtils.formatTime(hoursExpression, minuteParts[1])));
    } else if (hoursExpression.contains(",") && !StringUtils.containsAny(minutesExpression, specialCharacters)) {
        // Hours list with single minute (e.g. 30 6,14,16)
        String[] hourParts = hoursExpression.split(",");
        description.append("At");
        for (int i = 0; i < hourParts.length; i++) {
            description.append(" ").append(DateAndTimeUtils.formatTime(hourParts[i], minutesExpression));
            if (i < hourParts.length - 2) {
                description.append(",");
            }
            if (i == hourParts.length - 2) {
                description.append(" and");
            }
        }
    } else {
        String secondsDescription = getSecondsDescription(expression, expressionParts, options);
        String minutesDescription = getMinutesDescription(expression, expressionParts, options);
        String hoursDescription = getHoursDescription(expression, expressionParts, options);
        description.append(secondsDescription);
        if (description.length() > 0) {
            description.append(", ");
        }
        description.append(minutesDescription);
        if (description.length() > 0) {
            description.append(", ");
        }
        description.append(hoursDescription);
    }
    return description.toString();
}
 
Example 17
Source File: FuzzDir.java    From TrackRay with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Object start() {
    //TODO:处理的比较简单 后期再完善
    for (String dir : Payload.dirPayload) {
        if (StringUtils.isNotBlank(dir)){
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    String path = dir;
                    Language lang = task!=null?task.getResult().getSystemInfo().getLanguage():null;
                    if (path.contains("%EXT%")) {
                        path = path.replaceAll("%EXT%", lang != null && lang != Language.OTHER ? lang.getSuffix() : "php");
                    }
                    String url = task.getTargetStr().concat(path);
                    try {
                        HttpResponse response = new HttpURLRequest().url(url).get();
                        int code = response.getStatusCode();
                        String body = response.body();
                        if (code != 404) {
                            if (task != null) {
                                if (StringUtils.containsAny(body.toLowerCase(),
                                        "not found","error" ,
                                        "exception" ,"不存在","无法找到",
                                        "safedog","找不到","防火墙"))
                                    return;
                                task.getResult().getSystemInfo().getDirs().put(url, code);
                            }
                        }

                    } catch (MalformedURLException e) {
                        SysLog.error(e.getMessage());
                    }
                    HashSet<String> page403 = new HashSet<>();
                    for (Map.Entry<String, Integer> entry : task.getResult().getSystemInfo().getDirs().entrySet()) {
                        if (entry.getValue()==403)
                            page403.add(entry.getKey());
                    }
                    int dirsize = task.getResult().getSystemInfo().getDirs().size();
                    if (dirsize > 20  && (dirsize/2) <= page403.size()){

                        //如果403页面大于目录数的一半,则清除这些 无用的403页面
                        for (String page : page403) {
                            task.getResult().getSystemInfo().getDirs().remove(page);
                        }

                    }
                }
            };

            task.getExecutor().submit(runnable);
        }
    }
    return null;
}
 
Example 18
Source File: HttpUtil.java    From pepper-metrics with Apache License 2.0 4 votes vote down vote up
public static boolean profilerUrlCheck(String uri) {
	if (StringUtils.containsAny(uri, IGNORE_POST_FIX)) {
		return false;
	}
	return true;
}
 
Example 19
Source File: CommonUtils.java    From torrssen2 with MIT License 4 votes vote down vote up
public static boolean removeDirectory(String path, String outer, List<String> innerList, SettingRepository settingRepository) {
    String[] exts = {};
    Optional<Setting> exceptExtSetting = settingRepository.findByKey("EXCEPT_EXT");
    if(exceptExtSetting.isPresent()) {
        exts = StringUtils.split(StringUtils.lowerCase(exceptExtSetting.get().getValue()), ",");
    }
    
    Optional<Setting> delDirSetting = settingRepository.findByKey("DEL_DIR");

    log.debug("delete List");
    
    if (delDirSetting.isPresent()) {
        log.debug(delDirSetting.get().getValue());
        if(Boolean.parseBoolean(delDirSetting.get().getValue())) {
            boolean ret = true;

            File file = new File(path, outer);
            if (file.isDirectory()) {
                try {
                    for (String inner : innerList) {
                        if(!StringUtils.containsAny(StringUtils.lowerCase(FilenameUtils.getExtension(inner)), exts)) {
                            File src = new File(path + File.separator + outer, inner);
                            File trg = new File(path);
                            File remove = new File(path, inner);
                            if (remove.isFile()) {
                                FileUtils.forceDelete(remove);
                            }
                            FileUtils.moveFileToDirectory(src, trg, true);
                        }
                    }
                    FileUtils.forceDelete(new File(path, outer));
                } catch (IOException e) {
                    log.error(e.getMessage());
                    ret = false;
                }
            } else {
                ret = false;
            }

            return ret;
        }
    }
    return false;
}
 
Example 20
Source File: GradingService.java    From sakai with Educational Community License v2.0 3 votes vote down vote up
/**
 * extractCalculations() is a utility function for Calculated Questions.  It takes
 * one parameter, which is a block of text, and looks for any calculations
 * that are encoded in the text.  A calculations is enclosed in [[ ]].
 * <p>For example, if the passed parameter is <code>{a} + {b} = {{c}}, [[{a}+{b}]]</code>, 
 * the resulting list would contain one entry: a string of "{a}+{b}"
 * <p>Formulas must contain at least one variable OR parens OR calculation symbol (*-+/)
 * @param text contents to be searched
 * @return a list of matching calculations.  If no calculations are found, the 
 * list will be empty.
 */
public List<String> extractCalculations(String text) {
    List<String> calculations = extractCalculatedQuestionKeyFromItemText(text, CALCQ_CALCULATION_PATTERN);
    for (Iterator<String> iterator = calculations.iterator(); iterator.hasNext();) {
      String calc = iterator.next();
      if (!StringUtils.containsAny(calc, "{}()+-*/")) {
          iterator.remove();
      }
    }
    return calculations;
}