List of usage examples for org.springframework.util StringUtils deleteAny
public static String deleteAny(String inString, @Nullable String charsToDelete)
From source file:com.daon.identityx.utils.GenerateAndroidFacet.java
public static void main(String[] args) { String androidKeystoreLocation = System.getProperty("ANDROID_KEYSTORE_LOCATION", DEFAULT_ANDROID_KEYSTORE_LOCATION); String androidKeystorePassword = System.getProperty("ANDROID_KEYSTORE_PASSWORD", DEFAULT_ANDROID_KEYSTORE_PASSWORD); String androidKeystoreCert = System.getProperty("ANDROID_KEYSTORE_CERT_NAME", DEFAULT_ANDROID_KEYSTORE_CERT_NAME); String hashingAlgorithm = System.getProperty("HASHING_ALGORITHM", DEFAULT_HASHING_ALGORITHM); try {// www . ja v a2s. c om KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); File filePath = new File(androidKeystoreLocation); if (!filePath.exists()) { System.err.println( "The filepath to the debug keystore could not be located at: " + androidKeystoreCert); System.exit(1); } else { System.out.println("Found the Android Studio keystore at: " + androidKeystoreLocation); } keyStore.load(new FileInputStream(filePath), androidKeystorePassword.toCharArray()); System.out.println("Keystore loaded - password and location were OK"); Certificate cert = keyStore.getCertificate(androidKeystoreCert); if (cert == null) { System.err.println( "Could not location the certification in the store with the name: " + androidKeystoreCert); System.exit(1); } else { System.out.println("Certificate found in the store with name: " + androidKeystoreCert); } byte[] certBytes = cert.getEncoded(); MessageDigest digest = MessageDigest.getInstance(hashingAlgorithm); System.out.println("Hashing algorithm: " + hashingAlgorithm + " found."); byte[] hashedCert = digest.digest(certBytes); String base64HashedCert = Base64.getEncoder().encodeToString(hashedCert); System.out.println("Base64 encoded SHA-1 hash of the certificate: " + base64HashedCert); String base64HashedCertRemoveTrailing = StringUtils.deleteAny(base64HashedCert, "="); System.out.println( "Add the following facet to the Facets file in order for the debug app to be trusted by the FIDO client"); System.out.println("\"android:apk-key-hash:" + base64HashedCertRemoveTrailing + "\""); } catch (Throwable ex) { ex.printStackTrace(); } }
From source file:fr.xebia.springframework.security.core.userdetails.memory.ExtendedUserMapBuilder.java
/** * Build an {@link fr.xebia.springframework.security.core.userdetails.ExtendedUser} from user attributes. * Protected for test purpose.//ww w . j av a 2 s.c o m * @param userAttributes a list. * @return the build {@link fr.xebia.springframework.security.core.userdetails.ExtendedUser}. */ protected static ExtendedUser buildExtendedUser(String userAttributes) { if (userAttributes == null) { return null; } String[] userAttributesStringArray = StringUtils.delimitedListToStringArray(userAttributes, "="); if (userAttributesStringArray.length != 2) { return null; // we need a username and some attributes. } String username = userAttributesStringArray[0].trim(); Pattern pattern = Pattern.compile("(enabled|disabled){1}$"); Matcher matcher = pattern.matcher(userAttributesStringArray[1].trim()); // Check activated attribute boolean activated = true; if (matcher.find()) { activated = ENABLED.equals(matcher.group()); } // Check authorized IP addresses String allowedIpAddresses = ""; pattern = Pattern.compile("@\\(.*\\)"); matcher = pattern.matcher(userAttributesStringArray[1]); if (matcher.find()) { allowedIpAddresses = StringUtils.deleteAny(matcher.group(), "@() "); } // Get user password and roles : pattern = Pattern.compile("((,\\ *@\\(.*\\)){0,1}(\\ *,\\ *(enabled|disabled)\\ *){0,1})$"); String[] remainingAttributes = pattern.split(userAttributesStringArray[1]); if (remainingAttributes.length != 1) { return null; // password and role(s) must have been defined. } String[] attributes = StringUtils.commaDelimitedListToStringArray(remainingAttributes[0]); if (attributes.length < 2) { return null; // we need at least one password and one role. } String password = attributes[0].trim(); List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); for (int i = 1; i < attributes.length; i++) { authorities.add(new GrantedAuthorityImpl(attributes[i].trim())); } ExtendedUser extendedUser = new ExtendedUser(username, password, activated, true, true, true, authorities); extendedUser.setAllowedRemoteAddresses(allowedIpAddresses); return extendedUser; }
From source file:org.lightadmin.core.persistence.repository.JavassistDynamicJpaRepositoryClassFactory.java
private String generateDynamicRepositoryClassReference(Class<?> domainType) { String uuid = StringUtils.deleteAny(UUID.randomUUID().toString(), "-"); String packageName = ClassUtils.getPackageName(JavassistDynamicJpaRepositoryClassFactory.class); String domainRepositoryClassName = dynamicRepositoryBeanNameGenerator.generateBeanName(domainType, DynamicJpaRepository.class); return packageName + "." + domainRepositoryClassName + "$$DYNAMIC$$" + uuid; }
From source file:com.benfante.taglib.frontend.tags.CheckboxTag.java
/** * Autogenerate the '<code>for</code>' attribute value for this tag. * <p>//from w w w .j av a 2 s . c om * The default implementation delegates to {@link #getPropertyPath()}, * deleting invalid characters (such as "[" or "]"). */ protected String autogenerateFor() throws JspException { return StringUtils.deleteAny(getPropertyPath(), "[]"); }
From source file:com.benfante.taglib.frontend.tags.CheckboxTag.java
protected String autogenerateErrorId() throws JspException { String path = getPropertyPath(); if ("".equals(path) || "*".equals(path)) { path = (String) this.pageContext.getAttribute(FormTag.MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE); }//from w w w . j av a2s .c o m return StringUtils.deleteAny(path, "[]") + ".errors"; }
From source file:ch.digitalfondue.npjt.QueryType.java
private static JdbcAction actionFromTemplate(String template) { String tmpl = StringUtils.deleteAny(template.toLowerCase(Locale.ENGLISH), "() ").trim(); return tmpl.indexOf("select") == 0 ? JdbcAction.QUERY : JdbcAction.UPDATE; }
From source file:org.springmodules.validation.valang.predicates.GenericTestPredicate.java
private String deleteWhitespace(String s) { return StringUtils.deleteAny(s, " \t\r\n\b"); }
From source file:com.lm.lic.manager.util.GenUtil.java
public static String removeAllOccurancesOfString(String unstripped, String charsToDelete) { String stripped = StringUtils.deleteAny(unstripped, charsToDelete); return stripped; }
From source file:com.phoenixnap.oss.ramlapisync.naming.NamingHelper.java
/** * Converts an http contentType into a qualifier that can be used within a Java method * /*from ww w . j a v a2 s . c o m*/ * @param contentType The content type to convert application/json * @return qualifier, example V1Html */ public static String convertContentTypeToQualifier(String contentType) { //lets start off simple since qualifers are better if they are simple :) //if we have simple standard types lets add some heuristics if (contentType.equals(MediaType.APPLICATION_JSON_VALUE)) { return "AsJson"; } if (contentType.equals(MediaType.APPLICATION_OCTET_STREAM_VALUE)) { return "AsBinary"; } if (contentType.equals(MediaType.TEXT_PLAIN_VALUE) || contentType.equals(MediaType.TEXT_HTML_VALUE)) { return "AsText"; } //we have a non standard type. lets see if we have a version Matcher versionMatcher = CONTENT_TYPE_VERSION.matcher(contentType); if (versionMatcher.find()) { String version = versionMatcher.group(1); if (version != null) { return StringUtils.capitalize(version).replace(".", "_"); } } //if we got here we have some sort of funky content type. deal with it int seperatorIndex = contentType.indexOf("/"); if (seperatorIndex != -1 && seperatorIndex < contentType.length()) { String candidate = contentType.substring(seperatorIndex + 1).toLowerCase(); String out = ""; if (candidate.contains("json")) { candidate = candidate.replace("json", ""); out += "AsJson"; } candidate = StringUtils.deleteAny(candidate, " ,.+=-'\"\\|~`#$%^&\n\t"); if (StringUtils.hasText(candidate)) { out = StringUtils.capitalize(candidate) + out; } return "_" + out; } return ""; }
From source file:com.vmware.thinapp.common.util.AfUtil.java
/** * Attempt to extract the filename from the given Content-Disposition header * string. Example of this header string: * * "attachment; filename=name_of_file.txt" * * @param contentDisposition string from a HTTP Content-Disposition header * @return the filename extracted from the given string, null if parsing the * string fails.//from w w w. java 2 s .co m */ public static final String getFilenameFromContentDisposition(String contentDisposition) { if (contentDisposition == null) { return null; } final Matcher matcher = AfUtil.FILENAME_PATTERN.matcher(contentDisposition); if (matcher.matches()) { String[] temp = contentDisposition.split("filename="); if (temp != null && temp.length > 1) { String filename = temp[1]; /** filename could be in double quotes. */ filename = StringUtils.deleteAny(filename, "\""); return filename; } } return null; }