Prep work for OPENDJ-2803 Migrate Attribute
Inline server Attribute methods that do not exist on the SDK Attribute type:
- getNameWithOptions(): replaced with getAttributeDescription().toString()
- hasOptions(): replaced with getAttributeDescription().hasOptions()
- hasOption(String): replaced with getAttributeDescription().hasOption(String)
| | |
| | | */ |
| | | public static org.forgerock.opendj.ldap.Attribute from( |
| | | final org.opends.server.types.Attribute attribute) { |
| | | Attribute sdkAttribute = new LinkedAttribute(attribute.getNameWithOptions()); |
| | | Attribute sdkAttribute = new LinkedAttribute(attribute.getAttributeDescription()); |
| | | for (ByteString value : attribute) { |
| | | sdkAttribute.add(value); |
| | | } |
| | |
| | | { |
| | | for (org.opends.server.types.Attribute attr : attrs) |
| | | { |
| | | if (attr.getNameWithOptions().equalsIgnoreCase(attrName)) |
| | | if (attr.getAttributeDescription().toString().equalsIgnoreCase(attrName)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | attrs.put(objectclass); |
| | | for (org.opends.server.types.Attribute attr : newEntry.getAttributes()) |
| | | { |
| | | String attrName = attr.getNameWithOptions(); |
| | | Set<ByteString> values = new LinkedHashSet<>(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | values.add(it.next()); |
| | | } |
| | | BasicAttribute a = new BasicAttribute(attrName); |
| | | BasicAttribute a = new BasicAttribute(attr.getAttributeDescription().toString()); |
| | | for (ByteString value : values) |
| | | { |
| | | a.add(value.toByteArray()); |
| | |
| | | boolean done = false; |
| | | for (org.opends.server.types.Attribute attr : entry.getAttribute(attrName.toLowerCase())) |
| | | { |
| | | if (attr.getNameWithOptions().equals(attrName)) |
| | | if (attr.getAttributeDescription().toString().equals(attrName)) |
| | | { |
| | | List<ByteString> newValues = getValues(attr); |
| | | newValues.add(value); |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DN; |
| | |
| | | // This attribute is not multi-valued. |
| | | changeInitiatorsName = attr.iterator().next().toString(); |
| | | } |
| | | final String attrName = attr.getNameWithOptions(); |
| | | for (ByteString value : attr) |
| | | { |
| | | builder.append(attrName); |
| | | builder.append(attr.getAttributeDescription()); |
| | | appendLDIFSeparatorAndValue(builder, value); |
| | | builder.append('\n'); |
| | | } |
| | |
| | | // This attribute is not multi-valued. |
| | | changeInitiatorsName = attr.iterator().next().toString(); |
| | | } |
| | | final String attrName = attr.getNameWithOptions(); |
| | | final AttributeDescription attrDesc = attr.getAttributeDescription(); |
| | | builder.append(mod.getModificationType()); |
| | | builder.append(": "); |
| | | builder.append(attrName); |
| | | builder.append(attrDesc); |
| | | builder.append('\n'); |
| | | |
| | | for (ByteString value : attr) |
| | | { |
| | | builder.append(attrName); |
| | | builder.append(attrDesc); |
| | | appendLDIFSeparatorAndValue(builder, value); |
| | | builder.append('\n'); |
| | | } |
| | |
| | | } |
| | | else if (SchemaConfigManager.isSchemaAttribute(a)) |
| | | { |
| | | logger.error(ERR_SCHEMA_INVALID_REPLACE_MODIFICATION, a.getNameWithOptions()); |
| | | logger.error(ERR_SCHEMA_INVALID_REPLACE_MODIFICATION, a.getAttributeDescription()); |
| | | } |
| | | else |
| | | { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | for (Attribute a : attributeList) |
| | | { |
| | | if (a.hasOptions()) |
| | | final AttributeDescription attrDesc = a.getAttributeDescription(); |
| | | if (attrDesc.hasOptions()) |
| | | { |
| | | // This must be the pending value. |
| | | if (a.hasOption(OPTION_PENDING_VALUES)) |
| | | if (attrDesc.hasOption(OPTION_PENDING_VALUES)) |
| | | { |
| | | if (pendingValueSet) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | for (Attribute a : attributeList) |
| | | { |
| | | if (a.hasOptions()) |
| | | AttributeDescription attrDesc = a.getAttributeDescription(); |
| | | if (attrDesc.hasOptions()) |
| | | { |
| | | // This must be the pending value. |
| | | if (a.hasOption(OPTION_PENDING_VALUES)) |
| | | if (attrDesc.hasOption(OPTION_PENDING_VALUES)) |
| | | { |
| | | if (pendingValues != null) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | for (Attribute a : attributeList) |
| | | { |
| | | if (a.hasOptions()) |
| | | AttributeDescription attrDesc = a.getAttributeDescription(); |
| | | if (attrDesc.hasOptions()) |
| | | { |
| | | // This must be the pending value. |
| | | if (a.hasOption(OPTION_PENDING_VALUES)) |
| | | if (attrDesc.hasOption(OPTION_PENDING_VALUES)) |
| | | { |
| | | if (pendingValues != null) |
| | | { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | for (Attribute a : attributeList) |
| | | { |
| | | if (a.hasOptions()) |
| | | AttributeDescription attrDesc = a.getAttributeDescription(); |
| | | if (attrDesc.hasOptions()) |
| | | { |
| | | // This must be the pending value. |
| | | if (!a.hasOption(OPTION_PENDING_VALUES)) |
| | | if (!attrDesc.hasOption(OPTION_PENDING_VALUES)) |
| | | { |
| | | // This is illegal -- only the pending option is allowed for configuration attributes. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(a.getName())); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | for (Attribute a : attributeList) |
| | | { |
| | | if (a.hasOptions()) |
| | | AttributeDescription attrDesc = a.getAttributeDescription(); |
| | | if (attrDesc.hasOptions()) |
| | | { |
| | | // This must be the pending value. |
| | | if (a.hasOption(OPTION_PENDING_VALUES)) |
| | | if (attrDesc.hasOption(OPTION_PENDING_VALUES)) |
| | | { |
| | | if (pendingValues != null) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | for (Attribute a : attributeList) |
| | | { |
| | | if (a.hasOptions()) |
| | | AttributeDescription attrDesc = a.getAttributeDescription(); |
| | | if (attrDesc.hasOptions()) |
| | | { |
| | | // This must be the pending value. |
| | | if (a.hasOption(OPTION_PENDING_VALUES)) |
| | | if (attrDesc.hasOption(OPTION_PENDING_VALUES)) |
| | | { |
| | | if (pendingValues != null) |
| | | { |
| | |
| | | ERR_ADD_ATTR_IS_NO_USER_MOD.get(entryDN, attr.getName())); |
| | | } |
| | | |
| | | boolean hasBinaryOption = attr.getAttributeDescription().hasOption("binary"); |
| | | if(attrType.getSyntax().isBEREncodingRequired()) |
| | | { |
| | | if(!attr.hasOption("binary")) |
| | | if (!hasBinaryOption) |
| | | { |
| | | //A binary option wasn't provided by the client so add it. |
| | | AttributeBuilder builder = new AttributeBuilder(attr); |
| | |
| | | attr = builder.toAttribute(); |
| | | } |
| | | } |
| | | else if (attr.hasOption("binary")) |
| | | else if (hasBinaryOption) |
| | | { |
| | | // binary option is not honored for non-BER-encodable attributes. |
| | | throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, |
| | |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*; |
| | | |
| | | /** |
| | | * This class defines an operation that may be used to modify an entry in the |
| | | * Directory Server. |
| | | */ |
| | | /** This class defines an operation that may be used to modify an entry in the Directory Server. */ |
| | | public class ModifyOperationBasis |
| | | extends AbstractOperation implements ModifyOperation, |
| | | PreParseModifyOperation, |
| | |
| | | { |
| | | super(clientConnection, operationID, messageID, requestControls); |
| | | |
| | | |
| | | this.rawEntryDN = rawEntryDN; |
| | | this.rawModifications = rawModifications; |
| | | |
| | |
| | | { |
| | | super(clientConnection, operationID, messageID, requestControls); |
| | | |
| | | |
| | | this.entryDN = entryDN; |
| | | this.modifications = modifications; |
| | | |
| | |
| | | cancelRequest = null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final ByteString getRawEntryDN() |
| | | { |
| | | return rawEntryDN; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void setRawEntryDN(ByteString rawEntryDN) |
| | | { |
| | |
| | | return rawModifications; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void addRawModification(RawModification rawModification) |
| | | { |
| | |
| | | modifications = null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void setRawModifications(List<RawModification> rawModifications) |
| | | { |
| | |
| | | modifications = null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final List<Modification> getModifications() |
| | | { |
| | |
| | | Attribute attr = mod.getAttribute(); |
| | | AttributeType type = attr.getAttributeDescription().getAttributeType(); |
| | | |
| | | if(type.getSyntax().isBEREncodingRequired()) |
| | | boolean hasBinaryOption = attr.getAttributeDescription().hasOption("binary"); |
| | | if (type.getSyntax().isBEREncodingRequired()) |
| | | { |
| | | if(!attr.hasOption("binary")) |
| | | if (!hasBinaryOption) |
| | | { |
| | | //A binary option wasn't provided by the client so add it. |
| | | AttributeBuilder builder = new AttributeBuilder(attr); |
| | |
| | | mod.setAttribute(attr); |
| | | } |
| | | } |
| | | else if (attr.hasOption("binary")) |
| | | else if (hasBinaryOption) |
| | | { |
| | | // binary option is not honored for non-BER-encodable attributes. |
| | | throw new LDAPException(LDAPResultCode.UNDEFINED_ATTRIBUTE_TYPE, |
| | |
| | | return modifications; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void addModification(Modification modification) |
| | | throws DirectoryException |
| | |
| | | modifications.add(modification); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final OperationType getOperationType() |
| | | { |
| | |
| | | return OperationType.MODIFY; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN getProxiedAuthorizationDN() |
| | | { |
| | | return proxiedAuthorizationDN; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final List<Control> getResponseControls() |
| | | { |
| | | return responseControls; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void addResponseControl(Control control) |
| | | { |
| | | responseControls.add(control); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void removeResponseControl(Control control) |
| | | { |
| | | responseControls.remove(control); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void toString(StringBuilder buffer) |
| | | { |
| | |
| | | buffer.append(")"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN) |
| | | { |
| | | this.proxiedAuthorizationDN = proxiedAuthorizationDN; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void run() |
| | | { |
| | |
| | | // Check for and handle a request to cancel this operation. |
| | | checkIfCanceled(false); |
| | | |
| | | |
| | | // Process the entry DN to convert it from the raw form to the form |
| | | // required for the rest of the modify processing. |
| | | DN entryDN = getEntryDN(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Invokes the post response plugins. If a workflow has been executed |
| | | * then invoke the post response plugins provided by the workflow |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void updateOperationErrMsgAndResCode() |
| | | { |
| | |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | import org.opends.server.admin.std.server.EntityTagVirtualAttributeCfg; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | private static final Comparator<Attribute> ATTRIBUTE_COMPARATOR = |
| | | new Comparator<Attribute>() |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(final Attribute a1, final Attribute a2) |
| | | { |
| | | return a1.getNameWithOptions().compareTo(a2.getNameWithOptions()); |
| | | return a1.getAttributeDescription().compareTo(a2.getAttributeDescription()); |
| | | } |
| | | }; |
| | | |
| | | /** Current configuration. */ |
| | | private volatile EntityTagVirtualAttributeCfg config; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Default constructor invoked by reflection. |
| | | */ |
| | | /** Default constructor invoked by reflection. */ |
| | | public EntityTagVirtualAttributeProvider() |
| | | { |
| | | // Initialization performed by initializeVirtualAttributeProvider. |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | final EntityTagVirtualAttributeCfg configuration) |
| | |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult approximatelyEqualTo(final Entry entry, |
| | | final VirtualAttributeRule rule, final ByteString value) |
| | |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finalizeVirtualAttributeProvider() |
| | | { |
| | | config.removeEntityTagChangeListener(this); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Attribute getValues(final Entry entry, final VirtualAttributeRule rule) |
| | | { |
| | |
| | | return Attributes.create(rule.getAttributeType(), etag); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult greaterThanOrEqualTo(final Entry entry, |
| | | final VirtualAttributeRule rule, final ByteString value) |
| | |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue(final Entry entry, final VirtualAttributeRule rule) |
| | | { |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeVirtualAttributeProvider( |
| | | final EntityTagVirtualAttributeCfg configuration) throws ConfigException, |
| | |
| | | configuration.addEntityTagChangeListener(this); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | final EntityTagVirtualAttributeCfg configuration, |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isMultiValued() |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isSearchable(final VirtualAttributeRule rule, |
| | | final SearchOperation searchOperation, |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult lessThanOrEqualTo(final Entry entry, |
| | | final VirtualAttributeRule rule, final ByteString value) |
| | |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConditionResult matchesSubstring(final Entry entry, |
| | | final VirtualAttributeRule rule, final ByteString subInitial, |
| | |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void processSearch(final VirtualAttributeRule rule, |
| | | final SearchOperation searchOperation) |
| | |
| | | searchOperation.setResultCode(ResultCode.UNWILLING_TO_PERFORM); |
| | | } |
| | | |
| | | |
| | | |
| | | private void checksumAttribute(final EntityTagVirtualAttributeCfg cfg, |
| | | final Checksum checksummer, final Attribute attribute) |
| | | { |
| | |
| | | } |
| | | |
| | | // Checksum the attribute description. |
| | | final String atd = attribute.getNameWithOptions(); |
| | | final byte[] bytes = StaticUtils.getBytes(atd); |
| | | final byte[] bytes = StaticUtils.getBytes(attribute.getAttributeDescription().toString()); |
| | | checksummer.update(bytes, 0, bytes.length); |
| | | |
| | | // Checksum the attribute values. The value order may vary between |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private ByteString checksumEntry(final EntityTagVirtualAttributeCfg cfg, |
| | | final Checksum checksummer, final Entry entry) |
| | | { |
| | |
| | | return ByteString.wrap(bytes); |
| | | } |
| | | |
| | | |
| | | |
| | | private void checksumValue(final Checksum checksummer, final ByteString value) |
| | | { |
| | | final int size = value.length(); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.io.*; |
| | | import java.net.*; |
| | | import java.util.*; |
| | | import java.util.concurrent.*; |
| | | import java.io.BufferedReader; |
| | | import java.io.Closeable; |
| | | import java.io.File; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | | import java.net.ConnectException; |
| | | import java.net.InetAddress; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.Socket; |
| | | import java.net.SocketTimeoutException; |
| | | import java.net.UnknownHostException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Queue; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentLinkedQueue; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.ScheduledExecutorService; |
| | | import java.util.concurrent.ScheduledFuture; |
| | | import java.util.concurrent.Semaphore; |
| | | import java.util.concurrent.ThreadFactory; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.concurrent.locks.ReentrantReadWriteLock; |
| | | import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; |
| | | import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; |
| | | |
| | | import javax.net.ssl.*; |
| | | import javax.net.ssl.SSLContext; |
| | | import javax.net.ssl.SSLException; |
| | | import javax.net.ssl.SSLSocket; |
| | | import javax.net.ssl.SSLSocketFactory; |
| | | import javax.net.ssl.TrustManager; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.GeneralizedTime; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.protocols.ldap.*; |
| | | import org.opends.server.protocols.ldap.BindRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.ProtocolOp; |
| | | import org.opends.server.protocols.ldap.SearchRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.SearchResultDoneProtocolOp; |
| | | import org.opends.server.protocols.ldap.SearchResultEntryProtocolOp; |
| | | import org.opends.server.protocols.ldap.UnbindRequestProtocolOp; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.schema.UserPasswordSyntax; |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.HostPort; |
| | |
| | | for (Attribute attribute : userEntry.getAttribute(cachedPasswordTimeAttribute)) |
| | | { |
| | | // Ignore any attributes with options. |
| | | if (!attribute.hasOptions()) |
| | | if (!attribute.getAttributeDescription().hasOptions()) |
| | | { |
| | | for (ByteString value : attribute) |
| | | { |
| | |
| | | for (Attribute attribute : userEntry.getAttribute(cachedPasswordAttribute)) |
| | | { |
| | | // Ignore any attributes with options. |
| | | if (!attribute.hasOptions()) |
| | | if (!attribute.getAttributeDescription().hasOptions()) |
| | | { |
| | | for (ByteString value : attribute) |
| | | { |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | logger.trace("Adding end user recipient %s from attr %s", v, a.getNameWithOptions()); |
| | | logger.trace("Adding end user recipient %s from attr %s", v, a.getAttributeDescription()); |
| | | |
| | | recipients.add(v.toString()); |
| | | } |
| | |
| | | super(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void initializePlugin(Set<PluginType> pluginTypes, |
| | | SevenBitCleanPluginCfg configuration) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void finalizePlugin() |
| | | { |
| | | currentConfig.removeSevenBitCleanChangeListener(this); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final PluginResult.ImportLDIF |
| | | doLDIFImport(LDIFImportConfig importConfig, Entry entry) |
| | |
| | | // Get the current configuration for this plugin. |
| | | SevenBitCleanPluginCfg config = currentConfig; |
| | | |
| | | |
| | | // Make sure that the entry is within the scope of this plugin. While |
| | | // processing an LDIF import, we don't have access to the set of public |
| | | // naming contexts defined in the server, so if no explicit set of base DNs |
| | |
| | | return PluginResult.ImportLDIF.continueEntryProcessing(); |
| | | } |
| | | |
| | | |
| | | // Make sure all configured attributes have clean values. |
| | | for (AttributeType t : config.getAttributeType()) |
| | | { |
| | |
| | | if (!is7BitClean(v)) |
| | | { |
| | | LocalizableMessage rejectMessage = |
| | | ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(a.getNameWithOptions()); |
| | | ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(a.getAttributeDescription()); |
| | | return PluginResult.ImportLDIF.stopEntryProcessing(rejectMessage); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then everything is acceptable. |
| | | return PluginResult.ImportLDIF.continueEntryProcessing(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final PluginResult.PreParse |
| | | doPreParse(PreParseAddOperation addOperation) |
| | |
| | | // Get the current configuration for this plugin. |
| | | SevenBitCleanPluginCfg config = currentConfig; |
| | | |
| | | |
| | | // If the entry is within the scope of this plugin, then make sure all |
| | | // configured attributes have clean values. |
| | | DN entryDN; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then everything is acceptable. |
| | | return PluginResult.PreParse.continueOperationProcessing(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final PluginResult.PreParse |
| | | doPreParse(PreParseModifyOperation modifyOperation) |
| | |
| | | // Get the current configuration for this plugin. |
| | | SevenBitCleanPluginCfg config = currentConfig; |
| | | |
| | | |
| | | // If the target entry is within the scope of this plugin, then make sure |
| | | // all values that will be added during the modification will be acceptable. |
| | | DN entryDN; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then everything is acceptable. |
| | | return PluginResult.PreParse.continueOperationProcessing(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final PluginResult.PreParse |
| | | doPreParse(PreParseModifyDNOperation modifyDNOperation) |
| | |
| | | // Get the current configuration for this plugin. |
| | | SevenBitCleanPluginCfg config = currentConfig; |
| | | |
| | | |
| | | // If the target entry is within the scope of this plugin, then make sure |
| | | // all values that will be added during the modification will be acceptable. |
| | | DN entryDN; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then everything is acceptable. |
| | | return PluginResult.PreParse.continueOperationProcessing(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided DN is within the scope of this plugin. |
| | | * |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided value is 7-bit clean. |
| | | * |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAcceptable(PluginCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | |
| | | return isConfigurationChangeAcceptable(cfg, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | SevenBitCleanPluginCfg configuration, |
| | |
| | | // These are acceptable. |
| | | break; |
| | | |
| | | |
| | | default: |
| | | unacceptableReasons.add(ERR_PLUGIN_7BIT_INVALID_PLUGIN_TYPE.get(pluginType)); |
| | | configAcceptable = false; |
| | |
| | | return configAcceptable; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | SevenBitCleanPluginCfg configuration) |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | */ |
| | | public LDAPAttribute(Attribute attribute) |
| | | { |
| | | this.attributeType = attribute.getNameWithOptions(); |
| | | this.attributeType = attribute.getAttributeDescription().toString(); |
| | | |
| | | if (attribute.isVirtual()) |
| | | { |
| | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | if (attrList != null && attrList.getValue().size() == 1) |
| | | { |
| | | Attribute a = attrList.getValue().get(0); |
| | | if (!a.hasOptions()) |
| | | if (!a.getAttributeDescription().hasOptions()) |
| | | { |
| | | needsMerge = false; |
| | | tmp.add(new LDAPAttribute(a)); |
| | |
| | | if (attrList != null && attrList.getValue().size() == 1) |
| | | { |
| | | Attribute a = attrList.getValue().get(0); |
| | | if (!a.hasOptions()) |
| | | if (!a.getAttributeDescription().hasOptions()) |
| | | { |
| | | needsMerge = false; |
| | | tmp.add(new LDAPAttribute(a)); |
| | |
| | | |
| | | if (needsMerge) |
| | | { |
| | | AttributeBuilder builder = |
| | | new AttributeBuilder(attrList.getKey()); |
| | | AttributeBuilder builder = new AttributeBuilder(attrList.getKey()); |
| | | for (Attribute a : attrList.getValue()) |
| | | { |
| | | builder.addAll(a); |
| | |
| | | else |
| | | { |
| | | // LDAPv3 |
| | | for (List<Attribute> attrList : entry.getUserAttributes() |
| | | .values()) |
| | | for (List<Attribute> attrList : entry.getUserAttributes().values()) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | for (List<Attribute> attrList : entry |
| | | .getOperationalAttributes().values()) |
| | | for (List<Attribute> attrList : entry.getOperationalAttributes().values()) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | |
| | | throws IOException |
| | | { |
| | | stream.writeStartSequence(); |
| | | stream.writeOctetString(a.getNameWithOptions()); |
| | | stream.writeOctetString(a.getAttributeDescription().toString()); |
| | | stream.writeStartSet(); |
| | | for (ByteString value : a) |
| | | { |
| | |
| | | continue; |
| | | } |
| | | |
| | | String attrName = a.getNameWithOptions(); |
| | | String attrName = a.getAttributeDescription().toString(); |
| | | if (typesOnly) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(attrName); |
| | |
| | | continue; |
| | | } |
| | | |
| | | String attrName = a.getNameWithOptions(); |
| | | String attrName = a.getAttributeDescription().toString(); |
| | | if (typesOnly) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(attrName); |
| | |
| | | @Override |
| | | public String getName() |
| | | { |
| | | return getAttributeDescription().getAttributeType().getNameOrOID(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * <p> |
| | | * This implementation returns this attribute's name if there are no |
| | | * attribute options, otherwise it constructs a string comprising of |
| | | * this attribute's name followed by a semi-colon and a semi-colon |
| | | * separated list of its attribute options. |
| | | */ |
| | | @Override |
| | | public String getNameWithOptions() |
| | | { |
| | | if (!hasOptions()) |
| | | { |
| | | return getName(); |
| | | } |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append(getName()); |
| | | for (String option : getAttributeDescription().getOptions()) |
| | | { |
| | | buffer.append(';'); |
| | | buffer.append(option); |
| | | } |
| | | return buffer.toString(); |
| | | return getAttributeDescription().getNameOrOID(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return hashCode; |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | | return getAttributeDescription().hasOption(option); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * <p> |
| | | * This implementation retrieves the set of options associated with |
| | | * this attribute and tests to see if it is empty. |
| | | */ |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | | return getAttributeDescription().hasOptions(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * <p> |
| | |
| | | String getName(); |
| | | |
| | | /** |
| | | * Retrieves the user-provided name of this attribute, along with |
| | | * any options that might have been provided. |
| | | * |
| | | * @return The user-provided name of this attribute, along with any |
| | | * options that might have been provided. |
| | | */ |
| | | String getNameWithOptions(); |
| | | |
| | | /** |
| | | * Indicates whether this attribute has any value(s) that are |
| | | * greater than or equal to the provided value. |
| | | * |
| | |
| | | int hashCode(); |
| | | |
| | | /** |
| | | * Indicates whether this attribute has the specified option. |
| | | * |
| | | * @param option |
| | | * The option for which to make the determination. |
| | | * @return {@code true} if this attribute has the specified option, |
| | | * or {@code false} if not. |
| | | */ |
| | | boolean hasOption(String option); |
| | | |
| | | /** |
| | | * Indicates whether this attribute has any options at all. |
| | | * |
| | | * @return {@code true} if this attribute has at least one |
| | | * option, or {@code false} if not. |
| | | */ |
| | | boolean hasOptions(); |
| | | |
| | | /** |
| | | * Returns {@code true} if this attribute contains no |
| | | * attribute values. |
| | | * |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | | return attributeDescription.hasOption(option); |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | | return attributeDescription.hasOptions(); |
| | | } |
| | | |
| | | @Override |
| | | public final String getName() |
| | | { |
| | | return attributeDescription.getNameOrOID(); |
| | | } |
| | | |
| | | @Override |
| | | public final ConditionResult greaterThanOrEqualTo(ByteString assertionValue) |
| | | { |
| | | MatchingRule matchingRule = getAttributeType().getOrderingMatchingRule(); |
| | |
| | | public final void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("Attribute("); |
| | | buffer.append(getNameWithOptions()); |
| | | buffer.append(attributeDescription); |
| | | buffer.append(", {"); |
| | | Utils.joinAsString(buffer, ", ", values); |
| | | buffer.append("})"); |
| | |
| | | { |
| | | for (Attribute a : getAttribute(attributeType)) |
| | | { |
| | | if (!a.hasOptions() && a.contains(value)) |
| | | if (!a.getAttributeDescription().hasOptions() && a.contains(value)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | byte[] nameBytes = getBytes(a.getNameWithOptions()); |
| | | buffer.appendBytes(nameBytes); |
| | | buffer.appendBytes(getBytes(a.getAttributeDescription().toString())); |
| | | buffer.appendByte(0x00); |
| | | |
| | | buffer.appendBERLength(a.size()); |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | String attrName = a.getNameWithOptions(); |
| | | String attrName = a.getAttributeDescription().toString(); |
| | | for (ByteString v : a) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(attrName); |
| | |
| | | BufferedWriter writer, boolean wrapLines, int wrapColumn) |
| | | throws IOException |
| | | { |
| | | String attrName = attribute.getNameWithOptions(); |
| | | String attrName = attribute.getAttributeDescription().toString(); |
| | | if (typesOnly) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(attrName); |
| | |
| | | buffer.append(","); |
| | | } |
| | | |
| | | buffer.append(a.getNameWithOptions()); |
| | | buffer.append(a.getAttributeDescription()); |
| | | |
| | | buffer.append("={"); |
| | | Iterator<ByteString> valueIterator = a.iterator(); |
| | |
| | | { |
| | | this.collectiveAttributes.add(new CollectiveVirtualAttribute(subAttr)); |
| | | } |
| | | else if (subAttr.hasOption(ATTR_OPTION_COLLECTIVE)) |
| | | else if (subAttr.getAttributeDescription().hasOption(ATTR_OPTION_COLLECTIVE)) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(subAttr.getAttributeDescription().getAttributeType()); |
| | | builder.addAll(subAttr); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getNameWithOptions() |
| | | { |
| | | return getName(); |
| | | } |
| | | |
| | | @Override |
| | | public AttributeDescription getAttributeDescription() |
| | | { |
| | | return attributeDescription; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasOption(String option) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean hasOptions() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isEmpty() |
| | | { |
| | | return !provider.hasValue(entry, rule); |
| | |
| | | } |
| | | |
| | | //The attribute is not being ignored so check for binary option. |
| | | if(checkSchema |
| | | if (checkSchema |
| | | && !attrType.getSyntax().isBEREncodingRequired() |
| | | && attribute.hasOption("binary")) |
| | | && attribute.getAttributeDescription().hasOption("binary")) |
| | | { |
| | | LocalizableMessage message = ERR_LDIF_INVALID_ATTR_OPTION.get( |
| | | entryDN, lastEntryLineNumber, attrName); |
| | |
| | | for (int j = 0; j < attrList.size(); j++) |
| | | { |
| | | Attribute a = attrList.get(j); |
| | | if (a.hasOptions()) |
| | | if (a.getAttributeDescription().hasOptions()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | final String attrName = a.getNameWithOptions(); |
| | | final String attrName = a.getAttributeDescription().toString(); |
| | | writeAttribute(attrName, v, writer, wrapLines, wrapColumn); |
| | | } |
| | | } |
| | |
| | | { |
| | | for (Attribute a : entry.getUserAttribute(attrType)) |
| | | { |
| | | StringBuilder attrName = new StringBuilder(a.getNameWithOptions()); |
| | | String attrName = a.getAttributeDescription().toString(); |
| | | for (ByteString v : a) |
| | | { |
| | | writeAttribute(attrName, v, writer, wrapLines, wrapColumn); |
| | |
| | | { |
| | | for (Attribute a : entry.getUserAttribute(attrType)) |
| | | { |
| | | StringBuilder attrName = new StringBuilder(); |
| | | final String attrDesc = a.getAttributeDescription().toString(); |
| | | final StringBuilder attrName = new StringBuilder(2 + attrDesc.length()); |
| | | attrName.append("# "); |
| | | attrName.append(a.getNameWithOptions()); |
| | | attrName.append(attrDesc); |
| | | |
| | | for (ByteString v : a) |
| | | { |
| | |
| | | Modification m = iterator.next(); |
| | | Attribute a = m.getAttribute(); |
| | | |
| | | String name = a.getNameWithOptions(); |
| | | String name = a.getAttributeDescription().toString(); |
| | | |
| | | StringBuilder modTypeLine = new StringBuilder(); |
| | | modTypeLine.append(m.getModificationType()); |
| | |
| | | |
| | | for (int j = 0; j < attrList.size(); j++) { |
| | | Attribute a = attrList.get(j); |
| | | if (a.hasOptions()) |
| | | if (a.getAttributeDescription().hasOptions()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | |
| | | Attribute passwordAttr = attrList.get(0); |
| | | if (passwordAttr.hasOptions()) |
| | | if (passwordAttr.getAttributeDescription().hasOptions()) |
| | | { |
| | | LocalizableMessage message = ERR_PWPOLICY_ATTRIBUTE_OPTIONS_NOT_ALLOWED.get( |
| | | passwordAttribute.getNameOrOID()); |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg4; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Privilege; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SynchronizationProviderResult; |
| | | import org.opends.server.types.operation.PostOperationModifyOperation; |
| | |
| | | private void validatePasswordModification(Modification m, PasswordPolicy authPolicy) throws DirectoryException |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | | if (a.hasOptions()) |
| | | if (a.getAttributeDescription().hasOptions()) |
| | | { |
| | | switch (m.getModificationType().asEnum()) |
| | | { |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | byte[] nameBytes = getBytes(a.getNameWithOptions()); |
| | | buffer.appendBytes(nameBytes); |
| | | buffer.appendBytes(getBytes(a.getAttributeDescription().toString())); |
| | | buffer.appendByte(0x00); |
| | | |
| | | buffer.appendBERLength(a.size()); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | |
| | | e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("userpassword"); |
| | | assertThat(attrList).hasSize(1); |
| | | assertFalse(attrList.get(0).hasOptions()); |
| | | assertFalse(attrList.get(0).getAttributeDescription().hasOptions()); |
| | | assertThat(attrList.get(0)).hasSize(1); |
| | | } |
| | | |
| | |
| | | e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("userpassword"); |
| | | assertThat(attrList).hasSize(1); |
| | | assertFalse(attrList.get(0).hasOptions()); |
| | | assertFalse(attrList.get(0).getAttributeDescription().hasOptions()); |
| | | assertThat(attrList.get(0)).hasSize(1); |
| | | } |
| | | |
| | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("userpassword"); |
| | | assertThat(attrList).hasSize(1); |
| | | assertFalse(attrList.get(0).hasOptions()); |
| | | assertFalse(attrList.get(0).getAttributeDescription().hasOptions()); |
| | | assertThat(attrList.get(0)).hasSize(1); |
| | | } |
| | | |
| | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("userpassword"); |
| | | assertThat(attrList).hasSize(1); |
| | | assertFalse(attrList.get(0).hasOptions()); |
| | | assertFalse(attrList.get(0).getAttributeDescription().hasOptions()); |
| | | assertThat(attrList.get(0)).hasSize(1); |
| | | } |
| | | |
| | |
| | | List<Attribute> attrList = e.getAttribute(DirectoryServer.getAttributeType("usercertificate")); |
| | | assertThat(attrList).hasSize(1); |
| | | Attribute a = attrList.get(0); |
| | | assertTrue(a.hasOption("binary")); |
| | | assertTrue(a.getAttributeDescription().hasOption("binary")); |
| | | assertEquals(a.size(), 1); |
| | | assertEquals(Base64.encode(a.iterator().next()), certificateValue); |
| | | } |
| | |
| | | Set<String> actualNames = new HashSet<>(); |
| | | for (Attribute attribute : entry.getAttributes()) |
| | | { |
| | | actualNames.add(attribute.getNameWithOptions()); |
| | | actualNames.add(attribute.getAttributeDescription().toString()); |
| | | } |
| | | return actualNames; |
| | | } |
| | |
| | | assertThat(description).hasSize(1); |
| | | Attribute attribute = description.get(0); |
| | | assertEquals(attribute.size(), 1); |
| | | assertFalse(attribute.hasOptions()); |
| | | assertFalse(attribute.getAttributeDescription().hasOptions()); |
| | | assertTrue(attribute.contains(ByteString.valueOfUtf8("inherited description"))); |
| | | } |
| | | finally |
| | |
| | | throws Exception |
| | | { |
| | | // Check name and options. |
| | | String[] elements = a.getNameWithOptions().split(";"); |
| | | String[] elements = a.getAttributeDescription().toString().split(";"); |
| | | switch (elements.length) |
| | | { |
| | | case 0: |
| | | Assert.fail("Name and options could not be split: " |
| | | + a.getNameWithOptions()); |
| | | Assert.fail("Name and options could not be split: " + a.getAttributeDescription()); |
| | | break; |
| | | case 1: |
| | | Assert.assertEquals(elements[0], name); |
| | |
| | | throws Exception |
| | | { |
| | | // Check hasOption(). |
| | | AttributeDescription attrDesc = a.getAttributeDescription(); |
| | | for (String option : options) |
| | | { |
| | | Assert.assertTrue(a.hasOption(option)); |
| | | Assert.assertTrue(attrDesc.hasOption(option)); |
| | | |
| | | // Assumes internal normalization to lower-case. |
| | | Assert.assertTrue(a.hasOption(option.toUpperCase())); |
| | | Assert.assertTrue(attrDesc.hasOption(option.toUpperCase())); |
| | | } |
| | | |
| | | Assert.assertFalse(a.hasOption("xxxx")); |
| | | Assert.assertFalse(attrDesc.hasOption("xxxx")); |
| | | } |
| | | |
| | | |
| | |
| | | AttributeType type, String name, String[] options, String[] values) |
| | | throws Exception |
| | | { |
| | | Assert.assertEquals(options.length != 0, a.hasOptions()); |
| | | Assert.assertEquals(options.length != 0, a.getAttributeDescription().hasOptions()); |
| | | } |
| | | |
| | | |
| | |
| | | String[] options, String[] values) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(type, name); |
| | | for (String option : options) |
| | | { |
| | | builder.setOption(option); |
| | | } |
| | | for (String value : values) |
| | | { |
| | | builder.add(value); |
| | | } |
| | | builder.setOptions(Arrays.asList(options)); |
| | | builder.addAllStrings(Arrays.asList(values)); |
| | | return builder.toAttribute(); |
| | | } |
| | | } |