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

The following examples show how to use org.apache.commons.lang3.StringUtils#equalsAnyIgnoreCase() . These examples are extracted from open source projects. 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
@Override
public String route(final WxOpenXmlMessage wxMessage) throws WxErrorException {
  if (wxMessage == null) {
    throw new NullPointerException("message is empty");
  }
  if (StringUtils.equalsIgnoreCase(wxMessage.getInfoType(), "component_verify_ticket")) {
    getWxOpenConfigStorage().setComponentVerifyTicket(wxMessage.getComponentVerifyTicket());
    return "success";
  }
  //新增、跟新授权
  if (StringUtils.equalsAnyIgnoreCase(wxMessage.getInfoType(), "authorized", "updateauthorized")) {
    WxOpenQueryAuthResult queryAuth = wxOpenService.getWxOpenComponentService().getQueryAuth(wxMessage.getAuthorizationCode());
    if (queryAuth == null || queryAuth.getAuthorizationInfo() == null || queryAuth.getAuthorizationInfo().getAuthorizerAppid() == null) {
      throw new NullPointerException("getQueryAuth");
    }
    return "success";
  }
  return "";
}
 
Example 2
Source Project: super-cloudops   File: FlowManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * when pipeline finish, del the pipeline from runModel
 */
public void pipelineComplete(PipelineModel pipelineModel) {
	RunModel runModel = getRunModel(pipelineModel.getRunId());
	if (isNull(runModel)) {
		return;
	}
	List<Pipeline> pipelines = runModel.getPipelines();
	if (CollectionUtils.isEmpty(pipelines)) {
		return;
	}

	boolean isAllComplete = true;
	for (Pipeline p : pipelines) {
		if (!StringUtils.equalsAnyIgnoreCase(p.getStatus(), SUCCESS.toString(), FAILED.toString())) {
			isAllComplete = false;
			break;
		}
	}
	if (isAllComplete) {
		flowComplete(runModel);
	}
}
 
Example 3
Source Project: oauth-boot   File: SmsCodeCheckFilter.java    License: MIT License 6 votes vote down vote up
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {

    if(this.pathMatcher.match("/authentication/mobile",request.getRequestURI())
            && StringUtils.equalsAnyIgnoreCase(request.getMethod(),"post")){
        try {
            check(request,response,filterChain);
        }catch (Exception ex){
            if (ex instanceof VerificationCodeFailureException){
                failureHandler.onAuthenticationFailure(request,response, (AuthenticationException) ex);
            }
            throw ex;
        }

    }else {
        filterChain.doFilter(request,response);
    }
}
 
Example 4
Source Project: seed   File: ValidatorUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 验证对象中的属性的值是否符合注解定义
 * -------------------------------------------------------------------------------
 * 注意:被验证对象若为空对象,由于没什么可验证的,故直接返回验证通过
 * -------------------------------------------------------------------------------
 * @param obj             需要验证的对象,若其父类的属性也有验证注解则会一并验证
 * @param exceptFieldName 不需要验证的属性
 * @return 返回空Map<String, String>(not null)表示验证通过,否则会将各错误字段作为key放入Map,value为错误信息
 */
public static Map<String, String> validateToMap(Object obj, String... exceptFieldName){
    Map<String, String> resultMap = new HashMap<>();
    if(null == obj){
        return resultMap;
    }
    Set<ConstraintViolation<Object>> validateSet = validator.validate(obj);
    for(ConstraintViolation<Object> constraintViolation : validateSet){
        String field = constraintViolation.getPropertyPath().toString();
        String message = constraintViolation.getMessage();
        if(!StringUtils.equalsAnyIgnoreCase(field, exceptFieldName)){
            resultMap.put(field, message);
        }
    }
    return resultMap;
}
 
