@Override public boolean verifyCertificate(X509Certificate certificate, Attributes attributes) throws NamingException, RealmUnavailableException { Attribute attribute = attributes.get(ldapAttribute); if (attribute == null) return false; final int size = attribute.size(); try { MessageDigest md = MessageDigest.getInstance(algorithm); String digest = ByteIterator.ofBytes(md.digest(certificate.getEncoded())).hexEncode(true).drainToString(); for (int i = 0; i < size; i++) { Object attrDigest = attribute.get(i); if (attrDigest != null){ if (digest.equalsIgnoreCase((String) attrDigest)) { return true; } } } } catch (NoSuchAlgorithmException | CertificateEncodingException e) { throw new RealmUnavailableException(e); } return false; } }
/** * Determine if the remaining contents of this iterator are identical to the given string. If the * contents are not equal, the iterator will be positioned at the location of the first difference (i.e. the code point * returned by {@link #next()} will be the differing code point. If the contents are equal, the iterator will be * positioned at the end of its contents. * * @param other the other string * @return {@code true} if the contents are equal, {@code false} otherwise */ public boolean contentEquals(String other) { return contentEquals(CodePointIterator.ofString(other)); }
/** * Get a byte iterator over the UTF-8 encoding of this code point iterator. * * @return the byte iterator */ public ByteIterator asUtf8() { return asUtf8(false); }
/** * Drain all the remaining code points in this iterator to a new string, * inserting the given delimiter after every {@code n} code points. * * @param delim the delimiter * @param n the number of code points between each delimiter * @return the string */ public String drainToString(final int delim, final int n) { return hasNext() ? drainTo(new StringBuilder(), null, delim, n).toString() : ""; }
final String b64Password = getProperty(properties, prefix + PROPERTY_KEY_PASSWORD_BASE64, null, expandPasswords); if (b64Password != null) { setPassword(CodePointIterator.ofString(b64Password).base64Decode().asUtf8String().drainToString()); } else { final String password = getProperty(properties, prefix + PROPERTY_KEY_PASSWORD, null, expandPasswords);
/** * Determine if the remaining contents of this iterator are identical to the remaining contents of the other iterator. If the * contents are not equal, the iterators will be positioned at the location of the first difference (i.e. the code point * returned by {@link #next()} will be the differing code point. If the contents are equal, the iterators will both be * positioned at the end of their contents. * * @param other the other byte iterator * @return {@code true} if the contents are equal, {@code false} otherwise */ public final boolean contentEquals(CodePointIterator other) { for (;;) { if (hasNext()) { if (! other.hasNext()) { return false; } if (peekNext() != other.peekNext()) { return false; } next(); other.next(); } else { return ! other.hasNext(); } } }
public int next() throws NoSuchElementException { final int v = CodePointIterator.this.next(); return v > 255 ? '?' : v; }
public boolean hasPrev() { return st != 0 || CodePointIterator.this.hasPrev(); }
/** * Get a code point iterator for a string. * * @param string the string * @return the code point iterator */ public static CodePointIterator ofString(final String string) { return ofString(string, 0, string.length()); }
public boolean hasNext() { return st != 0 || CodePointIterator.this.hasNext(); }
/** * Drain all the remaining code points in this iterator to the given string builder, * inserting the given prefix before every {@code n} code points. * * @param b the string builder * @param prefix the prefix * @param n the number of code points between each prefix * @return the same string builder */ public StringBuilder drainTo(StringBuilder b, final String prefix, final int n) { return drainTo(b, prefix, -1, n); }
/** * Get a code point iterator for a character array. * * @param chars the array * @return the code point iterator */ public static CodePointIterator ofChars(final char[] chars) { return ofChars(chars, 0, chars.length); }
globalAuthConf = globalAuthConf.useCredentials(credentials); } else if (passwordBase64 != null) { globalAuthConf = globalAuthConf.usePassword(CodePointIterator.ofString(passwordBase64).base64Decode().asUtf8String().drainToString()); authConfig = authConfig.usePassword(connPassword); } else if (connPasswordBase64 != null) { authConfig = authConfig.usePassword(CodePointIterator.ofString(connPasswordBase64).base64Decode().asUtf8String().drainToString());
/** * Drain all the remaining code points in this iterator to a new string, * inserting the given prefix before every {@code n} code points. * * @param prefix the prefix * @param n the number of code points between each prefix * @return the string */ public String drainToString(final String prefix, final int n) { return hasNext() ? drainTo(new StringBuilder(), prefix, -1, n).toString() : ""; }