| | |
| | | */ |
| | | public static char byteToASCII(byte b) |
| | | { |
| | | if ((b >= 32) && (b <= 126)) |
| | | if (32 <= b && b <= 126) |
| | | { |
| | | return (char) b; |
| | | } |
| | |
| | | */ |
| | | public static String bytesToHexNoSpace(byte[] b) |
| | | { |
| | | if ((b == null) || (b.length == 0)) |
| | | if (b == null || b.length == 0) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | */ |
| | | public static String bytesToHex(byte[] b) |
| | | { |
| | | if ((b == null) || (b.length == 0)) |
| | | if (b == null || b.length == 0) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | */ |
| | | public static String bytesToHex(ByteSequence b) |
| | | { |
| | | if ((b == null) || (b.length() == 0)) |
| | | if (b == null || b.length() == 0) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | */ |
| | | public static String bytesToColonDelimitedHex(byte[] b) |
| | | { |
| | | if ((b == null) || (b.length == 0)) |
| | | if (b == null || b.length == 0) |
| | | { |
| | | return ""; |
| | | } |
| | |
| | | |
| | | int length = b.length; |
| | | int pos = 0; |
| | | while ((length - pos) >= 16) |
| | | while (length - pos >= 16) |
| | | { |
| | | StringBuilder asciiBuf = new StringBuilder(17); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | int remaining = (length - pos); |
| | | int remaining = length - pos; |
| | | if (remaining > 0) |
| | | { |
| | | StringBuilder asciiBuf = new StringBuilder(remaining+1); |
| | |
| | | int limit = b.limit(); |
| | | int length = limit - position; |
| | | int pos = 0; |
| | | while ((length - pos) >= 16) |
| | | while (length - pos >= 16) |
| | | { |
| | | StringBuilder asciiBuf = new StringBuilder(17); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | int remaining = (length - pos); |
| | | int remaining = length - pos; |
| | | if (remaining > 0) |
| | | { |
| | | StringBuilder asciiBuf = new StringBuilder(remaining+1); |
| | |
| | | } |
| | | } |
| | | |
| | | return (a.length - a2.length); |
| | | return a.length - a2.length; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | if (list1 == null) |
| | | { |
| | | return (list2 == null); |
| | | return list2 == null; |
| | | } |
| | | else if (list2 == null) |
| | | { |
| | |
| | | */ |
| | | public static boolean objectsAreEqual(Object o1, Object o2) |
| | | { |
| | | if (o1 == null) |
| | | { |
| | | return (o2 == null); |
| | | } |
| | | else |
| | | { |
| | | return o1.equals(o2); |
| | | } |
| | | return Objects.equals(o1, o2); |
| | | } |
| | | |
| | | |
| | |
| | | message.append(")"); |
| | | return message.toMessage(); |
| | | } |
| | | else if ((t instanceof InvocationTargetException) && |
| | | (t.getCause() != null)) |
| | | else if (t instanceof InvocationTargetException && t.getCause() != null) |
| | | { |
| | | return getExceptionMessage(t.getCause()); |
| | | } |
| | |
| | | throws ParseException |
| | | { |
| | | int length; |
| | | if ((hexString == null) || ((length = hexString.length()) == 0)) |
| | | if (hexString == null || ((length = hexString.length()) == 0)) |
| | | { |
| | | return new byte[0]; |
| | | } |
| | |
| | | |
| | | |
| | | int pos = 0; |
| | | int arrayLength = (length / 2); |
| | | int arrayLength = length / 2; |
| | | byte[] returnArray = new byte[arrayLength]; |
| | | for (int i=0; i < arrayLength; i++) |
| | | { |
| | |
| | | public static boolean needsBase64Encoding(ByteSequence valueBytes) |
| | | { |
| | | int length; |
| | | if ((valueBytes == null) || ((length = valueBytes.length()) == 0)) |
| | | if (valueBytes == null || ((length = valueBytes.length()) == 0)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | |
| | | |
| | | // If the value ends with a space, then it needs to be base64-encoded. |
| | | if ((length > 1) && (valueBytes.byteAt(length-1) == 0x20)) |
| | | if (length > 1 && valueBytes.byteAt(length-1) == 0x20) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | for (int i = 0; i < valueBytes.length(); i++) |
| | | { |
| | | b = valueBytes.byteAt(i); |
| | | if ((b > 127) || (b < 0)) |
| | | if (b < 0 || 127 < b) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | public static boolean needsBase64Encoding(String valueString) |
| | | { |
| | | int length; |
| | | if ((valueString == null) || ((length = valueString.length()) == 0)) |
| | | if (valueString == null || ((length = valueString.length()) == 0)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | |
| | | |
| | | // If the value ends with a space, then it needs to be base64-encoded. |
| | | if ((length > 1) && (valueString.charAt(length-1) == ' ')) |
| | | if (length > 1 && valueString.charAt(length-1) == ' ') |
| | | { |
| | | return true; |
| | | } |
| | |
| | | for (int i=0; i < length; i++) |
| | | { |
| | | char c = valueString.charAt(i); |
| | | if ((c <= 0) || (c == 0x0A) || (c == 0x0D) || (c > 127)) |
| | | if (c <= 0 || c == 0x0A || c == 0x0D || c > 127) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | */ |
| | | public static boolean mayUseExec() |
| | | { |
| | | return (! DirectoryServer.getEnvironmentConfig().disableExec()); |
| | | return !DirectoryServer.getEnvironmentConfig().disableExec(); |
| | | } |
| | | |
| | | |
| | |
| | | ProcessBuilder processBuilder = new ProcessBuilder(commandAndArgs); |
| | | processBuilder.redirectErrorStream(true); |
| | | |
| | | if ((workingDirectory != null) && workingDirectory.isDirectory()) |
| | | if (workingDirectory != null && workingDirectory.isDirectory()) |
| | | { |
| | | processBuilder.directory(workingDirectory); |
| | | } |
| | | |
| | | if ((environment != null) && (! environment.isEmpty())) |
| | | if (environment != null && !environment.isEmpty()) |
| | | { |
| | | processBuilder.environment().putAll(environment); |
| | | } |
| | |
| | | int endPos, |
| | | LocalizableMessageBuilder invalidReason) |
| | | { |
| | | if ((element == null) || (startPos >= endPos)) |
| | | if (element == null || startPos >= endPos) |
| | | { |
| | | invalidReason.append(ERR_SCHEMANAME_EMPTY_VALUE.get()); |
| | | return false; |
| | |
| | | // This should indicate an OID, but it may also be a name if name |
| | | // exceptions are enabled. Since we don't know for sure, we'll just |
| | | // hold off until we know for sure. |
| | | boolean isKnown = (! DirectoryServer.allowAttributeNameExceptions()); |
| | | boolean isKnown = !DirectoryServer.allowAttributeNameExceptions(); |
| | | boolean isNumeric = true; |
| | | boolean lastWasDot = false; |
| | | |
| | |
| | | { |
| | | lastWasDot = false; |
| | | |
| | | if (isAlpha(c) || (c == '-') || (c == '_')) |
| | | if (isAlpha(c) || c == '-' || c == '_') |
| | | { |
| | | if (isKnown) |
| | | { |
| | |
| | | { |
| | | case ' ': |
| | | // If we don't care about trimming, then we can always append the |
| | | // space. Otherwise, only do so if there are other characters in the |
| | | // value. |
| | | if (trim && (bufferLength == 0)) |
| | | // space. Otherwise, only do so if there are other characters in the value. |
| | | if (trim && bufferLength == 0) |
| | | { |
| | | break; |
| | | } |
| | |
| | | { |
| | | case ' ': |
| | | // If we don't care about trimming, then we can always append the |
| | | // space. Otherwise, only do so if there are other characters in the |
| | | // value. |
| | | if (trim && (bufferLength == 0)) |
| | | // space. Otherwise, only do so if there are other characters in the value. |
| | | if (trim && bufferLength == 0) |
| | | { |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | return (successful & file.delete()); |
| | | return successful & file.delete(); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | public static boolean isRelativePath(String path) |
| | | { |
| | | File f = new File(path); |
| | | return (! f.isAbsolute()); |
| | | return !f.isAbsolute(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | // If the provided DN was null or empty, then return null because we don't |
| | | // support it. |
| | | if ((dn == null) || dn.isRootDN()) |
| | | if (dn == null || dn.isRootDN()) |
| | | { |
| | | return null; |
| | | } |
| | |
| | | |
| | | // First, see if this type is allowed by the untypedObject class. If not, |
| | | // then we'll need to include the extensibleObject class. |
| | | if ((! structuralClass.isRequiredOrOptional(attrType)) && |
| | | (! extensibleObjectAdded)) |
| | | if (!structuralClass.isRequiredOrOptional(attrType) && !extensibleObjectAdded) |
| | | { |
| | | ObjectClass extensibleObjectOC = |
| | | DirectoryServer.getObjectClass(OC_EXTENSIBLE_OBJECT_LC); |
| | |
| | | // fall back |
| | | // to a more inefficient way that will work without a selector. |
| | | while (buffer.hasRemaining() |
| | | && (System.currentTimeMillis() < stopTime)) |
| | | && System.currentTimeMillis() < stopTime) |
| | | { |
| | | if (socketChannel.write(buffer) < 0) |
| | | { |