Example 5
@Override
public void save(BaseDataSource baseDataSource) {

	if (baseDataSource instanceof MysqlDataSource) {
		MysqlDataSource mysqlDataSource = (MysqlDataSource) baseDataSource;
		if (StringUtils.equalsAnyIgnoreCase(mysqlDataSource.getPassword(), "******")
				|| StringUtils.isBlank(mysqlDataSource.getPassword())) {
			mysqlDataSource.setPassword(null);
		}
	}
	CustomDataSource customDataSource = model2Properties(baseDataSource);
	if (customDataSource.getId() != null) {
		customDataSourcePropertiesDao.deleteByDataSourceId(customDataSource.getId());
		customDataSourcePropertiesDao.insertBatch(customDataSource.getCustomDataSourceProperties());
		customDataSource.preUpdate();
		customDatasourceDao.updateByPrimaryKeySelective(customDataSource);
	} else {
		customDataSource.preInsert();
		customDataSource.setStatus(1);
		List<CustomDataSourceProperties> customDataSourceProperties = customDataSource.getCustomDataSourceProperties();
		for (CustomDataSourceProperties properties : customDataSourceProperties) {
			properties.setDataSourceId(customDataSource.getId());
		}
		customDatasourceDao.insertSelective(customDataSource);
		customDataSourcePropertiesDao.insertBatch(customDataSource.getCustomDataSourceProperties());
	}
}
 
Example 6
Source Project: Prism   File: Prism.java    License: MIT License 5 votes vote down vote up
@Listener
public void onStartedServer(GameStartedServerEvent event) {
    String engine = getConfig().getStorageCategory().getEngine();
    try {
        if (StringUtils.equalsIgnoreCase(engine, "h2")) {
            storageAdapter = new H2StorageAdapter();
        } else if (StringUtils.equalsAnyIgnoreCase(engine, "mongo", "mongodb")) {
            storageAdapter = new MongoStorageAdapter();
        } else if (StringUtils.equalsIgnoreCase(engine, "mysql")) {
            storageAdapter = new MySQLStorageAdapter();
        } else {
            throw new Exception("Invalid storage engine configured.");
        }

        Preconditions.checkState(getStorageAdapter().connect());

        // Initialize the recording queue manager
        Task.builder()
                .async()
                .name("PrismRecordingQueueManager")
                .interval(1, TimeUnit.SECONDS)
                .execute(recordingQueueManager)
                .submit(getPluginContainer());
        getLogger().info("Prism started successfully. Bad guys beware.");
    } catch (Exception ex) {
        Sponge.getEventManager().unregisterPluginListeners(getPluginContainer());
        getLogger().error("Encountered an error processing {}::onStartedServer", "Prism", ex);
    }
}
 
Example 7
Source Project: prebid-server-java   File: Ccpa.java    License: Apache License 2.0 5 votes vote down vote up
private static void agreementSpecified(char agreement, String agreementType) {
    final boolean isAppropriateValue = StringUtils.equalsAnyIgnoreCase(Character.toString(agreement),
            NOT_ENFORCED_SIGNAL, ENFORCED_SIGNAL, NOT_DEFINED_SIGNAL);

    if (!isAppropriateValue) {
        throw new PreBidException(
                String.format("us_privacy must specify 'N' or 'n', 'Y' or 'y', '-' for the %s", agreementType));
    }
}
 
