List of usage examples for org.apache.commons.lang StringUtils lowerCase
public static String lowerCase(String str)
Converts a String to lower case as per String#toLowerCase() .
From source file:mitm.common.security.keystore.KeyStoreLoader.java
private void determineKeyStoreTypeFromFile(File file) throws KeyStoreException { String extension = StringUtils .defaultString(StringUtils.lowerCase(FilenameUtils.getExtension(file.getName()))); keyStoreType = extensionMap.get(extension); if (keyStoreType == null) { throw new KeyStoreException("Unable to determine key store type for extension " + extension); }//from w ww . j av a 2 s . c o m }
From source file:de.mgd.simplesoundboard.dao.FileSystemSoundResourceDao.java
private boolean isMediaFile(final File file) { return file.isFile() && FilenameUtils.isExtension(StringUtils.lowerCase(file.getName()), FILE_TYPES); }
From source file:com.gst.infrastructure.reportmailingjob.validation.ReportMailingJobValidator.java
/** * validate the request to create a new report mailing job * /* w w w .j a v a 2s .c om*/ * @param jsonCommand -- the JSON command object (instance of the JsonCommand class) * @return None **/ public void validateCreateRequest(final JsonCommand jsonCommand) { final String jsonString = jsonCommand.json(); final JsonElement jsonElement = jsonCommand.parsedJson(); if (StringUtils.isBlank(jsonString)) { throw new InvalidJsonException(); } final Type typeToken = new TypeToken<Map<String, Object>>() { }.getType(); this.fromJsonHelper.checkForUnsupportedParameters(typeToken, jsonString, ReportMailingJobConstants.CREATE_REQUEST_PARAMETERS); final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder dataValidatorBuilder = new DataValidatorBuilder(dataValidationErrors) .resource(StringUtils.lowerCase(ReportMailingJobConstants.REPORT_MAILING_JOB_RESOURCE_NAME)); final String name = this.fromJsonHelper.extractStringNamed(ReportMailingJobConstants.NAME_PARAM_NAME, jsonElement); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.NAME_PARAM_NAME).value(name).notBlank() .notExceedingLengthOf(100); final String startDateTime = this.fromJsonHelper .extractStringNamed(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME, jsonElement); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME) .value(startDateTime).notBlank(); final Integer stretchyReportId = this.fromJsonHelper.extractIntegerWithLocaleNamed( ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME, jsonElement); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME) .value(stretchyReportId).notNull().integerGreaterThanZero(); final String emailRecipients = this.fromJsonHelper .extractStringNamed(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME, jsonElement); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.EMAIL_RECIPIENTS_PARAM_NAME) .value(emailRecipients).notBlank(); final String emailSubject = this.fromJsonHelper .extractStringNamed(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME, jsonElement); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.EMAIL_SUBJECT_PARAM_NAME) .value(emailSubject).notBlank().notExceedingLengthOf(100); final String emailMessage = this.fromJsonHelper .extractStringNamed(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME, jsonElement); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.EMAIL_MESSAGE_PARAM_NAME) .value(emailMessage).notBlank(); if (this.fromJsonHelper.parameterExists(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME, jsonElement)) { final Boolean isActive = this.fromJsonHelper .extractBooleanNamed(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME, jsonElement); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.IS_ACTIVE_PARAM_NAME).value(isActive) .notNull(); } final Integer emailAttachmentFileFormatId = this.fromJsonHelper.extractIntegerSansLocaleNamed( ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME, jsonElement); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME) .value(emailAttachmentFileFormatId).notNull(); if (emailAttachmentFileFormatId != null) { dataValidatorBuilder.reset() .parameter(ReportMailingJobConstants.EMAIL_ATTACHMENT_FILE_FORMAT_ID_PARAM_NAME) .value(emailAttachmentFileFormatId) .isOneOfTheseValues(ReportMailingJobEmailAttachmentFileFormat.validIds()); } final String dateFormat = jsonCommand.dateFormat(); dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.DATE_FORMAT_PARAM_NAME).value(dateFormat) .notBlank(); if (StringUtils.isNotEmpty(dateFormat)) { try { final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(dateFormat) .withLocale(jsonCommand.extractLocale()); // try to parse the date time string LocalDateTime.parse(startDateTime, dateTimeFormatter); } catch (IllegalArgumentException ex) { dataValidatorBuilder.reset().parameter(ReportMailingJobConstants.DATE_FORMAT_PARAM_NAME) .value(dateFormat).failWithCode("invalid.date.format"); } } throwExceptionIfValidationWarningsExist(dataValidationErrors); }
From source file:com.haulmont.cuba.web.gui.components.WebSearchField.java
protected void executeSearch(final String newFilter) { if (optionsDatasource == null) return;/*from w w w . j ava2 s . c o m*/ String filterForDs = newFilter; if (mode == Mode.LOWER_CASE) { filterForDs = StringUtils.lowerCase(newFilter); } else if (mode == Mode.UPPER_CASE) { filterForDs = StringUtils.upperCase(newFilter); } if (escapeValueForLike && StringUtils.isNotEmpty(filterForDs)) { filterForDs = QueryUtils.escapeForLike(filterForDs); } if (!isRequired() && StringUtils.isEmpty(filterForDs)) { setValue(null); if (optionsDatasource.getState() == State.VALID) { optionsDatasource.clear(); } return; } if (StringUtils.length(filterForDs) >= minSearchStringLength) { optionsDatasource.refresh(Collections.singletonMap(SEARCH_STRING_PARAM, filterForDs)); if (optionsDatasource.getState() == State.VALID) { if (optionsDatasource.size() == 0) { if (searchNotifications != null) { searchNotifications.notFoundSuggestions(newFilter); } } else if (optionsDatasource.size() == 1) { setValue(optionsDatasource.getItems().iterator().next()); } } } else { if (optionsDatasource.getState() == State.VALID) { optionsDatasource.clear(); } if (searchNotifications != null && StringUtils.length(newFilter) > 0) { searchNotifications.needMinSearchStringLength(newFilter, minSearchStringLength); } } }
From source file:com.mmj.app.common.checkcode.CheckCodeManager.java
public boolean checkByMD5(CookieManager cookieManager, String checkcode, CookieNameEnum cookieNameEnum) { if (!needCheck) { return true; }/*from w ww . j a v a 2 s . c om*/ if (initException != null) {// ?? setup(); } boolean stillInitFailed = initException != null; if (stillInitFailed) { return true;// } // ??(??Cookie) if (StringUtils.isBlank(checkcode)) { return false; } String checkCodeInCookie = cookieManager.get(cookieNameEnum); if (StringUtils.isEmpty(checkCodeInCookie)) { return false; } checkCodeInCookie = Md5Encrypt.md5(StringUtils.lowerCase(checkCodeInCookie)); boolean isValid = StringUtils.equalsIgnoreCase(checkCodeInCookie, checkcode); if (!isValid) {// ???Cookie? cookieManager.set(cookieNameEnum, null); } return isValid; }
From source file:hudson.plugins.clearcase.history.FieldFilter.java
public boolean accept(String value) { switch (type) { case Equals:// w w w . j av a 2 s . c o m return StringUtils.equals(value, patternText); case EqualsIgnoreCase: return StringUtils.equalsIgnoreCase(value, patternText); case NotEquals: return !StringUtils.equals(value, patternText); case NotEqualsIgnoreCase: return !StringUtils.equalsIgnoreCase(value, patternText); case StartsWith: return value != null && value.startsWith(patternText); case StartsWithIgnoreCase: return value != null && value.toLowerCase().startsWith(patternText); case EndsWith: return value != null && value.endsWith(patternText); case EndsWithIgnoreCase: return value != null && value.toLowerCase().endsWith(patternText); case Contains: return StringUtils.contains(value, patternText); case ContainsIgnoreCase: return StringUtils.contains(StringUtils.lowerCase(value), patternText); case DoesNotContain: return !StringUtils.contains(value, patternText); case DoesNotContainIgnoreCase: LOGGER.fine(StringUtils.lowerCase(value) + " <>" + patternText); return !StringUtils.contains(StringUtils.lowerCase(value), patternText); case ContainsRegxp: Matcher m = pattern.matcher(StringUtils.defaultString(value)); return m.find(); case DoesNotContainRegxp: Matcher m2 = pattern.matcher(StringUtils.defaultString(value)); return !m2.find(); } return true; }
From source file:com.razorfish.security.AcceleratorAuthenticationProvider.java
@Override public Authentication authenticate(final Authentication authentication) throws AuthenticationException { final String username = (authentication.getPrincipal() == null) ? "NONE_PROVIDED" : authentication.getName();/*from ww w .j a v a 2s. c om*/ String usernameResult = username; UsernamePasswordAuthenticationToken token = (UsernamePasswordAuthenticationToken) authentication; if (!usernameResult.isEmpty()) { final List<CustomerModel> result = getCustomerDao().findCustomerByMobileNumber(usernameResult); if (!result.isEmpty()) { usernameResult = result.iterator().next().getOriginalUid(); token = new UsernamePasswordAuthenticationToken(usernameResult, (String) authentication.getCredentials()); token.setDetails(authentication.getDetails()); } } if (getBruteForceAttackCounter().isAttack(usernameResult)) { try { final UserModel userModel = getUserService().getUserForUID(StringUtils.lowerCase(usernameResult)); userModel.setLoginDisabled(true); getModelService().save(userModel); bruteForceAttackCounter.resetUserCounter(userModel.getUid()); } catch (final UnknownIdentifierException e) { LOG.warn("Brute force attack attempt for non existing user name " + usernameResult); } finally { throw new BadCredentialsException( messages.getMessage("CoreAuthenticationProvider.badCredentials", "Bad credentials")); } } checkCartForUser(usernameResult); return super.authenticate(token); }
From source file:mitm.djigzo.web.services.security.AuthenticationEntryPointWithRequestParams.java
@Override protected String determineUrlToUseForThisRequest(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) { /*//from www . jav a 2s .c o m * get the "action" parameter from the request and lookup the URL to use from the loginURLs map. If * there is no mapping, fallback to the default URL. */ String url = loginURLs.get(StringUtils.lowerCase(request.getParameter(loginPageParameter))); return url != null ? url : super.determineUrlToUseForThisRequest(request, response, exception); }
From source file:com.jkali.client.entity.Page.java
/** * ???.//from w w w. j a v a 2s . c om * * @param order * ?descasc,?','. */ public void setOrder(final String order) { // order? String[] orders = StringUtils.split(StringUtils.lowerCase(order), ','); for (String orderStr : orders) { if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr)) throw new IllegalArgumentException("??" + orderStr + "??"); } this.order = StringUtils.lowerCase(order); }
From source file:com.edgenius.wiki.render.impl.BaseMacroParameter.java
public void setMacroName(String macroName) { this.macroName = StringUtils.lowerCase(macroName); }