@Override public void setAlgorithm(String algorithm) throws NoSuchAlgorithmException { ConcurrentMessageDigest.init(algorithm); this.algorithm = algorithm; }
/** * Escape content for use in XML. * * @param content The content to escape * * @return The escaped content or {@code null} if the content was * {@code null} */ public static String xml(String content) { return xml(null, content); }
public static byte[] digestSHA1(byte[]... input) { return digest(SHA1, input); }
private static String getWebSocketAccept(String key) { byte[] digest = ConcurrentMessageDigest.digestSHA1( key.getBytes(StandardCharsets.ISO_8859_1), WS_ACCEPT); return Base64.encodeBase64String(digest); } }
public Principal authenticate(Realm realm) { // Second MD5 digest used to calculate the digest : // MD5(Method + ":" + uri) String a2 = method + ":" + uri; byte[] buffer = ConcurrentMessageDigest.digestMD5( a2.getBytes(StandardCharsets.ISO_8859_1)); String md5a2 = MD5Encoder.encode(buffer); return realm.authenticate(userName, response, nonce, nc, cnonce, qop, realmName, md5a2); }
private String encodeMD5(String value) throws NoSuchAlgorithmException { byte[] bytesOfMessage = value.getBytes(StandardCharsets.ISO_8859_1); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] thedigest = md.digest(bytesOfMessage); return MD5Encoder.encode(thedigest); }
/** * Convert the object to a string via {@link Object#toString()} and HTML * escape the resulting string for use in HTML content. * * @param obj The object to convert to String and then escape * * @return The escaped content or <code>"?"</code> if obj is * {@code null} */ public static String htmlElementContent(Object obj) { if (obj == null) { return "?"; } try { return htmlElementContent(obj.toString()); } catch (Exception e) { return null; } }
private static String getWebSocketAccept(String key) { byte[] digest = ConcurrentMessageDigest.digestSHA1( key.getBytes(StandardCharsets.ISO_8859_1), WS_ACCEPT); return Base64.encodeBase64String(digest); } }
public Principal authenticate(Realm realm) { // Second MD5 digest used to calculate the digest : // MD5(Method + ":" + uri) String a2 = method + ":" + uri; byte[] buffer = ConcurrentMessageDigest.digestMD5( a2.getBytes(StandardCharsets.ISO_8859_1)); String md5a2 = MD5Encoder.encode(buffer); return realm.authenticate(userName, response, nonce, nc, cnonce, qop, realmName, md5a2); }
private String encodeMD5(String value) throws NoSuchAlgorithmException { byte[] bytesOfMessage = value.getBytes(StandardCharsets.ISO_8859_1); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] thedigest = md.digest(bytesOfMessage); return MD5Encoder.encode(thedigest); }
/** * Escape content for use in XML. * * @param ifNull The value to return if content is {@code null} * @param content The content to escape * * @return The escaped content or the value of {@code ifNull} if the * content was {@code null} */ public static String xml(String ifNull, String content) { return xml(ifNull, false, content); }
public static byte[] digestSHA1(byte[]... input) { return digest(SHA1, input); }
@Override public void setAlgorithm(String algorithm) throws NoSuchAlgorithmException { ConcurrentMessageDigest.init(algorithm); this.algorithm = algorithm; }
private static String getWebSocketAccept(String key) { byte[] digest = ConcurrentMessageDigest.digestSHA1( key.getBytes(StandardCharsets.ISO_8859_1), WS_ACCEPT); return Base64.encodeBase64String(digest); } }
private String encodeMD5(String value) throws NoSuchAlgorithmException { byte[] bytesOfMessage = value.getBytes(StandardCharsets.ISO_8859_1); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] thedigest = md.digest(bytesOfMessage); return MD5Encoder.encode(thedigest); }
/** * Takes a potential expression and converts it into XML form. * @param expression The expression to convert * @return XML view */ public static String getExprInXml(String expression) { String returnString; int length = expression.length(); if (expression.startsWith(OPEN_EXPR) && expression.endsWith(CLOSE_EXPR)) { returnString = expression.substring(1, length - 1); } else { returnString = expression; } return Escape.xml(returnString); }
public static byte[] digestMD5(byte[]... input) { return digest(MD5, input); }
private static String getWebSocketAccept(String key) { byte[] digest = ConcurrentMessageDigest.digestSHA1( key.getBytes(StandardCharsets.ISO_8859_1), WS_ACCEPT); return Base64.encodeBase64String(digest); } }
public static byte[] digestMD5(byte[]... input) { return digest(MD5, input); }
public static byte[] digest(String algorithm, byte[]... input) { return digest(algorithm, 1, input); }