Autorefactored simplifying expressions:
- removed useless parentheses
- added parentheses to disambiguate expressions
- removed useless use of "this" keyword in method calls
- removed useless null checks in conjunction with use of instanceof operator
*.java:
Manually extracted local variables.
OperatingSystem.java:
Manually changed the code to use String.contains()
| | |
| | | this.description = description; |
| | | this.isValueSetByProperty = false; |
| | | |
| | | if ((shortIdentifier == null) && (longIdentifier == null)) { |
| | | if (shortIdentifier == null && longIdentifier == null) { |
| | | final LocalizableMessage message = ERR_ARG_NO_IDENTIFIER.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | | if (needsValue && (valuePlaceholder == null)) { |
| | | if (needsValue && valuePlaceholder == null) { |
| | | final LocalizableMessage message = ERR_ARG_NO_VALUE_PLACEHOLDER.get(name); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | * <CODE>false</CODE> if it does not have any values. |
| | | */ |
| | | public boolean hasValue() { |
| | | return (!values.isEmpty()); |
| | | return !values.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | // new argument should replace |
| | | for (final Iterator<Argument> it = this.args.iterator(); it.hasNext();) { |
| | | final Argument a = it.next(); |
| | | if (newShort != null && newShort.equals(a.getShortIdentifier()) || newLong != null |
| | | && newLong.equals(a.getLongIdentifier())) { |
| | | if ((newShort != null && newShort.equals(a.getShortIdentifier())) |
| | | || (newLong != null && newLong.equals(a.getLongIdentifier()))) { |
| | | it.remove(); |
| | | break; |
| | | } |
| | |
| | | callbacks.put(String.valueOf(i + 1), numericCallbacks.get(i)); |
| | | |
| | | // Second column. |
| | | if (useMultipleColumns && (j < sz)) { |
| | | if (useMultipleColumns && j < sz) { |
| | | nbuilder.appendCell(INFO_MENU_NUMERIC_OPTION.get(j + 1)); |
| | | |
| | | for (LocalizableMessage field : numericFields.get(j)) { |
| | |
| | | if (requestedSize == 0) { |
| | | // Calculate size based on requested actual size as a |
| | | // proportion of the total. |
| | | requestedSize = ((actualSize * available) / expandableColumnSize); |
| | | requestedSize = (actualSize * available) / expandableColumnSize; |
| | | columnWidths.set(i, requestedSize); |
| | | } |
| | | } |
| | |
| | | public static boolean isCertificateException(Throwable t) { |
| | | boolean returnValue = false; |
| | | |
| | | while (!returnValue && (t != null)) { |
| | | returnValue = (t instanceof SSLHandshakeException) || (t instanceof GeneralSecurityException); |
| | | while (!returnValue && t != null) { |
| | | returnValue = t instanceof SSLHandshakeException || t instanceof GeneralSecurityException; |
| | | t = t.getCause(); |
| | | } |
| | | |
| | |
| | | return file.canWrite(); |
| | | } |
| | | final File parentFile = file.getParentFile(); |
| | | return (parentFile != null && parentFile.canWrite()); |
| | | return parentFile != null && parentFile.canWrite(); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | private static boolean isOutOfMemory(Throwable t) { |
| | | boolean isOutOfMemory = false; |
| | | while (!isOutOfMemory && (t != null)) { |
| | | while (!isOutOfMemory && t != null) { |
| | | if (t instanceof OutOfMemoryError) { |
| | | isOutOfMemory = true; |
| | | } else if (t instanceof IOException) { |
| | |
| | | */ |
| | | @BeforeClass |
| | | public void setup() throws Exception { |
| | | parser = new SubCommandArgumentParser(this.getClass().getName(), LocalizableMessage.raw("test description"), |
| | | true); |
| | | parser = new SubCommandArgumentParser(getClass().getName(), LocalizableMessage.raw("test description"), true); |
| | | |
| | | sc1 = new SubCommand(parser, "sub-command1", INFO_BACKUPDB_DESCRIPTION_BACKEND_ID.get()); |
| | | sc2 = new SubCommand(parser, "sub-command2", true, 2, 4, "args1 arg2 [arg3 arg4]", |
| | |
| | | */ |
| | | @Test |
| | | public void testAllowsTrailingArgumentsFalse1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX")); |
| | | Assert.assertFalse(sc.allowsTrailingArguments()); |
| | |
| | | */ |
| | | @Test |
| | | public void testAllowsTrailingArgumentsFalse2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, LocalizableMessage.raw("XXX")); |
| | | Assert.assertFalse(sc.allowsTrailingArguments()); |
| | |
| | | */ |
| | | @Test |
| | | public void testAllowsTrailingArgumentsTrue() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, "args1 arg2 [arg3 arg4]", |
| | | LocalizableMessage.raw("XXX")); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetMaxTrailingArguments1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX")); |
| | | Assert.assertEquals(sc.getMaxTrailingArguments(), 0); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetMaxTrailingArguments2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, LocalizableMessage.raw("XXX")); |
| | | Assert.assertEquals(sc.getMaxTrailingArguments(), 0); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetMaxTrailingArguments3() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, "args1 arg2 [arg3 arg4]", |
| | | LocalizableMessage.raw("XXX")); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetMinTrailingArguments1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX")); |
| | | Assert.assertEquals(sc.getMinTrailingArguments(), 0); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetMinTrailingArguments2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, LocalizableMessage.raw("XXX")); |
| | | Assert.assertEquals(sc.getMinTrailingArguments(), 0); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetMinTrailingArguments3() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, "args1 arg2 [arg3 arg4]", |
| | | LocalizableMessage.raw("XXX")); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetTrailingArgumentsDisplayName1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX")); |
| | | Assert.assertNull(sc.getTrailingArgumentsDisplayName()); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetTrailingArgumentsDisplayName2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, LocalizableMessage.raw("XXX")); |
| | | Assert.assertNull(sc.getTrailingArgumentsDisplayName()); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetTrailingArgumentsDisplayName3() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, "args1 arg2 [arg3 arg4]", |
| | | LocalizableMessage.raw("XXX")); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetTrailingArguments1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX")); |
| | | parser.parseArguments(new String[] { "sub-command1" }); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetTrailingArguments2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, LocalizableMessage.raw("XXX")); |
| | | parser.parseArguments(new String[] { "sub-command2" }); |
| | |
| | | */ |
| | | @Test |
| | | public void testGetTrailingArguments3() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this.getClass().getName(), |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(getClass().getName(), |
| | | LocalizableMessage.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, "args1 arg2 [arg3 arg4]", |
| | | LocalizableMessage.raw("XXX")); |
| | |
| | | * definition was not found. |
| | | */ |
| | | public final AbstractManagedObjectDefinition<? extends C, ? extends S> getChild(String name) { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | if (name == null || name.length() == 0) { |
| | | throw new IllegalArgumentException("null or empty managed object name"); |
| | | } |
| | | |
| | |
| | | * requested property definition was not found. |
| | | */ |
| | | public final PropertyDefinition<?> getPropertyDefinition(String name) { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | if (name == null || name.length() == 0) { |
| | | throw new IllegalArgumentException("null or empty property name"); |
| | | } |
| | | |
| | |
| | | * requested relation definition was not found. |
| | | */ |
| | | public final RelationDefinition<?, ?> getRelationDefinition(String name) { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | if (name == null || name.length() == 0) { |
| | | throw new IllegalArgumentException("null or empty relation name"); |
| | | } |
| | | |
| | |
| | | * found. |
| | | */ |
| | | public final AggregationPropertyDefinition<?, ?> getAggregationPropertyDefinition(String name) { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | if (name == null || name.length() == 0) { |
| | | throw new IllegalArgumentException("null or empty aggregation property name"); |
| | | } |
| | | |
| | |
| | | * the {@link TopCfgDefn}. |
| | | */ |
| | | public final boolean isTop() { |
| | | return (this instanceof TopCfgDefn); |
| | | return this instanceof TopCfgDefn; |
| | | } |
| | | |
| | | /** |
| | |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (nvalue > upperLimit)) { |
| | | if (upperLimit != null && nvalue > upperLimit) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | |
| | | |
| | | // Check the unit is in range - values must not be more granular |
| | | // than the base unit. |
| | | if ((ms % baseUnit.getDuration()) != 0) { |
| | | if (ms % baseUnit.getDuration() != 0) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | |
| | | * @return Returns milliseconds in this unit. |
| | | */ |
| | | public double fromMilliSeconds(long duration) { |
| | | return ((double) duration / sz); |
| | | return (double) duration / sz; |
| | | } |
| | | |
| | | /** |
| | |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (value > upperLimit)) { |
| | | if (upperLimit != null && value > upperLimit) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (value > upperLimit)) { |
| | | if (upperLimit != null && value > upperLimit) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | |
| | | * @return Returns size in this unit. |
| | | */ |
| | | public double fromBytes(long amount) { |
| | | return ((double) amount / sz); |
| | | return (double) amount / sz; |
| | | } |
| | | |
| | | /** |
| | |
| | | if (value > Long.MAX_VALUE) { |
| | | throw new NumberFormatException("number too big (exceeded long.MAX_VALUE"); |
| | | } |
| | | return (long) (value); |
| | | return (long) value; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public final void close() { |
| | | this.getDriver().close(); |
| | | getDriver().close(); |
| | | } |
| | | |
| | | } |
| | |
| | | builder.appendCell("*)"); |
| | | builder.appendCell(valuePrinter.print(pd, vl.get(i))); |
| | | |
| | | if (useMultipleColumns && (j < sz)) { |
| | | if (useMultipleColumns && j < sz) { |
| | | builder.appendCell(); |
| | | builder.appendCell("*)"); |
| | | builder.appendCell(valuePrinter.print(pd, vl.get(j))); |
| | |
| | | extractIntermediateListener(ConfigAddListener configListener) { |
| | | // @Checkstyle:on |
| | | if (configListener instanceof ConfigAddListenerAdaptor) { |
| | | ConfigAddListenerAdaptor<T> adaptor = ((ConfigAddListenerAdaptor<T>) configListener); |
| | | ConfigAddListenerAdaptor<T> adaptor = (ConfigAddListenerAdaptor<T>) configListener; |
| | | return Pair.of(adaptor, adaptor.getServerManagedObjectAddListener()); |
| | | } |
| | | return Pair.empty(); |
| | |
| | | int i = delayWrappers; |
| | | for (; i > 0; i--) { |
| | | wrappedListener = delayListener.getDelayedAddListener(); |
| | | if (wrappedListener != null && wrappedListener instanceof DelayedConfigAddListener) { |
| | | if (wrappedListener instanceof DelayedConfigAddListener) { |
| | | delayListener = (DelayedConfigAddListener) configListener; |
| | | } else { |
| | | break; |
| | |
| | | |
| | | ConfigAddListener delayedListener = delayListener.getDelayedAddListener(); |
| | | |
| | | if (delayedListener != null && delayedListener instanceof ConfigAddListenerAdaptor) { |
| | | if (delayedListener instanceof ConfigAddListenerAdaptor) { |
| | | ConfigAddListenerAdaptor<?> adaptor = (ConfigAddListenerAdaptor<?>) delayedListener; |
| | | ServerManagedObjectAddListener<?> l2 = adaptor.getServerManagedObjectAddListener(); |
| | | if (l2 instanceof ServerManagedObjectAddListenerAdaptor<?>) { |
| | |
| | | int i = delayWrappers; |
| | | for (; i > 0; i--) { |
| | | wrappedListener = delayListener.getDelayedAddListener(); |
| | | if (wrappedListener != null && wrappedListener instanceof DelayedConfigAddListener) { |
| | | if (wrappedListener instanceof DelayedConfigAddListener) { |
| | | delayListener = (DelayedConfigAddListener) l; |
| | | } else { |
| | | break; |
| | |
| | | |
| | | ConfigDeleteListener delayedListener = delayListener.getDelayedDeleteListener(); |
| | | |
| | | if (delayedListener != null && delayedListener instanceof ConfigDeleteListenerAdaptor) { |
| | | if (delayedListener instanceof ConfigDeleteListenerAdaptor) { |
| | | ConfigDeleteListenerAdaptor<?> adaptor = (ConfigDeleteListenerAdaptor<?>) delayedListener; |
| | | ServerManagedObjectDeleteListener<?> l2 = adaptor.getServerManagedObjectDeleteListener(); |
| | | if (l2 instanceof ServerManagedObjectDeleteListenerAdaptor<?>) { |
| | |
| | | int i = delayWrappers; |
| | | for (; i > 0; i--) { |
| | | wrappedListener = delayListener.getDelayedAddListener(); |
| | | if (wrappedListener != null && wrappedListener instanceof DelayedConfigAddListener) { |
| | | if (wrappedListener instanceof DelayedConfigAddListener) { |
| | | delayListener = (DelayedConfigAddListener) configListener; |
| | | } else { |
| | | break; |
| | |
| | | |
| | | ConfigAddListener delayedListener = delayListener.getDelayedAddListener(); |
| | | |
| | | if (delayedListener != null && delayedListener instanceof ConfigAddListenerAdaptor) { |
| | | if (delayedListener instanceof ConfigAddListenerAdaptor) { |
| | | ConfigAddListenerAdaptor<?> adaptor = (ConfigAddListenerAdaptor<?>) delayedListener; |
| | | if (adaptor.getServerManagedObjectAddListener() == listener) { |
| | | configRepository.deregisterAddListener(parentDN, configListener); |
| | |
| | | int i = delayWrappers; |
| | | for (; i > 0; i--) { |
| | | wrappedListener = delayListener.getDelayedAddListener(); |
| | | if (wrappedListener != null && wrappedListener instanceof DelayedConfigAddListener) { |
| | | if (wrappedListener instanceof DelayedConfigAddListener) { |
| | | delayListener = (DelayedConfigAddListener) configListener; |
| | | } else { |
| | | break; |
| | |
| | | |
| | | ConfigDeleteListener delayedListener = delayListener.getDelayedDeleteListener(); |
| | | |
| | | if (delayedListener != null && delayedListener instanceof ConfigDeleteListenerAdaptor) { |
| | | if (delayedListener instanceof ConfigDeleteListenerAdaptor) { |
| | | ConfigDeleteListenerAdaptor<?> adaptor = (ConfigDeleteListenerAdaptor<?>) delayedListener; |
| | | if (adaptor.getServerManagedObjectDeleteListener() == listener) { |
| | | configRepository.deregisterAddListener(parentDN, configListener); |
| | |
| | | // Get the configuration entry. |
| | | DN targetDN = DNBuilder.create(path); |
| | | try { |
| | | return (configRepository.getEntry(targetDN) != null); |
| | | return configRepository.getEntry(targetDN) != null; |
| | | } catch (ConfigException e) { |
| | | // Assume it doesn't exist. |
| | | return false; |
| | |
| | | final ExtendedRequest<?> request, final DecodeOptions options) |
| | | throws DecodeException { |
| | | final ByteString requestValue = request.getValue(); |
| | | if ((requestValue == null) || (requestValue.length() <= 0)) { |
| | | if (requestValue == null || requestValue.length() <= 0) { |
| | | throw DecodeException.error(ERR_PWPSTATE_EXTOP_NO_REQUEST_VALUE.get()); |
| | | } |
| | | try { |
| | |
| | | } |
| | | |
| | | final String lowerName = osName.toLowerCase(); |
| | | if ((lowerName.indexOf("solaris") >= 0) || (lowerName.indexOf("sunos") >= 0)) { |
| | | if (lowerName.contains("solaris") || lowerName.contains("sunos")) { |
| | | return SOLARIS; |
| | | } else if (lowerName.indexOf("linux") >= 0) { |
| | | } else if (lowerName.contains("linux")) { |
| | | return LINUX; |
| | | } else if ((lowerName.indexOf("hp-ux") >= 0) || (lowerName.indexOf("hp ux") >= 0) |
| | | || (lowerName.indexOf("hpux") >= 0)) { |
| | | } else if (lowerName.contains("hp-ux") |
| | | || lowerName.contains("hp ux") |
| | | || lowerName.contains("hpux")) { |
| | | return HPUX; |
| | | } else if (lowerName.indexOf("aix") >= 0) { |
| | | } else if (lowerName.contains("aix")) { |
| | | return AIX; |
| | | } else if (lowerName.indexOf("windows") >= 0) { |
| | | } else if (lowerName.contains("windows")) { |
| | | if (lowerName.indexOf("windows 7") != -1) { |
| | | return WINDOWS7; |
| | | } else if (lowerName.indexOf("vista") != -1) { |
| | |
| | | return WINDOWS_SERVER_2008; |
| | | } |
| | | return WINDOWS; |
| | | } else if ((lowerName.indexOf("freebsd") >= 0) || (lowerName.indexOf("free bsd") >= 0)) { |
| | | } else if (lowerName.contains("freebsd") || lowerName.contains("free bsd")) { |
| | | return FREEBSD; |
| | | } else if ((lowerName.indexOf("macos x") >= 0) || (lowerName.indexOf("mac os x") >= 0)) { |
| | | } else if (lowerName.contains("macos x") || lowerName.contains("mac os x")) { |
| | | return MACOSX; |
| | | } else if (lowerName.indexOf("z/os") >= 0) { |
| | | } else if (lowerName.contains("z/os")) { |
| | | return ZOS; |
| | | } |
| | | return UNKNOWN; |
| | |
| | | } |
| | | } |
| | | } else { |
| | | if ((throwable instanceof InvocationTargetException) && (throwable.getCause() != null)) { |
| | | if (throwable instanceof InvocationTargetException && throwable.getCause() != null) { |
| | | throwable = throwable.getCause(); |
| | | } |
| | | // add class name and message of the exception |
| | |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | | |
| | | if ((peekLength < 1) || (peekLength > 4)) { |
| | | if (peekLength < 1 || peekLength > 4) { |
| | | final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | | |
| | | if ((peekLength < 1) || (peekLength > 8)) { |
| | | if (peekLength < 1 || peekLength > 8) { |
| | | final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | long longValue = 0; |
| | | for (int i = 0; i < peekLength; i++) { |
| | | final int readByte = reader.get(); |
| | | if ((i == 0) && (readByte < 0)) { |
| | | if (i == 0 && readByte < 0) { |
| | | longValue = 0xFFFFFFFFFFFFFFFFL; |
| | | } |
| | | longValue = (longValue << 8) | (readByte & 0xFF); |
| | |
| | | int intValue = 0; |
| | | for (int i = 0; i < peekLength; i++) { |
| | | final int readByte = reader.get(); |
| | | if ((i == 0) && (readByte < 0)) { |
| | | if (i == 0 && readByte < 0) { |
| | | intValue = 0xFFFFFFFF; |
| | | } |
| | | intValue = (intValue << 8) | (readByte & 0xFF); |
| | |
| | | |
| | | // Make sure that the element is not larger than the maximum allowed |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) { |
| | | if (maxElementSize > 0 && peekLength > maxElementSize) { |
| | | final LocalizableMessage message = |
| | | ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | .get(peekLength, maxElementSize); |
| | |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | | |
| | | if ((peekLength < 1) || (peekLength > 4)) { |
| | | if (peekLength < 1 || peekLength > 4) { |
| | | final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | | |
| | | if ((peekLength < 1) || (peekLength > 8)) { |
| | | if (peekLength < 1 || peekLength > 8) { |
| | | final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | ERR_ASN1_INTEGER_TRUNCATED_VALUE.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | if ((i == 0) && (((byte) readByte) < 0)) { |
| | | if (i == 0 && ((byte) readByte) < 0) { |
| | | longValue = 0xFFFFFFFFFFFFFFFFL; |
| | | } |
| | | longValue = (longValue << 8) | (readByte & 0xFF); |
| | |
| | | ERR_ASN1_INTEGER_TRUNCATED_VALUE.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | | if ((i == 0) && (((byte) readByte) < 0)) { |
| | | if (i == 0 && ((byte) readByte) < 0) { |
| | | intValue = 0xFFFFFFFF; |
| | | } |
| | | intValue = (intValue << 8) | (readByte & 0xFF); |
| | |
| | | |
| | | // Make sure that the element is not larger than the maximum allowed |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) { |
| | | if (maxElementSize > 0 && peekLength > maxElementSize) { |
| | | final LocalizableMessage message = |
| | | ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | .get(peekLength, maxElementSize); |
| | |
| | | */ |
| | | private boolean needFirstLengthByteState(final boolean isBlocking, |
| | | final boolean throwEofException) throws IOException { |
| | | if (!isBlocking && (in.available() <= 0)) { |
| | | if (!isBlocking && in.available() <= 0) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | return false; |
| | | } |
| | | peekLength = (readByte & 0x7F); |
| | | peekLength = readByte & 0x7F; |
| | | if (peekLength != readByte) { |
| | | lengthBytesNeeded = peekLength; |
| | | if (lengthBytesNeeded > 4) { |
| | |
| | | |
| | | // Make sure that the element is not larger than the maximum allowed |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) { |
| | | if (maxElementSize > 0 && peekLength > maxElementSize) { |
| | | final LocalizableMessage message = |
| | | ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | .get(peekLength, maxElementSize); |
| | |
| | | private boolean needTypeState(final boolean isBlocking, final boolean throwEofException) |
| | | throws IOException { |
| | | // Read just the type. |
| | | if (!isBlocking && (in.available() <= 0)) { |
| | | if (!isBlocking && in.available() <= 0) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | if (str.length() > 0) { |
| | | char c = str.charAt(0); |
| | | int startPos = 0; |
| | | if ((c == ' ') || (c == '#')) { |
| | | if (c == ' ' || c == '#') { |
| | | builder.append('\\'); |
| | | builder.append(c); |
| | | startPos = 1; |
| | |
| | | } |
| | | |
| | | int pos = 0; |
| | | final int arrayLength = (length / 2); |
| | | final int arrayLength = length / 2; |
| | | final byte[] hexArray = new byte[arrayLength]; |
| | | for (int i = 0; i < arrayLength; i++) { |
| | | switch (hexBuffer.charAt(pos++)) { |
| | |
| | | ERR_ATTR_SYNTAX_DN_HEX_VALUE_TOO_SHORT.get(reader.getString()); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | | } else if ((c == ' ') || (c == ',') || (c == ';')) { |
| | | } else if (c == ' ' || c == ',' || c == ';') { |
| | | // This denotes the end of the value. |
| | | break; |
| | | } else { |
| | |
| | | return true; |
| | | } else if (object instanceof Entry) { |
| | | final Entry other = (Entry) object; |
| | | if (!this.getName().equals(other.getName())) { |
| | | if (!getName().equals(other.getName())) { |
| | | return false; |
| | | } |
| | | // Distinguished name is the same, compare attributes. |
| | | if (this.getAttributeCount() != other.getAttributeCount()) { |
| | | if (getAttributeCount() != other.getAttributeCount()) { |
| | | return false; |
| | | } |
| | | for (final Attribute attribute : this.getAllAttributes()) { |
| | | for (final Attribute attribute : getAllAttributes()) { |
| | | final Attribute otherAttribute = |
| | | other.getAttribute(attribute.getAttributeDescription()); |
| | | if (!attribute.equals(otherAttribute)) { |
| | |
| | | |
| | | @Override |
| | | public int hashCode() { |
| | | int hashCode = this.getName().hashCode(); |
| | | for (final Attribute attribute : this.getAllAttributes()) { |
| | | int hashCode = getName().hashCode(); |
| | | for (final Attribute attribute : getAllAttributes()) { |
| | | hashCode += attribute.hashCode(); |
| | | } |
| | | return hashCode; |
| | |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | | builder.append('"'); |
| | | builder.append(this.getName()); |
| | | builder.append(getName()); |
| | | builder.append("\":{"); |
| | | boolean firstValue = true; |
| | | for (final Attribute attribute : this.getAllAttributes()) { |
| | | for (final Attribute attribute : getAllAttributes()) { |
| | | if (!firstValue) { |
| | | builder.append(','); |
| | | } |
| | |
| | | } |
| | | |
| | | private static boolean isEmpty(final Attribute attribute) { |
| | | return (attribute == null) || attribute.isEmpty(); |
| | | return attribute == null || attribute.isEmpty(); |
| | | } |
| | | |
| | | private final Attribute attribute; |
| | |
| | | |
| | | @Override |
| | | public boolean equals(final Object object) { |
| | | return (object == this || attribute.equals(object)); |
| | | return object == this || attribute.equals(object); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * @return The normalized string representation of the provided DN. |
| | | */ |
| | | public String toNormalizedString() { |
| | | final StringBuilder builder = new StringBuilder(this.size()); |
| | | final StringBuilder builder = new StringBuilder(size()); |
| | | if (rdn() == null) { |
| | | return builder.toString(); |
| | | } |
| | | |
| | | int i = this.size() - 1; |
| | | int i = size() - 1; |
| | | normalizeRDN(builder, parent(i).rdn()); |
| | | for (i--; i >= 0; i--) { |
| | | final RDN rdn = parent(i).rdn(); |
| | |
| | | } |
| | | char c = str.charAt(0); |
| | | int startPos = 0; |
| | | if ((c == ' ') || (c == '#')) { |
| | | if (c == ' ' || c == '#') { |
| | | builder.append('\\'); |
| | | builder.append(c); |
| | | startPos = 1; |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object object) { |
| | | return (object == this || entry.equals(object)); |
| | | return object == this || entry.equals(object); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * @return The newly created {@code and} filter. |
| | | */ |
| | | public static Filter and(final Filter... subFilters) { |
| | | if ((subFilters == null) || (subFilters.length == 0)) { |
| | | if (subFilters == null || subFilters.length == 0) { |
| | | // RFC 4526 - TRUE filter. |
| | | return alwaysTrue(); |
| | | } else if (subFilters.length == 1) { |
| | |
| | | * @return The newly created {@code or} filter. |
| | | */ |
| | | public static Filter or(final Filter... subFilters) { |
| | | if ((subFilters == null) || (subFilters.length == 0)) { |
| | | if (subFilters == null || subFilters.length == 0) { |
| | | // RFC 4526 - FALSE filter. |
| | | return alwaysFalse(); |
| | | } else if (subFilters.length == 1) { |
| | |
| | | final Object initialSubstring, final Collection<?> anySubstrings, |
| | | final Object finalSubstring) { |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifFalse((initialSubstring != null) || (finalSubstring != null) |
| | | || ((anySubstrings != null) && (anySubstrings.size() > 0)), |
| | | "at least one substring (initial, any or final)" + " must be specified"); |
| | | Reject.ifFalse(initialSubstring != null |
| | | || finalSubstring != null |
| | | || (anySubstrings != null && anySubstrings.size() > 0), |
| | | "at least one substring (initial, any or final) must be specified"); |
| | | |
| | | List<ByteString> anySubstringList; |
| | | if ((anySubstrings == null) || (anySubstrings.size() == 0)) { |
| | | if (anySubstrings == null || anySubstrings.size() == 0) { |
| | | anySubstringList = Collections.emptyList(); |
| | | } else if (anySubstrings.size() == 1) { |
| | | final Object anySubstring = anySubstrings.iterator().next(); |
| | |
| | | |
| | | // If the filter is enclosed in a pair of single quotes it |
| | | // is invalid (issue #1024). |
| | | if ((string.length() > 1) && string.startsWith("'") && string.endsWith("'")) { |
| | | if (string.length() > 1 && string.startsWith("'") && string.endsWith("'")) { |
| | | final LocalizableMessage message = ERR_LDAP_FILTER_ENCLOSED_IN_APOSTROPHES.get(string); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | if (valueBytes[i] == 0x5C /* The backslash character */) { |
| | | // The next two bytes must be the hex characters that comprise |
| | | // the binary value. |
| | | if ((i + 2) >= valueBytes.length) { |
| | | if (i + 2 >= valueBytes.length) { |
| | | final LocalizableMessage message = |
| | | ERR_LDAP_FILTER_INVALID_ESCAPED_BYTE.get(string, errorIndex + i + 1); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | |
| | | // Make sure that the filter has at least one of an attribute |
| | | // description and/or a matching rule ID. |
| | | if ((attributeDescription == null) && (matchingRule == null)) { |
| | | if (attributeDescription == null && matchingRule == null) { |
| | | final LocalizableMessage message = |
| | | ERR_LDAP_FILTER_EXTENSIBLE_MATCH_NO_AD_OR_MR.get(string, startIndex); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | // TODO: this is a bit overkill - it will escape all non-ascii |
| | | // chars! |
| | | final byte b = value.byteAt(i); |
| | | if (((b & 0x7F) != b) || // Not 7-bit clean |
| | | (b <= 0x1F) || // Below the printable character range |
| | | (b == 0x28) || // Open parenthesis |
| | | (b == 0x29) || // Close parenthesis |
| | | (b == 0x2A) || // Asterisk |
| | | (b == 0x5C) || // Backslash |
| | | (b == 0x7F) /* Delete character */) { |
| | | if (((b & 0x7F) != b) // Not 7-bit clean |
| | | || b <= 0x1F // Below the printable character range |
| | | || b == 0x28 // Open parenthesis |
| | | || b == 0x29 // Close parenthesis |
| | | || b == 0x2A // Asterisk |
| | | || b == 0x5C // Backslash |
| | | || b == 0x7F /* Delete character */) { |
| | | builder.append('\\'); |
| | | builder.append(byteToHex(b)); |
| | | } else { |
| | |
| | | * <code>false</code> otherwise. |
| | | */ |
| | | public boolean hasNext() { |
| | | return (pos < length); |
| | | return pos < length; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import static com.forgerock.opendj.ldap.CoreMessages.*; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.GregorianCalendar; |
| | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import static com.forgerock.opendj.ldap.CoreMessages.*; |
| | | |
| | | /** |
| | | * An LDAP generalized time as defined in RFC 4517. This class facilitates |
| | | * parsing of generalized time values to and from {@link Date} and |
| | |
| | | case '-': |
| | | // These are fine only if there are exactly two or four more |
| | | // digits that specify a valid offset. |
| | | if ((length == 13) || (length == 15)) { |
| | | if (length == 13 || length == 15) { |
| | | final TimeZone tz = getTimeZoneForOffset(valueString, 10); |
| | | return createTime(valueString, year, month, day, hour, minute, second, tz); |
| | | } else { |
| | |
| | | case '-': |
| | | // These are fine only if there are exactly two or four more |
| | | // digits that specify a valid offset. |
| | | if ((length == 15) || (length == 17)) { |
| | | if (length == 15 || length == 17) { |
| | | final TimeZone tz = getTimeZoneForOffset(valueString, 12); |
| | | return createTime(valueString, year, month, day, hour, minute, second, tz); |
| | | } else { |
| | |
| | | case '-': |
| | | // These are fine only if there are exactly two or four more |
| | | // digits that specify a valid offset. |
| | | if ((length == 17) || (length == 19)) { |
| | | if (length == 17 || length == 19) { |
| | | final TimeZone tz = getTimeZoneForOffset(valueString, 14); |
| | | return createTime(valueString, year, month, day, hour, minute, second, tz); |
| | | } else { |
| | |
| | | */ |
| | | private static TimeZone getTimeZoneForOffset(final String value, final int startPos) { |
| | | final String offSetStr = value.substring(startPos); |
| | | if ((offSetStr.length() != 3) && (offSetStr.length() != 5)) { |
| | | final int len = offSetStr.length(); |
| | | if (len != 3 && len != 5) { |
| | | final LocalizableMessage message = |
| | | WARN_ATTR_SYNTAX_GENERALIZED_TIME_INVALID_OFFSET.get(value, offSetStr); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | |
| | | final StringBuilder builder = new StringBuilder(); |
| | | if (hostPortIdx < 0) { |
| | | // We got anything here like the host and port? |
| | | if (urlLength > (schemeIdx + 3)) { |
| | | if (urlLength > schemeIdx + 3) { |
| | | final String hostAndPort = urlString.substring(schemeIdx + 3, urlLength); |
| | | port = parseHostPort(urlString, hostAndPort, builder); |
| | | host = builder.toString(); |
| | |
| | | @Override |
| | | boolean add(final LinkedAttribute attribute, final ByteString value) { |
| | | final ByteString normalizedValue = normalizeValue(attribute, value); |
| | | return (attribute.multipleValues.put(normalizedValue, value) == null); |
| | | return attribute.multipleValues.put(normalizedValue, value) == null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | public CancelExtendedRequest decodeExtendedRequest(final ExtendedRequest<?> request, |
| | | final DecodeOptions options) throws DecodeException { |
| | | final ByteString requestValue = request.getValue(); |
| | | if ((requestValue == null) || (requestValue.length() <= 0)) { |
| | | if (requestValue == null || requestValue.length() <= 0) { |
| | | throw DecodeException.error(ERR_EXTOP_CANCEL_NO_REQUEST_VALUE.get()); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public boolean hasValue() { |
| | | return (authorizationID != null); |
| | | return authorizationID != null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | warnings.add(message); |
| | | } |
| | | |
| | | return (isValid = true); |
| | | return isValid = true; |
| | | } |
| | | |
| | | private void failValidation(final List<AttributeType> invalidSchemaElements, |
| | |
| | | // then that is an error. |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_EXPECTED_OPEN_PARENTHESIS.get(definition, (reader |
| | | .pos() - 1), String.valueOf(c)); |
| | | final DecodeException e = DecodeException.error(message); |
| | | final DecodeException e = DecodeException.error( |
| | | ERR_ATTR_SYNTAX_ATTRTYPE_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, reader.pos() - 1, String.valueOf(c))); |
| | | logger.debug(LocalizableMessage.raw("%s", e)); |
| | | throw e; |
| | | } |
| | |
| | | // then that is an error. |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DCR_EXPECTED_OPEN_PARENTHESIS.get(definition, (reader.pos() - 1), c); |
| | | final DecodeException e = DecodeException.error(message); |
| | | final DecodeException e = DecodeException.error( |
| | | ERR_ATTR_SYNTAX_DCR_EXPECTED_OPEN_PARENTHESIS.get(definition, reader.pos() - 1, c)); |
| | | logger.debug(LocalizableMessage.raw("%s", e)); |
| | | throw e; |
| | | } |
| | |
| | | } |
| | | superiorRules = Collections.unmodifiableSet(superiorRules); |
| | | |
| | | return (isValid = true); |
| | | return isValid = true; |
| | | } |
| | | |
| | | private void failValidation(final List<DITStructureRule> invalidSchemaElements, |
| | |
| | | // then that is an error. |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_EXPECTED_OPEN_PARENTHESIS.get(definition, (reader.pos() - 1), c); |
| | | final DecodeException e = DecodeException.error(message); |
| | | final DecodeException e = DecodeException.error( |
| | | ERR_ATTR_SYNTAX_DSR_EXPECTED_OPEN_PARENTHESIS.get(definition, reader.pos() - 1, c)); |
| | | logger.debug(LocalizableMessage.raw("%s", e)); |
| | | throw e; |
| | | } |
| | |
| | | if (posPlusOne == 'C' && !(pos == 1 && valueString.charAt(0) == 'M')) { |
| | | if (((posPlusTwo = valueString.charAt(pos + 2)) == 'I' || posPlusTwo == 'E' || posPlusTwo == 'H') |
| | | && !(posPlusTwo == 'H' && valueString.charAt(pos + 3) == 'U')) { |
| | | if (pos == 1 && valueString.charAt(pos - 1) == 'A' |
| | | if ((pos == 1 && valueString.charAt(pos - 1) == 'A') |
| | | || hasSubstring(valueString, pos - 1, "UCCEE") |
| | | || hasSubstring(valueString, pos - 1, "UCCES")) { |
| | | // Values like "accident", "accede", and "succeed". |
| | |
| | | final String paramStr = valueString.substring(paramStartPos, pos); |
| | | if (!ALLOWED_FAX_PARAMETERS.contains(paramStr)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_ILLEGAL_PARAMETER.get( |
| | | valueString, paramStr, paramStartPos, (pos - 1))); |
| | | valueString, paramStr, paramStartPos, pos - 1)); |
| | | return false; |
| | | } |
| | | |
| | |
| | | // make sure it is valid. |
| | | final String paramStr = valueString.substring(paramStartPos); |
| | | if (!ALLOWED_FAX_PARAMETERS.contains(paramStr)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_ILLEGAL_PARAMETER.get(valueString, |
| | | paramStr, paramStartPos, (pos - 1))); |
| | | invalidReason.append(ERR_ATTR_SYNTAX_FAXNUMBER_ILLEGAL_PARAMETER.get( |
| | | valueString, paramStr, paramStartPos, pos - 1)); |
| | | return false; |
| | | } |
| | | |
| | |
| | | invalidReason); |
| | | } else { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_GUIDE_ILLEGAL_CHAR.get( |
| | | valueStr, criteria, c, (i + 1))); |
| | | valueStr, criteria, c, i + 1)); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | // If it is not, then that is an error. |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_OPEN_PARENTHESIS.get(definition, (reader.pos() - 1), |
| | | String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | | throw DecodeException.error(ERR_ATTR_SYNTAX_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, reader.pos() - 1, c)); |
| | | } |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | |
| | | // then that is an error. |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_ATTRSYNTAX_EXPECTED_OPEN_PARENTHESIS.get(definition, (reader.pos() - 1), c); |
| | | final DecodeException e = DecodeException.error(message); |
| | | final DecodeException e = DecodeException.error( |
| | | ERR_ATTR_SYNTAX_ATTRSYNTAX_EXPECTED_OPEN_PARENTHESIS.get(definition, reader.pos() - 1, c)); |
| | | logger.debug(LocalizableMessage.raw("%s", e)); |
| | | throw e; |
| | | } |
| | |
| | | |
| | | Builder(final String oid, final SchemaBuilder builder) { |
| | | super(builder); |
| | | this.oid(oid); |
| | | oid(oid); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return The parent schema builder. |
| | | */ |
| | | public SchemaBuilder addToSchemaOverwrite() { |
| | | return this.getSchemaBuilder().addMatchingRule(new MatchingRule(this), true); |
| | | return getSchemaBuilder().addMatchingRule(new MatchingRule(this), true); |
| | | } |
| | | |
| | | /** |
| | |
| | | * If there is an existing matching rule with the same numeric OID. |
| | | */ |
| | | public SchemaBuilder addToSchema() { |
| | | return this.getSchemaBuilder().addMatchingRule(new MatchingRule(this), false); |
| | | return getSchemaBuilder().addMatchingRule(new MatchingRule(this), false); |
| | | } |
| | | |
| | | @Override |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MR_EXPECTED_OPEN_PARENTHESIS.get(definition, |
| | | (reader.pos() - 1), c); |
| | | ERR_ATTR_SYNTAX_MR_EXPECTED_OPEN_PARENTHESIS.get(definition, reader.pos() - 1, c); |
| | | final DecodeException e = DecodeException.error(message); |
| | | logger.debug(LocalizableMessage.raw("%s", e)); |
| | | throw e; |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_EXPECTED_OPEN_PARENTHESIS.get(definition, |
| | | (reader.pos() - 1), c); |
| | | ERR_ATTR_SYNTAX_MRUSE_EXPECTED_OPEN_PARENTHESIS.get(definition, reader.pos() - 1, c); |
| | | final DecodeException e = DecodeException.error(message); |
| | | logger.debug(LocalizableMessage.raw("%s", e)); |
| | | throw e; |
| | |
| | | |
| | | Builder(final String oid, final SchemaBuilder builder) { |
| | | super(builder); |
| | | this.oid(oid); |
| | | oid(oid); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return The parent schema builder. |
| | | */ |
| | | public SchemaBuilder addToSchemaOverwrite() { |
| | | return this.getSchemaBuilder().addNameForm(new NameForm(this), true); |
| | | return getSchemaBuilder().addNameForm(new NameForm(this), true); |
| | | } |
| | | |
| | | /** |
| | |
| | | * OID. |
| | | */ |
| | | public SchemaBuilder addToSchema() { |
| | | return this.getSchemaBuilder().addNameForm(new NameForm(this), false); |
| | | return getSchemaBuilder().addNameForm(new NameForm(this), false); |
| | | } |
| | | |
| | | @Override |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_NAME_FORM_EXPECTED_OPEN_PARENTHESIS.get(definition, (reader |
| | | .pos() - 1), c); |
| | | ERR_ATTR_SYNTAX_NAME_FORM_EXPECTED_OPEN_PARENTHESIS.get(definition, reader.pos() - 1, c); |
| | | final DecodeException e = DecodeException.error(message); |
| | | logger.debug(LocalizableMessage.raw("%s", e)); |
| | | throw e; |
| | |
| | | requiredAttributes = Collections.unmodifiableSet(requiredAttributes); |
| | | superiorClasses = Collections.unmodifiableSet(superiorClasses); |
| | | |
| | | return (isValid = true); |
| | | return isValid = true; |
| | | } |
| | | |
| | | private void failValidation(final List<ObjectClass> invalidSchemaElements, |
| | |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_EXPECTED_OPEN_PARENTHESIS1.get(definition, |
| | | (reader.pos() - 1), c); |
| | | ERR_ATTR_SYNTAX_OBJECTCLASS_EXPECTED_OPEN_PARENTHESIS1.get(definition, reader.pos() - 1, c); |
| | | final DecodeException e = DecodeException.error(message); |
| | | logger.debug(LocalizableMessage.raw("%s", e)); |
| | | throw e; |
| | |
| | | // If it is not, then that is an error. |
| | | final char c = reader.read(); |
| | | if (c != '(') { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_EXPECTED_OPEN_PARENTHESIS.get(definition, (reader.pos() - 1), |
| | | String.valueOf(c)); |
| | | throw DecodeException.error(message); |
| | | throw DecodeException.error(ERR_ATTR_SYNTAX_EXPECTED_OPEN_PARENTHESIS.get( |
| | | definition, reader.pos() - 1, c)); |
| | | } |
| | | |
| | | // Skip over any spaces immediately following the opening parenthesis. |
| | |
| | | |
| | | Builder(final String oid, final SchemaBuilder builder) { |
| | | super(builder); |
| | | this.oid(oid); |
| | | oid(oid); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return The parent schema builder. |
| | | */ |
| | | public SchemaBuilder addToSchemaOverwrite() { |
| | | return this.getSchemaBuilder().addSyntax(new Syntax(this), true); |
| | | return getSchemaBuilder().addSyntax(new Syntax(this), true); |
| | | } |
| | | |
| | | /** |
| | |
| | | * If there is an existing syntax with the same numeric OID. |
| | | */ |
| | | public SchemaBuilder addToSchema() { |
| | | return this.getSchemaBuilder().addSyntax(new Syntax(this), false); |
| | | return getSchemaBuilder().addSyntax(new Syntax(this), false); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | SchemaBuilder addToSchema(final boolean overwrite) { |
| | | if (overwrite) { |
| | | return this.addToSchemaOverwrite(); |
| | | return addToSchemaOverwrite(); |
| | | } |
| | | return this.addToSchema(); |
| | | return addToSchema(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // The next character must be a printable string character. |
| | | c = valueString.charAt(pos++); |
| | | if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, String |
| | | .valueOf(c), (pos - 1))); |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, c, pos - 1)); |
| | | return false; |
| | | } |
| | | |
| | |
| | | c = valueString.charAt(pos++); |
| | | if (!PrintableStringSyntaxImpl.isPrintableCharacter(c)) { |
| | | invalidReason.append(ERR_ATTR_SYNTAX_TELEX_NOT_PRINTABLE.get(valueString, String |
| | | .valueOf(c), (pos - 1))); |
| | | .valueOf(c), pos - 1)); |
| | | return false; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public boolean hasNext() { |
| | | return (sourceEntry != null || targetEntry != null); |
| | | return sourceEntry != null || targetEntry != null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | // @formatter:off |
| | | final Iterator<Map.Entry<byte[], byte[]>> i = |
| | | entries.subMap(changeNormDN, |
| | | getBytes((changeDN.child(RDN.maxValue())). |
| | | getBytes(changeDN.child(RDN.maxValue()). |
| | | toNormalizedString())).entrySet().iterator(); |
| | | // @formatter:on |
| | | |
| | |
| | | final String line = replaceConstants(lines[lineNumber], lineNumber, constants, warnings); |
| | | |
| | | final String lowerLine = line.toLowerCase(); |
| | | if ((line.length() == 0) || line.startsWith("#")) { |
| | | if (line.length() == 0 || line.startsWith("#")) { |
| | | // This is a comment or a blank line, so we'll ignore it. |
| | | continue; |
| | | } else if (lowerLine.startsWith(INCLUDE_LABEL)) { |
| | |
| | | } |
| | | } |
| | | // Then, find the position of the first non-blank character in the line. |
| | | while ((pos < length) && (lowerLine.charAt(pos) == ' ')) { |
| | | while (pos < length && lowerLine.charAt(pos) == ' ') { |
| | | pos++; |
| | | } |
| | | |
| | |
| | | if (nextEntry != null) { |
| | | return true; |
| | | } |
| | | while ((entriesCount < numberOfEntries) || generateForever()) { |
| | | while (entriesCount < numberOfEntries || generateForever()) { |
| | | // get the template entry |
| | | if (!currentEntryIsInitialized) { |
| | | nextEntry = buildTemplateEntry(); |
| | |
| | | */ |
| | | TemplateValue getValue(final AttributeType attributeType) { |
| | | final List<TemplateValue> values = attributes.get(attributeType); |
| | | if ((values != null)) { |
| | | if (values != null) { |
| | | return values.get(0); |
| | | } |
| | | return null; |
| | |
| | | |
| | | private void initialize(Schema schema, Branch branch, Template template, String[] arguments, int lineNumber) |
| | | throws DecodeException { |
| | | if ((arguments.length < 1) || (arguments.length > 2)) { |
| | | if (arguments.length < 1 || arguments.length > 2) { |
| | | LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), |
| | | lineNumber, 1, 2, arguments.length); |
| | | throw DecodeException.fatalError(message); |
| | |
| | | final TagResult generateValue(TemplateEntry templateEntry, TemplateValue templateValue, |
| | | String separator) { |
| | | DN dn = templateEntry.getDN(); |
| | | if ((dn == null) || dn.isRootDN()) { |
| | | if (dn == null || dn.isRootDN()) { |
| | | return TagResult.SUCCESS; |
| | | } |
| | | |
| | |
| | | random = templateFile.getRandom(); |
| | | |
| | | // There must be at least one argument, and possibly two. |
| | | if ((arguments.length < 1) || (arguments.length > 2)) { |
| | | if (arguments.length < 1 || arguments.length > 2) { |
| | | LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), |
| | | lineNumber, 1, 2, arguments.length); |
| | | throw DecodeException.fatalError(message); |
| | |
| | | |
| | | private void initialize(Schema schema, Branch branch, Template template, String[] arguments, int lineNumber) |
| | | throws DecodeException { |
| | | if ((arguments.length < 1) || (arguments.length > 2)) { |
| | | if (arguments.length < 1 || arguments.length > 2) { |
| | | LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), |
| | | lineNumber, 1, 2, arguments.length); |
| | | throw DecodeException.fatalError(message); |
| | |
| | | @Override |
| | | TagResult generateValue(TemplateEntry templateEntry, TemplateValue templateValue) { |
| | | List<TemplateValue> values = templateEntry.getValues(attributeType); |
| | | if ((values == null) || values.isEmpty()) { |
| | | if (values == null || values.isEmpty()) { |
| | | return TagResult.FAILURE; |
| | | } |
| | | |
| | |
| | | @Override |
| | | TagResult generateValue(TemplateEntry templateEntry, TemplateValue templateValue) { |
| | | DN parentDN = templateEntry.getParentDN(); |
| | | if ((parentDN == null) || parentDN.isRootDN()) { |
| | | if (parentDN == null || parentDN.isRootDN()) { |
| | | return TagResult.SUCCESS; |
| | | } |
| | | templateValue.append(parentDN); |
| | |
| | | |
| | | // There must be at least one argument, to specify the type of |
| | | // random value to generate. |
| | | if ((arguments == null) || (arguments.length == 0)) { |
| | | if (arguments == null || arguments.length == 0) { |
| | | LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_NO_RANDOM_TYPE_ARGUMENT.get(lineNumber); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | getName(), lineNumber); |
| | | throw DecodeException.fatalError(message, nfe); |
| | | } |
| | | } else if ((numArgs == 3) || (numArgs == 4)) { |
| | | } else if (numArgs == 3 || numArgs == 4) { |
| | | randomType = RandomType.NUMERIC; |
| | | |
| | | if (numArgs == 4) { |
| | |
| | | characterSet = ALPHANUMERIC_CHARS; |
| | | decodeLength(arguments, 1, lineNumber, warnings); |
| | | } else if (randomTypeString.equals("chars")) { |
| | | if ((numArgs < 3) || (numArgs > 4)) { |
| | | if (numArgs < 3 || numArgs > 4) { |
| | | LocalizableMessage message = ERR_ENTRY_GENERATOR_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), |
| | | lineNumber, 3, 4, numArgs); |
| | | throw DecodeException.fatalError(message); |
| | |
| | | @Override |
| | | TagResult generateValue(TemplateEntry templateEntry, TemplateValue templateValue) { |
| | | DN dn = templateEntry.getDN(); |
| | | if ((dn == null) || dn.isRootDN()) { |
| | | if (dn == null || dn.isRootDN()) { |
| | | return TagResult.SUCCESS; |
| | | } else { |
| | | templateValue.append(dn.rdn()); |
| | |
| | | @Override |
| | | TagResult generateValue(TemplateEntry templateEntry, TemplateValue templateValue) { |
| | | DN parentDN = templateEntry.getParentDN(); |
| | | if ((parentDN == null) || parentDN.isRootDN()) { |
| | | if (parentDN == null || parentDN.isRootDN()) { |
| | | return TagResult.SUCCESS; |
| | | } |
| | | templateValue.append(parentDN.rdn()); |
| | |
| | | assertThat(((ModifyRequest) cr).getModifications().size()).isEqualTo(3); |
| | | for (Modification mod : ((ModifyRequest) cr).getModifications()) { |
| | | if (mod.getModificationType() == ModificationType.ADD) { |
| | | assertThat((mod.getAttribute().getAttributeDescription().toString()) |
| | | .equals("description") |
| | | || (mod.getAttribute().getAttributeDescription().toString()) |
| | | .equals("userPassword")); |
| | | |
| | | assertThat((mod.getAttribute().firstValueAsString()).equals("A new description.") |
| | | || (mod.getAttribute().firstValueAsString()).equals("secret12")); |
| | | assertThat(mod.getAttribute().getAttributeDescription().toString().equals("description") |
| | | || mod.getAttribute().getAttributeDescription().toString().equals("userPassword")); |
| | | assertThat(mod.getAttribute().firstValueAsString().equals("A new description.") |
| | | || mod.getAttribute().firstValueAsString().equals("secret12")); |
| | | } |
| | | if (mod.getModificationType() == ModificationType.DELETE) { |
| | | assertThat(mod.getAttribute().getAttributeDescription().toString()).isEqualTo( |
| | | "userPassword"); |
| | | assertThat(mod.getAttribute().getAttributeDescription().toString()).isEqualTo("userPassword"); |
| | | assertThat(mod.getAttribute().firstValueAsString()).isEqualTo("changeme"); |
| | | } |
| | | } |
| | |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | | |
| | | if ((peekLength < 1) || (peekLength > 4)) { |
| | | if (peekLength < 1 || peekLength > 4) { |
| | | final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | // Read the header if haven't done so already |
| | | peekLength(); |
| | | |
| | | if ((peekLength < 1) || (peekLength > 8)) { |
| | | if (peekLength < 1 || peekLength > 8) { |
| | | final LocalizableMessage message = ERR_ASN1_INTEGER_INVALID_LENGTH.get(peekLength); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | long longValue = 0; |
| | | for (int i = 0; i < peekLength; i++) { |
| | | final int readByte = buffer.get(); |
| | | if ((i == 0) && (((byte) readByte) < 0)) { |
| | | if (i == 0 && ((byte) readByte) < 0) { |
| | | longValue = 0xFFFFFFFFFFFFFFFFL; |
| | | } |
| | | longValue = (longValue << 8) | (readByte & 0xFF); |
| | |
| | | int intValue = 0; |
| | | for (int i = 0; i < peekLength; i++) { |
| | | final int readByte = buffer.get(); |
| | | if ((i == 0) && (((byte) readByte) < 0)) { |
| | | if (i == 0 && ((byte) readByte) < 0) { |
| | | intValue = 0xFFFFFFFF; |
| | | } |
| | | intValue = (intValue << 8) | (readByte & 0xFF); |
| | |
| | | |
| | | // Make sure that the element is not larger than the maximum allowed |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) { |
| | | if (maxElementSize > 0 && peekLength > maxElementSize) { |
| | | final LocalizableMessage m = |
| | | ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | .get(peekLength, maxElementSize); |
| | |
| | | |
| | | // Make sure that the element is not larger than the maximum allowed |
| | | // message size. |
| | | if ((maxElementSize > 0) && (peekLength > maxElementSize)) { |
| | | if (maxElementSize > 0 && peekLength > maxElementSize) { |
| | | final LocalizableMessage m = |
| | | ERR_LDAP_CLIENT_DECODE_MAX_REQUEST_SIZE_EXCEEDED |
| | | .get(peekLength, maxElementSize); |
| | |
| | | */ |
| | | private boolean needTypeState(final boolean ensureRead) throws IOException { |
| | | // Read just the type. |
| | | if (ensureRead && (readLimiter.remaining() <= 0)) { |
| | | if (ensureRead && readLimiter.remaining() <= 0) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.getClass().getName(); |
| | | return getClass().getName(); |
| | | } |
| | | |
| | | public boolean hasInputRemaining(final AttributeStorage storage, final Buffer input) { |
| | |
| | | } |
| | | |
| | | public String getName() { |
| | | return this.getClass().getName(); |
| | | return getClass().getName(); |
| | | } |
| | | |
| | | public boolean hasInputRemaining(final AttributeStorage storage, final Buffer input) { |
| | |
| | | * @param operation Operation specified as an argument (add or del). |
| | | */ |
| | | private static ModificationType getModificationType(String operation) { |
| | | if (!(operation.equalsIgnoreCase("add") || operation.equalsIgnoreCase("del"))) { |
| | | final boolean isAdd = operation.equalsIgnoreCase("add"); |
| | | if (!(isAdd || operation.equalsIgnoreCase("del"))) { |
| | | printUsage(); |
| | | } |
| | | return (operation.equalsIgnoreCase("add")) |
| | | ? ModificationType.ADD : ModificationType.DELETE; |
| | | return isAdd ? ModificationType.ADD : ModificationType.DELETE; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return <CODE>true</CODE> if the command was launched to setup a proxy and <CODE>false</CODE> otherwise. |
| | | */ |
| | | public boolean isCreateProxy() { |
| | | return (argParser.getSubCommand("create-proxy") != null); |
| | | return argParser.getSubCommand("create-proxy") != null; |
| | | } |
| | | |
| | | /** |
| | |
| | | errorMessages.add(ERR_SEVERAL_CERTIFICATE_TYPE_SPECIFIED.get()); |
| | | } |
| | | |
| | | if (certificateRequired && noPrompt.isPresent() && (certificateType == 0)) { |
| | | if (certificateRequired && noPrompt.isPresent() && certificateType == 0) { |
| | | errorMessages.add(ERR_CERTIFICATE_REQUIRED_FOR_SSL_OR_STARTTLS.get()); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | public boolean isOnlyBaseEntry() { |
| | | return (type == Type.BASE_ENTRY_ONLY); |
| | | return type == Type.BASE_ENTRY_ONLY; |
| | | } |
| | | |
| | | public boolean isEmptyDatabase() { |
| | | return (type == Type.EMPTY_DATABASE); |
| | | return type == Type.EMPTY_DATABASE; |
| | | } |
| | | |
| | | public boolean isImportLDIF() { |
| | | return (type == Type.IMPORT_LDIF); |
| | | return type == Type.IMPORT_LDIF; |
| | | } |
| | | |
| | | public boolean isAutomaticallyImportGenerated() { |
| | | return (type == Type.AUTOMATICALLY_GENERATED); |
| | | return type == Type.AUTOMATICALLY_GENERATED; |
| | | } |
| | | |
| | | public File getLdifImportDataPath() { |
| | |
| | | * Sets the type of this server as : replication activated and this is the first server in topology. |
| | | */ |
| | | void setFirstInTopology() { |
| | | this.setType(Type.FIRST_IN_TOPOLOGY); |
| | | setType(Type.FIRST_IN_TOPOLOGY); |
| | | } |
| | | |
| | | /** |
| | | * Sets the type of this server as : replication activated and this is a server in an existing topology. |
| | | */ |
| | | void setInExistingTopology() { |
| | | this.setType(Type.IN_EXISTING_TOPOLOGY); |
| | | setType(Type.IN_EXISTING_TOPOLOGY); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | void validate() throws ConfigException { |
| | | if (isFirstInTopology() || isPartOfReplicationTopology()) { |
| | | if (this.getReplicationConfiguration() == null) { |
| | | if (getReplicationConfiguration() == null) { |
| | | throw new ConfigException(LocalizableMessage.raw("No replication configuration found")); |
| | | } |
| | | if (isPartOfReplicationTopology()) { |
| | | Reject.ifNull(this.getReplicationConfiguration().getAdministrator(), |
| | | Reject.ifNull(getReplicationConfiguration().getAdministrator(), |
| | | "Administrator name should not be null"); |
| | | Reject.ifNull(this.getReplicationConfiguration().getPassword(), "Admin password should not be null"); |
| | | Reject.ifNull(this.getReplicationConfiguration().getGlobalAdministrator(), |
| | | Reject.ifNull(getReplicationConfiguration().getPassword(), "Admin password should not be null"); |
| | | Reject.ifNull(getReplicationConfiguration().getGlobalAdministrator(), |
| | | "Global administrator should not be null"); |
| | | Reject.ifNull(this.getReplicationConfiguration().getGlobalAdministratorPassword(), |
| | | Reject.ifNull(getReplicationConfiguration().getGlobalAdministratorPassword(), |
| | | "Global administrator should not be null"); |
| | | if (getReplicationConfiguration().getSuffixes() == null |
| | | || getReplicationConfiguration().getSuffixes().size() == 0) { |
| | |
| | | @Override |
| | | public Result modifyDN(final ModifyDNRequest request) throws LdapException { |
| | | final ModifyDNOperation modifyDNOperation = |
| | | icc.processModifyDN(to(valueOf(request.getName())), to(valueOf(request |
| | | .getNewRDN())), request.isDeleteOldRDN(), |
| | | (request.getNewSuperior() != null ? to(valueOf(request |
| | | .getNewSuperior())) : null), to(request.getControls())); |
| | | icc.processModifyDN(to(valueOf(request.getName())), |
| | | to(valueOf(request.getNewRDN())), |
| | | request.isDeleteOldRDN(), |
| | | (request.getNewSuperior() != null ? to(valueOf(request.getNewSuperior())) : null), |
| | | to(request.getControls())); |
| | | return getResponseResult(modifyDNOperation); |
| | | } |
| | | |
| | |
| | | return extendedResult; |
| | | |
| | | } catch (DecodeException e) { |
| | | org.opends.server.types.DN matchedDN = extendedOperation.getMatchedDN(); |
| | | return request.getResultDecoder().newExtendedErrorResult( |
| | | ResultCode.valueOf(extendedOperation.getResultCode().getIntValue()), |
| | | (extendedOperation.getMatchedDN() != null ? extendedOperation |
| | | .getMatchedDN().toString() : null), |
| | | matchedDN != null ? matchedDN.toString() : null, |
| | | extendedOperation.getErrorMessage().toString()); |
| | | } |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | import org.forgerock.opendj.ldap.responses.Result; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.CompareOperation; |
| | | import org.opends.server.core.ExtendedOperation; |
| | |
| | | result.addControl(from(c)); |
| | | } |
| | | } |
| | | result.setDiagnosticMessage((operation.getErrorMessage() != null ? operation |
| | | .getErrorMessage().toString() : null)); |
| | | result.setMatchedDN((operation.getMatchedDN() != null) ? operation.getMatchedDN() |
| | | .toString() : null); |
| | | final MessageBuilder errorMsg = operation.getErrorMessage(); |
| | | org.opends.server.types.DN matchedDN = operation.getMatchedDN(); |
| | | result.setDiagnosticMessage(errorMsg != null ? errorMsg.toString() : null); |
| | | result.setMatchedDN(matchedDN != null ? matchedDN.toString() : null); |
| | | if (result.isSuccess()) { |
| | | return result; |
| | | } else { |
| | |
| | | |
| | | Connection connection = factory.getConnection(); |
| | | PlainSASLBindRequest request = |
| | | Requests.newPlainSASLBindRequest("u:user.0", ("password").toCharArray()); |
| | | Requests.newPlainSASLBindRequest("u:user.0", "password".toCharArray()); |
| | | try { |
| | | connection.bind(request); |
| | | } finally { |
| | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | |
| | | PlainSASLBindRequest request = |
| | | Requests.newPlainSASLBindRequest("u:user.0", ("password").toCharArray()); |
| | | Requests.newPlainSASLBindRequest("u:user.0", "password".toCharArray()); |
| | | try { |
| | | connection.bind(request); |
| | | } finally { |
| | |
| | | @Test(groups = { "needRunningServer" }) |
| | | public static void testgetCredentials() throws Exception { |
| | | final PlainSASLBindRequest request = |
| | | Requests.newPlainSASLBindRequest("u:user.0", ("password").toCharArray()); |
| | | Requests.newPlainSASLBindRequest("u:user.0", "password".toCharArray()); |
| | | |
| | | String serverName = InetAddress.getByName(null).getCanonicalHostName(); |
| | | final BindClient bindClient = request.createBindClient(serverName); |
| | |
| | | @Test(groups = { "needRunningServer" }) |
| | | public static void testgetCredentialsEmptyByteString() throws Exception { |
| | | final CRAMMD5SASLBindRequest request = |
| | | Requests.newCRAMMD5SASLBindRequest("u:user.2", ("password").toCharArray()); |
| | | Requests.newCRAMMD5SASLBindRequest("u:user.2", "password".toCharArray()); |
| | | |
| | | String serverName = InetAddress.getByName(null).getCanonicalHostName(); |
| | | final BindClient bindClient = request.createBindClient(serverName); |
| | |
| | | @Override |
| | | public Result modifyDN(final ModifyDNRequest request) throws LdapException { |
| | | final ModifyDNOperation modifyDNOperation = |
| | | icc.processModifyDN(valueOf(request.getName()), valueOf(request.getNewRDN()), |
| | | icc.processModifyDN(valueOf(request.getName()), |
| | | valueOf(request.getNewRDN()), |
| | | request.isDeleteOldRDN(), |
| | | (request.getNewSuperior() != null ? valueOf(request.getNewSuperior()) : null), |
| | | request.getNewSuperior() != null ? valueOf(request.getNewSuperior()) : null, |
| | | to(request.getControls())); |
| | | return getResponseResult(modifyDNOperation); |
| | | } |
| | |
| | | |
| | | Connection connection = factory.getConnection(); |
| | | PlainSASLBindRequest request = |
| | | Requests.newPlainSASLBindRequest("u:user.0", ("password").toCharArray()); |
| | | Requests.newPlainSASLBindRequest("u:user.0", "password".toCharArray()); |
| | | try { |
| | | connection.bind(request); |
| | | } finally { |
| | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | |
| | | PlainSASLBindRequest request = |
| | | Requests.newPlainSASLBindRequest("u:user.0", ("password").toCharArray()); |
| | | Requests.newPlainSASLBindRequest("u:user.0", "password".toCharArray()); |
| | | try { |
| | | connection.bind(request); |
| | | } finally { |
| | |
| | | @Test(groups = { "needRunningServer" }) |
| | | public static void testgetCredentials() throws Exception { |
| | | final PlainSASLBindRequest request = |
| | | Requests.newPlainSASLBindRequest("u:user.0", ("password").toCharArray()); |
| | | Requests.newPlainSASLBindRequest("u:user.0", "password".toCharArray()); |
| | | |
| | | String serverName = InetAddress.getByName(null).getCanonicalHostName(); |
| | | final BindClient bindClient = request.createBindClient(serverName); |
| | |
| | | @Test(groups = { "needRunningServer" }) |
| | | public static void testgetCredentialsEmptyByteString() throws Exception { |
| | | final CRAMMD5SASLBindRequest request = |
| | | Requests.newCRAMMD5SASLBindRequest("u:user.2", ("password").toCharArray()); |
| | | Requests.newCRAMMD5SASLBindRequest("u:user.2", "password".toCharArray()); |
| | | |
| | | String serverName = InetAddress.getByName(null).getCanonicalHostName(); |
| | | final BindClient bindClient = request.createBindClient(serverName); |