Minor refactoring: remove Validator class and use forgerock-util Reject instead.
156 files modified
1 files deleted
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import org.opends.server.authorization.dseecompat.Aci; |
| | | import org.opends.server.authorization.dseecompat.AciException; |
| | |
| | | @Override |
| | | public void validateValue(Aci value) |
| | | throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | | } |
| | |
| | | @Override |
| | | public Aci decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | | return Aci.decode(ByteString.valueOf(value), DN.rootDN()); |
| | |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | | import static com.forgerock.opendj.util.StaticUtils.*; |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | | validateValue(value); |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public AttributeType decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | String name = value.trim().toLowerCase(); |
| | | AttributeType type = DirectoryServer.getAttributeType(name, !isCheckSchema); |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(AttributeType value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // No implementation required. |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | import java.util.HashMap; |
| | |
| | | @Override |
| | | public void validateValue(Boolean value) |
| | | throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | | } |
| | |
| | | @Override |
| | | public Boolean decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | String nvalue = value.trim().toLowerCase(); |
| | | Boolean b = VALUE_MAP.get(nvalue); |
| | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | | import static com.forgerock.opendj.ldap.ExtensionMessages.*; |
| | | import static com.forgerock.opendj.util.StaticUtils.*; |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.BufferedReader; |
| | |
| | | */ |
| | | public synchronized void addExtension(String... extensions) throws InitializationException, IllegalStateException, |
| | | IllegalArgumentException { |
| | | ensureNotNull(extensions); |
| | | Reject.ifNull(extensions); |
| | | |
| | | if (loader == null) { |
| | | throw new IllegalStateException("Class loader provider is disabled."); |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.EnumSet; |
| | |
| | | * The name of a class which property values must implement. |
| | | */ |
| | | public final void addInstanceOf(String className) { |
| | | ensureNotNull(className); |
| | | Reject.ifNull(className); |
| | | |
| | | /* |
| | | * Do some basic checks to make sure the string representation is |
| | |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | | validateValue(value); |
| | |
| | | */ |
| | | public <T> Class<? extends T> loadClass(String className, Class<T> instanceOf) |
| | | throws IllegalPropertyValueException, ClassCastException { |
| | | ensureNotNull(className, instanceOf); |
| | | Reject.ifNull(className); |
| | | Reject.ifNull(instanceOf); |
| | | |
| | | // Make sure that the named class is valid. |
| | | validateClassName(className); |
| | |
| | | */ |
| | | @Override |
| | | public String normalizeValue(String value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | return value.trim(); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(String value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // Always make sure the name is a valid class name. |
| | | validateClassName(value); |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(DN value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | if (baseDN != null) { |
| | | DN parent = value.parent(); |
| | |
| | | */ |
| | | @Override |
| | | public DN decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | | // TODO: is it correct to replace server DN.decode by SDK valueOf ? |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | |
| | |
| | | * maximum unit. |
| | | */ |
| | | public final void setBaseUnit(String unit) throws IllegalArgumentException { |
| | | ensureNotNull(unit); |
| | | Reject.ifNull(unit); |
| | | |
| | | setBaseUnit(DurationUnit.getUnit(unit)); |
| | | } |
| | |
| | | * unit. |
| | | */ |
| | | public final void setBaseUnit(DurationUnit unit) throws IllegalArgumentException { |
| | | ensureNotNull(unit); |
| | | Reject.ifNull(unit); |
| | | |
| | | // Make sure that the base unit is not bigger than the maximum |
| | | // unit. |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(Long value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | long nvalue = baseUnit.toMilliSeconds(value); |
| | | if (!allowUnlimited && nvalue < lowerLimit) { |
| | |
| | | */ |
| | | @Override |
| | | public String encodeValue(Long value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as |
| | | // "unlimited". |
| | |
| | | */ |
| | | @Override |
| | | public Long decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // First check for the special "unlimited" value when necessary. |
| | | if (allowUnlimited) { |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | import java.util.HashMap; |
| | |
| | | */ |
| | | @Override |
| | | public E decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | String nvalue = value.trim().toLowerCase(); |
| | | E eValue = decodeMap.get(nvalue); |
| | |
| | | */ |
| | | @Override |
| | | public String normalizeValue(E value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | return value.toString().trim().toLowerCase(); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(E value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(AddressMask value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public AddressMask decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | | return AddressMask.decode(value); |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(InetAddress value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public InetAddress decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | | return InetAddress.getByName(value); |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | |
| | | * relation does not use a property for naming. |
| | | */ |
| | | public void setNamingProperty(PropertyDefinition<?> namingPropertyDefinition) { |
| | | ensureNotNull(namingPropertyDefinition); |
| | | Reject.ifNull(namingPropertyDefinition); |
| | | this.namingPropertyDefinition = namingPropertyDefinition; |
| | | } |
| | | |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | import java.util.Locale; |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(Integer value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | if (!allowUnlimited && value < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | |
| | | */ |
| | | @Override |
| | | public String encodeValue(Integer value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as "unlimited". |
| | | if (allowUnlimited) { |
| | |
| | | */ |
| | | @Override |
| | | public Integer decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | if (allowUnlimited) { |
| | | if (value.trim().equalsIgnoreCase(UNLIMITED)) { |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.EnumSet; |
| | |
| | | * The administrator action. |
| | | */ |
| | | public final void setAdministratorAction(AdministratorAction adminAction) { |
| | | ensureNotNull(adminAction); |
| | | Reject.ifNull(adminAction); |
| | | this.adminAction = adminAction; |
| | | } |
| | | |
| | |
| | | * The default behavior provider. |
| | | */ |
| | | public final void setDefaultBehaviorProvider(DefaultBehaviorProvider<T> defaultBehavior) { |
| | | ensureNotNull(defaultBehavior); |
| | | Reject.ifNull(defaultBehavior); |
| | | this.defaultBehavior = defaultBehavior; |
| | | } |
| | | |
| | |
| | | * The property option. |
| | | */ |
| | | public final void setOption(PropertyOption option) { |
| | | ensureNotNull(option); |
| | | Reject.ifNull(option); |
| | | options.add(option); |
| | | } |
| | | |
| | |
| | | */ |
| | | protected PropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, Class<T> theClass, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<T> defaultBehavior) { |
| | | ensureNotNull(d, theClass, propertyName); |
| | | ensureNotNull(options, adminAction, defaultBehavior); |
| | | Reject.ifNull(d); |
| | | Reject.ifNull(theClass); |
| | | Reject.ifNull(propertyName); |
| | | Reject.ifNull(options); |
| | | Reject.ifNull(adminAction); |
| | | Reject.ifNull(defaultBehavior); |
| | | |
| | | this.definition = d; |
| | | this.theClass = theClass; |
| | |
| | | * argument is less than, equal to, or greater than the second. |
| | | */ |
| | | public int compare(T o1, T o2) { |
| | | ensureNotNull(o1, o2); |
| | | Reject.ifNull(o1); |
| | | Reject.ifNull(o2); |
| | | |
| | | String s1 = normalizeValue(o1); |
| | | String s2 = normalizeValue(o2); |
| | |
| | | * If the property value is invalid. |
| | | */ |
| | | public String encodeValue(T value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | return value.toString(); |
| | | } |
| | |
| | | * If the property value is invalid. |
| | | */ |
| | | public String normalizeValue(T value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | return encodeValue(value); |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | import java.util.Locale; |
| | |
| | | * The relation option. |
| | | */ |
| | | public final void setOption(RelationOption option) { |
| | | ensureNotNull(option); |
| | | Reject.ifNull(option); |
| | | common.options.add(option); |
| | | } |
| | | |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(Long value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | if (!allowUnlimited && value < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | |
| | | */ |
| | | @Override |
| | | public String encodeValue(Long value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as "unlimited". |
| | | if (allowUnlimited) { |
| | |
| | | */ |
| | | @Override |
| | | public Long decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | // First check for the special "unlimited" value when necessary. |
| | | if (allowUnlimited) { |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.EnumSet; |
| | | import java.util.Locale; |
| | |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | | validateValue(value); |
| | |
| | | */ |
| | | @Override |
| | | public String normalizeValue(String value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | if (isCaseInsensitive()) { |
| | | return value.trim().toLowerCase(); |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(String value) throws IllegalPropertyValueException { |
| | | ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | |
| | | if (pattern != null) { |
| | | Matcher matcher = pattern.matcher(value); |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | |
| | | * If the tag name was not recognized. |
| | | */ |
| | | public static Tag valueOf(String name) throws IllegalArgumentException { |
| | | ensureNotNull(name); |
| | | Reject.ifNull(name); |
| | | |
| | | // Hack to force initialization of the tag definitions. |
| | | RootCfgDefn.getInstance(); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.DecodingException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.PropertyException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | // Create the message. |
| | | private static LocalizableMessage createMessage(ManagedObject<?> partialManagedObject, |
| | | Collection<PropertyException> causes) { |
| | | Validator.ensureNotNull(causes); |
| | | Validator.ensureTrue(!causes.isEmpty(), "causes should not be empty"); |
| | | Reject.ifNull(causes); |
| | | Reject.ifFalse(!causes.isEmpty(), "causes should not be empty"); |
| | | |
| | | ManagedObjectDefinition<?, ?> d = partialManagedObject |
| | | .getManagedObjectDefinition(); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.OperationsException; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | // Create the message. |
| | | private static LocalizableMessage createMessage( |
| | | Collection<PropertyIsMandatoryException> causes) { |
| | | Validator.ensureNotNull(causes); |
| | | Validator.ensureTrue(!causes.isEmpty(), "causes should not be empty"); |
| | | Reject.ifNull(causes); |
| | | Reject.ifFalse(!causes.isEmpty(), "causes should not be empty"); |
| | | |
| | | if (causes.size() == 1) { |
| | | return ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_SINGLE.get(causes |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This exception is thrown when the client or server refuses to create, delete, |
| | |
| | | |
| | | // Gets the default message. |
| | | private static LocalizableMessage getDefaultMessage(Collection<LocalizableMessage> messages) { |
| | | Validator.ensureNotNull(messages); |
| | | Validator.ensureTrue(!messages.isEmpty(), "Messages should not be empty"); |
| | | Reject.ifNull(messages); |
| | | Reject.ifFalse(!messages.isEmpty(), "Messages should not be empty"); |
| | | |
| | | if (messages.size() == 1) { |
| | | return ERR_OPERATION_REJECTED_EXCEPTION_SINGLE.get(messages.iterator().next()); |
| | |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.spi.Driver; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDAP management connection context. |
| | |
| | | * @return Returns the new management context. |
| | | */ |
| | | public static ManagementContext createFromContext(LDAPConnection connection) { |
| | | Validator.ensureNotNull(connection); |
| | | Reject.ifNull(connection); |
| | | return new LDAPManagementContext(connection, LDAPProfile.getInstance()); |
| | | } |
| | | |
| | |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A condition which evaluates to <code>true</code> if and only if all of its |
| | |
| | | * The sub-conditions which will be combined using a logical AND. |
| | | */ |
| | | public ANDCondition(Condition... conditions) { |
| | | Validator.ensureNotNull(conditions); |
| | | Reject.ifNull(conditions); |
| | | this.conditions = Arrays.asList(conditions); |
| | | } |
| | | |
| | |
| | | import java.util.SortedSet; |
| | | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * A condition which evaluates to <code>true</code> if and only if a property |
| | | * contains a particular value. |
| | |
| | | * The string representation of the required property value. |
| | | */ |
| | | public ContainsCondition(String propertyName, String stringValue) { |
| | | Validator.ensureNotNull(propertyName, stringValue); |
| | | Reject.ifNull(propertyName); |
| | | Reject.ifNull(stringValue); |
| | | this.propertyName = propertyName; |
| | | this.propertyStringValue = stringValue; |
| | | } |
| | |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A condition which evaluates to <code>true</code> if and only if a particular |
| | |
| | | * The property name. |
| | | */ |
| | | public IsPresentCondition(String propertyName) { |
| | | Validator.ensureNotNull(propertyName); |
| | | Reject.ifNull(propertyName); |
| | | this.propertyName = propertyName; |
| | | } |
| | | |
| | |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A condition which evaluates to <code>true</code> if the sub-condition is |
| | |
| | | * The sub-condition which will be inverted. |
| | | */ |
| | | public NOTCondition(Condition condition) { |
| | | Validator.ensureNotNull(condition); |
| | | Reject.ifNull(condition); |
| | | this.condition = condition; |
| | | } |
| | | |
| | |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A condition which evaluates to <code>false</code> if and only if all of its |
| | |
| | | * The sub-conditions which will be combined using a logical OR. |
| | | */ |
| | | public ORCondition(Condition... conditions) { |
| | | Validator.ensureNotNull(conditions); |
| | | Reject.ifNull(conditions); |
| | | this.conditions = Arrays.asList(conditions); |
| | | } |
| | | |
| | |
| | | package org.opends.server.admin.server; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | |
| | | |
| | | // Gets the default message. |
| | | private static LocalizableMessage getDefaultMessage(Collection<LocalizableMessage> messages) { |
| | | ensureNotNull(messages); |
| | | ensureTrue(!messages.isEmpty(), "messages should not be empty"); |
| | | Reject.ifNull(messages); |
| | | Reject.ifFalse(!messages.isEmpty(), "messages should not be empty"); |
| | | |
| | | if (messages.size() == 1) { |
| | | return ERR_CONSTRAINT_VIOLATION_EXCEPTION_SINGLE.get(messages.iterator().next()); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.DecodingException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.PropertyException; |
| | | import static com.forgerock.opendj.util.Validator.*; |
| | | |
| | | /** |
| | | * The requested server managed object was found but one or more of its |
| | |
| | | // Create the message. |
| | | private static LocalizableMessage createMessage(ServerManagedObject<?> partialManagedObject, |
| | | Collection<PropertyException> causes) { |
| | | ensureNotNull(causes); |
| | | ensureTrue(!causes.isEmpty(), "causes should nnot be empty"); |
| | | Reject.ifNull(causes); |
| | | Reject.ifFalse(!causes.isEmpty(), "causes should nnot be empty"); |
| | | |
| | | ManagedObjectDefinition<?, ?> d = partialManagedObject.getManagedObjectDefinition(); |
| | | if (causes.size() == 1) { |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.util.Reject; |
| | | import org.testng.Assert; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * A mock LDAP connection which is used to verify that an add operation was |
| | | * requested and that it has the correct parameters. |
| | |
| | | * The attribute's expected values (never empty). |
| | | */ |
| | | public void addExpectedAttribute(String expectedName, String... expectedValues) { |
| | | Validator.ensureNotNull(expectedName); |
| | | Validator.ensureNotNull(expectedValues); |
| | | Validator.ensureTrue(expectedValues.length > 0, "should have at least one expected value"); |
| | | Reject.ifNull(expectedName); |
| | | Reject.ifNull(expectedValues); |
| | | Reject.ifFalse(expectedValues.length > 0, "should have at least one expected value"); |
| | | attributes.put(expectedName, Arrays.asList(expectedValues)); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.requests.ModifyRequest; |
| | | import org.testng.Assert; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A mock LDAP connection which is used to verify that a modify operation was |
| | |
| | | * deleted). |
| | | */ |
| | | public void addExpectedModification(String expectedName, String... expectedValues) { |
| | | Validator.ensureNotNull(expectedName); |
| | | Validator.ensureNotNull(expectedValues); |
| | | Reject.ifNull(expectedName); |
| | | Reject.ifNull(expectedValues); |
| | | modifications.put(expectedName, Arrays.asList(expectedValues)); |
| | | } |
| | | |
| | |
| | | <artifactId>slf4j-api</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.forgerock.commons</groupId> |
| | | <artifactId>forgerock-util</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.forgerock</groupId> |
| | | <artifactId>forgerock-build-tools</artifactId> |
| | | <version>${forgerockBuildToolsVersion}</version> |
| | |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | import org.forgerock.opendj.ldap.controls.ControlDecoder; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The Sun-defined account usability request control. The OID for this control |
| | |
| | | |
| | | public AccountUsabilityRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof AccountUsabilityRequestControl) { |
| | | return (AccountUsabilityRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.controls.ControlDecoder; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The Sun-defined account usability response control. The OID for this control |
| | |
| | | |
| | | public AccountUsabilityResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof AccountUsabilityResponseControl) { |
| | | return (AccountUsabilityResponseControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | import org.forgerock.opendj.ldap.controls.ControlDecoder; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The Sun-defined real attributes only request control. The OID for this |
| | |
| | | |
| | | public RealAttributesOnlyRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof RealAttributesOnlyRequestControl) { |
| | | return (RealAttributesOnlyRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | import org.forgerock.opendj.ldap.controls.ControlDecoder; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The Sun-defined virtual attributes only request control. The OID for this |
| | |
| | | |
| | | public VirtualAttributesOnlyRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof VirtualAttributesOnlyRequestControl) { |
| | | return (VirtualAttributesOnlyRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.responses.AbstractExtendedResult; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Get connection ID extended result. |
| | |
| | | * If {@code resultCode} was {@code null}. |
| | | */ |
| | | public static GetConnectionIDExtendedResult newResult(final ResultCode resultCode) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | return new GetConnectionIDExtendedResult(resultCode); |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.FutureResult; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An implementation of {@code FutureResult} which can be used in cases where |
| | |
| | | * If {@code errorResult} was {@code null}. |
| | | */ |
| | | public CompletedFutureResult(final ErrorResultException errorResult, final int requestID) { |
| | | Validator.ensureNotNull(errorResult); |
| | | Reject.ifNull(errorResult); |
| | | this.result = null; |
| | | this.errorResult = errorResult; |
| | | this.requestID = requestID; |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ProviderNotFoundException; |
| | | import org.forgerock.opendj.ldap.spi.Provider; |
| | | import org.forgerock.util.Reject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | |
| | | * If {@code c} or {@code separator} were {@code null}. |
| | | */ |
| | | public static String joinCollection(Collection<?> c, String separator) { |
| | | Validator.ensureNotNull(c, separator); |
| | | Reject.ifNull(c); |
| | | Reject.ifNull(separator); |
| | | |
| | | switch (c.size()) { |
| | | case 0: |
| | |
| | | * @return The updated {@code StringBuilder}. |
| | | */ |
| | | public static StringBuilder toLowerCase(final ByteSequence b, final StringBuilder builder) { |
| | | Validator.ensureNotNull(b, builder); |
| | | Reject.ifNull(b); |
| | | Reject.ifNull(builder); |
| | | |
| | | // FIXME: What locale should we use for non-ASCII characters? I |
| | | // think we should use default to the Unicode StringPrep. |
| | |
| | | * @return The lower-case representation of the given string. |
| | | */ |
| | | public static String toLowerCase(final String s) { |
| | | Validator.ensureNotNull(s); |
| | | Reject.ifNull(s); |
| | | |
| | | // FIXME: What locale should we use for non-ASCII characters? I |
| | | // think we should use default to the Unicode StringPrep. |
| | |
| | | * @return The updated {@code StringBuilder}. |
| | | */ |
| | | public static StringBuilder toLowerCase(final String s, final StringBuilder builder) { |
| | | Validator.ensureNotNull(s, builder); |
| | | Reject.ifNull(s); |
| | | Reject.ifNull(builder); |
| | | |
| | | // FIXME: What locale should we use for non-ASCII characters? I |
| | | // think we should use default to the Unicode StringPrep. |
| | |
| | | */ |
| | | package com.forgerock.opendj.util; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.ensureNotNull; |
| | | |
| | | import java.text.Normalizer; |
| | | import java.text.Normalizer.Form; |
| | |
| | | import java.util.HashSet; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class defines the "stringprep" profile as defined in RFC 4518. It must |
| | |
| | | */ |
| | | public static void prepareUnicode(final StringBuilder buffer, final ByteSequence sequence, |
| | | final boolean trim, final boolean foldCase) { |
| | | ensureNotNull(buffer); |
| | | ensureNotNull(sequence); |
| | | Reject.ifNull(buffer); |
| | | Reject.ifNull(sequence); |
| | | |
| | | // Optimize in the case of purely ascii characters which is the most |
| | | // common case. |
| | | final int length = sequence.length(); |
| | |
| | | |
| | | package com.forgerock.opendj.util; |
| | | |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A sub-string reader. |
| | | */ |
| | |
| | | * the source of the reader. |
| | | */ |
| | | public SubstringReader(final String s) { |
| | | Validator.ensureNotNull(s); |
| | | Reject.ifNull(s); |
| | | source = s; |
| | | length = s.length(); |
| | | pos = 0; |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.SubstringReader; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * An attribute value assertion (AVA) as defined in RFC 4512 section 2.3 |
| | |
| | | * {@code null}. |
| | | */ |
| | | public AVA(final AttributeType attributeType, final Object attributeValue) { |
| | | Validator.ensureNotNull(attributeType, attributeValue); |
| | | Reject.ifNull(attributeType); |
| | | Reject.ifNull(attributeValue); |
| | | |
| | | this.attributeType = attributeType; |
| | | this.attributeValue = ByteString.valueOf(attributeValue); |
| | |
| | | * {@code null}. |
| | | */ |
| | | public AVA(final String attributeType, final Object attributeValue) { |
| | | Validator.ensureNotNull(attributeType, attributeValue); |
| | | Reject.ifNull(attributeType); |
| | | Reject.ifNull(attributeValue); |
| | | |
| | | this.attributeType = Schema.getDefaultSchema().getAttributeType(attributeType); |
| | | this.attributeValue = ByteString.valueOf(attributeValue); |
| | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class provides a skeletal implementation of the {@code Attribute} |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean add(final Object... values) { |
| | | Validator.ensureNotNull(values); |
| | | Reject.ifNull(values); |
| | | boolean modified = false; |
| | | for (final Object value : values) { |
| | | modified |= add(ByteString.valueOf(value)); |
| | |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_UNEXPECTED_SEARCH_RESULT_ENTRIES; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_UNEXPECTED_SEARCH_RESULT_ENTRIES_NO_COUNT; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_UNEXPECTED_SEARCH_RESULT_REFERENCES; |
| | | |
| | | import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult; |
| | | |
| | | import java.util.Collection; |
| | |
| | | import org.forgerock.opendj.ldif.ChangeRecord; |
| | | import org.forgerock.opendj.ldif.ChangeRecordVisitor; |
| | | import org.forgerock.opendj.ldif.ConnectionEntryReader; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class provides a skeletal implementation of the {@code Connection} |
| | |
| | | public Result search(final SearchRequest request, |
| | | final Collection<? super SearchResultEntry> entries, |
| | | final Collection<? super SearchResultReference> references) throws ErrorResultException { |
| | | Validator.ensureNotNull(request, entries); |
| | | Reject.ifNull(request); |
| | | Reject.ifNull(entries); |
| | | |
| | | // FIXME: does this need to be thread safe? |
| | | final SearchResultHandler handler = new SearchResultHandler() { |
| | |
| | | import org.forgerock.opendj.ldif.ChangeRecord; |
| | | import org.forgerock.opendj.ldif.ConnectionEntryReader; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An abstract base class from which connection wrappers may be easily |
| | |
| | | * The connection to be wrapped. |
| | | */ |
| | | protected AbstractConnectionWrapper(final C connection) { |
| | | Validator.ensureNotNull(connection); |
| | | Reject.ifNull(connection); |
| | | this.connection = connection; |
| | | } |
| | | |
| | |
| | | |
| | | import com.forgerock.opendj.util.Iterables; |
| | | import com.forgerock.opendj.util.Predicate; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class provides a skeletal implementation of the {@code Entry} interface, |
| | |
| | | |
| | | @Override |
| | | public Iterable<Attribute> getAllAttributes(final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | |
| | | return Iterables.filteredIterable(getAllAttributes(), FIND_ATTRIBUTES_PREDICATE, |
| | | attributeDescription); |
| | |
| | | import java.util.concurrent.ScheduledFuture; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.AsynchronousFutureResult; |
| | | import com.forgerock.opendj.util.ReferenceCountedObject; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * An abstract load balancing algorithm providing monitoring and failover |
| | |
| | | AbstractLoadBalancingAlgorithm(final Collection<? extends ConnectionFactory> factories, |
| | | final LoadBalancerEventListener listener, final long interval, final TimeUnit unit, |
| | | final ScheduledExecutorService scheduler) { |
| | | Validator.ensureNotNull(factories, unit); |
| | | Reject.ifNull(factories); |
| | | Reject.ifNull(unit); |
| | | |
| | | this.monitoredFactories = new ArrayList<MonitoredConnectionFactory>(factories.size()); |
| | | int i = 0; |
| | |
| | | import java.util.Collection; |
| | | import java.util.Map; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Abstract implementation for {@code Map} based entries. |
| | |
| | | */ |
| | | @Override |
| | | public final Entry setName(final DN dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = dn; |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.ASCIICharProp; |
| | | import com.forgerock.opendj.util.Iterators; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * An attribute description as defined in RFC 4512 section 2.5. Attribute |
| | |
| | | * {@code null}. |
| | | */ |
| | | public AttributeDescription withOption(final String option) { |
| | | Validator.ensureNotNull(option); |
| | | Reject.ifNull(option); |
| | | |
| | | final String normalizedOption = toLowerCase(option); |
| | | if (pimpl.hasOption(normalizedOption)) { |
| | |
| | | * {@code null}. |
| | | */ |
| | | public AttributeDescription withoutOption(final String option) { |
| | | Validator.ensureNotNull(option); |
| | | Reject.ifNull(option); |
| | | |
| | | final String normalizedOption = toLowerCase(option); |
| | | if (!pimpl.hasOption(normalizedOption)) { |
| | |
| | | * If {@code attributeType} was {@code null}. |
| | | */ |
| | | public static AttributeDescription create(final AttributeType attributeType) { |
| | | Validator.ensureNotNull(attributeType); |
| | | Reject.ifNull(attributeType); |
| | | |
| | | // Use object identity in case attribute type does not come from |
| | | // core schema. |
| | |
| | | * If {@code attributeType} or {@code option} was {@code null}. |
| | | */ |
| | | public static AttributeDescription create(final AttributeType attributeType, final String option) { |
| | | Validator.ensureNotNull(attributeType, option); |
| | | Reject.ifNull(attributeType); |
| | | Reject.ifNull(option); |
| | | |
| | | final String oid = attributeType.getNameOrOID(); |
| | | final StringBuilder builder = new StringBuilder(oid.length() + option.length() + 1); |
| | |
| | | */ |
| | | public static AttributeDescription create(final AttributeType attributeType, |
| | | final String... options) { |
| | | Validator.ensureNotNull(attributeType, options); |
| | | Reject.ifNull(attributeType); |
| | | Reject.ifNull(options); |
| | | |
| | | switch (options.length) { |
| | | case 0: |
| | |
| | | @SuppressWarnings("serial") |
| | | public static AttributeDescription valueOf(final String attributeDescription, |
| | | final Schema schema) { |
| | | Validator.ensureNotNull(attributeDescription, schema); |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifNull(schema); |
| | | |
| | | // First look up the attribute description in the cache. |
| | | final WeakHashMap<Schema, Map<String, AttributeDescription>> threadLocalMap = CACHE.get(); |
| | |
| | | import java.util.Iterator; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.Iterators; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * This class contains methods for creating and manipulating attributes. |
| | |
| | | */ |
| | | public static final Attribute renameAttribute(final Attribute attribute, |
| | | final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attribute, attributeDescription); |
| | | Reject.ifNull(attribute); |
| | | Reject.ifNull(attributeDescription); |
| | | |
| | | // Optimize for the case where no renaming is required. |
| | | if (attribute.getAttributeDescription() == attributeDescription) { |
| | |
| | | */ |
| | | public static final Attribute renameAttribute(final Attribute attribute, |
| | | final String attributeDescription) { |
| | | Validator.ensureNotNull(attribute, attributeDescription); |
| | | Reject.ifNull(attribute); |
| | | Reject.ifNull(attributeDescription); |
| | | return renameAttribute(attribute, AttributeDescription.valueOf(attributeDescription)); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import static com.forgerock.opendj.util.Validator.ensureNotNull; |
| | | import org.forgerock.util.Reject; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_BASE64_DECODE_INVALID_CHARACTER; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_BASE64_DECODE_INVALID_LENGTH; |
| | | |
| | |
| | | * If {@code base64} was {@code null}. |
| | | */ |
| | | static ByteString decode(final String base64) { |
| | | ensureNotNull(base64); |
| | | Reject.ifNull(base64); |
| | | |
| | | // The encoded value must have length that is a multiple of four |
| | | // bytes. |
| | |
| | | * If {@code bytes} was {@code null}. |
| | | */ |
| | | static String encode(final ByteSequence bytes) { |
| | | ensureNotNull(bytes); |
| | | Reject.ifNull(bytes); |
| | | |
| | | final StringBuilder buffer = new StringBuilder(4 * bytes.length() / 3); |
| | | |
| | |
| | | import java.util.concurrent.Semaphore; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | import org.forgerock.opendj.ldap.requests.AbandonRequest; |
| | | import org.forgerock.opendj.ldap.requests.AddRequest; |
| | | import org.forgerock.opendj.ldap.requests.BindRequest; |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | import org.forgerock.opendj.ldif.ChangeRecord; |
| | | import org.forgerock.opendj.ldif.ConnectionEntryReader; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.AsynchronousFutureResult; |
| | | import com.forgerock.opendj.util.CompletedFutureResult; |
| | | import com.forgerock.opendj.util.ReferenceCountedObject; |
| | | import com.forgerock.opendj.util.TimeSource; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * A connection pool implementation which maintains a cache of pooled |
| | |
| | | |
| | | @Override |
| | | public void addConnectionEventListener(final ConnectionEventListener listener) { |
| | | Validator.ensureNotNull(listener); |
| | | Reject.ifNull(listener); |
| | | final boolean notifyClose; |
| | | final boolean notifyErrorOccurred; |
| | | synchronized (stateLock) { |
| | |
| | | |
| | | @Override |
| | | public void removeConnectionEventListener(final ConnectionEventListener listener) { |
| | | Validator.ensureNotNull(listener); |
| | | Reject.ifNull(listener); |
| | | synchronized (stateLock) { |
| | | if (listeners != null) { |
| | | listeners.remove(listener); |
| | |
| | | CachedConnectionPool(final ConnectionFactory factory, final int corePoolSize, |
| | | final int maximumPoolSize, final long idleTimeout, final TimeUnit unit, |
| | | final ScheduledExecutorService scheduler) { |
| | | Validator.ensureNotNull(factory); |
| | | Validator.ensureTrue(corePoolSize >= 0, "corePoolSize < 0"); |
| | | Validator.ensureTrue(maximumPoolSize > 0, "maxPoolSize <= 0"); |
| | | Validator.ensureTrue(corePoolSize <= maximumPoolSize, "corePoolSize > maxPoolSize"); |
| | | Validator.ensureTrue(idleTimeout >= 0, "idleTimeout < 0"); |
| | | Validator.ensureTrue(idleTimeout == 0 || unit != null, "time unit is null"); |
| | | Reject.ifNull(factory); |
| | | Reject.ifFalse(corePoolSize >= 0, "corePoolSize < 0"); |
| | | Reject.ifFalse(maximumPoolSize > 0, "maxPoolSize <= 0"); |
| | | Reject.ifFalse(corePoolSize <= maximumPoolSize, "corePoolSize > maxPoolSize"); |
| | | Reject.ifFalse(idleTimeout >= 0, "idleTimeout < 0"); |
| | | Reject.ifFalse(idleTimeout == 0 || unit != null, "time unit is null"); |
| | | |
| | | this.factory = factory; |
| | | this.corePoolSize = corePoolSize; |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.requests.BindRequest; |
| | | import org.forgerock.opendj.ldap.requests.SearchRequest; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class contains methods for creating and manipulating connection |
| | |
| | | */ |
| | | public static ConnectionFactory newAuthenticatedConnectionFactory( |
| | | final ConnectionFactory factory, final BindRequest request) { |
| | | Validator.ensureNotNull(factory, request); |
| | | Reject.ifNull(factory); |
| | | Reject.ifNull(request); |
| | | |
| | | return new AuthenticatedConnectionFactory(factory, request); |
| | | } |
| | |
| | | */ |
| | | public static Connection newInternalConnection( |
| | | final RequestHandler<RequestContext> requestHandler) { |
| | | Validator.ensureNotNull(requestHandler); |
| | | Reject.ifNull(requestHandler); |
| | | return newInternalConnection(adaptRequestHandler(requestHandler)); |
| | | } |
| | | |
| | |
| | | * If {@code serverConnection} was {@code null}. |
| | | */ |
| | | public static Connection newInternalConnection(final ServerConnection<Integer> serverConnection) { |
| | | Validator.ensureNotNull(serverConnection); |
| | | Reject.ifNull(serverConnection); |
| | | return new InternalConnection(serverConnection); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static ConnectionFactory newInternalConnectionFactory( |
| | | final RequestHandler<RequestContext> requestHandler) { |
| | | Validator.ensureNotNull(requestHandler); |
| | | Reject.ifNull(requestHandler); |
| | | return new InternalConnectionFactory<Void>(Connections |
| | | .<Void> newServerConnectionFactory(requestHandler), null); |
| | | } |
| | |
| | | */ |
| | | public static <C> ConnectionFactory newInternalConnectionFactory( |
| | | final RequestHandlerFactory<C, RequestContext> factory, final C clientContext) { |
| | | Validator.ensureNotNull(factory); |
| | | Reject.ifNull(factory); |
| | | return new InternalConnectionFactory<C>(newServerConnectionFactory(factory), clientContext); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static <C> ConnectionFactory newInternalConnectionFactory( |
| | | final ServerConnectionFactory<C, Integer> factory, final C clientContext) { |
| | | Validator.ensureNotNull(factory); |
| | | Reject.ifNull(factory); |
| | | return new InternalConnectionFactory<C>(factory, clientContext); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static ConnectionFactory newNamedConnectionFactory(final ConnectionFactory factory, |
| | | final String name) { |
| | | Validator.ensureNotNull(factory, name); |
| | | Reject.ifNull(factory); |
| | | Reject.ifNull(name); |
| | | |
| | | return new ConnectionFactory() { |
| | | |
| | |
| | | */ |
| | | public static <C> ServerConnectionFactory<C, Integer> newServerConnectionFactory( |
| | | final RequestHandler<RequestContext> requestHandler) { |
| | | Validator.ensureNotNull(requestHandler); |
| | | Reject.ifNull(requestHandler); |
| | | return new RequestHandlerFactoryAdapter<C>(new RequestHandlerFactory<C, RequestContext>() { |
| | | @Override |
| | | public RequestHandler<RequestContext> handleAccept(final C clientContext) { |
| | |
| | | */ |
| | | public static <C> ServerConnectionFactory<C, Integer> newServerConnectionFactory( |
| | | final RequestHandlerFactory<C, RequestContext> factory) { |
| | | Validator.ensureNotNull(factory); |
| | | Reject.ifNull(factory); |
| | | return new RequestHandlerFactoryAdapter<C>(factory); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.SubstringReader; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * A distinguished name (DN) as defined in RFC 4512 section 2.3 is the |
| | |
| | | * string. |
| | | */ |
| | | public static String escapeAttributeValue(final Object attributeValue) { |
| | | Validator.ensureNotNull(attributeValue); |
| | | Reject.ifNull(attributeValue); |
| | | final String s = String.valueOf(attributeValue); |
| | | final StringBuilder builder = new StringBuilder(s.length()); |
| | | AVA.escapeAttributeValue(s, builder); |
| | |
| | | * @see #format(String, Schema, Object...) |
| | | */ |
| | | public static DN valueOf(final String dn, final Schema schema) { |
| | | Validator.ensureNotNull(dn, schema); |
| | | Reject.ifNull(dn); |
| | | Reject.ifNull(schema); |
| | | if (dn.length() == 0) { |
| | | return ROOT_DN; |
| | | } |
| | |
| | | * If {@code dn} was {@code null}. |
| | | */ |
| | | public DN child(final DN dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | |
| | | if (dn.isRootDN()) { |
| | | return this; |
| | |
| | | * @see RDN#maxValue() |
| | | */ |
| | | public DN child(final RDN rdn) { |
| | | Validator.ensureNotNull(rdn); |
| | | Reject.ifNull(rdn); |
| | | return new DN(this, rdn, null); |
| | | } |
| | | |
| | |
| | | * If {@code dn} was {@code null}. |
| | | */ |
| | | public DN child(final String dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | return child(valueOf(dn)); |
| | | } |
| | | |
| | |
| | | * If {@code index} is less than zero. |
| | | */ |
| | | public DN localName(final int index) { |
| | | Validator.ensureTrue(index >= 0, "index less than zero"); |
| | | Reject.ifFalse(index >= 0, "index less than zero"); |
| | | |
| | | if (index == 0) { |
| | | return ROOT_DN; |
| | |
| | | public DN parent(final int index) { |
| | | // We allow size + 1 so that we can return null as the parent of the |
| | | // Root DN. |
| | | Validator.ensureTrue(index >= 0, "index less than zero"); |
| | | Reject.ifFalse(index >= 0, "index less than zero"); |
| | | |
| | | DN parentDN = this; |
| | | for (int i = 0; parentDN != null && i < index; i++) { |
| | |
| | | * If {@code fromDN} or {@code toDN} was {@code null}. |
| | | */ |
| | | public DN rename(final DN fromDN, final DN toDN) { |
| | | Validator.ensureNotNull(fromDN, toDN); |
| | | Reject.ifNull(fromDN); |
| | | Reject.ifNull(toDN); |
| | | |
| | | if (!isSubordinateOrEqualTo(fromDN)) { |
| | | return this; |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Decode options allow applications to control how requests and responses are |
| | |
| | | * If {@code factory} was {@code null}. |
| | | */ |
| | | public final DecodeOptions setAttributeFactory(final AttributeFactory factory) { |
| | | Validator.ensureNotNull(factory); |
| | | Reject.ifNull(factory); |
| | | this.attributeFactory = factory; |
| | | return this; |
| | | } |
| | |
| | | * If {@code factory} was {@code null}. |
| | | */ |
| | | public final DecodeOptions setEntryFactory(final EntryFactory factory) { |
| | | Validator.ensureNotNull(factory); |
| | | Reject.ifNull(factory); |
| | | this.entryFactory = factory; |
| | | return this; |
| | | } |
| | |
| | | * If {@code schema} was {@code null}. |
| | | */ |
| | | public final DecodeOptions setSchema(final Schema schema) { |
| | | Validator.ensureNotNull(schema); |
| | | Reject.ifNull(schema); |
| | | this.schemaResolver = new FixedSchemaResolver(schema); |
| | | return this; |
| | | } |
| | |
| | | * If {@code resolver} was {@code null}. |
| | | */ |
| | | public final DecodeOptions setSchemaResolver(final SchemaResolver resolver) { |
| | | Validator.ensureNotNull(resolver); |
| | | Reject.ifNull(resolver); |
| | | this.schemaResolver = resolver; |
| | | return this; |
| | | } |
| | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import static org.forgerock.opendj.ldap.AttributeDescription.objectClass; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_ENTRY_DUPLICATE_VALUES; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_ENTRY_INCREMENT_CANNOT_PARSE_AS_INT; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_ENTRY_INCREMENT_INVALID_VALUE_COUNT; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_ENTRY_INCREMENT_NO_SUCH_ATTRIBUTE; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.*; |
| | | import static com.forgerock.opendj.ldap.CoreMessages.ERR_ENTRY_UNKNOWN_MODIFICATION_TYPE; |
| | | import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.Iterables; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * This class contains methods for creating and manipulating entries. |
| | |
| | | * @see Requests#newModifyRequest(Entry, Entry) |
| | | */ |
| | | public static ModifyRequest diffEntries(final Entry fromEntry, final Entry toEntry) { |
| | | Validator.ensureNotNull(fromEntry, toEntry); |
| | | Reject.ifNull(fromEntry); |
| | | Reject.ifNull(toEntry); |
| | | |
| | | final ModifyRequest request = Requests.newModifyRequest(fromEntry.getName()); |
| | | |
| | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An {@code ErrorResultIOException} adapts an {@code ErrorResultException} to |
| | |
| | | * If {@code cause} was {@code null}. |
| | | */ |
| | | public ErrorResultIOException(final ErrorResultException cause) { |
| | | super(Validator.ensureNotNull(cause)); |
| | | super(Reject.checkNotNull(cause)); |
| | | |
| | | this.cause = cause; |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * A search filter as defined in RFC 4511. In addition this class also provides |
| | |
| | | return alwaysTrue(); |
| | | } else if (subFilters.size() == 1) { |
| | | final Filter subFilter = subFilters.iterator().next(); |
| | | Validator.ensureNotNull(subFilter); |
| | | Reject.ifNull(subFilter); |
| | | return new Filter(new AndImpl(Collections.singletonList(subFilter))); |
| | | } else { |
| | | final List<Filter> subFiltersList = new ArrayList<Filter>(subFilters.size()); |
| | | for (final Filter subFilter : subFilters) { |
| | | Validator.ensureNotNull(subFilter); |
| | | Reject.ifNull(subFilter); |
| | | subFiltersList.add(subFilter); |
| | | } |
| | | return new Filter(new AndImpl(Collections.unmodifiableList(subFiltersList))); |
| | |
| | | // RFC 4526 - TRUE filter. |
| | | return alwaysTrue(); |
| | | } else if (subFilters.length == 1) { |
| | | Validator.ensureNotNull(subFilters[0]); |
| | | Reject.ifNull(subFilters[0]); |
| | | return new Filter(new AndImpl(Collections.singletonList(subFilters[0]))); |
| | | } else { |
| | | final List<Filter> subFiltersList = new ArrayList<Filter>(subFilters.length); |
| | | for (final Filter subFilter : subFilters) { |
| | | Validator.ensureNotNull(subFilter); |
| | | Reject.ifNull(subFilter); |
| | | subFiltersList.add(subFilter); |
| | | } |
| | | return new Filter(new AndImpl(Collections.unmodifiableList(subFiltersList))); |
| | |
| | | * @return The newly created {@code approximate match} filter. |
| | | */ |
| | | public static Filter approx(final String attributeDescription, final Object assertionValue) { |
| | | Validator.ensureNotNull(attributeDescription, assertionValue); |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifNull(assertionValue); |
| | | return new Filter(new ApproxMatchImpl(attributeDescription, ByteString |
| | | .valueOf(assertionValue))); |
| | | } |
| | |
| | | * @return The newly created {@code equality match} filter. |
| | | */ |
| | | public static Filter equality(final String attributeDescription, final Object assertionValue) { |
| | | Validator.ensureNotNull(attributeDescription, assertionValue); |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifNull(assertionValue); |
| | | return new Filter(new EqualityMatchImpl(attributeDescription, ByteString |
| | | .valueOf(assertionValue))); |
| | | } |
| | |
| | | * @see #format(String, Object...) |
| | | */ |
| | | public static String escapeAssertionValue(final Object assertionValue) { |
| | | Validator.ensureNotNull(assertionValue); |
| | | Reject.ifNull(assertionValue); |
| | | final ByteString bytes = ByteString.valueOf(assertionValue); |
| | | final StringBuilder builder = new StringBuilder(bytes.length()); |
| | | valueToFilterString(builder, bytes); |
| | |
| | | */ |
| | | public static Filter extensible(final String matchingRule, final String attributeDescription, |
| | | final Object assertionValue, final boolean dnAttributes) { |
| | | Validator.ensureTrue((matchingRule != null) || (attributeDescription != null), |
| | | "matchingRule and/or " + "attributeDescription must not be null"); |
| | | Validator.ensureNotNull(assertionValue); |
| | | Reject.ifFalse(matchingRule != null || attributeDescription != null, |
| | | "matchingRule and/or attributeDescription must not be null"); |
| | | Reject.ifNull(assertionValue); |
| | | return new Filter(new ExtensibleMatchImpl(matchingRule, attributeDescription, ByteString |
| | | .valueOf(assertionValue), dnAttributes)); |
| | | } |
| | |
| | | */ |
| | | public static Filter greaterOrEqual(final String attributeDescription, |
| | | final Object assertionValue) { |
| | | Validator.ensureNotNull(attributeDescription, assertionValue); |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifNull(assertionValue); |
| | | return new Filter(new GreaterOrEqualImpl(attributeDescription, ByteString |
| | | .valueOf(assertionValue))); |
| | | } |
| | |
| | | * @return The newly created {@code less or equal} filter. |
| | | */ |
| | | public static Filter lessOrEqual(final String attributeDescription, final Object assertionValue) { |
| | | Validator.ensureNotNull(attributeDescription, assertionValue); |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifNull(assertionValue); |
| | | return new Filter(new LessOrEqualImpl(attributeDescription, ByteString |
| | | .valueOf(assertionValue))); |
| | | } |
| | |
| | | * @return The newly created {@code not} filter. |
| | | */ |
| | | public static Filter not(final Filter subFilter) { |
| | | Validator.ensureNotNull(subFilter); |
| | | Reject.ifNull(subFilter); |
| | | return new Filter(new NotImpl(subFilter)); |
| | | } |
| | | |
| | |
| | | return alwaysFalse(); |
| | | } else if (subFilters.size() == 1) { |
| | | final Filter subFilter = subFilters.iterator().next(); |
| | | Validator.ensureNotNull(subFilter); |
| | | Reject.ifNull(subFilter); |
| | | return new Filter(new OrImpl(Collections.singletonList(subFilter))); |
| | | } else { |
| | | final List<Filter> subFiltersList = new ArrayList<Filter>(subFilters.size()); |
| | | for (final Filter subFilter : subFilters) { |
| | | Validator.ensureNotNull(subFilter); |
| | | Reject.ifNull(subFilter); |
| | | subFiltersList.add(subFilter); |
| | | } |
| | | return new Filter(new OrImpl(Collections.unmodifiableList(subFiltersList))); |
| | |
| | | // RFC 4526 - FALSE filter. |
| | | return alwaysFalse(); |
| | | } else if (subFilters.length == 1) { |
| | | Validator.ensureNotNull(subFilters[0]); |
| | | Reject.ifNull(subFilters[0]); |
| | | return new Filter(new OrImpl(Collections.singletonList(subFilters[0]))); |
| | | } else { |
| | | final List<Filter> subFiltersList = new ArrayList<Filter>(subFilters.length); |
| | | for (final Filter subFilter : subFilters) { |
| | | Validator.ensureNotNull(subFilter); |
| | | Reject.ifNull(subFilter); |
| | | subFiltersList.add(subFilter); |
| | | } |
| | | return new Filter(new OrImpl(Collections.unmodifiableList(subFiltersList))); |
| | |
| | | * @return The newly created {@code present} filter. |
| | | */ |
| | | public static Filter present(final String attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | if (toLowerCase(attributeDescription).equals("objectclass")) { |
| | | return OBJECT_CLASS_PRESENT; |
| | | } |
| | |
| | | public static Filter substrings(final String attributeDescription, |
| | | final Object initialSubstring, final Collection<?> anySubstrings, |
| | | final Object finalSubstring) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Validator.ensureTrue((initialSubstring != null) || (finalSubstring != null) |
| | | 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"); |
| | | |
| | |
| | | anySubstringList = Collections.emptyList(); |
| | | } else if (anySubstrings.size() == 1) { |
| | | final Object anySubstring = anySubstrings.iterator().next(); |
| | | Validator.ensureNotNull(anySubstring); |
| | | Reject.ifNull(anySubstring); |
| | | anySubstringList = Collections.singletonList(ByteString.valueOf(anySubstring)); |
| | | } else { |
| | | anySubstringList = new ArrayList<ByteString>(anySubstrings.size()); |
| | | for (final Object anySubstring : anySubstrings) { |
| | | Validator.ensureNotNull(anySubstring); |
| | | Reject.ifNull(anySubstring); |
| | | |
| | | anySubstringList.add(ByteString.valueOf(anySubstring)); |
| | | } |
| | |
| | | * @return The newly created {@code unrecognized} filter. |
| | | */ |
| | | public static Filter unrecognized(final byte filterTag, final ByteString filterBytes) { |
| | | Validator.ensureNotNull(filterBytes); |
| | | Reject.ifNull(filterBytes); |
| | | return new Filter(new UnrecognizedImpl(filterTag, filterBytes)); |
| | | } |
| | | |
| | |
| | | * @see #format(String, Object...) |
| | | */ |
| | | public static Filter valueOf(final String string) { |
| | | Validator.ensureNotNull(string); |
| | | Reject.ifNull(string); |
| | | |
| | | // If the filter is enclosed in a pair of single quotes it |
| | | // is invalid (issue #1024). |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDAP generalized time as defined in RFC 4517. This class facilitates |
| | |
| | | * @return A generalized time representing the provided {@code Calendar}. |
| | | */ |
| | | public static GeneralizedTime valueOf(final Calendar calendar) { |
| | | Validator.ensureNotNull(calendar); |
| | | Reject.ifNull(calendar); |
| | | return new GeneralizedTime((Calendar) calendar.clone(), null, -1L, null); |
| | | } |
| | | |
| | |
| | | * @return A generalized time representing the provided {@code Date}. |
| | | */ |
| | | public static GeneralizedTime valueOf(final Date date) { |
| | | Validator.ensureNotNull(date); |
| | | Reject.ifNull(date); |
| | | return new GeneralizedTime(null, (Date) date.clone(), -1L, null); |
| | | } |
| | | |
| | |
| | | * since the epoch. |
| | | */ |
| | | public static GeneralizedTime valueOf(final long timeMS) { |
| | | Validator.ensureTrue(timeMS >= 0, "timeMS must be >= 0"); |
| | | Reject.ifFalse(timeMS >= 0, "timeMS must be >= 0"); |
| | | return new GeneralizedTime(null, null, timeMS, null); |
| | | } |
| | | |
| | |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.concurrent.locks.AbstractQueuedSynchronizer; |
| | | |
| | | import org.forgerock.opendj.ldap.requests.AbandonRequest; |
| | | import org.forgerock.opendj.ldap.requests.AddRequest; |
| | | import org.forgerock.opendj.ldap.requests.BindRequest; |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | import org.forgerock.opendj.ldap.spi.ConnectionState; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.AsynchronousFutureResult; |
| | | import com.forgerock.opendj.util.CompletedFutureResult; |
| | |
| | | import com.forgerock.opendj.util.RecursiveFutureResult; |
| | | import com.forgerock.opendj.util.ReferenceCountedObject; |
| | | import com.forgerock.opendj.util.TimeSource; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * An heart beat connection factory can be used to create connections that sends |
| | |
| | | HeartBeatConnectionFactory(final ConnectionFactory factory, final long interval, |
| | | final long timeout, final TimeUnit unit, final SearchRequest heartBeat, |
| | | final ScheduledExecutorService scheduler) { |
| | | Validator.ensureNotNull(factory, unit); |
| | | Validator.ensureTrue(interval >= 0, "negative interval"); |
| | | Validator.ensureTrue(timeout >= 0, "negative timeout"); |
| | | Reject.ifNull(factory); |
| | | Reject.ifNull(unit); |
| | | Reject.ifFalse(interval >= 0, "negative interval"); |
| | | Reject.ifFalse(timeout >= 0, "negative timeout"); |
| | | |
| | | this.heartBeatRequest = heartBeat != null ? heartBeat : DEFAULT_SEARCH; |
| | | this.interval = interval; |
| | |
| | | import org.forgerock.opendj.ldap.spi.LDAPSearchFutureResultImpl; |
| | | |
| | | import com.forgerock.opendj.util.CompletedFutureResult; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class defines a pseudo-connection object that can be used for performing |
| | |
| | | */ |
| | | @Override |
| | | public void addConnectionEventListener(final ConnectionEventListener listener) { |
| | | Validator.ensureNotNull(listener); |
| | | Reject.ifNull(listener); |
| | | listeners.add(listener); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void removeConnectionEventListener(final ConnectionEventListener listener) { |
| | | Validator.ensureNotNull(listener); |
| | | Reject.ifNull(listener); |
| | | listeners.remove(listener); |
| | | } |
| | | |
| | |
| | | import javax.net.ssl.X509ExtendedKeyManager; |
| | | import javax.net.ssl.X509KeyManager; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class contains methods for creating common types of key manager. |
| | |
| | | */ |
| | | public static X509KeyManager useKeyStoreFile(final String file, final char[] password, |
| | | final String format) throws GeneralSecurityException, IOException { |
| | | Validator.ensureNotNull(file); |
| | | Reject.ifNull(file); |
| | | |
| | | final File keyStoreFile = new File(file); |
| | | final String keyStoreFormat = format != null ? format : KeyStore.getDefaultType(); |
| | |
| | | */ |
| | | public static X509KeyManager useSingleCertificate(final String alias, |
| | | final X509KeyManager keyManager) { |
| | | Validator.ensureNotNull(alias, keyManager); |
| | | Reject.ifNull(alias); |
| | | Reject.ifNull(keyManager); |
| | | return new SelectCertificate(keyManager, alias); |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.spi.LDAPConnectionFactoryImpl; |
| | | import org.forgerock.opendj.ldap.spi.TransportProvider; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A factory class which can be used to obtain connections to an LDAP Directory |
| | |
| | | * provider requested using options is not found. |
| | | */ |
| | | public LDAPConnectionFactory(final SocketAddress address, final LDAPOptions options) { |
| | | Validator.ensureNotNull(address, options); |
| | | Reject.ifNull(address); |
| | | Reject.ifNull(options); |
| | | this.provider = getProvider(TransportProvider.class, options.getTransportProvider(), |
| | | options.getProviderClassLoader()); |
| | | this.impl = provider.getLDAPConnectionFactory(address, options); |
| | |
| | | * provider requested using options is not found. |
| | | */ |
| | | public LDAPConnectionFactory(final String host, final int port, final LDAPOptions options) { |
| | | Validator.ensureNotNull(host, options); |
| | | Reject.ifNull(host); |
| | | Reject.ifNull(options); |
| | | final SocketAddress address = new InetSocketAddress(host, port); |
| | | this.provider = getProvider(TransportProvider.class, options.getTransportProvider(), |
| | | options.getProviderClassLoader()); |
| | |
| | | import java.net.InetAddress; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.SocketAddress; |
| | | |
| | | import org.forgerock.opendj.ldap.spi.LDAPListenerImpl; |
| | | import org.forgerock.opendj.ldap.spi.TransportProvider; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDAP server connection listener which waits for LDAP connection requests |
| | |
| | | public LDAPListener(final int port, |
| | | final ServerConnectionFactory<LDAPClientContext, Integer> factory, |
| | | final LDAPListenerOptions options) throws IOException { |
| | | Validator.ensureNotNull(factory, options); |
| | | Reject.ifNull(factory); |
| | | Reject.ifNull(options); |
| | | final SocketAddress address = new InetSocketAddress(port); |
| | | this.provider = getProvider(TransportProvider.class, options.getTransportProvider(), |
| | | options.getProviderClassLoader()); |
| | |
| | | public LDAPListener(final SocketAddress address, |
| | | final ServerConnectionFactory<LDAPClientContext, Integer> factory, |
| | | final LDAPListenerOptions options) throws IOException { |
| | | Validator.ensureNotNull(address, factory, options); |
| | | Reject.ifNull(address); |
| | | Reject.ifNull(factory); |
| | | Reject.ifNull(options); |
| | | this.provider = getProvider(TransportProvider.class, options.getTransportProvider(), |
| | | options.getProviderClassLoader()); |
| | | this.impl = provider.getLDAPListener(address, factory, options); |
| | |
| | | public LDAPListener(final String host, final int port, |
| | | final ServerConnectionFactory<LDAPClientContext, Integer> factory, |
| | | final LDAPListenerOptions options) throws IOException { |
| | | Validator.ensureNotNull(host, factory, options); |
| | | Reject.ifNull(host); |
| | | Reject.ifNull(factory); |
| | | Reject.ifNull(options); |
| | | final SocketAddress address = new InetSocketAddress(host, port); |
| | | this.provider = getProvider(TransportProvider.class, options.getTransportProvider(), |
| | | options.getProviderClassLoader()); |
| | |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Common options for LDAP listeners. |
| | |
| | | * If {@code decodeOptions} was {@code null}. |
| | | */ |
| | | public LDAPListenerOptions setDecodeOptions(final DecodeOptions decodeOptions) { |
| | | Validator.ensureNotNull(decodeOptions); |
| | | Reject.ifNull(decodeOptions); |
| | | this.decodeOptions = decodeOptions; |
| | | return this; |
| | | } |
| | |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Common options for LDAP client connections. |
| | |
| | | * If {@code decodeOptions} was {@code null}. |
| | | */ |
| | | public final LDAPOptions setDecodeOptions(final DecodeOptions decodeOptions) { |
| | | Validator.ensureNotNull(decodeOptions); |
| | | Reject.ifNull(decodeOptions); |
| | | this.decodeOptions = decodeOptions; |
| | | return this; |
| | | } |
| | |
| | | */ |
| | | public final LDAPOptions addEnabledProtocol(String... protocols) { |
| | | for (final String protocol : protocols) { |
| | | enabledProtocols.add(Validator.ensureNotNull(protocol)); |
| | | enabledProtocols.add(Reject.checkNotNull(protocol)); |
| | | } |
| | | return this; |
| | | } |
| | |
| | | */ |
| | | public final LDAPOptions addEnabledCipherSuite(String... suites) { |
| | | for (final String suite : suites) { |
| | | enabledCipherSuites.add(Validator.ensureNotNull(suite)); |
| | | enabledCipherSuites.add(Reject.checkNotNull(suite)); |
| | | } |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.forgerock.opendj.ldap.requests.SearchRequest; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * An LDAP URL as defined in RFC 4516. In addition, the secure ldap (ldaps://) |
| | |
| | | * If {@code url} or {@code schema} was {@code null}. |
| | | */ |
| | | public static LDAPUrl valueOf(final String url, final Schema schema) { |
| | | Validator.ensureNotNull(url, schema); |
| | | Reject.ifNull(url); |
| | | Reject.ifNull(schema); |
| | | return new LDAPUrl(url, schema); |
| | | } |
| | | |
| | |
| | | |
| | | private static void percentDecoder(final String urlString, final int index, final String s, |
| | | final StringBuilder decoded) { |
| | | Validator.ensureNotNull(s, decoded); |
| | | Reject.ifNull(s); |
| | | Reject.ifNull(decoded); |
| | | decoded.append(s); |
| | | |
| | | int srcPos = 0, dstPos = 0; |
| | |
| | | * The buffer that contains the final percent encoded value. |
| | | */ |
| | | private static void percentEncoder(final String urlElement, final StringBuilder encodedBuffer) { |
| | | Validator.ensureNotNull(urlElement); |
| | | Reject.ifNull(urlElement); |
| | | for (int count = 0; count < urlElement.length(); count++) { |
| | | final char c = urlElement.charAt(count); |
| | | if (VALID_CHARS.contains(c)) { |
| | |
| | | |
| | | private int parseHostPort(final String urlString, final String hostAndPort, |
| | | final StringBuilder host) { |
| | | Validator.ensureNotNull(hostAndPort, port, host); |
| | | Reject.ifNull(hostAndPort); |
| | | Reject.ifNull((Object) port); |
| | | Reject.ifNull(host); |
| | | int urlPort = isSecured ? DEFAULT_SSL_PORT : DEFAULT_PORT; |
| | | if (hostAndPort.length() == 0) { |
| | | host.append(DEFAULT_HOST); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An implementation of the {@code Attribute} interface with predictable |
| | |
| | | * If {@code attributeDescription} was {@code null}. |
| | | */ |
| | | public LinkedAttribute(final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | this.attributeDescription = attributeDescription; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean add(final ByteString value) { |
| | | Validator.ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | return pimpl.add(this, value); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean contains(final Object value) { |
| | | Validator.ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | return pimpl.contains(this, ByteString.valueOf(value)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean containsAll(final Collection<?> values) { |
| | | Validator.ensureNotNull(values); |
| | | Reject.ifNull(values); |
| | | return pimpl.containsAll(this, values); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean remove(final Object value) { |
| | | Validator.ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | return pimpl.remove(this, ByteString.valueOf(value)); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public <T> boolean retainAll(final Collection<T> values, |
| | | final Collection<? super T> missingValues) { |
| | | Validator.ensureNotNull(values); |
| | | Reject.ifNull(values); |
| | | return pimpl.retainAll(this, values, missingValues); |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An implementation of the {@code Entry} interface which uses a |
| | |
| | | * If {@code name} was {@code null}. |
| | | */ |
| | | public LinkedHashMapEntry(final DN name) { |
| | | super(Validator.ensureNotNull(name), new LinkedHashMap<AttributeDescription, Attribute>()); |
| | | super(Reject.checkNotNull(name), new LinkedHashMap<AttributeDescription, Attribute>()); |
| | | } |
| | | |
| | | /** |
| | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import com.forgerock.opendj.util.CompletedFutureResult; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A load balancing connection factory allocates connections using the provided |
| | |
| | | private final LoadBalancingAlgorithm algorithm; |
| | | |
| | | LoadBalancer(final LoadBalancingAlgorithm algorithm) { |
| | | Validator.ensureNotNull(algorithm); |
| | | Reject.ifNull(algorithm); |
| | | this.algorithm = algorithm; |
| | | } |
| | | |
| | |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A modification to be performed on an entry during a Modify operation. |
| | |
| | | * The the attribute containing the values to be modified. |
| | | */ |
| | | public Modification(final ModificationType modificationType, final Attribute attribute) { |
| | | Validator.ensureNotNull(modificationType, attribute); |
| | | Reject.ifNull(modificationType); |
| | | Reject.ifNull(attribute); |
| | | this.modificationType = modificationType; |
| | | this.attribute = attribute; |
| | | } |
| | |
| | | |
| | | import com.forgerock.opendj.util.Iterators; |
| | | import com.forgerock.opendj.util.SubstringReader; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A relative distinguished name (RDN) as defined in RFC 4512 section 2.3 is the |
| | |
| | | } |
| | | |
| | | private RDN(final AVA[] avas, final String stringValue) { |
| | | Validator.ensureNotNull((Object[]) avas); |
| | | Reject.ifNull(avas); |
| | | this.avas = avas; |
| | | this.stringValue = stringValue; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An adapter which converts a {@code RequestHandlerFactory} into a |
| | |
| | | */ |
| | | @Override |
| | | public void addCancelRequestListener(final CancelRequestListener listener) { |
| | | Validator.ensureNotNull(listener); |
| | | Reject.ifNull(listener); |
| | | |
| | | boolean invokeImmediately = false; |
| | | synchronized (stateLock) { |
| | |
| | | */ |
| | | @Override |
| | | public void removeCancelRequestListener(final CancelRequestListener listener) { |
| | | Validator.ensureNotNull(listener); |
| | | Reject.ifNull(listener); |
| | | |
| | | synchronized (stateLock) { |
| | | if (cancelRequestListeners != null) { |
| | |
| | | private <R extends ExtendedResult> void cancel(final LocalizableMessage reason, |
| | | final ExtendedRequest<R> cancelRequest, final ResultHandler<R> cancelResultHandler, |
| | | final boolean sendResult) { |
| | | Validator.ensureNotNull(reason); |
| | | Reject.ifNull(reason); |
| | | |
| | | if (!isCancelSupported) { |
| | | if (cancelResultHandler != null) { |
| | |
| | | |
| | | import com.forgerock.opendj.util.Collections2; |
| | | import com.forgerock.opendj.util.FutureResultTransformer; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The root DSE is a DSA-specific Entry (DSE) and not part of any naming context |
| | |
| | | * If {@code entry} was {@code null} . |
| | | */ |
| | | public static RootDSE valueOf(Entry entry) { |
| | | Validator.ensureNotNull(entry); |
| | | Reject.ifNull(entry); |
| | | return new RootDSE(entry); |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Thrown when an iteration over a set of search results using a |
| | |
| | | * If {@code reference} was {@code null}. |
| | | */ |
| | | public SearchResultReferenceIOException(final SearchResultReference reference) { |
| | | super(Validator.ensureNotNull(reference).toString()); |
| | | super(Reject.checkNotNull(reference).toString()); |
| | | this.reference = reference; |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A search result sort key as defined in RFC 2891 is used to specify how search |
| | |
| | | * If {@code schema} or {@code keys} was {@code null}. |
| | | */ |
| | | public static Comparator<Entry> comparator(final Schema schema, final Collection<SortKey> keys) { |
| | | Validator.ensureNotNull(schema, keys); |
| | | Validator.ensureTrue(!keys.isEmpty(), "keys must not be empty"); |
| | | Reject.ifNull(schema); |
| | | Reject.ifNull(keys); |
| | | Reject.ifFalse(!keys.isEmpty(), "keys must not be empty"); |
| | | |
| | | final List<Comparator<Entry>> comparators = new ArrayList<Comparator<Entry>>(keys.size()); |
| | | for (final SortKey key : keys) { |
| | |
| | | * If {@code sortKeys} was {@code null}. |
| | | */ |
| | | public static Comparator<Entry> comparator(final String sortKeys) { |
| | | Validator.ensureNotNull(sortKeys); |
| | | Reject.ifNull(sortKeys); |
| | | |
| | | final List<Comparator<Entry>> comparators = new LinkedList<Comparator<Entry>>(); |
| | | final StringTokenizer tokenizer = new StringTokenizer(sortKeys, ","); |
| | |
| | | * If {@code sortKey} was {@code null}. |
| | | */ |
| | | public static final SortKey valueOf(String sortKey) { |
| | | Validator.ensureNotNull(sortKey); |
| | | Reject.ifNull(sortKey); |
| | | |
| | | boolean reverseOrder = false; |
| | | if (sortKey.startsWith("-")) { |
| | |
| | | */ |
| | | public SortKey(final AttributeDescription attributeDescription, final boolean isReverseOrder, |
| | | final MatchingRule orderingMatchingRule) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | this.attributeDescription = attributeDescription.toString(); |
| | | this.orderingMatchingRule = |
| | | orderingMatchingRule != null ? orderingMatchingRule.getNameOrOID() : null; |
| | |
| | | */ |
| | | public SortKey(final String attributeDescription, final boolean isReverseOrder, |
| | | final String orderingMatchingRule) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | this.attributeDescription = attributeDescription; |
| | | this.orderingMatchingRule = orderingMatchingRule; |
| | | this.isReverseOrder = isReverseOrder; |
| | |
| | | * If {@code schema} was {@code null}. |
| | | */ |
| | | public Comparator<Entry> comparator(final Schema schema) { |
| | | Validator.ensureNotNull(schema); |
| | | Reject.ifNull(schema); |
| | | |
| | | final AttributeDescription ad = AttributeDescription.valueOf(attributeDescription, schema); |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An implementation of the {@code Entry} interface which uses a {@code TreeMap} |
| | |
| | | * If {@code name} was {@code null}. |
| | | */ |
| | | public TreeMapEntry(final DN name) { |
| | | super(Validator.ensureNotNull(name), new TreeMap<AttributeDescription, Attribute>()); |
| | | super(Reject.checkNotNull(name), new TreeMap<AttributeDescription, Attribute>()); |
| | | } |
| | | |
| | | /** |
| | |
| | | import javax.net.ssl.X509TrustManager; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class contains methods for creating common types of trust manager. |
| | |
| | | */ |
| | | public static X509TrustManager checkHostName(final String hostNamePattern, |
| | | final X509TrustManager trustManager) { |
| | | Validator.ensureNotNull(trustManager, hostNamePattern); |
| | | Reject.ifNull(trustManager); |
| | | Reject.ifNull(hostNamePattern); |
| | | return new CheckHostName(trustManager, hostNamePattern); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static X509TrustManager checkUsingTrustStore(final String file, final char[] password, |
| | | final String format) throws GeneralSecurityException, IOException { |
| | | Validator.ensureNotNull(file); |
| | | Reject.ifNull(file); |
| | | |
| | | final File trustStoreFile = new File(file); |
| | | final String trustStoreFormat = format != null ? format : KeyStore.getDefaultType(); |
| | |
| | | * If {@code trustManager} was {@code null}. |
| | | */ |
| | | public static X509TrustManager checkValidityDates(final X509TrustManager trustManager) { |
| | | Validator.ensureNotNull(trustManager); |
| | | Reject.ifNull(trustManager); |
| | | return new CheckValidatyDates(trustManager); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The assertion request control as defined in RFC 4528. The Assertion control |
| | |
| | | |
| | | public AssertionRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof AssertionRequestControl) { |
| | | return (AssertionRequestControl) control; |
| | |
| | | |
| | | // Prevent direct instantiation. |
| | | private AssertionRequestControl(final boolean isCritical, final Filter filter) { |
| | | Validator.ensureNotNull(filter); |
| | | Reject.ifNull(filter); |
| | | this.isCritical = isCritical; |
| | | this.filter = filter; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The authorization request control as defined in RFC 3829. The authorization |
| | |
| | | |
| | | public AuthorizationIdentityRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof AuthorizationIdentityRequestControl) { |
| | | return (AuthorizationIdentityRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The authorization response control as defined in RFC 3829. The authorization |
| | |
| | | |
| | | public AuthorizationIdentityResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof AuthorizationIdentityResponseControl) { |
| | | return (AuthorizationIdentityResponseControl) control; |
| | |
| | | // Prevent direct instantiation. |
| | | private AuthorizationIdentityResponseControl(final boolean isCritical, |
| | | final String authorizationID) { |
| | | Validator.ensureNotNull(authorizationID); |
| | | Reject.ifNull(authorizationID); |
| | | this.isCritical = isCritical; |
| | | this.authorizationID = authorizationID; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * The entry change notification response control as defined in |
| | |
| | | |
| | | public EntryChangeNotificationResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control, options); |
| | | Reject.ifNull(control); |
| | | Reject.ifNull(options); |
| | | |
| | | if (control instanceof EntryChangeNotificationResponseControl) { |
| | | return (EntryChangeNotificationResponseControl) control; |
| | |
| | | private EntryChangeNotificationResponseControl(final boolean isCritical, |
| | | final PersistentSearchChangeType changeType, final DN previousName, |
| | | final long changeNumber) { |
| | | Validator.ensureNotNull(changeType); |
| | | Reject.ifNull(changeType); |
| | | this.isCritical = isCritical; |
| | | this.changeType = changeType; |
| | | this.previousName = previousName; |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A generic control which can be used to represent arbitrary raw request and |
| | |
| | | * If {@code control} was {@code null}. |
| | | */ |
| | | public static GenericControl newControl(final Control control) { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof GenericControl) { |
| | | return (GenericControl) control; |
| | |
| | | |
| | | // Prevent direct instantiation. |
| | | private GenericControl(final String oid, final boolean isCritical, final ByteString value) { |
| | | Validator.ensureNotNull(oid); |
| | | Reject.ifNull(oid); |
| | | this.oid = oid; |
| | | this.isCritical = isCritical; |
| | | this.value = value; |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A partial implementation of the get effective rights request control as |
| | |
| | | |
| | | public GetEffectiveRightsRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof GetEffectiveRightsRequestControl) { |
| | | return (GetEffectiveRightsRequestControl) control; |
| | |
| | | */ |
| | | public static GetEffectiveRightsRequestControl newControl(final boolean isCritical, |
| | | final DN authorizationName, final Collection<AttributeType> attributes) { |
| | | Validator.ensureNotNull(attributes); |
| | | Reject.ifNull(attributes); |
| | | |
| | | final Collection<AttributeType> copyOfAttributes = |
| | | Collections.unmodifiableList(new ArrayList<AttributeType>(attributes)); |
| | |
| | | */ |
| | | public static GetEffectiveRightsRequestControl newControl(final boolean isCritical, |
| | | final String authorizationName, final String... attributes) { |
| | | Validator.ensureNotNull((Object) attributes); |
| | | Reject.ifNull((Object) attributes); |
| | | |
| | | final DN dn = authorizationName == null ? null : DN.valueOf(authorizationName); |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The ManageDsaIT request control as defined in RFC 3296. This control allows |
| | |
| | | |
| | | public ManageDsaITRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof ManageDsaITRequestControl) { |
| | | return (ManageDsaITRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * The matched values request control as defined in RFC 3876. The matched values |
| | |
| | | |
| | | public MatchedValuesRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof MatchedValuesRequestControl) { |
| | | return (MatchedValuesRequestControl) control; |
| | |
| | | */ |
| | | public static MatchedValuesRequestControl newControl(final boolean isCritical, |
| | | final Collection<Filter> filters) { |
| | | Validator.ensureNotNull(filters); |
| | | Validator.ensureTrue(filters.size() > 0, "filters is empty"); |
| | | Reject.ifNull(filters); |
| | | Reject.ifFalse(filters.size() > 0, "filters is empty"); |
| | | |
| | | List<Filter> copyOfFilters; |
| | | if (filters.size() == 1) { |
| | |
| | | */ |
| | | public static MatchedValuesRequestControl newControl(final boolean isCritical, |
| | | final String... filters) { |
| | | Validator.ensureTrue(filters.length > 0, "filters is empty"); |
| | | Reject.ifFalse(filters.length > 0, "filters is empty"); |
| | | |
| | | final List<Filter> parsedFilters = new ArrayList<Filter>(filters.length); |
| | | for (final String filter : filters) { |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The Netscape password expired response control as defined in |
| | |
| | | |
| | | public PasswordExpiredResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PasswordExpiredResponseControl) { |
| | | return (PasswordExpiredResponseControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The Netscape password expiring response control as defined in |
| | |
| | | |
| | | public PasswordExpiringResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PasswordExpiringResponseControl) { |
| | | return (PasswordExpiringResponseControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The password policy request control as defined in |
| | |
| | | |
| | | public PasswordPolicyRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PasswordPolicyRequestControl) { |
| | | return (PasswordPolicyRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * The password policy response control as defined in |
| | |
| | | |
| | | public PasswordPolicyResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PasswordPolicyResponseControl) { |
| | | return (PasswordPolicyResponseControl) control; |
| | |
| | | * If {@code errorType} was {@code null}. |
| | | */ |
| | | public static PasswordPolicyResponseControl newControl(final PasswordPolicyErrorType errorType) { |
| | | Validator.ensureNotNull(errorType); |
| | | Reject.ifNull(errorType); |
| | | |
| | | return new PasswordPolicyResponseControl(false, null, -1, errorType); |
| | | } |
| | |
| | | */ |
| | | public static PasswordPolicyResponseControl newControl( |
| | | final PasswordPolicyWarningType warningType, final int warningValue) { |
| | | Validator.ensureNotNull(warningType); |
| | | Validator.ensureTrue(warningValue >= 0, "warningValue is negative"); |
| | | Reject.ifNull(warningType); |
| | | Reject.ifFalse(warningValue >= 0, "warningValue is negative"); |
| | | |
| | | return new PasswordPolicyResponseControl(false, warningType, warningValue, null); |
| | | } |
| | |
| | | public static PasswordPolicyResponseControl newControl( |
| | | final PasswordPolicyWarningType warningType, final int warningValue, |
| | | final PasswordPolicyErrorType errorType) { |
| | | Validator.ensureNotNull(warningType, errorType); |
| | | Validator.ensureTrue(warningValue >= 0, "warningValue is negative"); |
| | | Reject.ifNull(warningType); |
| | | Reject.ifNull(errorType); |
| | | Reject.ifFalse(warningValue >= 0, "warningValue is negative"); |
| | | |
| | | return new PasswordPolicyResponseControl(false, warningType, warningValue, errorType); |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The Microsoft defined permissive modify request control. The OID for this |
| | |
| | | |
| | | public PermissiveModifyRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PermissiveModifyRequestControl) { |
| | | return (PermissiveModifyRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The persistent search request control as defined in |
| | |
| | | |
| | | public PersistentSearchRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PersistentSearchRequestControl) { |
| | | return (PersistentSearchRequestControl) control; |
| | |
| | | public static PersistentSearchRequestControl newControl(final boolean isCritical, |
| | | final boolean changesOnly, final boolean returnECs, |
| | | final Collection<PersistentSearchChangeType> changeTypes) { |
| | | Validator.ensureNotNull(changeTypes); |
| | | Reject.ifNull(changeTypes); |
| | | |
| | | final Set<PersistentSearchChangeType> copyOfChangeTypes = |
| | | EnumSet.noneOf(PersistentSearchChangeType.class); |
| | |
| | | public static PersistentSearchRequestControl newControl(final boolean isCritical, |
| | | final boolean changesOnly, final boolean returnECs, |
| | | final PersistentSearchChangeType... changeTypes) { |
| | | Validator.ensureNotNull((Object) changeTypes); |
| | | Reject.ifNull((Object) changeTypes); |
| | | |
| | | return newControl(isCritical, changesOnly, returnECs, Arrays.asList(changeTypes)); |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The post-read request control as defined in RFC 4527. This control allows the |
| | |
| | | |
| | | public PostReadRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PostReadRequestControl) { |
| | | return (PostReadRequestControl) control; |
| | |
| | | */ |
| | | public static PostReadRequestControl newControl(final boolean isCritical, |
| | | final Collection<String> attributes) { |
| | | Validator.ensureNotNull(attributes); |
| | | Reject.ifNull(attributes); |
| | | |
| | | if (attributes.isEmpty()) { |
| | | return isCritical ? CRITICAL_EMPTY_INSTANCE : NONCRITICAL_EMPTY_INSTANCE; |
| | |
| | | */ |
| | | public static PostReadRequestControl newControl(final boolean isCritical, |
| | | final String... attributes) { |
| | | Validator.ensureNotNull((Object) attributes); |
| | | Reject.ifNull((Object) attributes); |
| | | |
| | | if (attributes.length == 0) { |
| | | return isCritical ? CRITICAL_EMPTY_INSTANCE : NONCRITICAL_EMPTY_INSTANCE; |
| | |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The post-read response control as defined in RFC 4527. This control is |
| | |
| | | |
| | | public PostReadResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PostReadResponseControl) { |
| | | return (PostReadResponseControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The pre-read request control as defined in RFC 4527. This control allows the |
| | |
| | | |
| | | public PreReadRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PreReadRequestControl) { |
| | | return (PreReadRequestControl) control; |
| | |
| | | */ |
| | | public static PreReadRequestControl newControl(final boolean isCritical, |
| | | final Collection<String> attributes) { |
| | | Validator.ensureNotNull(attributes); |
| | | Reject.ifNull(attributes); |
| | | |
| | | if (attributes.isEmpty()) { |
| | | return isCritical ? CRITICAL_EMPTY_INSTANCE : NONCRITICAL_EMPTY_INSTANCE; |
| | |
| | | */ |
| | | public static PreReadRequestControl newControl(final boolean isCritical, |
| | | final String... attributes) { |
| | | Validator.ensureNotNull((Object) attributes); |
| | | Reject.ifNull((Object) attributes); |
| | | |
| | | if (attributes.length == 0) { |
| | | return isCritical ? CRITICAL_EMPTY_INSTANCE : NONCRITICAL_EMPTY_INSTANCE; |
| | |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The pre-read response control as defined in RFC 4527. This control is |
| | |
| | | |
| | | public PreReadResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof PreReadResponseControl) { |
| | | return (PreReadResponseControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The proxy authorization v1 request control as defined in |
| | |
| | | |
| | | public ProxiedAuthV1RequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof ProxiedAuthV1RequestControl) { |
| | | return (ProxiedAuthV1RequestControl) control; |
| | |
| | | * If {@code authorizationName} was {@code null}. |
| | | */ |
| | | public static ProxiedAuthV1RequestControl newControl(final DN authorizationName) { |
| | | Validator.ensureNotNull(authorizationName); |
| | | Reject.ifNull(authorizationName); |
| | | return new ProxiedAuthV1RequestControl(authorizationName); |
| | | } |
| | | |
| | |
| | | * If {@code authorizationName} was {@code null}. |
| | | */ |
| | | public static ProxiedAuthV1RequestControl newControl(final String authorizationName) { |
| | | Validator.ensureNotNull(authorizationName); |
| | | Reject.ifNull(authorizationName); |
| | | return new ProxiedAuthV1RequestControl(DN.valueOf(authorizationName)); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The proxy authorization v2 request control as defined in RFC 4370. This |
| | |
| | | |
| | | public ProxiedAuthV2RequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof ProxiedAuthV2RequestControl) { |
| | | return (ProxiedAuthV2RequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.SortKey; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The server-side sort request control as defined in RFC 2891. This control may |
| | |
| | | |
| | | public ServerSideSortRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof ServerSideSortRequestControl) { |
| | | return (ServerSideSortRequestControl) control; |
| | |
| | | */ |
| | | public static ServerSideSortRequestControl newControl(final boolean isCritical, |
| | | final Collection<SortKey> keys) { |
| | | Validator.ensureNotNull(keys); |
| | | Validator.ensureTrue(!keys.isEmpty(), "keys must not be empty"); |
| | | Reject.ifNull(keys); |
| | | Reject.ifFalse(!keys.isEmpty(), "keys must not be empty"); |
| | | |
| | | return new ServerSideSortRequestControl(isCritical, Collections |
| | | .unmodifiableList(new ArrayList<SortKey>(keys))); |
| | |
| | | */ |
| | | public static ServerSideSortRequestControl newControl(final boolean isCritical, |
| | | final String sortKeys) { |
| | | Validator.ensureNotNull(sortKeys); |
| | | Reject.ifNull(sortKeys); |
| | | |
| | | final List<SortKey> keys = new LinkedList<SortKey>(); |
| | | final StringTokenizer tokenizer = new StringTokenizer(sortKeys, ","); |
| | |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The server-side sort response control as defined in RFC 2891. This control is |
| | |
| | | |
| | | public ServerSideSortResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control, options); |
| | | Reject.ifNull(control); |
| | | Reject.ifNull(options); |
| | | |
| | | if (control instanceof ServerSideSortResponseControl) { |
| | | return (ServerSideSortResponseControl) control; |
| | |
| | | * If {@code result} was {@code null}. |
| | | */ |
| | | public static ServerSideSortResponseControl newControl(final ResultCode result) { |
| | | Validator.ensureNotNull(result); |
| | | Reject.ifNull(result); |
| | | |
| | | return new ServerSideSortResponseControl(false, result, null); |
| | | } |
| | |
| | | */ |
| | | public static ServerSideSortResponseControl newControl(final ResultCode result, |
| | | final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(result); |
| | | Reject.ifNull(result); |
| | | |
| | | return new ServerSideSortResponseControl(false, result, attributeDescription); |
| | | } |
| | |
| | | */ |
| | | public static ServerSideSortResponseControl newControl(final ResultCode result, |
| | | final String attributeDescription) { |
| | | Validator.ensureNotNull(result); |
| | | Reject.ifNull(result); |
| | | |
| | | if (attributeDescription != null) { |
| | | return new ServerSideSortResponseControl(false, result, AttributeDescription |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The simple paged results request and response control as defined in RFC 2696. |
| | |
| | | |
| | | public SimplePagedResultsControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof SimplePagedResultsControl) { |
| | | return (SimplePagedResultsControl) control; |
| | |
| | | */ |
| | | public static SimplePagedResultsControl newControl(final boolean isCritical, final int size, |
| | | final ByteString cookie) { |
| | | Validator.ensureNotNull(cookie); |
| | | Reject.ifNull(cookie); |
| | | return new SimplePagedResultsControl(isCritical, size, cookie); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The sub-entries request control as defined in RFC 3672. This control may be |
| | |
| | | |
| | | public SubentriesRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof SubentriesRequestControl) { |
| | | return (SubentriesRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The tree delete request control as defined in draft-armijo-ldap-treedelete. |
| | |
| | | |
| | | public SubtreeDeleteRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof SubtreeDeleteRequestControl) { |
| | | return (SubtreeDeleteRequestControl) control; |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The virtual list view request control as defined in |
| | |
| | | |
| | | public VirtualListViewRequestControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof VirtualListViewRequestControl) { |
| | | return (VirtualListViewRequestControl) control; |
| | |
| | | public static VirtualListViewRequestControl newAssertionControl(final boolean isCritical, |
| | | final ByteString assertionValue, final int beforeCount, final int afterCount, |
| | | final ByteString contextID) { |
| | | Validator.ensureNotNull(assertionValue); |
| | | Validator.ensureTrue(beforeCount >= 0, "beforeCount is less than 0"); |
| | | Validator.ensureTrue(afterCount >= 0, "afterCount is less than 0"); |
| | | Reject.ifNull(assertionValue); |
| | | Reject.ifFalse(beforeCount >= 0, "beforeCount is less than 0"); |
| | | Reject.ifFalse(afterCount >= 0, "afterCount is less than 0"); |
| | | |
| | | return new VirtualListViewRequestControl(isCritical, beforeCount, afterCount, -1, -1, |
| | | assertionValue, contextID); |
| | |
| | | public static VirtualListViewRequestControl newOffsetControl(final boolean isCritical, |
| | | final int offset, final int contentCount, final int beforeCount, final int afterCount, |
| | | final ByteString contextID) { |
| | | Validator.ensureTrue(beforeCount >= 0, "beforeCount is less than 0"); |
| | | Validator.ensureTrue(afterCount >= 0, "afterCount is less than 0"); |
| | | Validator.ensureTrue(offset > 0, "beforeCount is less than 1"); |
| | | Validator.ensureTrue(contentCount >= 0, "afterCount is less than 0"); |
| | | Reject.ifFalse(beforeCount >= 0, "beforeCount is less than 0"); |
| | | Reject.ifFalse(afterCount >= 0, "afterCount is less than 0"); |
| | | Reject.ifFalse(offset > 0, "beforeCount is less than 1"); |
| | | Reject.ifFalse(contentCount >= 0, "afterCount is less than 0"); |
| | | |
| | | return new VirtualListViewRequestControl(isCritical, beforeCount, afterCount, offset, |
| | | contentCount, null, contextID); |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * The virtual list view response control as defined in |
| | |
| | | |
| | | public VirtualListViewResponseControl decodeControl(final Control control, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | |
| | | if (control instanceof VirtualListViewResponseControl) { |
| | | return (VirtualListViewResponseControl) control; |
| | |
| | | */ |
| | | public static VirtualListViewResponseControl newControl(final int targetPosition, |
| | | final int contentCount, final ResultCode result, final ByteString contextID) { |
| | | Validator.ensureNotNull(result); |
| | | Validator.ensureTrue(targetPosition >= 0, "targetPosition is less than 0"); |
| | | Validator.ensureTrue(contentCount >= 0, "contentCount is less than 0"); |
| | | Reject.ifNull(result); |
| | | Reject.ifFalse(targetPosition >= 0, "targetPosition is less than 0"); |
| | | Reject.ifFalse(contentCount >= 0, "contentCount is less than 0"); |
| | | |
| | | return new VirtualListViewResponseControl(false, targetPosition, contentCount, result, |
| | | contextID); |
| | |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | import org.forgerock.opendj.ldap.controls.ControlDecoder; |
| | | import org.forgerock.opendj.ldap.controls.GenericControl; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Abstract request implementation. |
| | |
| | | } |
| | | |
| | | AbstractRequestImpl(final Request request) { |
| | | Validator.ensureNotNull(request); |
| | | Reject.ifNull(request); |
| | | for (final Control control : request.getControls()) { |
| | | // Create defensive copy. |
| | | controls.add(GenericControl.newControl(control)); |
| | |
| | | |
| | | @Override |
| | | public final R addControl(final Control control) { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | controls.add(control); |
| | | return getThis(); |
| | | } |
| | |
| | | @Override |
| | | public final <C extends Control> C getControl(final ControlDecoder<C> decoder, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(decoder, options); |
| | | Reject.ifNull(decoder); |
| | | Reject.ifNull(options); |
| | | final Control control = getControl(controls, decoder.getOID()); |
| | | return control != null ? decoder.decodeControl(control, options) : null; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | import org.forgerock.opendj.ldap.controls.ControlDecoder; |
| | | import org.forgerock.opendj.ldap.controls.GenericControl; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.Collections2; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * Unmodifiable request implementation. |
| | |
| | | @Override |
| | | public final <C extends Control> C getControl(final ControlDecoder<C> decoder, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(decoder, options); |
| | | Reject.ifNull(decoder); |
| | | Reject.ifNull(options); |
| | | |
| | | final List<Control> controls = impl.getControls(); |
| | | final Control control = AbstractRequestImpl.getControl(controls, decoder.getOID()); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Anonymous SASL bind request implementation. |
| | |
| | | } |
| | | |
| | | AnonymousSASLBindRequestImpl(final String traceString) { |
| | | Validator.ensureNotNull(traceString); |
| | | Reject.ifNull(traceString); |
| | | this.traceString = traceString; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public AnonymousSASLBindRequest setTraceString(final String traceString) { |
| | | Validator.ensureNotNull(traceString); |
| | | Reject.ifNull(traceString); |
| | | this.traceString = traceString; |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.responses.BindResult; |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * CRAM-MD5 SASL bind request implementation. |
| | |
| | | } |
| | | |
| | | CRAMMD5SASLBindRequestImpl(final String authenticationID, final byte[] password) { |
| | | Validator.ensureNotNull(authenticationID, password); |
| | | Reject.ifNull(authenticationID); |
| | | Reject.ifNull(password); |
| | | this.authenticationID = authenticationID; |
| | | this.password = password; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public CRAMMD5SASLBindRequest setAuthenticationID(final String authenticationID) { |
| | | Validator.ensureNotNull(authenticationID); |
| | | Reject.ifNull(authenticationID); |
| | | this.authenticationID = authenticationID; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public CRAMMD5SASLBindRequest setPassword(final byte[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = password; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public CRAMMD5SASLBindRequest setPassword(final char[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Compare request implementation. |
| | |
| | | |
| | | @Override |
| | | public CompareRequest setAssertionValue(final Object value) { |
| | | Validator.ensureNotNull(value); |
| | | Reject.ifNull(value); |
| | | this.assertionValue = ByteString.valueOf(value); |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public CompareRequest setAttributeDescription(final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | this.attributeDescription = attributeDescription; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public CompareRequest setAttributeDescription(final String attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | this.attributeDescription = AttributeDescription.valueOf(attributeDescription); |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public CompareRequest setName(final DN dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = dn; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public CompareRequest setName(final String dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = DN.valueOf(dn); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Delete request implementation. |
| | |
| | | |
| | | @Override |
| | | public DeleteRequest setName(final DN dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = dn; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public DeleteRequest setName(final String dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = DN.valueOf(dn); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.responses.BindResult; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * Digest-MD5 SASL bind request implementation. |
| | |
| | | } |
| | | |
| | | DigestMD5SASLBindRequestImpl(final String authenticationID, final byte[] password) { |
| | | Validator.ensureNotNull(authenticationID, password); |
| | | Reject.ifNull(authenticationID); |
| | | Reject.ifNull(password); |
| | | this.authenticationID = authenticationID; |
| | | this.password = password; |
| | | } |
| | | |
| | | @Override |
| | | public DigestMD5SASLBindRequest addAdditionalAuthParam(final String name, final String value) { |
| | | Validator.ensureNotNull(name, value); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(value); |
| | | additionalAuthParams.put(name, value); |
| | | return this; |
| | | } |
| | |
| | | @Override |
| | | public DigestMD5SASLBindRequest addQOP(final String... qopValues) { |
| | | for (final String qopValue : qopValues) { |
| | | this.qopValues.add(Validator.ensureNotNull(qopValue)); |
| | | this.qopValues.add(Reject.checkNotNull(qopValue)); |
| | | } |
| | | return this; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public DigestMD5SASLBindRequest setAuthenticationID(final String authenticationID) { |
| | | Validator.ensureNotNull(authenticationID); |
| | | Reject.ifNull(authenticationID); |
| | | this.authenticationID = authenticationID; |
| | | return this; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public DigestMD5SASLBindRequest setPassword(final byte[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = password; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public DigestMD5SASLBindRequest setPassword(final char[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.responses.BindResult; |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import com.sun.security.auth.callback.TextCallbackHandler; |
| | | import com.sun.security.auth.module.Krb5LoginModule; |
| | | |
| | |
| | | } |
| | | |
| | | GSSAPISASLBindRequestImpl(final String authenticationID, final byte[] password) { |
| | | Validator.ensureNotNull(authenticationID, password); |
| | | Reject.ifNull(authenticationID); |
| | | Reject.ifNull(password); |
| | | this.authenticationID = authenticationID; |
| | | this.password = password; |
| | | } |
| | | |
| | | GSSAPISASLBindRequestImpl(final Subject subject) { |
| | | Validator.ensureNotNull(subject); |
| | | Reject.ifNull(subject); |
| | | this.subject = subject; |
| | | } |
| | | |
| | | @Override |
| | | public GSSAPISASLBindRequest addAdditionalAuthParam(final String name, final String value) { |
| | | Validator.ensureNotNull(name, value); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(value); |
| | | additionalAuthParams.put(name, value); |
| | | return this; |
| | | } |
| | |
| | | @Override |
| | | public GSSAPISASLBindRequest addQOP(final String... qopValues) { |
| | | for (final String qopValue : qopValues) { |
| | | this.qopValues.add(Validator.ensureNotNull(qopValue)); |
| | | this.qopValues.add(Reject.checkNotNull(qopValue)); |
| | | } |
| | | return this; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public GSSAPISASLBindRequest setAuthenticationID(final String authenticationID) { |
| | | Validator.ensureNotNull(authenticationID); |
| | | Reject.ifNull(authenticationID); |
| | | this.authenticationID = authenticationID; |
| | | return this; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public GSSAPISASLBindRequest setPassword(final byte[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = password; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public GSSAPISASLBindRequest setPassword(final char[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Generic bind request implementation. |
| | |
| | | |
| | | @Override |
| | | public GenericBindRequest setAuthenticationValue(final byte[] bytes) { |
| | | Validator.ensureNotNull(bytes); |
| | | Reject.ifNull(bytes); |
| | | this.authenticationValue = bytes; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public GenericBindRequest setName(final String name) { |
| | | Validator.ensureNotNull(name); |
| | | Reject.ifNull(name); |
| | | this.name = name; |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Generic extended request implementation. |
| | |
| | | |
| | | @Override |
| | | public GenericExtendedRequest setOID(final String oid) { |
| | | Validator.ensureNotNull(oid); |
| | | Reject.ifNull(oid); |
| | | this.requestName = oid; |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.forgerock.opendj.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Modify DN request implementation. |
| | |
| | | |
| | | @Override |
| | | public ModifyDNRequest setName(final DN dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = dn; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public ModifyDNRequest setName(final String dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = DN.valueOf(dn); |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public ModifyDNRequest setNewRDN(final RDN rdn) { |
| | | Validator.ensureNotNull(rdn); |
| | | Reject.ifNull(rdn); |
| | | this.newRDN = rdn; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public ModifyDNRequest setNewRDN(final String rdn) { |
| | | Validator.ensureNotNull(rdn); |
| | | Reject.ifNull(rdn); |
| | | this.newRDN = RDN.valueOf(rdn); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldif.ChangeRecordVisitor; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Modify request implementation. |
| | |
| | | |
| | | @Override |
| | | public ModifyRequest addModification(final Modification change) { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | changes.add(change); |
| | | return this; |
| | | } |
| | |
| | | @Override |
| | | public ModifyRequest addModification(final ModificationType type, |
| | | final String attributeDescription, final Object... values) { |
| | | Validator.ensureNotNull(type, attributeDescription, values); |
| | | Reject.ifNull(type); |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifNull(values); |
| | | changes.add(new Modification(type, new LinkedAttribute(attributeDescription, values))); |
| | | return this; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public ModifyRequest setName(final DN dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = dn; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public ModifyRequest setName(final String dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | this.name = DN.valueOf(dn); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.responses.BindResult; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * Plain SASL bind request implementation. |
| | |
| | | } |
| | | |
| | | PlainSASLBindRequestImpl(final String authenticationID, final byte[] password) { |
| | | Validator.ensureNotNull(authenticationID, password); |
| | | Reject.ifNull(authenticationID); |
| | | Reject.ifNull(password); |
| | | this.authenticationID = authenticationID; |
| | | this.password = password; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public PlainSASLBindRequest setAuthenticationID(final String authenticationID) { |
| | | Validator.ensureNotNull(authenticationID); |
| | | Reject.ifNull(authenticationID); |
| | | this.authenticationID = authenticationID; |
| | | return this; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public PlainSASLBindRequest setPassword(final byte[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = password; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public PlainSASLBindRequest setPassword(final char[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldif.ChangeRecord; |
| | | import org.forgerock.opendj.ldif.LDIFChangeRecordReader; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class contains various methods for creating and manipulating requests. |
| | |
| | | * If {@code entry} was {@code null} . |
| | | */ |
| | | public static AddRequest newAddRequest(final Entry entry) { |
| | | Validator.ensureNotNull(entry); |
| | | Reject.ifNull(entry); |
| | | return new AddRequestImpl(entry); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static CompareRequest newCompareRequest(final DN name, |
| | | final AttributeDescription attributeDescription, final Object assertionValue) { |
| | | Validator.ensureNotNull(name, attributeDescription, assertionValue); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifNull(assertionValue); |
| | | return new CompareRequestImpl(name, attributeDescription, ByteString |
| | | .valueOf(assertionValue)); |
| | | } |
| | |
| | | */ |
| | | public static CompareRequest newCompareRequest(final String name, |
| | | final String attributeDescription, final Object assertionValue) { |
| | | Validator.ensureNotNull(name, attributeDescription, assertionValue); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(attributeDescription); |
| | | Reject.ifNull(assertionValue); |
| | | return new CompareRequestImpl(DN.valueOf(name), AttributeDescription |
| | | .valueOf(attributeDescription), ByteString.valueOf(assertionValue)); |
| | | } |
| | |
| | | * If {@code name} was {@code null}. |
| | | */ |
| | | public static DeleteRequest newDeleteRequest(final DN name) { |
| | | Validator.ensureNotNull(name); |
| | | Reject.ifNull(name); |
| | | return new DeleteRequestImpl(name); |
| | | } |
| | | |
| | |
| | | * If {@code name} was {@code null}. |
| | | */ |
| | | public static DeleteRequest newDeleteRequest(final String name) { |
| | | Validator.ensureNotNull(name); |
| | | Reject.ifNull(name); |
| | | return new DeleteRequestImpl(DN.valueOf(name)); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static GenericBindRequest newGenericBindRequest(final byte authenticationType, |
| | | final byte[] authenticationValue) { |
| | | Validator.ensureNotNull(authenticationValue); |
| | | Reject.ifNull(authenticationValue); |
| | | return new GenericBindRequestImpl("", authenticationType, authenticationValue); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static GenericBindRequest newGenericBindRequest(final String name, |
| | | final byte authenticationType, final byte[] authenticationValue) { |
| | | Validator.ensureNotNull(name, authenticationValue); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(authenticationValue); |
| | | return new GenericBindRequestImpl(name, authenticationType, authenticationValue); |
| | | } |
| | | |
| | |
| | | * If {@code requestName} was {@code null}. |
| | | */ |
| | | public static GenericExtendedRequest newGenericExtendedRequest(final String requestName) { |
| | | Validator.ensureNotNull(requestName); |
| | | Reject.ifNull(requestName); |
| | | return new GenericExtendedRequestImpl(requestName); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static GenericExtendedRequest newGenericExtendedRequest(final String requestName, |
| | | final Object requestValue) { |
| | | Validator.ensureNotNull(requestName); |
| | | Reject.ifNull(requestName); |
| | | return new GenericExtendedRequestImpl(requestName).setValue(requestValue); |
| | | } |
| | | |
| | |
| | | * If {@code name} or {@code newRDN} was {@code null}. |
| | | */ |
| | | public static ModifyDNRequest newModifyDNRequest(final DN name, final RDN newRDN) { |
| | | Validator.ensureNotNull(name, newRDN); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(newRDN); |
| | | return new ModifyDNRequestImpl(name, newRDN); |
| | | } |
| | | |
| | |
| | | * If {@code name} or {@code newRDN} was {@code null}. |
| | | */ |
| | | public static ModifyDNRequest newModifyDNRequest(final String name, final String newRDN) { |
| | | Validator.ensureNotNull(name, newRDN); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(newRDN); |
| | | return new ModifyDNRequestImpl(DN.valueOf(name), RDN.valueOf(newRDN)); |
| | | } |
| | | |
| | |
| | | * If {@code name} was {@code null}. |
| | | */ |
| | | public static ModifyRequest newModifyRequest(final DN name) { |
| | | Validator.ensureNotNull(name); |
| | | Reject.ifNull(name); |
| | | return new ModifyRequestImpl(name); |
| | | } |
| | | |
| | |
| | | * If {@code name} was {@code null}. |
| | | */ |
| | | public static ModifyRequest newModifyRequest(final String name) { |
| | | Validator.ensureNotNull(name); |
| | | Reject.ifNull(name); |
| | | return new ModifyRequestImpl(DN.valueOf(name)); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static SearchRequest newSearchRequest(final DN name, final SearchScope scope, |
| | | final Filter filter, final String... attributeDescriptions) { |
| | | Validator.ensureNotNull(name, scope, filter); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(scope); |
| | | Reject.ifNull(filter); |
| | | final SearchRequest request = new SearchRequestImpl(name, scope, filter); |
| | | for (final String attributeDescription : attributeDescriptions) { |
| | | request.addAttribute(attributeDescription); |
| | |
| | | */ |
| | | public static SearchRequest newSearchRequest(final String name, final SearchScope scope, |
| | | final String filter, final String... attributeDescriptions) { |
| | | Validator.ensureNotNull(name, scope, filter); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(scope); |
| | | Reject.ifNull(filter); |
| | | final SearchRequest request = |
| | | new SearchRequestImpl(DN.valueOf(name), scope, Filter.valueOf(filter)); |
| | | for (final String attributeDescription : attributeDescriptions) { |
| | |
| | | * If {@code name} or {@code password} was {@code null}. |
| | | */ |
| | | public static SimpleBindRequest newSimpleBindRequest(final String name, final byte[] password) { |
| | | Validator.ensureNotNull(name, password); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(password); |
| | | return new SimpleBindRequestImpl(name, password); |
| | | } |
| | | |
| | |
| | | * If {@code name} or {@code password} was {@code null}. |
| | | */ |
| | | public static SimpleBindRequest newSimpleBindRequest(final String name, final char[] password) { |
| | | Validator.ensureNotNull(name, password); |
| | | Reject.ifNull(name); |
| | | Reject.ifNull(password); |
| | | return new SimpleBindRequestImpl(name, getBytes(password)); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Search request implementation. |
| | |
| | | @Override |
| | | public SearchRequest addAttribute(final String... attributeDescriptions) { |
| | | for (final String attributeDescription : attributeDescriptions) { |
| | | attributes.add(Validator.ensureNotNull(attributeDescription)); |
| | | attributes.add(Reject.checkNotNull(attributeDescription)); |
| | | } |
| | | return this; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public SearchRequest setDereferenceAliasesPolicy(final DereferenceAliasesPolicy policy) { |
| | | Validator.ensureNotNull(policy); |
| | | Reject.ifNull(policy); |
| | | |
| | | this.dereferenceAliasesPolicy = policy; |
| | | return this; |
| | |
| | | |
| | | @Override |
| | | public SearchRequest setFilter(final Filter filter) { |
| | | Validator.ensureNotNull(filter); |
| | | Reject.ifNull(filter); |
| | | |
| | | this.filter = filter; |
| | | return this; |
| | |
| | | |
| | | @Override |
| | | public SearchRequest setName(final DN dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | |
| | | this.name = dn; |
| | | return this; |
| | |
| | | |
| | | @Override |
| | | public SearchRequest setName(final String dn) { |
| | | Validator.ensureNotNull(dn); |
| | | Reject.ifNull(dn); |
| | | |
| | | this.name = DN.valueOf(dn); |
| | | return this; |
| | |
| | | |
| | | @Override |
| | | public SearchRequest setScope(final SearchScope scope) { |
| | | Validator.ensureNotNull(scope); |
| | | Reject.ifNull(scope); |
| | | |
| | | this.scope = scope; |
| | | return this; |
| | |
| | | |
| | | @Override |
| | | public SearchRequest setSizeLimit(final int limit) { |
| | | Validator.ensureTrue(limit >= 0, "negative size limit"); |
| | | Reject.ifFalse(limit >= 0, "negative size limit"); |
| | | |
| | | this.sizeLimit = limit; |
| | | return this; |
| | |
| | | |
| | | @Override |
| | | public SearchRequest setTimeLimit(final int limit) { |
| | | Validator.ensureTrue(limit >= 0, "negative time limit"); |
| | | Reject.ifFalse(limit >= 0, "negative time limit"); |
| | | |
| | | this.timeLimit = limit; |
| | | return this; |
| | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Simple bind request implementation. |
| | |
| | | |
| | | @Override |
| | | public SimpleBindRequest setName(final String name) { |
| | | Validator.ensureNotNull(name); |
| | | Reject.ifNull(name); |
| | | this.name = name; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public SimpleBindRequest setPassword(final byte[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = password; |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public SimpleBindRequest setPassword(final char[] password) { |
| | | Validator.ensureNotNull(password); |
| | | Reject.ifNull(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.responses.GenericExtendedResult; |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Start TLS extended request implementation. |
| | |
| | | private SSLContext sslContext; |
| | | |
| | | StartTLSExtendedRequestImpl(final SSLContext sslContext) { |
| | | Validator.ensureNotNull(sslContext); |
| | | Reject.ifNull(sslContext); |
| | | this.sslContext = sslContext; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public StartTLSExtendedRequest addEnabledCipherSuite(final String... suites) { |
| | | for (final String suite : suites) { |
| | | this.enabledCipherSuites.add(Validator.ensureNotNull(suite)); |
| | | this.enabledCipherSuites.add(Reject.checkNotNull(suite)); |
| | | } |
| | | return this; |
| | | } |
| | |
| | | @Override |
| | | public StartTLSExtendedRequest addEnabledProtocol(final String... protocols) { |
| | | for (final String protocol : protocols) { |
| | | this.enabledProtocols.add(Validator.ensureNotNull(protocol)); |
| | | this.enabledProtocols.add(Reject.checkNotNull(protocol)); |
| | | } |
| | | return this; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public StartTLSExtendedRequest setSSLContext(final SSLContext sslContext) { |
| | | Validator.ensureNotNull(sslContext); |
| | | Reject.ifNull(sslContext); |
| | | this.sslContext = sslContext; |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | import org.forgerock.opendj.ldap.controls.ControlDecoder; |
| | | import org.forgerock.opendj.ldap.controls.GenericControl; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Modifiable response implementation. |
| | |
| | | } |
| | | |
| | | AbstractResponseImpl(final Response response) { |
| | | Validator.ensureNotNull(response); |
| | | Reject.ifNull(response); |
| | | for (final Control control : response.getControls()) { |
| | | // Create defensive copy. |
| | | controls.add(GenericControl.newControl(control)); |
| | |
| | | |
| | | @Override |
| | | public final S addControl(final Control control) { |
| | | Validator.ensureNotNull(control); |
| | | Reject.ifNull(control); |
| | | controls.add(control); |
| | | return getThis(); |
| | | } |
| | |
| | | @Override |
| | | public final <C extends Control> C getControl(final ControlDecoder<C> decoder, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(decoder, options); |
| | | Reject.ifNull(decoder); |
| | | Reject.ifNull(options); |
| | | final Control control = getControl(controls, decoder.getOID()); |
| | | return control != null ? decoder.decodeControl(control, options) : null; |
| | | } |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Modifiable result implementation. |
| | |
| | | |
| | | @Override |
| | | public final S addReferralURI(final String uri) { |
| | | Validator.ensureNotNull(uri); |
| | | Reject.ifNull(uri); |
| | | |
| | | referralURIs.add(uri); |
| | | return getThis(); |
| | |
| | | |
| | | @Override |
| | | public final S setResultCode(final ResultCode resultCode) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | |
| | | this.resultCode = resultCode; |
| | | return getThis(); |
| | |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | import org.forgerock.opendj.ldap.controls.ControlDecoder; |
| | | import org.forgerock.opendj.ldap.controls.GenericControl; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.Collections2; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * Unmodifiable response implementation. |
| | |
| | | protected final S impl; |
| | | |
| | | AbstractUnmodifiableResponseImpl(final S impl) { |
| | | Validator.ensureNotNull(impl); |
| | | Reject.ifNull(impl); |
| | | this.impl = impl; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public final <C extends Control> C getControl(final ControlDecoder<C> decoder, |
| | | final DecodeOptions options) throws DecodeException { |
| | | Validator.ensureNotNull(decoder, options); |
| | | Reject.ifNull(decoder); |
| | | Reject.ifNull(options); |
| | | |
| | | final List<Control> controls = impl.getControls(); |
| | | final Control control = AbstractResponseImpl.getControl(controls, decoder.getOID()); |
| | |
| | | import org.forgerock.opendj.ldap.LinkedHashMapEntry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class contains various methods for creating and manipulating responses. |
| | |
| | | * If {@code resultCode} was {@code null}. |
| | | */ |
| | | public static BindResult newBindResult(final ResultCode resultCode) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | return new BindResultImpl(resultCode); |
| | | } |
| | | |
| | |
| | | * If {@code resultCode} was {@code null}. |
| | | */ |
| | | public static CompareResult newCompareResult(final ResultCode resultCode) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | return new CompareResultImpl(resultCode); |
| | | } |
| | | |
| | |
| | | * If {@code resultCode} was {@code null}. |
| | | */ |
| | | public static GenericExtendedResult newGenericExtendedResult(final ResultCode resultCode) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | return new GenericExtendedResultImpl(resultCode); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static PasswordModifyExtendedResult newPasswordModifyExtendedResult( |
| | | final ResultCode resultCode) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | return new PasswordModifyExtendedResultImpl(resultCode); |
| | | } |
| | | |
| | |
| | | * If {@code resultCode} was {@code null}. |
| | | */ |
| | | public static Result newResult(final ResultCode resultCode) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | return new ResultImpl(resultCode); |
| | | } |
| | | |
| | |
| | | * If {@code entry} was {@code null} . |
| | | */ |
| | | public static SearchResultEntry newSearchResultEntry(final Entry entry) { |
| | | Validator.ensureNotNull(entry); |
| | | Reject.ifNull(entry); |
| | | return new SearchResultEntryImpl(entry); |
| | | } |
| | | |
| | |
| | | * If {@code uri} was {@code null}. |
| | | */ |
| | | public static SearchResultReference newSearchResultReference(final String uri) { |
| | | Validator.ensureNotNull(uri); |
| | | Reject.ifNull(uri); |
| | | return new SearchResultReferenceImpl(uri); |
| | | } |
| | | |
| | |
| | | * If {@code resultCode} was {@code null} . |
| | | */ |
| | | public static WhoAmIExtendedResult newWhoAmIExtendedResult(final ResultCode resultCode) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | return new WhoAmIExtendedResultImpl(ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Search result reference implementation. |
| | |
| | | |
| | | @Override |
| | | public SearchResultReference addURI(final String uri) { |
| | | Validator.ensureNotNull(uri); |
| | | Reject.ifNull(uri); |
| | | uris.add(uri); |
| | | return this; |
| | | } |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * This class defines a data structure for storing and interacting with an |
| | |
| | | final String definition) { |
| | | super(description, extraProperties, definition); |
| | | |
| | | Validator.ensureNotNull(oid, names, description, attributeUsage); |
| | | Validator.ensureTrue(superiorType != null || syntax != null, |
| | | "superiorType and/or syntax must not be null"); |
| | | Validator.ensureNotNull(extraProperties); |
| | | Reject.ifNull(oid); |
| | | Reject.ifNull(names); |
| | | Reject.ifNull(description); |
| | | Reject.ifNull(attributeUsage); |
| | | Reject.ifFalse(superiorType != null || syntax != null, "superiorType and/or syntax must not be null"); |
| | | Reject.ifNull(extraProperties); |
| | | |
| | | this.oid = oid; |
| | | this.names = names; |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class defines a DIT content rule, which defines the set of allowed, |
| | |
| | | final Map<String, List<String>> extraProperties, final String definition) { |
| | | super(description, extraProperties, definition); |
| | | |
| | | Validator.ensureNotNull(structuralClassOID, names); |
| | | Validator.ensureNotNull(auxiliaryClassOIDs, optionalAttributeOIDs, prohibitedAttributeOIDs, |
| | | requiredAttributeOIDs); |
| | | Reject.ifNull(structuralClassOID); |
| | | Reject.ifNull(names); |
| | | Reject.ifNull(auxiliaryClassOIDs); |
| | | Reject.ifNull(optionalAttributeOIDs); |
| | | Reject.ifNull(prohibitedAttributeOIDs); |
| | | Reject.ifNull(requiredAttributeOIDs); |
| | | this.names = names; |
| | | this.isObsolete = obsolete; |
| | | this.structuralClassOID = structuralClassOID; |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class defines a DIT structure rule, which is used to indicate the types |
| | |
| | | final Map<String, List<String>> extraProperties, final String definition) { |
| | | super(description, extraProperties, definition); |
| | | |
| | | Validator.ensureNotNull(ruleID, nameFormOID, superiorRuleIDs); |
| | | Reject.ifNull(ruleID); |
| | | Reject.ifNull(nameFormOID); |
| | | Reject.ifNull(superiorRuleIDs); |
| | | this.ruleID = ruleID; |
| | | this.names = names; |
| | | this.isObsolete = obsolete; |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class is the ordering matching rule implementation for an enum syntax |
| | |
| | | private final EnumSyntaxImpl syntax; |
| | | |
| | | EnumOrderingMatchingRule(final EnumSyntaxImpl syntax) { |
| | | Validator.ensureNotNull(syntax); |
| | | Reject.ifNull(syntax); |
| | | this.syntax = syntax; |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class provides an enumeration-based mechanism where a new syntax and its |
| | |
| | | private final List<String> entries; |
| | | |
| | | EnumSyntaxImpl(final String oid, final List<String> entries) { |
| | | Validator.ensureNotNull(oid, entries); |
| | | Reject.ifNull(oid); |
| | | Reject.ifNull(entries); |
| | | this.oid = oid; |
| | | final List<String> entryStrings = new ArrayList<String>(entries.size()); |
| | | |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class defines a data structure for storing and interacting with a |
| | |
| | | final Map<String, List<String>> extraProperties, final String definition) { |
| | | super(description, extraProperties, definition); |
| | | |
| | | Validator.ensureNotNull(oid, names, attributeOIDs); |
| | | Reject.ifNull(oid); |
| | | Reject.ifNull(names); |
| | | Reject.ifNull(attributeOIDs); |
| | | this.oid = oid; |
| | | this.names = names; |
| | | this.isObsolete = obsolete; |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class defines a data structure for storing and interacting with an |
| | |
| | | final String definition) { |
| | | super(description, extraProperties, definition); |
| | | |
| | | Validator.ensureNotNull(oid, names); |
| | | Validator.ensureNotNull(superiorClassOIDs, requiredAttributeOIDs, optionalAttributeOIDs, |
| | | objectClassType); |
| | | Reject.ifNull(oid); |
| | | Reject.ifNull(names); |
| | | Reject.ifNull(superiorClassOIDs); |
| | | Reject.ifNull(requiredAttributeOIDs); |
| | | Reject.ifNull(optionalAttributeOIDs); |
| | | Reject.ifNull(objectClassType); |
| | | this.oid = oid; |
| | | this.names = names; |
| | | this.isObsolete = obsolete; |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class provides a regex mechanism where a new syntax and its |
| | |
| | | private final Pattern pattern; |
| | | |
| | | RegexSyntaxImpl(final Pattern pattern) { |
| | | Validator.ensureNotNull(pattern); |
| | | Reject.ifNull(pattern); |
| | | this.pattern = pattern; |
| | | } |
| | | |
| | |
| | | |
| | | import com.forgerock.opendj.util.FutureResultTransformer; |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class defines a data structure that holds information about the |
| | |
| | | * The default schema which should be used by this application. |
| | | */ |
| | | public static void setDefaultSchema(final Schema schema) { |
| | | Validator.ensureNotNull(schema); |
| | | Reject.ifNull(schema); |
| | | DefaultSchema.schema = schema; |
| | | } |
| | | |
| | |
| | | import com.forgerock.opendj.util.RecursiveFutureResult; |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.SubstringReader; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Schema builders should be used for incremental construction of new schemas. |
| | |
| | | * If {@code definition} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addAttributeType(final String definition, final boolean overwrite) { |
| | | Validator.ensureNotNull(definition); |
| | | Reject.ifNull(definition); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code definition} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addDITContentRule(final String definition, final boolean overwrite) { |
| | | Validator.ensureNotNull(definition); |
| | | Reject.ifNull(definition); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code definition} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addDITStructureRule(final String definition, final boolean overwrite) { |
| | | Validator.ensureNotNull(definition); |
| | | Reject.ifNull(definition); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | */ |
| | | public SchemaBuilder addEnumerationSyntax(final String oid, final String description, |
| | | final boolean overwrite, final String... enumerations) { |
| | | Validator.ensureNotNull((Object) enumerations); |
| | | Reject.ifNull((Object) enumerations); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code definition} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addMatchingRule(final String definition, final boolean overwrite) { |
| | | Validator.ensureNotNull(definition); |
| | | Reject.ifNull(definition); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code definition} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addMatchingRuleUse(final String definition, final boolean overwrite) { |
| | | Validator.ensureNotNull(definition); |
| | | Reject.ifNull(definition); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code definition} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addNameForm(final String definition, final boolean overwrite) { |
| | | Validator.ensureNotNull(definition); |
| | | Reject.ifNull(definition); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code definition} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addObjectClass(final String definition, final boolean overwrite) { |
| | | Validator.ensureNotNull(definition); |
| | | Reject.ifNull(definition); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | */ |
| | | public SchemaBuilder addPatternSyntax(final String oid, final String description, |
| | | final Pattern pattern, final boolean overwrite) { |
| | | Validator.ensureNotNull(pattern); |
| | | Reject.ifNull(pattern); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code entry} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addSchema(final Entry entry, final boolean overwrite) { |
| | | Validator.ensureNotNull(entry); |
| | | Reject.ifNull(entry); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code schema} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addSchema(final Schema schema, final boolean overwrite) { |
| | | Validator.ensureNotNull(schema); |
| | | Reject.ifNull(schema); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | */ |
| | | public SchemaBuilder addSubstitutionSyntax(final String oid, final String description, |
| | | final String substituteSyntax, final boolean overwrite) { |
| | | Validator.ensureNotNull(substituteSyntax); |
| | | Reject.ifNull(substituteSyntax); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | * If {@code definition} was {@code null}. |
| | | */ |
| | | public SchemaBuilder addSyntax(final String definition, final boolean overwrite) { |
| | | Validator.ensureNotNull(definition); |
| | | Reject.ifNull(definition); |
| | | |
| | | lazyInitBuilder(); |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An abstract base class for LDAP schema definitions which contain an |
| | |
| | | |
| | | SchemaElement(final String description, final Map<String, List<String>> extraProperties, |
| | | final String definition) { |
| | | Validator.ensureNotNull(description, extraProperties); |
| | | Reject.ifNull(description); |
| | | Reject.ifNull(extraProperties); |
| | | this.description = description; |
| | | this.extraProperties = extraProperties; // Should already be unmodifiable. |
| | | this.definition = definition; |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * This class defines a data structure for storing and interacting with an LDAP |
| | |
| | | Collections.singletonList(schema.getDefaultSyntax().getOID())), |
| | | null); |
| | | |
| | | Validator.ensureNotNull(oid); |
| | | Reject.ifNull(oid); |
| | | this.oid = oid; |
| | | this.schema = schema; |
| | | this.impl = schema.getDefaultSyntax().impl; |
| | |
| | | final SyntaxImpl implementation) { |
| | | super(description, extraProperties, definition); |
| | | |
| | | Validator.ensureNotNull(oid); |
| | | Reject.ifNull(oid); |
| | | this.oid = oid; |
| | | this.impl = implementation; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Common LDIF reader functionality. |
| | |
| | | } |
| | | |
| | | AbstractLDIFReader(final List<String> ldifLines) { |
| | | Validator.ensureNotNull(ldifLines); |
| | | Reject.ifNull(ldifLines); |
| | | this.impl = new LDIFReaderListImpl(ldifLines); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Common LDIF writer functionality. |
| | |
| | | } |
| | | |
| | | final void writeComment0(final CharSequence comment) throws IOException { |
| | | Validator.ensureNotNull(comment); |
| | | Reject.ifNull(comment); |
| | | |
| | | /* |
| | | * First, break up the comment into multiple lines to preserve the |
| | |
| | | import org.forgerock.opendj.ldap.requests.ModifyDNRequest; |
| | | import org.forgerock.opendj.ldap.requests.ModifyRequest; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A {@code ConnectionChangeRecordWriter} is a bridge from {@code Connection}s |
| | |
| | | * If {@code connection} was {@code null}. |
| | | */ |
| | | public ConnectionChangeRecordWriter(final Connection connection) { |
| | | Validator.ensureNotNull(connection); |
| | | Reject.ifNull(connection); |
| | | this.connection = connection; |
| | | } |
| | | |
| | |
| | | */ |
| | | public ConnectionChangeRecordWriter writeChangeRecord(final AddRequest change) |
| | | throws ErrorResultIOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | try { |
| | | connection.add(change); |
| | | } catch (final ErrorResultException e) { |
| | |
| | | */ |
| | | public ConnectionChangeRecordWriter writeChangeRecord(final ChangeRecord change) |
| | | throws ErrorResultIOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | |
| | | final IOException e = change.accept(ChangeRecordVisitorWriter.getInstance(), this); |
| | | try { |
| | |
| | | */ |
| | | public ConnectionChangeRecordWriter writeChangeRecord(final DeleteRequest change) |
| | | throws ErrorResultIOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | try { |
| | | connection.delete(change); |
| | | } catch (final ErrorResultException e) { |
| | |
| | | */ |
| | | public ConnectionChangeRecordWriter writeChangeRecord(final ModifyDNRequest change) |
| | | throws ErrorResultIOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | try { |
| | | connection.modifyDN(change); |
| | | } catch (final ErrorResultException e) { |
| | |
| | | */ |
| | | public ConnectionChangeRecordWriter writeChangeRecord(final ModifyRequest change) |
| | | throws ErrorResultIOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | try { |
| | | connection.modify(change); |
| | | } catch (final ErrorResultException e) { |
| | |
| | | * If {@code comment} was {@code null}. |
| | | */ |
| | | public ConnectionChangeRecordWriter writeComment(final CharSequence comment) { |
| | | Validator.ensureNotNull(comment); |
| | | Reject.ifNull(comment); |
| | | |
| | | // Do nothing. |
| | | return this; |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A {@code ConnectionEntryReader} is a bridge from {@code Connection}s to |
| | |
| | | */ |
| | | public ConnectionEntryReader(final Connection connection, final SearchRequest searchRequest, |
| | | final BlockingQueue<Response> entries) { |
| | | Validator.ensureNotNull(connection); |
| | | Reject.ifNull(connection); |
| | | buffer = new BufferHandler(entries); |
| | | future = connection.searchAsync(searchRequest, null, buffer); |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.ErrorResultIOException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A {@code ConnectionEntryWriter} is a bridge from {@code Connection}s to |
| | |
| | | * If {@code connection} was {@code null}. |
| | | */ |
| | | public ConnectionEntryWriter(final Connection connection) { |
| | | Validator.ensureNotNull(connection); |
| | | Reject.ifNull(connection); |
| | | this.connection = connection; |
| | | } |
| | | |
| | |
| | | * If {@code comment} was {@code null}. |
| | | */ |
| | | public ConnectionEntryWriter writeComment(final CharSequence comment) { |
| | | Validator.ensureNotNull(comment); |
| | | Reject.ifNull(comment); |
| | | |
| | | // Do nothing. |
| | | return this; |
| | |
| | | * If {@code entry} was {@code null}. |
| | | */ |
| | | public ConnectionEntryWriter writeEntry(final Entry entry) throws ErrorResultIOException { |
| | | Validator.ensureNotNull(entry); |
| | | Reject.ifNull(entry); |
| | | try { |
| | | connection.add(entry); |
| | | } catch (final ErrorResultException e) { |
| | |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A template driven entry generator, as used by the make-ldif tool. |
| | |
| | | * Path of the template file. |
| | | */ |
| | | public EntryGenerator(final String templatePath) { |
| | | Validator.ensureNotNull(templatePath); |
| | | Reject.ifNull(templatePath); |
| | | this.templatePath = templatePath; |
| | | } |
| | | |
| | |
| | | * Lines defining the template file. |
| | | */ |
| | | public EntryGenerator(final String... templateLines) { |
| | | Validator.ensureNotNull((Object[]) templateLines); |
| | | Reject.ifNull(templateLines); |
| | | this.templateLines = templateLines; |
| | | } |
| | | |
| | |
| | | * Lines defining the template file. |
| | | */ |
| | | public EntryGenerator(final List<String> templateLines) { |
| | | Validator.ensureNotNull(templateLines); |
| | | Reject.ifNull(templateLines); |
| | | this.templateLines = templateLines.toArray(new String[templateLines.size()]); |
| | | } |
| | | |
| | |
| | | * Input stream to read the template file. |
| | | */ |
| | | public EntryGenerator(final InputStream templateStream) { |
| | | Validator.ensureNotNull(templateStream); |
| | | Reject.ifNull(templateStream); |
| | | this.templateStream = templateStream; |
| | | } |
| | | |
| | |
| | | * @return A reference to this {@code EntryGenerator}. |
| | | */ |
| | | public EntryGenerator setResourcePath(final String path) { |
| | | Validator.ensureNotNull(path); |
| | | Reject.ifNull(path); |
| | | resourcePath = path; |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDIF change record reader reads change records using the LDAP Data |
| | |
| | | */ |
| | | public LDIFChangeRecordReader setExcludeAttribute( |
| | | final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | excludeAttributes.add(attributeDescription); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFChangeRecordReader}. |
| | | */ |
| | | public LDIFChangeRecordReader setExcludeBranch(final DN excludeBranch) { |
| | | Validator.ensureNotNull(excludeBranch); |
| | | Reject.ifNull(excludeBranch); |
| | | excludeBranches.add(excludeBranch); |
| | | return this; |
| | | } |
| | |
| | | */ |
| | | public LDIFChangeRecordReader setIncludeAttribute( |
| | | final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | includeAttributes.add(attributeDescription); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFChangeRecordReader}. |
| | | */ |
| | | public LDIFChangeRecordReader setIncludeBranch(final DN includeBranch) { |
| | | Validator.ensureNotNull(includeBranch); |
| | | Reject.ifNull(includeBranch); |
| | | includeBranches.add(includeBranch); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFChangeRecordReader}. |
| | | */ |
| | | public LDIFChangeRecordReader setSchema(final Schema schema) { |
| | | Validator.ensureNotNull(schema); |
| | | Reject.ifNull(schema); |
| | | this.schema = schemaValidationPolicy.adaptSchemaForValidation(schema); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.requests.ModifyDNRequest; |
| | | import org.forgerock.opendj.ldap.requests.ModifyRequest; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDIF change record writer writes change records using the LDAP Data |
| | |
| | | */ |
| | | public LDIFChangeRecordWriter setExcludeAttribute( |
| | | final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | excludeAttributes.add(attributeDescription); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFChangeRecordWriter}. |
| | | */ |
| | | public LDIFChangeRecordWriter setExcludeBranch(final DN excludeBranch) { |
| | | Validator.ensureNotNull(excludeBranch); |
| | | Reject.ifNull(excludeBranch); |
| | | excludeBranches.add(excludeBranch); |
| | | return this; |
| | | } |
| | |
| | | */ |
| | | public LDIFChangeRecordWriter setIncludeAttribute( |
| | | final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | includeAttributes.add(attributeDescription); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFChangeRecordWriter}. |
| | | */ |
| | | public LDIFChangeRecordWriter setIncludeBranch(final DN includeBranch) { |
| | | Validator.ensureNotNull(includeBranch); |
| | | Reject.ifNull(includeBranch); |
| | | includeBranches.add(includeBranch); |
| | | return this; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final AddRequest change) throws IOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | |
| | | // Skip if branch containing the entry is excluded. |
| | | if (isBranchExcluded(change.getName())) { |
| | |
| | | */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ChangeRecord change) throws IOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | |
| | | // Skip if branch containing the entry is excluded. |
| | | if (isBranchExcluded(change.getName())) { |
| | |
| | | */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final DeleteRequest change) throws IOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | |
| | | // Skip if branch containing the entry is excluded. |
| | | if (isBranchExcluded(change.getName())) { |
| | |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ModifyDNRequest change) |
| | | throws IOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | |
| | | // Skip if branch containing the entry is excluded. |
| | | if (isBranchExcluded(change.getName())) { |
| | |
| | | */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ModifyRequest change) throws IOException { |
| | | Validator.ensureNotNull(change); |
| | | Reject.ifNull(change); |
| | | |
| | | // If there aren't any modifications, then there's nothing to do. |
| | | if (change.getModifications().isEmpty()) { |
| | |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDIF entry reader reads attribute value records (entries) using the LDAP |
| | |
| | | * @return A reference to this {@code LDIFEntryReader}. |
| | | */ |
| | | public LDIFEntryReader setExcludeAttribute(final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | excludeAttributes.add(attributeDescription); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryReader}. |
| | | */ |
| | | public LDIFEntryReader setExcludeBranch(final DN excludeBranch) { |
| | | Validator.ensureNotNull(excludeBranch); |
| | | Reject.ifNull(excludeBranch); |
| | | excludeBranches.add(excludeBranch); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryReader}. |
| | | */ |
| | | public LDIFEntryReader setExcludeFilter(final Matcher excludeFilter) { |
| | | Validator.ensureNotNull(excludeFilter); |
| | | Reject.ifNull(excludeFilter); |
| | | excludeFilters.add(excludeFilter); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryReader}. |
| | | */ |
| | | public LDIFEntryReader setIncludeAttribute(final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | includeAttributes.add(attributeDescription); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryReader}. |
| | | */ |
| | | public LDIFEntryReader setIncludeBranch(final DN includeBranch) { |
| | | Validator.ensureNotNull(includeBranch); |
| | | Reject.ifNull(includeBranch); |
| | | includeBranches.add(includeBranch); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryReader}. |
| | | */ |
| | | public LDIFEntryReader setIncludeFilter(final Matcher includeFilter) { |
| | | Validator.ensureNotNull(includeFilter); |
| | | Reject.ifNull(includeFilter); |
| | | includeFilters.add(includeFilter); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryReader}. |
| | | */ |
| | | public LDIFEntryReader setSchema(final Schema schema) { |
| | | Validator.ensureNotNull(schema); |
| | | Reject.ifNull(schema); |
| | | this.schema = schemaValidationPolicy.adaptSchemaForValidation(schema); |
| | | return this; |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.Matcher; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDIF entry writer writes attribute value records (entries) using the LDAP |
| | |
| | | * @return A reference to this {@code LDIFEntryWriter}. |
| | | */ |
| | | public LDIFEntryWriter setExcludeAttribute(final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | excludeAttributes.add(attributeDescription); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryWriter}. |
| | | */ |
| | | public LDIFEntryWriter setExcludeBranch(final DN excludeBranch) { |
| | | Validator.ensureNotNull(excludeBranch); |
| | | Reject.ifNull(excludeBranch); |
| | | excludeBranches.add(excludeBranch); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryWriter}. |
| | | */ |
| | | public LDIFEntryWriter setExcludeFilter(final Matcher excludeFilter) { |
| | | Validator.ensureNotNull(excludeFilter); |
| | | Reject.ifNull(excludeFilter); |
| | | excludeFilters.add(excludeFilter); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryWriter}. |
| | | */ |
| | | public LDIFEntryWriter setIncludeAttribute(final AttributeDescription attributeDescription) { |
| | | Validator.ensureNotNull(attributeDescription); |
| | | Reject.ifNull(attributeDescription); |
| | | includeAttributes.add(attributeDescription); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryWriter}. |
| | | */ |
| | | public LDIFEntryWriter setIncludeBranch(final DN includeBranch) { |
| | | Validator.ensureNotNull(includeBranch); |
| | | Reject.ifNull(includeBranch); |
| | | includeBranches.add(includeBranch); |
| | | return this; |
| | | } |
| | |
| | | * @return A reference to this {@code LDIFEntryWriter}. |
| | | */ |
| | | public LDIFEntryWriter setIncludeFilter(final Matcher includeFilter) { |
| | | Validator.ensureNotNull(includeFilter); |
| | | Reject.ifNull(includeFilter); |
| | | includeFilters.add(includeFilter); |
| | | return this; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public LDIFEntryWriter writeEntry(final Entry entry) throws IOException { |
| | | Validator.ensureNotNull(entry); |
| | | Reject.ifNull(entry); |
| | | |
| | | // Skip if branch containing the entry is excluded. |
| | | if (isBranchExcluded(entry.getName())) { |
| | |
| | | import org.forgerock.opendj.ldif.TemplateTag.TagResult; |
| | | import org.forgerock.opendj.ldif.TemplateTag.UnderscoreDNTag; |
| | | import org.forgerock.opendj.ldif.TemplateTag.UnderscoreParentDNTag; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.Pair; |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * A template file allow to generate entries from a collection of constant |
| | |
| | | */ |
| | | TemplateFile(Schema schema, Map<String, String> constants, String resourcePath, Random random) |
| | | throws IOException { |
| | | Validator.ensureNotNull(schema, random); |
| | | Reject.ifNull(schema); |
| | | Reject.ifNull(random); |
| | | this.schema = schema; |
| | | this.constants = constants != null ? constants : new HashMap<String, String>(); |
| | | this.resourcePath = resourcePath; |
| | |
| | | import org.glassfish.grizzly.ssl.SSLFilter; |
| | | |
| | | import com.forgerock.opendj.util.CompletedFutureResult; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * LDAP connection implementation. |
| | |
| | | |
| | | @Override |
| | | public void addConnectionEventListener(final ConnectionEventListener listener) { |
| | | Validator.ensureNotNull(listener); |
| | | Reject.ifNull(listener); |
| | | final boolean notifyClose; |
| | | final boolean notifyErrorOccurred; |
| | | synchronized (stateLock) { |
| | |
| | | @Override |
| | | public void close(final UnbindRequest request, final String reason) { |
| | | // FIXME: I18N need to internationalize this message. |
| | | Validator.ensureNotNull(request); |
| | | Reject.ifNull(request); |
| | | close(request, false, Responses.newResult(ResultCode.CLIENT_SIDE_USER_CANCELLED) |
| | | .setDiagnosticMessage(reason != null ? reason : "Connection closed by client")); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void removeConnectionEventListener(final ConnectionEventListener listener) { |
| | | Validator.ensureNotNull(listener); |
| | | Reject.ifNull(listener); |
| | | synchronized (stateLock) { |
| | | if (listeners != null) { |
| | | listeners.remove(listener); |
| | |
| | | import org.glassfish.grizzly.ssl.SSLFilter; |
| | | import org.glassfish.grizzly.ssl.SSLUtils; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Grizzly filter implementation for decoding LDAP requests and handling server |
| | |
| | | |
| | | @Override |
| | | public void disconnect(final ResultCode resultCode, final String message) { |
| | | Validator.ensureNotNull(resultCode); |
| | | Reject.ifNull(resultCode); |
| | | final GenericExtendedResult notification = |
| | | Responses.newGenericExtendedResult(resultCode).setOID( |
| | | LDAP.OID_NOTICE_OF_DISCONNECTION).setDiagnosticMessage(message); |
| | |
| | | @Override |
| | | public void enableTLS(final SSLContext sslContext, final String[] protocols, |
| | | final String[] suites, final boolean wantClientAuth, final boolean needClientAuth) { |
| | | Validator.ensureNotNull(sslContext); |
| | | Reject.ifNull(sslContext); |
| | | synchronized (this) { |
| | | if (isTLSEnabled()) { |
| | | throw new IllegalStateException("TLS already enabled"); |
| | |
| | | import org.forgerock.opendj.ldap.ResultHandler; |
| | | import org.forgerock.opendj.ldap.requests.BindRequest; |
| | | import org.forgerock.opendj.ldap.responses.BindResult; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import com.forgerock.opendj.util.FutureResultTransformer; |
| | | import com.forgerock.opendj.util.RecursiveFutureResult; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | /** |
| | | * An authenticated connection factory can be used to create pre-authenticated |
| | |
| | | * If {@code factory} or {@code request} was {@code null}. |
| | | */ |
| | | AuthenticatedConnectionFactory(final ConnectionFactory factory, final BindRequest request) { |
| | | Validator.ensureNotNull(factory, request); |
| | | Reject.ifNull(factory); |
| | | Reject.ifNull(request); |
| | | this.parentFactory = factory; |
| | | |
| | | // FIXME: should do a defensive copy. |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A source of data for performance tools. |
| | |
| | | * If an exception occurs while parsing. |
| | | */ |
| | | public static DataSource[] parse(final List<String> sources) throws ArgumentException { |
| | | Validator.ensureNotNull(sources); |
| | | Reject.ifNull(sources); |
| | | final DataSource[] dataSources = new DataSource[sources.size()]; |
| | | for (int i = 0; i < sources.size(); i++) { |
| | | final String dataSourceDef = sources.get(i); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | import com.forgerock.opendj.util.Validator; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A trust manager which prompts the user for the length of time that they would |
| | |
| | | PromptingTrustManager(final ConsoleApplication app, final String acceptedStorePath, |
| | | final X509TrustManager sourceTrustManager) throws KeyStoreException, IOException, |
| | | NoSuchAlgorithmException, CertificateException { |
| | | Validator.ensureNotNull(app, acceptedStorePath); |
| | | Reject.ifNull(app); |
| | | Reject.ifNull(acceptedStorePath); |
| | | this.app = app; |
| | | this.nestedTrustManager = sourceTrustManager; |
| | | inMemoryTrustStore = KeyStore.getInstance(KeyStore.getDefaultType()); |
| | |
| | | <artifactId>slf4j-jdk14</artifactId> |
| | | <version>${slf4jVersion}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.forgerock.commons</groupId> |
| | | <artifactId>forgerock-util</artifactId> |
| | | <version>1.2.0-SNAPSHOT</version> |
| | | </dependency> |
| | | </dependencies> |
| | | </dependencyManagement> |
| | | <dependencies> |