use of com.unboundid.ldap.sdk.LDAPRuntimeException in project ldapsdk by pingidentity.
the class LogFieldSyntax method sha256.
/**
* Retrieves a SHA-256 digest of the contents of the provided buffer.
*
* @param buffer The buffer containing the data to digest. It must not be
* {@code null}.
*
* @return The bytes that comprise the SHA-256 digest.
*/
@NotNull()
protected final byte[] sha256(@NotNull final ByteStringBuffer buffer) {
MessageDigest digest = threadLocalDigests.get();
if (digest == null) {
try {
digest = CryptoHelper.getMessageDigest(TOKEN_DIGEST_ALGORITHM);
} catch (final Exception e) {
Debug.debugException(e);
throw new LDAPRuntimeException(new LDAPException(ResultCode.ENCODING_ERROR, ERR_LOG_SYNTAX_TOKENIZE_DIGEST_ERROR.get(TOKEN_DIGEST_ALGORITHM), e));
}
}
digest.update(buffer.getBackingArray(), 0, buffer.length());
return digest.digest();
}
use of com.unboundid.ldap.sdk.LDAPRuntimeException in project ldapsdk by pingidentity.
the class StreamFileValuePatternComponent method append.
/**
* {@inheritDoc}
*/
@Override()
void append(@NotNull final StringBuilder buffer) {
String line = lineQueue.poll();
if (line != null) {
buffer.append(line);
return;
}
while (true) {
try {
StreamFileValuePatternReaderThread readerThread;
synchronized (this) {
readerThread = threadRef.get();
if (readerThread == null) {
readerThread = new StreamFileValuePatternReaderThread(file, lineQueue, maxOfferBlockTimeMillis, nextReadPosition, threadRef);
threadRef.set(readerThread);
readerThread.start();
}
}
line = lineQueue.poll(10L, TimeUnit.MILLISECONDS);
if (line != null) {
buffer.append(line);
return;
}
} catch (final Exception e) {
Debug.debugException(e);
throw new LDAPRuntimeException(new LDAPException(ResultCode.LOCAL_ERROR, ERR_STREAM_FILE_VALUE_PATTERN_ERROR_GETTING_NEXT_VALUE.get(file.getAbsolutePath(), StaticUtils.getExceptionMessage(e)), e));
}
}
}
use of com.unboundid.ldap.sdk.LDAPRuntimeException in project ldapsdk by pingidentity.
the class ValuesOnlyLDAPResultWriter method writeSearchResultEntry.
/**
* {@inheritDoc}
*/
@Override()
public void writeSearchResultEntry(@NotNull final SearchResultEntry entry) {
try {
for (final Attribute a : entry.getAttributes()) {
for (final byte[] value : a.getValueByteArrays()) {
getPrintStream().write(value);
getPrintStream().write(StaticUtils.EOL_BYTES);
}
}
} catch (final Exception e) {
Debug.debugException(e);
throw new LDAPRuntimeException(new LDAPException(ResultCode.OTHER, ERR_VALUES_ONLY_OUTPUT_FORMAT_WRITE_ERROR.get(StaticUtils.getExceptionMessage(e)), e));
}
}
use of com.unboundid.ldap.sdk.LDAPRuntimeException in project ldapsdk by pingidentity.
the class JSONLDAPResultWriter method toJSON.
/**
* Encodes the provided LDAP result as a JSON object.
*
* @param result The LDAP result to be encoded as a JSON object. It must
* not be {@code null}.
*
* @return The JSON object containing the encoded representation of the
* LDAP result.
*/
@NotNull()
public static JSONObject toJSON(@NotNull final LDAPResult result) {
try {
final JSONBuffer jsonBuffer = new JSONBuffer();
toJSON(result, jsonBuffer);
return jsonBuffer.toJSONObject();
} catch (final JSONException e) {
// This should never happen.
Debug.debugException(e);
throw new LDAPRuntimeException(new LDAPException(ResultCode.ENCODING_ERROR, e.getMessage(), e));
}
}
use of com.unboundid.ldap.sdk.LDAPRuntimeException in project ldapsdk by pingidentity.
the class JSONLDAPResultWriter method toJSON.
/**
* Encodes the provided entry as a JSON object.
*
* @param entry The entry to be encoded as a JSON object. It must not be
* {@code null}.
*
* @return The JSON object containing the encoded representation of the
* entry.
*/
@NotNull()
public static JSONObject toJSON(@NotNull final Entry entry) {
try {
final JSONBuffer jsonBuffer = new JSONBuffer();
toJSON(entry, jsonBuffer);
return jsonBuffer.toJSONObject();
} catch (final JSONException e) {
// This should never happen.
Debug.debugException(e);
throw new LDAPRuntimeException(new LDAPException(ResultCode.ENCODING_ERROR, e.getMessage(), e));
}
}
Aggregations