use of org.apache.commons.lang3.StringUtils in project xwiki-platform by xwiki.
the class LiveTableResultsTest method setUp.
@Before
@SuppressWarnings("deprecation")
public void setUp() throws Exception {
setOutputSyntax(Syntax.PLAIN_1_0);
request.put("outputSyntax", "plain");
request.put("xpage", "plain");
oldcore.getXWikiContext().setAction("get");
queryService = mock(QueryManagerScriptService.class);
oldcore.getMocker().registerComponent(ScriptService.class, "query", queryService);
modelService = mock(ModelScriptService.class);
oldcore.getMocker().registerComponent(ScriptService.class, "model", modelService);
TagPluginApi tagPluginApi = mock(TagPluginApi.class);
doReturn(tagPluginApi).when(oldcore.getSpyXWiki()).getPluginApi(eq("tag"), any(XWikiContext.class));
registerVelocityTool("stringtool", new StringUtils());
registerVelocityTool("mathtool", new MathTool());
registerVelocityTool("regextool", new RegexTool());
registerVelocityTool("numbertool", new NumberTool());
loadPage(new DocumentReference("xwiki", "XWiki", "LiveTableResultsMacros"));
}
use of org.apache.commons.lang3.StringUtils in project cas by apereo.
the class DefaultCasCookieValueManager method obtainValueFromCompoundCookie.
@Override
protected String obtainValueFromCompoundCookie(final String value, final HttpServletRequest request) {
val cookieParts = Splitter.on(String.valueOf(COOKIE_FIELD_SEPARATOR)).splitToList(value);
val cookieValue = cookieParts.get(0);
if (!cookieProperties.isPinToSession()) {
LOGGER.trace("Cookie session-pinning is disabled. Returning cookie value as it was provided");
return cookieValue;
}
if (cookieParts.size() != COOKIE_FIELDS_LENGTH) {
throw new InvalidCookieException("Invalid cookie. Required fields are missing");
}
val cookieIpAddress = cookieParts.get(1);
val cookieUserAgent = cookieParts.get(2);
if (Stream.of(cookieValue, cookieIpAddress, cookieUserAgent).anyMatch(StringUtils::isBlank)) {
throw new InvalidCookieException("Invalid cookie. Required fields are empty");
}
val clientInfo = ClientInfoHolder.getClientInfo();
if (clientInfo == null) {
throw new InvalidCookieException("Unable to match required remote address " + cookieIpAddress + " because client ip at time of cookie creation is unknown");
}
if (!cookieIpAddress.equals(clientInfo.getClientIpAddress())) {
if (StringUtils.isBlank(cookieProperties.getAllowedIpAddressesPattern()) || !RegexUtils.find(cookieProperties.getAllowedIpAddressesPattern(), clientInfo.getClientIpAddress())) {
throw new InvalidCookieException("Invalid cookie. Required remote address " + cookieIpAddress + " does not match " + clientInfo.getClientIpAddress());
}
LOGGER.debug("Required remote address [{}] does not match [{}], but it's authorized proceed", cookieIpAddress, clientInfo.getClientIpAddress());
}
val agent = HttpRequestUtils.getHttpServletRequestUserAgent(request);
if (!cookieUserAgent.equals(agent)) {
throw new InvalidCookieException("Invalid cookie. Required user-agent " + cookieUserAgent + " does not match " + agent);
}
return cookieValue;
}
use of org.apache.commons.lang3.StringUtils in project cas by apereo.
the class AbstractWebApplicationServiceResponseBuilder method getWebApplicationServiceResponseType.
/**
* Determine response type response.
*
* @param finalService the final service
* @return the response type
*/
protected Response.ResponseType getWebApplicationServiceResponseType(final WebApplicationService finalService) {
val request = HttpRequestUtils.getHttpServletRequestFromRequestAttributes();
val methodRequest = Optional.ofNullable(request).map(httpServletRequest -> httpServletRequest.getParameter(CasProtocolConstants.PARAMETER_METHOD)).orElse(null);
final Function<String, String> func = FunctionUtils.doIf(StringUtils::isBlank, t -> {
val registeredService = this.servicesManager.findServiceBy(finalService);
if (registeredService != null) {
return registeredService.getResponseType();
}
return null;
}, f -> methodRequest);
val method = func.apply(methodRequest);
if (StringUtils.isBlank(method)) {
return Response.ResponseType.REDIRECT;
}
return Response.ResponseType.valueOf(method.toUpperCase());
}
use of org.apache.commons.lang3.StringUtils in project metacat by Netflix.
the class MySqlTagService method buildParametrizedInClause.
private static String buildParametrizedInClause(final Set<String> tags, final List<SqlParameterValue> params, final int index) {
final String tagList = tags.stream().filter(StringUtils::isNotBlank).map(v -> "?").collect(Collectors.joining(", "));
params.addAll(index, tags.stream().filter(StringUtils::isNotBlank).map(p -> new SqlParameterValue(Types.VARCHAR, p)).collect(Collectors.toList()));
return StringUtils.isBlank(tagList) ? EMPTY_CLAUSE : tagList;
}
use of org.apache.commons.lang3.StringUtils in project yorc-a4c-plugin by ystia.
the class ToscaComponentExporter method getVelocityContext.
static Map<String, Object> getVelocityContext() {
Map<String, Object> velocityCtx = new HashMap<>();
velocityCtx.put("vtPath", "org/ystia/yorc/alien4cloud/plugin/tosca");
velocityCtx.put("yorcUtils", new ToscaComponentUtils());
velocityCtx.put("stringsUtils", new StringUtils());
return velocityCtx;
}
Aggregations