当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.remove方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils.remove方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.remove方法的具体用法?Java StringUtils.remove怎么用?Java StringUtils.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildMetadataGeneratorParameters

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Build metadata generator parameters by passing the encryption,
 * signing and back-channel certs to the parameter generator.
 *
 * @throws Exception Thrown if cert files are missing, or metadata file inaccessible.
 */
protected void buildMetadataGeneratorParameters() throws Exception {
    final SamlIdPProperties idp = casProperties.getAuthn().getSamlIdp();
    final Resource template = this.resourceLoader.getResource("classpath:/template-idp-metadata.xml");

    String signingKey = FileUtils.readFileToString(idp.getMetadata().getSigningCertFile().getFile(), StandardCharsets.UTF_8);
    signingKey = StringUtils.remove(signingKey, BEGIN_CERTIFICATE);
    signingKey = StringUtils.remove(signingKey, END_CERTIFICATE).trim();

    String encryptionKey = FileUtils.readFileToString(idp.getMetadata().getEncryptionCertFile().getFile(), StandardCharsets.UTF_8);
    encryptionKey = StringUtils.remove(encryptionKey, BEGIN_CERTIFICATE);
    encryptionKey = StringUtils.remove(encryptionKey, END_CERTIFICATE).trim();

    try (StringWriter writer = new StringWriter()) {
        IOUtils.copy(template.getInputStream(), writer, StandardCharsets.UTF_8);
        final String metadata = writer.toString()
                .replace("${entityId}", idp.getEntityId())
                .replace("${scope}", idp.getScope())
                .replace("${idpEndpointUrl}", getIdPEndpointUrl())
                .replace("${encryptionKey}", encryptionKey)
                .replace("${signingKey}", signingKey);
        FileUtils.write(idp.getMetadata().getMetadataFile(), metadata, StandardCharsets.UTF_8);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:30,代码来源:TemplatedMetadataAndCertificatesGenerationService.java

示例2: getMatcherResult

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 得到匹配结果分组。
 * @param
 * @param str     字符串
 * @param strict  使用严格方式,即只有字符完全匹配上正则表达式时才返回结果
 * @return        如果没有匹配上,返回一个null。
 */
public static String[] getMatcherResult(String str,String regexp,boolean strict){
    if(!strict){
        String tmp=StringUtils.remove(str, "\\(");
        tmp=StringUtils.remove(str, "\\)");
        if(tmp.indexOf('(')>-1 && tmp.indexOf(')')>-1){
            //用户给出的正则中已经有了分组信息
        }else{
            regexp="("+regexp+")";//补充一个默认分组
        }
    }
    Matcher m=getMatcher(str,regexp,strict);
    if(!m.matches())return null;
    int n=m.groupCount();
    if(n==0)return new String[]{m.group()};
    String[] result=new String[n];
    for(int i=1;i<=n;i++){
        result[i-1]=m.group(i);
    }
    return result;
}
 
开发者ID:liaojiacan,项目名称:zkAdmin,代码行数:28,代码来源:RegexpUtils.java

示例3: rmXSSDangerousCharacters

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String rmXSSDangerousCharacters(String[] xss, String script) {// 移除存在XSS攻击威胁的字符串

			if (null == xss || xss.length == 0) {
				return script;
			}

			for (String remove : xss) {

				if (StringUtils.isBlank(remove)) {
					continue;
				}

				String regex = remove + ".*" + remove;

				Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
				Matcher m = p.matcher(script);

				while (m.find()) {
					String st = m.group();
					script = StringUtils.remove(script, st);
					log.warn(st + "已移除");
				}
			}

			return script;
		}
 
开发者ID:Fetax,项目名称:Fetax-AI,代码行数:27,代码来源:XSSFilter.java

示例4: makeFile

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Creates a JSON file for a registered service.
 * The file is named as {@code [SERVICE-NAME]-[SERVICE-ID]-.{@value #FILE_EXTENSION}}
 *
 * @param service Registered service.
 * @return JSON file in service registry directory.
 * @throws IllegalArgumentException if file name is invalid
 */
protected File makeFile(final RegisteredService service) {
    final String fileName = StringUtils.remove(service.getName() + '-' + service.getId() + '.' + FILE_EXTENSION, " ");
    try {
        final File svcFile = new File(serviceRegistryDirectory.toFile(), fileName);
        LOGGER.debug("Using [{}] as the service definition file", svcFile.getCanonicalPath());
        return svcFile;
    } catch (final IOException e) {
        LOGGER.warn("Service file name {} is invalid; Examine for illegal characters in the name.", fileName);
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:JsonServiceRegistryDao.java

示例5: makeFile

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Creates a JSON file for a registered service.
 * The file is named as <code>[SERVICE-NAME]-[SERVICE-ID]-.{@value #FILE_EXTENSION}</code>
 *
 * @param service Registered service.
 * @return JSON file in service registry directory.
 * @throws IllegalArgumentException if file name is invalid
 */
protected File makeFile(final RegisteredService service) {
    final String fileName = StringUtils.remove(service.getName() + '-' + service.getId() + '.' + FILE_EXTENSION, " ");
    try {
        final File svcFile = new File(serviceRegistryDirectory.toFile(), fileName);
        LOGGER.debug("Using [{}] as the service definition file", svcFile.getCanonicalPath());
        return svcFile;
    } catch (final IOException e) {
        LOGGER.warn("Service file name {} is invalid; Examine for illegal characters in the name.", fileName);
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:JsonServiceRegistryDao.java

示例6: handleRequest

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Handle request.
 *
 * @param request  the request
 * @param response the response
 * @return the model and view
 * @throws Exception the exception
 */
@GetMapping(path = OAuth20Constants.BASE_OAUTH20_URL + '/' + OAuth20Constants.CALLBACK_AUTHORIZE_URL)
public ModelAndView handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    this.callbackController.callback(request, response);
    final String url = StringUtils.remove(response.getHeader("Location"), "redirect:");
    final J2EContext ctx = WebUtils.getPac4jJ2EContext(request, response);
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
    return oAuth20CallbackAuthorizeViewResolver.resolve(ctx, manager, url);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:17,代码来源:OAuth20CallbackAuthorizeEndpointController.java

示例7: compress

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Use ZipOutputStream to zip text to byte array, then convert
 * byte array to base64 string, so it can be transferred via http request.
 *
 * @param srcTxt the src txt
 * @return the string in UTF-8 format and base64'ed, or null.
 */
public static String compress(final String srcTxt) {
    try {
        final ByteArrayOutputStream rstBao = new ByteArrayOutputStream();
        final GZIPOutputStream zos = new GZIPOutputStream(rstBao);
        zos.write(srcTxt.getBytes());
        IOUtils.closeQuietly(zos);
        final byte[] bytes = rstBao.toByteArray();
        final String base64 = StringUtils.remove(Base64.encodeBase64String(bytes), '\0');
        return new String(StandardCharsets.UTF_8.encode(base64).array(), StandardCharsets.UTF_8);
    } catch (final IOException e) {
        LOGGER.error(e.getMessage(), e);
    }
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:CompressionUtils.java

示例8: makeFile

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Creates a file for a registered service.
 * The file is named as {@code [SERVICE-NAME]-[SERVICE-ID]-.{@value #getExtension()}}
 *
 * @param service Registered service.
 * @return file in service registry directory.
 * @throws IllegalArgumentException if file name is invalid
 */
protected File makeFile(final RegisteredService service) {
    final String fileName = StringUtils.remove(service.getName() + '-' + service.getId() + '.' + getExtension(), " ");
    try {
        final File svcFile = new File(this.serviceRegistryDirectory.toFile(), fileName);
        LOGGER.debug("Using [{}] as the service definition file", svcFile.getCanonicalPath());
        return svcFile;
    } catch (final IOException e) {
        LOGGER.warn("Service file name [{}] is invalid; Examine for illegal characters in the name.", fileName);
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:AbstractResourceBasedServiceRegistryDao.java

示例9: getmachineInfo

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * ==============help method=============
 */
private Triple<String, String, String> getmachineInfo(String providerAndConsumerKv, String groupService) {
    String thralUrl = consulClient.getKVValue(providerAndConsumerKv).getValue().getDecodedValue();
    GrpcURL url = GrpcURL.valueOf(thralUrl);
    String flagAndIp = StringUtils.remove(providerAndConsumerKv, groupService + "/");
    String[] serverInfos = StringUtils.split(flagAndIp, "/");
    String machineFlag = serverInfos[1];
    return new ImmutableTriple<String, String, String>(machineFlag, url.getAddress(),
                                                       url.getParameter(Constants.HTTP_PORT_KEY));
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:13,代码来源:ConsulRegistryRepository.java

示例10: rmXSSBetween

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String rmXSSBetween(String script, final String open, final String close) {// 移除存在XSS攻击威胁的字符串

			String[] xss = StringUtils.substringsBetween(script, open, close);

			if (null != xss && xss.length > 0) {

				for (String xs : xss) {
					script = StringUtils.remove(script, open + xs + close);
					log.warn(open + xs + close + "已移除");
				}
			}

			return script;
		}
 
开发者ID:Fetax,项目名称:Fetax-AI,代码行数:15,代码来源:XSSFilter.java

示例11: removeRootPath

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private Function<String, String> removeRootPath(final String absolutePath) {
    return new Function<String, String>() {
        @Override
        public String apply(String fileName) {
            String tmp = StringUtils.remove(fileName, removeLastSeparator(absolutePath));
            return removeLeaderSeparator(tmp);
        }
    };
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:10,代码来源:LocalHttpService.java

示例12: formatKeyString

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
protected String formatKeyString(String key) {
  return StringUtils.remove(key, "-");
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:4,代码来源:BaseMetricsActor.java

示例13: generateServicekey

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String generateServicekey(String group, String service, String version) {
    return StringUtils.remove(group, Constants.CONSUL_SERVICE_PRE) + ":" + service + ":" + version;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:4,代码来源:ConsulRegistryRepository.java

示例14: crawlQuoraPage

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void crawlQuoraPage(String url, boolean crawlRelated) {
	// log("crawling for Quora url : " + url);
	uniqueQuoraLinks.add(url);
	Document doc = getDocument(url);
	if (doc == null) {
		// log("document is null for quora url: " + url);
		return;
	}

	Elements statsElements = doc.select("div.QuestionStats");
	for (Element statsElement : statsElements) {
		System.out.print(count++ + "\t" + url);
		Elements statsElementValues = statsElement.getElementsByTag("strong");
		int i = 1;
		for (Element statsElementValue : statsElementValues) {
			if (i > 2) {
				break;
			}
			System.out.print("\t" + statsElementValue.getElementsByTag("strong").text());
			i++;
		}
	}

	Elements activityElements = doc.getElementsByClass("QuestionLastActivityTime");
	if (activityElements.size() > 0) {
		for (Element activityElement : activityElements) {
			String lastAsked = StringUtils.remove(activityElement.text(), "Last asked: ");
			if (!lastAsked.contains("201")) {
				lastAsked = lastAsked + ", 2016";
			}
			System.out.println("\t" + lastAsked);
		}
	} else {
		System.out.println();
	}

	if (crawlRelated) {
		// log("crawlRelated is true for : " + url);
		Elements relatedQuestions = doc.getElementsByClass("question_related");
		List<Element> relatedQuestionList = new ArrayList<>();
		for (Element relatedQuestion : relatedQuestions) {
			Elements relatedQuestionHrefs = relatedQuestion.select("a[href]");
			for (Element element : relatedQuestionHrefs) {
				relatedQuestionList.add(element);
			}
		}

		relatedQuestionList = Utils.getSublist(relatedQuestionList, QuoraConstants.numReLatedQuestion);
		for (Element relatedQuestionHref : relatedQuestionList) {
			String relatedUrl = relatedQuestionHref.absUrl("href");
			if (!uniqueQuoraLinks.contains(relatedUrl)) {
				crawlQuoraPage(relatedUrl, false);
			}
		}

	}
}
 
开发者ID:thekosmix,项目名称:Quora-Marketing,代码行数:58,代码来源:QuoraCrawler.java

示例15: handle

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected String handle(String input, String second) {
    return StringUtils.remove(input, second);
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:5,代码来源:Remove.java


注:本文中的org.apache.commons.lang3.StringUtils.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。