Tabnine Logo
ByteIterator
Code IndexAdd Tabnine to your IDE (free)

How to use
ByteIterator
in
org.wildfly.security.util

Best Java code snippets using org.wildfly.security.util.ByteIterator (Showing top 20 results out of 315)

origin: wildfly/wildfly

/**
 * Get a code point iterator for a UTF-8 encoded array.
 *
 * @param bytes the array
 * @param offs the array offset
 * @param len the number of characters to include
 * @return the code point iterator
 */
public static CodePointIterator ofUtf8Bytes(final byte[] bytes, final int offs, final int len) {
  if (len <= 0) {
    return EMPTY;
  }
  return ByteIterator.ofBytes(bytes, offs, len).asUtf8String();
}
origin: wildfly/wildfly

public int read(final byte[] b) throws IOException {
  final int result = drain(b);
  /* As drain(byte[] dst) never returns a negative result,
   * we need to perform some additional checks to honor
   * the contract of InputStream.read(byte[]). Citing from its JavaDoc:
   *
   * If the length of <code>b</code> is zero, then no bytes are read and
   * <code>0</code> is returned; otherwise, there is an attempt to read at
   * least one byte. If no byte is available because the stream is at the
   * end of the file, the value <code>-1</code> is returned; otherwise, at
   * least one byte is read and stored into <code>b</code>. */
  return result == 0 ? (b.length == 0 ? 0 : -1) : result;
}
origin: wildfly/wildfly

public ByteStringBuilder append(ByteIterator iterator) {
  return iterator.appendTo(this);
}
origin: wildfly/wildfly

public int read() throws IOException {
  return hasNext() ? next() : -1;
}
origin: wildfly/wildfly

/**
 * Get a code point iterator for a ISO-8859-1 (Latin-1) encoded array.
 *
 * @param bytes the array
 * @param offs the array offset
 * @param len the number of characters to include
 * @return the code point iterator
 */
public static CodePointIterator ofLatin1Bytes(final byte[] bytes, final int offs, final int len) {
  if (len <= 0) {
    return EMPTY;
  }
  return ByteIterator.ofBytes(bytes, offs, len).asLatin1String();
}
origin: wildfly/wildfly

public ByteIterator doFinal(MessageDigest digest) throws IllegalStateException {
  update(digest);
  return ByteIterator.ofBytes(digest.digest());
}
origin: wildfly/wildfly

/**
 * Get a byte iterator for a byte array.
 *
 * @param bytes the array
 * @return the byte iterator
 */
public static ByteIterator ofBytes(final byte... bytes) {
  return ofBytes(bytes, 0, bytes.length);
}
origin: wildfly/wildfly

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);
origin: wildfly/wildfly

public ByteIterator doFinal(Mac mac) throws IllegalStateException {
  return ByteIterator.ofBytes(mac.doFinal(drain()));
}
origin: wildfly/wildfly

public boolean hasPrev() {
  return offset > 0 && ByteIterator.this.hasPrev();
}
origin: wildfly/wildfly

public boolean hasNext() {
  return ByteIterator.this.hasNext();
}
origin: wildfly/wildfly

  @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;
  }
}
origin: wildfly/wildfly

public boolean hasNext() {
  return ByteIterator.this.hasNext() && ! isDelim(ByteIterator.this.peekNext());
}
origin: wildfly/wildfly

if (! hasNext()) {
  return CodePointIterator.EMPTY;
final int offset = offset();
return new CodePointIterator() {
  public boolean hasNext() {
origin: wildfly/wildfly

/**
 * Base32-encode the current stream.
 *
 * @param alphabet the alphabet to use
 * @return an iterator over the encoded characters
 */
public CodePointIterator base32Encode(final Base32Alphabet alphabet) {
  return base32Encode(alphabet, true);
}
origin: wildfly/wildfly

/**
 * Base64-encode the current stream.
 *
 * @param alphabet the alphabet to use
 * @return an iterator over the encoded characters
 */
public CodePointIterator base64Encode(final Base64Alphabet alphabet) {
  return base64Encode(alphabet, true);
}
origin: wildfly/wildfly

/**
 * Drain all the remaining bytes in this iterator.
 *
 * @return the remaining bytes as a single array
 */
public byte[] drain() {
  return drainTo(new ByteArrayOutputStream()).toByteArray();
}
origin: wildfly/wildfly

/**
 * Drain all the remaining bytes in this iterator to the given stream.
 *
 * @param stream the stream
 * @return the same stream
 */
public ByteArrayOutputStream drainTo(ByteArrayOutputStream stream) {
  while (hasNext()) {
    stream.write(next());
  }
  return stream;
}
origin: wildfly/wildfly

public ByteIterator sign(Signature signature) throws IllegalStateException {
  update(signature);
  try {
    return ByteIterator.ofBytes(signature.sign());
  } catch (SignatureException e) {
    throw new IllegalStateException(e);
  }
}
origin: wildfly/wildfly

/**
 * Get a byte iterator for a byte array with interleave.
 *
 * @param bytes the array
 * @param interleave the interleave table to use
 * @return the byte iterator
 */
public static ByteIterator ofBytes(final byte[] bytes, final int[] interleave) {
  return ofBytes(bytes, 0, bytes.length, interleave);
}
org.wildfly.security.utilByteIterator

Javadoc

A byte iterator.

Most used methods

  • asUtf8String
    Get this byte iterator as a UTF-8 string.
  • drain
    Drains up to len bytes from this iterator into the given dst array. An attempt is made to drain as m
  • ofBytes
    Get a byte iterator for a byte array with interleave.
  • appendTo
  • asLatin1String
    Get this byte iterator as a Latin-1 string.
  • base32Encode
    Base32-encode the current stream.
  • base64Encode
    Base64-encode the current stream.
  • drainTo
    Drain all the remaining bytes in this iterator to the given stream.
  • hasNext
    Determine if there are more bytes after the current byte.
  • hasPrev
    Determine if there are more bytes before the current byte.
  • hexEncode
    Hex-encode the current stream.
  • next
    Get the next byte.
  • hexEncode,
  • next,
  • offset,
  • peekNext,
  • peekPrev,
  • prev,
  • update,
  • hexDecode

Popular in Java

  • Finding current android device location
  • findViewById (Activity)
  • getApplicationContext (Context)
  • putExtra (Intent)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • JCheckBox (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now