private static String extractController(String path) { String controller = substringBeforeLast(path, SLASH); if (controller.startsWith(SLASH)) { return substring(controller, 1); } return controller; }
public static synchronized String encrypt( String secret, String plainText ) { secret = substring( rightPad( secret, 16 ), 0, 16 ); SecretKey key = new SecretKeySpec( secret.getBytes(), "AES" ); try { cipher.init( Cipher.ENCRYPT_MODE, key ); byte[] cipherText = cipher.doFinal( plainText.getBytes() ); return new String( coder.encode( cipherText ) ); } catch ( Exception e ) { logger.error( "Encryption error", e ); } return null; }
@SuppressWarnings("unused") public static synchronized String decrypt( String secret, String codedText ) { secret = substring( rightPad( secret, 16 ), 0, 16 ); SecretKey key = new SecretKeySpec( secret.getBytes(), "AES" ); byte[] encypted = coder.decode( codedText.getBytes() ); try { cipher.init( Cipher.DECRYPT_MODE, key ); byte[] decrypted = cipher.doFinal( encypted ); return new String( decrypted ); } catch ( Exception e ) { logger.error( "Decryption error", e ); } return null; } }
public static PathPattern create(String s) { String trimmed = StringUtils.trim(s); if (StringUtils.startsWithIgnoreCase(trimmed, ABSOLUTE_PATH_PATTERN_PREFIX)) { LOG.warn("Using absolute path pattern is deprecated. Please use relative path instead of '" + trimmed + "'"); return new AbsolutePathPattern(StringUtils.substring(trimmed, ABSOLUTE_PATH_PATTERN_PREFIX.length())); } return new RelativePathPattern(trimmed); }
String toRipRegex = StringUtils.substring(pattern, last, index); builder.append(convertWildcard(ripRegex(toRipRegex))); last = index;
@Override public void addLine(String line) { LineRange range = null; if (i < rangesPerLine.length) { range = rangesPerLine[i]; } if (range == null) { delegate.addLine(""); } else { delegate.addLine(StringUtils.substring(line, range.startOffset(), range.endOffset())); } i++; }
private Domain getDomainForName(String name) { Domain domain = null; if (StringUtils.isNotBlank(name)) { //removing all the special characters and trimming its length to 190 to make the domain valid. String domainName = StringUtils.substring(name.replaceAll("\\W", ""), 0, 190); if (StringUtils.isNotBlank(domainName)) { domain = _domainService.getDomainByName(domainName, Domain.ROOT_DOMAIN); if (domain == null) { domain = _domainService.createDomain(domainName, Domain.ROOT_DOMAIN, domainName, UUID.randomUUID().toString()); } } } return domain; }
public IllegalTokenException(List<String> tokens, int tokensIndex, String rawText, int rawTextOffset, int displayLength) { super("The tokens are not a substring sequence of the raw text: Can't find \"" + tokens.get(tokensIndex) + "\" in \"" + StringUtils.substring(rawText, rawTextOffset, rawTextOffset + displayLength) + "...\"."); this.tokens = tokens; this.tokensIndex = tokensIndex; this.rawText = rawText; this.rawTextOffset = rawTextOffset; } }
private Optional<Long> parseProjectId(final String project) { try { return Optional.of(Long.parseLong(StringUtils.substring(project, PROJECT_ID_PREFIX.length()))); } catch (NumberFormatException e) { return Optional.empty(); } }
@Override public Jwt getJwt(String authentication) { return JwtHelper.decode(StringUtils.substring(authentication, BEARER_BEGIN_INDEX)); } }
public static String getSortableValue(final String value) { String result; if (StringUtils.hasText(value)) { result = org.apache.commons.lang.StringUtils.substring(value.trim(), 0, SORT_LENGTH); } else { result = ""; } result = DiacriticsRemover.alphaSortable(result, false); return result; }
/** * Gets the property defined as event handler (not necessary a Function if something else has been set). * @param eventName the event name (like "onclick") * @return the property */ protected Object getEventHandlerProp(final String eventName) { if (eventListenersContainer_ == null) { return null; } return eventListenersContainer_.getEventHandlerProp(StringUtils.substring(eventName.toLowerCase(), 2)); }
/** * Gets the property defined as event handler (not necessary a Function if something else has been set). * @param eventName the event name (like "onclick") * @return the property */ protected Object getEventHandlerProp(final String eventName) { if (eventListenersContainer_ == null) { return null; } return eventListenersContainer_.getEventHandlerProp(StringUtils.substring(eventName.toLowerCase(), 2)); }
public boolean isMetadataSupportFile( String requestedPath ) { if ( isSupportFile( requestedPath ) ) { String basefilePath = StringUtils.substring( requestedPath, 0, requestedPath.lastIndexOf( '.' ) ); if ( isMetadata( basefilePath ) ) { return true; } } return false; }
public static PathPattern create(String s) { String trimmed = StringUtils.trim(s); if (StringUtils.startsWithIgnoreCase(trimmed, "file:")) { return new AbsolutePathPattern(StringUtils.substring(trimmed, "file:".length())); } return new RelativePathPattern(trimmed); }
@Override public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) { String value = super.logicalCollectionColumnName(columnName, propertyName, referencedColumn); return StringUtils.substring(tablePrefix + addUnderscores(value), 0, maxLength); }
@Override public String logicalColumnName(String columnName, String propertyName) { String value = super.logicalColumnName(columnName, propertyName); return StringUtils.substring(tablePrefix + addUnderscores(value), 0, maxLength); }
@Override protected PossibleLogImporters doInBackground() throws Exception { publish(Boolean.TRUE); String text = StringUtils.substring(textArea.getText(),0,20000); LOGGER.info("Will process " + text.length() + " chars from clipboard"); final long start = System.currentTimeMillis(); final Collection<LogImporter> logImporters = getOtrosApplication().getAllPluginables().getLogImportersContainer().getElements(); final PossibleLogImporters possibleLogImporters = Utils.detectPossibleLogImporter(logImporters,text.getBytes()); long duration = System.currentTimeMillis() - start; LOGGER.debug("Finished log format detection, it took " + duration + "ms, have found " + possibleLogImporters.getLogImporter()); return possibleLogImporters; }
private void assertResult(List<Book> result, String phrase) { for ( Book book : result ) { assertTrue( "QueryBooksBySummaryTask: phrase=" + phrase + ", summary=" + StringUtils.substring( book.getSummary(), 0, 50 ), StringUtils.containsIgnoreCase( book.getSummary(), phrase ) ); } }