Example 8
Source Project: seed   File: CodecUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Hmac签名
 * 方法内部首先会过滤Map<String,String>参数中的部分键值对
 * 过滤规则为移除键名为cert、hmac、sign、signMsg及键值为null或键值长度为零的键值对
 * 过滤后会产生一个字符串,其格式为按照键名升序排序的key11=value11&key22=value22&key=signKey
 * 最后调用 {@link #buildHmacSign(String, String, String)} 签名,返回签名后的小写的十六进制字符串
 * @param param     待签名的Map<String,String>
 * @param key       签名用到的密钥字符串
 * @param algorithm 可传:HmacMD5、HmacSHA1、HmacSHA256、HmacSHA512
 * @return String algorithm digest as a lowerCase hex string
 */
public static String buildHmacSign(Map<String, String> param, String key, String algorithm){
    StringBuilder sb = new StringBuilder();
    List<String> keys = new ArrayList<>(param.keySet());
    Collections.sort(keys);
    for(String obj : keys){
        String value = param.get(obj);
        if(StringUtils.equalsAnyIgnoreCase(obj, "cert", "hmac", "sign", "signMsg") || StringUtils.isEmpty(value)){
            continue;
        }
        sb.append(obj).append("=").append(value).append("&");
    }
    sb.append("key=").append(key);
    return buildHmacSign(sb.toString(), key, algorithm);
}
 
Example 9
Source Project: seed   File: CodecUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 根据指定的签名密钥和算法签名Map<String,String>
 * 方法内部首先会过滤Map<String,String>参数中的部分键值对
 * 过滤规则为移除键名为cert、hmac、sign、signMsg及键值为null或键值长度为零的键值对
 * 过滤后会产生一个字符串,其格式为按照键名升序排序的key11=value11|key22=value22|key=signKey
 * 最后调用 {@link #buildHexSign(String, String, String)} 签名,返回签名后的小写的十六进制字符串
 * @param param     待签名的Map<String,String>
 * @param charset   签名时转码用到的字符集
 * @param algorithm 可传:MD5、SHA、SHA1、SHA-1、SHA-256、SHA-384、SHA-512
 * @param signKey   签名用到的密钥
 * @return String algorithm digest as a lowerCase hex string
 */
public static String buildHexSign(Map<String, String> param, String charset, String algorithm, String signKey){
    StringBuilder sb = new StringBuilder();
    List<String> keys = new ArrayList<>(param.keySet());
    Collections.sort(keys);
    for (String key : keys) {
        String value = param.get(key);
        if(StringUtils.equalsAnyIgnoreCase(key, "cert", "hmac", "sign", "signMsg") || StringUtils.isEmpty(value)){
            continue;
        }
        sb.append(key).append("=").append(value).append("|");
    }
    sb.append("key=").append(signKey);
    return buildHexSign(sb.toString(), charset, algorithm);
}
 
Example 10
Source Project: salesforce-jdbc   File: ForceOAuthClient.java    License: MIT License 5 votes vote down vote up
private boolean isBadTokenError(HttpResponseException e) {
    return ((e.getStatusCode() == HttpStatusCodes.STATUS_CODE_FORBIDDEN)
            && StringUtils.equalsAnyIgnoreCase(e.getContent(),
            BAD_TOKEN_SF_ERROR_CODE, MISSING_TOKEN_SF_ERROR_CODE, WRONG_ORG_SF_ERROR_CODE))
            ||
            (e.getStatusCode() == HttpStatusCodes.STATUS_CODE_NOT_FOUND &&
                    StringUtils.equalsIgnoreCase(e.getContent(), BAD_ID_SF_ERROR_CODE));
}
 
Example 11
Source Project: para   File: JWTRestfulAuthFilter.java    License: Apache License 2.0 5 votes vote down vote up
private UserAuthentication getOrCreateUser(App app, String identityProvider, String accessToken)
		throws IOException {
	if ("facebook".equalsIgnoreCase(identityProvider)) {
		return facebookAuth.getOrCreateUser(app, accessToken);
	} else if ("google".equalsIgnoreCase(identityProvider)) {
		return googleAuth.getOrCreateUser(app, accessToken);
	} else if ("github".equalsIgnoreCase(identityProvider)) {
		return githubAuth.getOrCreateUser(app, accessToken);
	} else if ("linkedin".equalsIgnoreCase(identityProvider)) {
		return linkedinAuth.getOrCreateUser(app, accessToken);
	} else if ("twitter".equalsIgnoreCase(identityProvider)) {
		return twitterAuth.getOrCreateUser(app, accessToken);
	} else if ("microsoft".equalsIgnoreCase(identityProvider)) {
		return microsoftAuth.getOrCreateUser(app, accessToken);
	} else if ("slack".equalsIgnoreCase(identityProvider)) {
		return slackAuth.getOrCreateUser(app, accessToken);
	} else if ("amazon".equalsIgnoreCase(identityProvider)) {
		return amazonAuth.getOrCreateUser(app, accessToken);
	} else if ("oauth2".equalsIgnoreCase(identityProvider)) {
		return oauth2Auth.getOrCreateUser(app, accessToken);
	} else if ("oauth2second".equalsIgnoreCase(identityProvider)) {
		return oauth2Auth.getOrCreateUser(app, accessToken, "second");
	} else if ("oauth2third".equalsIgnoreCase(identityProvider)) {
		return oauth2Auth.getOrCreateUser(app, accessToken, "third");
	} else if ("ldap".equalsIgnoreCase(identityProvider)) {
		return ldapAuth.getOrCreateUser(app, accessToken);
	} else if ("passwordless".equalsIgnoreCase(identityProvider)) {
		return passwordlessAuth.getOrCreateUser(app, accessToken);
	} else if (StringUtils.equalsAnyIgnoreCase(identityProvider, "password", "generic")) {
		return passwordAuth.getOrCreateUser(app, accessToken);
	}
	return null;
}
 
Example 12
Source Project: scoold   File: HttpUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Fetches an avatar at a given URL.
 * @param url image URL
 * @param res response
 * @return the content of the image or null
 */
public static void getAvatar(String url, HttpServletResponse res) {
	if (StringUtils.isBlank(url)) {
		getDefaultAvatarImage(res);
		return;
	}
	HttpGet get = new HttpGet(url);
	get.setHeader(HttpHeaders.USER_AGENT, "Scoold Image Validator, https://scoold.com");
	try (CloseableHttpResponse img = HttpUtils.getHttpClient().execute(get)) {
		if (img.getStatusLine().getStatusCode() == HttpStatus.SC_OK && img.getEntity() != null) {
			String contentType = img.getEntity().getContentType().getValue();
			if (StringUtils.equalsAnyIgnoreCase(contentType, "image/gif", "image/jpeg", "image/jpg", "image/png",
					"image/webp", "image/bmp", "image/svg+xml")) {
				for (Header header : img.getAllHeaders()) {
					res.setHeader(header.getName(), header.getValue());
				}
				if (!res.containsHeader(org.apache.http.HttpHeaders.CACHE_CONTROL)) {
					res.setHeader(org.apache.http.HttpHeaders.CACHE_CONTROL, "max-age=" + TimeUnit.HOURS.toSeconds(24));
				}
				IOUtils.copy(img.getEntity().getContent(), res.getOutputStream());
			}
		} else {
			LoggerFactory.getLogger(HttpUtils.class).debug("Failed to get user avatar from {}, status: {} {}", url,
					img.getStatusLine().getStatusCode(), img.getStatusLine().getReasonPhrase());
			getDefaultAvatarImage(res);
		}
	} catch (IOException ex) {
		getDefaultAvatarImage(res);
		LoggerFactory.getLogger(HttpUtils.class).debug("Failed to get user avatar from {}: {}", url, ex.getMessage());
	}
}
 
Example 13
/**
 * 进行插件安装
 */
public void doUploadAndUpgrade() {
    if (!isMultipartRequest()) {
        renderError(404);
        return;
    }

    UploadFile ufile = getFile();
    if (ufile == null) {
        renderFail(null);
        return;
    }

    String oldAddonId = getPara("id");
    AddonInfo oldAddon = AddonManager.me().getAddonInfo(oldAddonId);
    if (oldAddon == null) {
        renderFail("无法读取旧的插件信息,可能已经被卸载。", ufile);
        return;
    }

    if (!StringUtils.equalsAnyIgnoreCase(FileUtil.getSuffix(ufile.getFileName()), ".zip", ".jar")) {
        renderFail("只支持 .zip 或 .jar 的插件文件", ufile);
        return;
    }

    try {
        Ret ret = AddonManager.me().upgrade(ufile.getFile(), oldAddonId);
        render(ret);
        return;
    } catch (Exception ex) {
        LOG.error(ex.toString(), ex);
        renderFail("插件升级失败,请联系管理员", ufile);
        return;
    } finally {
        deleteFileQuietly(ufile.getFile());
    }
}
 
Example 14
@Override
public void htlExpression(Expression expression, Node node) {
    if (expression.containsOption(Syntax.CONTEXT_OPTION)) {
        String context = expression.getOptions().get(Syntax.CONTEXT_OPTION).accept(new HtlStringOptionVisitor());
        if (StringUtils.equalsAnyIgnoreCase(context, MarkupContext.UNSAFE.getName())) {
            createViolation(node.getStartLinePosition(), RULE_MESSAGE);
        }
    }

}
 
Example 15
/**
 * 网页内容解析 ss 信息
 */
@Override
protected Set<ShadowSocksDetailsEntity> parse(Document document) {
	Elements tableList = document.select("div.elementor-tabs-content-wrapper table");

	Set<ShadowSocksDetailsEntity> set = new HashSet<>();
	for (int i = 0; i < tableList.size(); i++) {
		try {
			Element table = tableList.get(i);
			// 取 h4 信息,为 ss 信息
			Elements ssHtml = table.select("tr");

			if (StringUtils.equalsAnyIgnoreCase("shadowsocksR", table.select("tr td").first().text())) {
				String server = ssHtml.get(1).select("td").get(1).text();
				int server_port = 5240;
				String password = ssHtml.get(3).select("td").get(1).text();
				String method = ssHtml.get(4).select("td").get(1).text();

				String obfs = ssHtml.get(5).select("td").get(1).text();
				String protocol = ssHtml.get(6).select("td").get(1).text();
				// log.debug("---------------->{}={}={}={}={}={}", server, server_port, password, method, obfs, protocol);

				ShadowSocksDetailsEntity ss = new ShadowSocksDetailsEntity(server, server_port, password, method, protocol, obfs);
				ss.setValid(false);
				ss.setValidTime(new Date());
				ss.setTitle(document.title());
				ss.setRemarks(TARGET_URL);
				ss.setGroup("ShadowSocks-Share");

				// 测试网络
				if (isReachable(ss))
					ss.setValid(true);

				// 无论是否可用都入库
				set.add(ss);

				log.debug("*************** 第 {} 条 ***************{}{}", set.size(), System.lineSeparator(), ss);
			}

		} catch (Exception e) {
			log.error(e.getMessage(), e);
		}
	}
	return set;
}
 
Example 16
private void applyLines(Data dataIn, XWPFDocument doc) throws XmlException, IOException {
    // small hack to not having to rework the commandline parsing just now
    String includeIndicator = System.getProperty("org.dstadler.poi.mailmerge.includeindicator");

    CTBody body = doc.getDocument().getBody();

    // read the current full Body text
    String srcString = body.xmlText();

    // apply the replacements line-by-line
    boolean first = true;
    List<String> headers = dataIn.getHeaders();
    for(List<String> data : dataIn.getData()) {
        log.info("Applying to template: " + data);

        // if the option is set ignore lines which do not have the indicator set
        if(includeIndicator != null) {
            int indicatorPos = headers.indexOf(includeIndicator);
            Preconditions.checkState(indicatorPos >= 0,
                    "An include-indicator is set via system properties as %s, but there is no such column, had: %s",
                    includeIndicator, headers);

            if(!StringUtils.equalsAnyIgnoreCase(data.get(indicatorPos), "1", "true")) {
                log.info("Skipping line " + data + " because include-indicator was not set");
                continue;
            }
        }

        String replaced = srcString;
        for(int fieldNr = 0;fieldNr < headers.size();fieldNr++) {
            String header = headers.get(fieldNr);
            String value = data.get(fieldNr);

            // ignore columns without headers as we cannot match them
            if(header == null) {
                continue;
            }

            // use empty string for data-cells that have no value
            if(value == null) {
                value = "";
            }

            replaced = replaced.replace("${" + header + "}", value);
        }

        // check for missed replacements or formatting which interferes
        if(replaced.contains("${")) {
            log.warning("Still found template-marker after doing replacement: " +
                    StringUtils.abbreviate(StringUtils.substring(replaced, replaced.indexOf("${")), 200));
        }

        appendBody(body, replaced, first);

        first = false;
    }
}
 
Example 17
Source Project: scoold   File: ScooldUtils.java    License: Apache License 2.0 4 votes vote down vote up
public boolean isLanguageRTL(String langCode) {
	return StringUtils.equalsAnyIgnoreCase(langCode, "ar", "he", "dv", "iw", "fa", "ps", "sd", "ug", "ur", "yi");
}
 
Example 18
Source Project: bobcat   File: CapabilitiesProvider.java    License: Apache License 2.0 4 votes vote down vote up
private Object prepareType(String property) {
  return StringUtils.equalsAnyIgnoreCase(property, BOOLEAN_STRINGS) ? Boolean.valueOf(property)
      : property;
}
 
Example 19
/**
 * 进行插件安装
 */
public void doUploadAndInstall() {
    if (!isMultipartRequest()) {
        renderError(404);
        return;
    }

    UploadFile ufile = getFile();
    if (ufile == null) {
        renderJson(Ret.fail().set("success", false));
        return;
    }

    if (!StringUtils.equalsAnyIgnoreCase(FileUtil.getSuffix(ufile.getFileName()), ".zip", ".jar")) {
        renderFail("只支持 .zip 或 .jar 的插件文件",ufile);
        return;
    }

    AddonInfo addon = AddonUtil.readSimpleAddonInfo(ufile.getFile());
    if (addon == null || StrUtil.isBlank(addon.getId())) {
        renderFail("无法读取插件配置信息。",ufile);
        return;
    }

    File newAddonFile = addon.buildJarFile();

    //当插件文件存在的时候,有两种可能
    // 1、该插件确实存在,此时不能再次安装
    // 2、该插件可能没有被卸载干净,此时需要尝试清除之前已经被卸载的插件
    if (newAddonFile.exists()) {

        //说明该插件已经被安装了
        if (AddonManager.me().getAddonInfo(addon.getId()) != null) {
            renderFail("该插件已经存在。",ufile);
            return;
        }
        //该插件之前已经被卸载了
        else {

            //尝试再次去清除jar包,若还是无法删除,则无法安装
            if (!AddonUtil.forceDelete(newAddonFile)) {
                renderFail("该插件已经存在。",ufile);
                return;
            }
        }
    }

    if (!newAddonFile.getParentFile().exists()) {
        newAddonFile.getParentFile().mkdirs();
    }

    try {
        FileUtils.moveFile(ufile.getFile(), newAddonFile);
        if (!AddonManager.me().install(newAddonFile)) {
            renderFail("该插件安装失败,请联系管理员。",ufile);
            return;
        }
        if (!AddonManager.me().start(addon.getId())) {
            renderFail("该插件安装失败,请联系管理员。",ufile);
            return;
        }
    } catch (Exception e) {
        LOG.error("addon install error : ", e);
        renderFail("该插件安装失败,请联系管理员。",ufile);
        deleteFileQuietly(newAddonFile);
        return;
    }

    renderJson(Ret.ok().set("success", true));
}
 
Example 20
Source Project: EasyReport   File: AppEnvConsts.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 应用部署环境名是否为生产环境
 *
 * @return true|false
 */
public static boolean isProductionMode() {
    return StringUtils.equalsAnyIgnoreCase(ENV_NAME, "prod");
}