List of usage examples for org.apache.commons.lang3 StringUtils removeEndIgnoreCase
public static String removeEndIgnoreCase(final String str, final String remove)
Case insensitive removal of a substring if it is at the end of a source string, otherwise returns the source string.
A null source string will return null .
From source file:nz.net.orcon.kanban.tools.ComplexDateConverter.java
protected String removeDays(String stringIn) { return StringUtils.removeEndIgnoreCase(stringIn, DAYS); }
From source file:org.cryptomator.crypto.aes256.Aes256Cryptor.java
/** * @see #encryptPathComponent(String, SecretKey, CryptorIOSupport) *//*www. j av a 2 s. c om*/ private String decryptPathComponent(final String encrypted, final SecretKey key, CryptorIOSupport ioSupport) throws IllegalBlockSizeException, BadPaddingException, IOException { final String ivAndCiphertext; if (encrypted.endsWith(LONG_NAME_FILE_EXT)) { final String basename = StringUtils.removeEnd(encrypted, LONG_NAME_FILE_EXT); final String crc32 = StringUtils.substringBefore(basename, LONG_NAME_PREFIX_SEPARATOR); final String uuid = StringUtils.substringAfter(basename, LONG_NAME_PREFIX_SEPARATOR); final String metadataFilename = crc32 + METADATA_FILE_EXT; final LongFilenameMetadata metadata = this.getMetadata(ioSupport, metadataFilename); ivAndCiphertext = metadata.getEncryptedFilenameForUUID(UUID.fromString(uuid)); } else if (encrypted.endsWith(BASIC_FILE_EXT)) { ivAndCiphertext = StringUtils.removeEndIgnoreCase(encrypted, BASIC_FILE_EXT); } else { throw new IllegalArgumentException("Unsupported path component: " + encrypted); } final String partialIvStr = StringUtils.substringBefore(ivAndCiphertext, IV_PREFIX_SEPARATOR); final String ciphertext = StringUtils.substringAfter(ivAndCiphertext, IV_PREFIX_SEPARATOR); final ByteBuffer iv = ByteBuffer.allocate(AES_BLOCK_LENGTH); iv.put(ENCRYPTED_FILENAME_CODEC.decode(partialIvStr)); final Cipher cipher = this.aesCtrCipher(key, iv.array(), Cipher.DECRYPT_MODE); final byte[] encryptedBytes = ENCRYPTED_FILENAME_CODEC.decode(ciphertext); final byte[] paddedCleartextBytes = cipher.doFinal(encryptedBytes); // remove NULL padding (not valid in file names anyway) final int beginOfPadding = ArrayUtils.indexOf(paddedCleartextBytes, (byte) 0x00); if (beginOfPadding == -1) { return new String(paddedCleartextBytes, StandardCharsets.UTF_8); } else { final byte[] cleartextBytes = Arrays.copyOf(paddedCleartextBytes, beginOfPadding); return new String(cleartextBytes, StandardCharsets.UTF_8); } }
From source file:org.jbb.members.rest.base.MemberExceptionMapper.java
public ErrorDetail mapToErrorDetail(ConstraintViolation<?> violation) { String propertyPath = violation.getPropertyPath().toString(); if ("visiblePassword".equals(propertyPath)) { PasswordPolicy passwordPolicy = passwordService.currentPolicy(); return new ErrorDetail("password", MessageFormat.format(violation.getMessage(), passwordPolicy.getMinimumLength(), passwordPolicy.getMaximumLength())); }/*ww w . jav a 2 s . com*/ return new ErrorDetail(StringUtils.removeEndIgnoreCase(propertyPath, ".value"), violation.getMessage()); }
From source file:org.jbb.members.web.registration.logic.RegistrationErrorsBindingMapper.java
private static String unwrap(String s) { if (s.isEmpty()) { return "password"; }/*from ww w . ja va 2 s. c om*/ return StringUtils.removeEndIgnoreCase(s, ".value"); }
From source file:org.ligoj.app.plugin.prov.aws.in.ProvAwsPriceImportResource.java
/** * Install a new EC2 instance type// ww w. ja v a 2 s .com */ private ProvInstanceType installInstanceType(final UpdateContext context, final AwsEc2Price csv) { final ProvInstanceType type = context.getInstanceTypes().computeIfAbsent(csv.getInstanceType(), k -> { final ProvInstanceType t = new ProvInstanceType(); t.setNode(context.getNode()); t.setCpu(csv.getCpu()); t.setName(csv.getInstanceType()); // Convert GiB to MiB, and rounded final String memoryStr = StringUtils.removeEndIgnoreCase(csv.getMemory(), " GiB").replace(",", ""); t.setRam((int) Math.round(Double.parseDouble(memoryStr) * 1024d)); t.setConstant(!"Variable".equals(csv.getEcu())); return t; }); // Update the statistics only once if (context.getInstanceTypesMerged().add(type.getName())) { type.setDescription(ArrayUtils.toString(ArrayUtils .removeAllOccurences(new String[] { csv.getPhysicalProcessor(), csv.getClockSpeed() }, null))); // Rating type.setCpuRate(getRate("cpu", csv)); type.setRamRate(getRate("ram", csv)); type.setNetworkRate(getRate("network", csv, csv.getNetworkPerformance())); type.setStorageRate(toStorage(csv)); // Need this update itRepository.saveAndFlush(type); } return type; }
From source file:xin.nic.sdk.registrar.util.UrlUtil.java
/** * ?//* w ww . j av a 2 s. c o m*/ * * @param url URL * @return /?URL */ private static String removeLastSlash(String url) { return StringUtils.removeEndIgnoreCase(url, "/"); }