/** * Constructor * * @param keyId Key id * @param base64Key A {@link SignAndVerifyKey} key * @throws InvalidKeyException if the key was invalid */ public IDVKeyAPIClient(String keyId, KeyType keyType, String base64Key) throws InvalidKeyException { this(keyId, keyType, base64Decode(base64Key)); }
public static boolean isNotBlank(String txt) { return !isBlank(txt); }
/** * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. * Uses UTF8 encoding. * * @param pArray a byte array containing binary data * @return A String containing only Base-N character data */ public String encodeToString(final byte[] pArray) { return StringUtils.utf8(encode(pArray)); }
public static String urlPathEncode( String path ) { StringBuilder buffer = new StringBuilder(); for (char c : path.toCharArray()) { if (UNSAFE_URLPATH.indexOf(c) >= 0) { buffer.append('%'); buffer.append(toHex(c / 16)); buffer.append(toHex(c % 16)); } else if( c < 32 && c > 128 ) { buffer.append(urlEncode(Character.toString(c))); } else { buffer.append(c); } } return buffer.toString(); }
private static String resolveVarSub(String exp, Map<String, String> provisioningParams, boolean neverFail) throws IllegalArgumentException { if( containsVariableSubstitution(exp) ) { exp = substituteVariables(exp,provisioningParams,neverFail); Pattern pattern = getVarSubFuncPattern(); Matcher m = pattern.matcher(exp); if (m.find()) { boolean suffixFunc = functionName.equals("s"); if (prefixFunc || suffixFunc) { String[] args = splitTwoArgFunction(functionParams, neverFail); if (args != null) { String xfix = args[0]; String val = resolveVarSub(args[1],provisioningParams, neverFail); if (StringUtils.isNotBlank(val)) { return suffixFunc ? xfix + val : val + xfix; } else { resolveVarSubFail(exp, neverFail); return resolveVarSub(functionParams,provisioningParams, neverFail).toUpperCase(); } else if (functionName.equals("l")) { return resolveVarSub(functionParams,provisioningParams, neverFail).toLowerCase(); } else if (functionName.equals("c")) { return capitalize(resolveVarSub(functionParams,provisioningParams, neverFail)); } else if (functionName.equals("eb64")) { return base64Encode(utf8(resolveVarSub(functionParams,provisioningParams, neverFail))); } else if (functionName.equals("db64")) { return utf8(base64Decode(resolveVarSub(functionParams,provisioningParams, neverFail))); } else if (functionName.equals("t")) {
public URLBuilder setRef(String ref) { this.ref = StringUtils.urlEncode(ref); return this; }
String df = template.filter(defaultValue); String dfOverride = template.getDefaultValue(id); if (StringUtils.isNotBlank(dfOverride)) { df = dfOverride; if (response == null) { throw new TemplateExecutionException("Template processing cancelled by user"); } else if (!blankAllowed && StringUtils.isBlank(response)) { val = null; } else {
public static boolean notEmpty(String... values) { for (String value : values) { if (StringUtils.isEmpty(value)) { return false; } } return true; } }
public static String saltedB64Digest(byte[] data, DigestAlgorithm alg) { return StringUtils.base64Encode(saltedDigest(data, alg)); }
@Override public String toString() { StringBuilder url = new StringBuilder(); if (isNotEmpty(protocol)) { url.append(protocol).append("://"); if (isNotEmpty(userInfo)) { url.append(StringUtils.urlEncode(userInfo)).append('@'); if (isNotEmpty(host)) { url.append(host);
private InputStream getContent() throws TemplateExecutionException { try { if (StringUtils.isNotBlank(resource)) { if (!resource.startsWith("/")) { resource = "/" + resource; } resource = template.filter(resource); try (InputStream is = getClass().getResourceAsStream(resource)) { if (process == null || process) { content = IOUtils.toString(is, getEncoding()); } else { return is; } } } if (content == null) { throw new TemplateExecutionException("Content missing from " + path); } if (trim == null || trim) { content = content.trim(); } if (process == null || process) { return new ByteArrayInputStream(template.filter(content).getBytes(getEncoding())); } else { return new ByteArrayInputStream(content.getBytes(getEncoding())); } } catch (IOException e) { throw new TemplateExecutionException(e); } }
/** * Convert a UUID in base 32 string format into a {@link UUID} object * @param base32Uuid uuid in base 32 format * @return UUID object */ @NotNull public static UUID b32StrToUuid( @NotNull String base32Uuid ) { return byteArrayToUuid(StringUtils.base32Decode(base32Uuid)); } }
/** * Convert a UUID to a base 32 string (without padding) * @param uuid UUID * @return base32 string for the uuid */ @NotNull public static String uuidToB32Str(@NotNull UUID uuid) { return StringUtils.base32Encode(uuidToByteArray(uuid)).replace("=",""); }
public URLBuilder(String url) { if (url == null) { throw new IllegalArgumentException("url mustn't be null"); } URI u = URI.create(url); protocol = u.getScheme(); userInfo = u.getUserInfo(); host = u.getHost(); port = u.getPort(); path = new StringBuilder(); String uPath = u.getPath(); if (uPath != null) { if (!uPath.startsWith("/")) { path.append('/'); } this.path.append(uPath); } if (isNotEmpty(u.getQuery())) { parseQueryParams(u.getQuery()); } ref = u.getFragment(); }
public URLBuilder setUserInfo(String userInfo) { this.userInfo = StringUtils.urlEncode(userInfo); return this; }
public static boolean notEmpty(String... values) { for (String value : values) { if (StringUtils.isEmpty(value)) { return false; } } return true; } }
public String toBase64Encoded() { return StringUtils.base64Encode(toByteArray()); }
public static String urlPathEncode(String path) { StringBuilder buffer = new StringBuilder(); for (char c : path.toCharArray()) { if (UNSAFE_URLPATH.indexOf(c) >= 0) { buffer.append('%'); buffer.append(toHex(c / 16)); buffer.append(toHex(c % 16)); } else if (c < 32 && c > 128) { buffer.append(urlEncode(Character.toString(c))); } else { buffer.append(c); } } return buffer.toString(); }
@Override public String toString() { StringBuilder url = new StringBuilder(); if (isNotEmpty(protocol)) { url.append(protocol).append("://"); if (isNotEmpty(userInfo)) { url.append(StringUtils.urlEncode(userInfo)).append('@'); if (isNotEmpty(host)) { url.append(host);
t.generate(target); getLog().info("Finished generate template project"); if (StringUtils.isNotBlank(abort)) { throw new MojoExecutionException(abort);