Code cleanup
AttributeBuilder.java:
Removed setInitialCapacity(), (no op)
Added addAllStrings() and made use of it.
Attributes.java:
Changed create(String attributeName, String firstValueString, String... otherValueStrings) to create(String attributeName, String... valueStrings) + made use of it.
*.java:
Removed javadocs duplicating javadocs from overridden methods.
| | |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteSequenceReader; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | if (numValues == 1 && options.isEmpty()) |
| | | { |
| | | final int valueLength = reader.getBERLength(); |
| | | final ByteString valueBytes = reader.getByteSequence(valueLength) |
| | | .toByteString(); |
| | | return Attributes.create(attrType, valueBytes); |
| | | final ByteSequence valueBytes = reader.getByteSequence(valueLength); |
| | | return Attributes.create(attrType, valueBytes.toByteString()); |
| | | } |
| | | else |
| | | { |
| | | // Read the appropriate number of values. |
| | | final AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | builder.setOptions(options); |
| | | builder.setInitialCapacity(numValues); |
| | | for (int i = 0; i < numValues; i++) |
| | | { |
| | | final int valueLength = reader.getBERLength(); |
| | | final ByteString valueBytes = reader.getByteSequence(valueLength) |
| | | .toByteString(); |
| | | builder.add(valueBytes); |
| | | final ByteSequence valueBytes = reader.getByteSequence(valueLength); |
| | | builder.add(valueBytes.toByteString()); |
| | | } |
| | | return builder.toAttribute(); |
| | | } |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.SortedSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.opends.server.api.ConfigHandler; |
| | | import org.opends.server.backends.pluggable.SuffixContainer; |
| | | import org.opends.server.controls.GetEffectiveRightsRequestControl; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ExtendedOperation; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | |
| | | return true; |
| | | } |
| | | |
| | | final AttributeBuilder builder = |
| | | new AttributeBuilder(refAttrType, ATTR_REFERRAL_URL); |
| | | |
| | | // Load the values, a bind rule might want to evaluate them. |
| | | final List<String> URLStrings = reference.getReferralURLs(); |
| | | for (String URLString : URLStrings) |
| | | { |
| | | builder.add(URLString); |
| | | } |
| | | final AttributeBuilder builder = new AttributeBuilder(refAttrType, ATTR_REFERRAL_URL); |
| | | builder.addAllStrings(reference.getReferralURLs()); |
| | | |
| | | final Entry e = new Entry(dn, null, null, null); |
| | | e.addAttribute(builder.toAttribute(), null); |
| | |
| | | if (dependencies != null && !dependencies.isEmpty()) { |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_DEPENDENCY, true); |
| | | AttributeBuilder builder = new AttributeBuilder(t); |
| | | for (String s : dependencies) { |
| | | builder.add(s); |
| | | } |
| | | builder.addAllStrings(dependencies); |
| | | userAttrs.put(t, builder.toAttributeList()); |
| | | } |
| | | |
| | |
| | | HashMap<AttributeType,List<Attribute>> dseOperationalAttrs = new HashMap<>(); |
| | | |
| | | |
| | | Attribute publicNamingContextAttr = createDNAttribute( |
| | | Attribute publicNamingContextAttr = createAttribute( |
| | | ATTR_NAMING_CONTEXTS, ATTR_NAMING_CONTEXTS_LC, |
| | | DirectoryServer.getPublicNamingContexts().keySet()); |
| | | addAttribute(publicNamingContextAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add the "ds-private-naming-contexts" attribute. |
| | | Attribute privateNamingContextAttr = createDNAttribute( |
| | | Attribute privateNamingContextAttr = createAttribute( |
| | | ATTR_PRIVATE_NAMING_CONTEXTS, ATTR_PRIVATE_NAMING_CONTEXTS, |
| | | DirectoryServer.getPrivateNamingContexts().keySet()); |
| | | addAttribute(privateNamingContextAttr, dseUserAttrs, dseOperationalAttrs); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates an attribute for the root DSE meant to hold a set of DNs. |
| | | * |
| | | * @param name The name for the attribute. |
| | | * @param lowerName The name for the attribute formatted in all lowercase |
| | | * characters. |
| | | * @param values The set of DN values to use for the attribute. |
| | | * |
| | | * @return The constructed attribute. |
| | | */ |
| | | private Attribute createDNAttribute(String name, String lowerName, |
| | | Collection<DN> values) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType(lowerName); |
| | | if (type == null) |
| | | { |
| | | type = DirectoryServer.getDefaultAttributeType(name); |
| | | } |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(type, name); |
| | | for (DN dn : values) { |
| | | builder.add(dn.toString()); |
| | | } |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates an attribute for the root DSE with the following |
| | | * criteria. |
| | | * |
| | |
| | | * @return The constructed attribute. |
| | | */ |
| | | private Attribute createAttribute(String name, String lowerName, |
| | | Collection<String> values) |
| | | Collection<? extends Object> values) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType(lowerName); |
| | | if (type == null) |
| | |
| | | } |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(type, name); |
| | | builder.setInitialCapacity(values.size()); |
| | | for (String s : values) { |
| | | builder.add(s); |
| | | } |
| | | builder.addAllStrings(values); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(schemaAttributeType); |
| | | builder.setInitialCapacity(elements.size()); |
| | | for (Object element : elements) |
| | | { |
| | | /* |
| | |
| | | return Attributes.create(rule.getAttributeType(), valueString); |
| | | default: |
| | | AttributeBuilder builder = new AttributeBuilder(rule.getAttributeType()); |
| | | for (String valueStr : userDefinedValues) |
| | | { |
| | | builder.add(valueStr); |
| | | } |
| | | builder.addAllStrings(userDefinedValues); |
| | | return builder.toAttribute(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.schema.BooleanSyntax; |
| | | import org.opends.server.types.*; |
| | | |
| | | |
| | | /** |
| | | * This class implements a monitor provider that will report generic information |
| | | * for an enabled Directory Server backend, including its backend ID, base DNs, |
| | |
| | | { |
| | | /** The attribute type that will be used to report the backend ID. */ |
| | | private AttributeType backendIDType; |
| | | |
| | | /** The attribute type that will be used to report the set of base DNs. */ |
| | | private AttributeType baseDNType; |
| | | |
| | | /** The attribute type that will be used to report the number of entries. */ |
| | | private AttributeType entryCountType; |
| | | |
| | | /** |
| | | * The attribute type that will be used to report the number of entries per |
| | | * base DN. |
| | | */ |
| | | /** The attribute type that will be used to report the number of entries per base DN. */ |
| | | private AttributeType baseDNEntryCountType; |
| | | |
| | | /** The attribute type that will be used to indicate if a backend is private. */ |
| | | private AttributeType isPrivateType; |
| | | |
| | | /** The attribute type that will be used to report the writability mode. */ |
| | | private AttributeType writabilityModeType; |
| | | |
| | |
| | | this.backend = backend; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeMonitorProvider(MonitorProviderCfg configuration) |
| | | { |
| | | monitorName = backend.getBackendID() + " Backend"; |
| | |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_BACKEND_WRITABILITY_MODE, true); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return monitorName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the objectclass that should be included in the monitor entry |
| | | * created from this monitor provider. |
| | |
| | | * @return The objectclass that should be included in the monitor entry |
| | | * created from this monitor provider. |
| | | */ |
| | | @Override |
| | | public ObjectClass getMonitorObjectClass() |
| | | { |
| | | return DirectoryConfig.getObjectClass(OC_MONITOR_BACKEND, true); |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | LinkedList<Attribute> attrs = new LinkedList<>(); |
| | | |
| | | attrs.add(Attributes.create(backendIDType, backend.getBackendID())); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(baseDNType); |
| | | DN[] baseDNs = backend.getBaseDNs(); |
| | | for (DN dn : baseDNs) |
| | | { |
| | | builder.add(dn.toString()); |
| | | } |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(baseDNType); |
| | | builder.addAllStrings(Arrays.asList(baseDNs)); |
| | | attrs.add(builder.toAttribute()); |
| | | |
| | | attrs.add(Attributes.create(isPrivateType, BooleanSyntax |
| | |
| | | if (!listeners.isEmpty()) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(listenerType); |
| | | for (HostPort hp : listeners) |
| | | { |
| | | builder.add(hp.toString()); |
| | | } |
| | | builder.addAllStrings(listeners); |
| | | attrs.add(builder.toAttribute()); |
| | | } |
| | | |
| | |
| | | return attrs; |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.StackTraceMonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | /** |
| | | * This class defines a Directory Server monitor provider that can be used to |
| | |
| | | public class StackTraceMonitorProvider |
| | | extends MonitorProvider<StackTraceMonitorProviderCfg> |
| | | { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeMonitorProvider( |
| | | StackTraceMonitorProviderCfg configuration) |
| | | throws ConfigException, InitializationException |
| | |
| | | // No initialization is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name of this monitor provider. It should be unique among all |
| | | * monitor providers, including all instances of the same monitor provider. |
| | | * |
| | | * @return The name of this monitor provider. |
| | | */ |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return "JVM Stack Trace"; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a set of attributes containing monitor data that should be |
| | | * returned to the client if the corresponding monitor entry is requested. |
| | | * |
| | | * @return A set of attributes containing monitor data that should be |
| | | * returned to the client if the corresponding monitor entry is |
| | | * requested. |
| | | */ |
| | | public ArrayList<Attribute> getMonitorData() |
| | | @Override |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | Map<Thread,StackTraceElement[]> threadStacks = Thread.getAllStackTraces(); |
| | | |
| | | |
| | | // Re-arrange all of the elements by thread ID so that there is some logical order. |
| | | TreeMap<Long,Map.Entry<Thread,StackTraceElement[]>> orderedStacks = new TreeMap<>(); |
| | | for (Map.Entry<Thread,StackTraceElement[]> e : threadStacks.entrySet()) |
| | |
| | | orderedStacks.put(e.getKey().getId(), e); |
| | | } |
| | | |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getDefaultAttributeType("jvmThread"); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | |
| | | StackTraceElement[] stackElements = e.getValue(); |
| | | |
| | | long id = t.getId(); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append("id="); |
| | | buffer.append(id); |
| | | buffer.append(" ---------- "); |
| | | buffer.append(t.getName()); |
| | | buffer.append(" ----------"); |
| | | builder.add(buffer.toString()); |
| | | builder.add("id=" + id + " ---------- " + t.getName() + " ----------"); |
| | | |
| | | // Create an attribute for the stack trace. |
| | | if (stackElements != null) |
| | | { |
| | | for (int j=0; j < stackElements.length; j++) |
| | | { |
| | | buffer = new StringBuilder(); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append("id="); |
| | | buffer.append(id); |
| | | buffer.append(" frame["); |
| | |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.lang.management.ManagementFactory; |
| | |
| | | import javax.net.ssl.SSLContext; |
| | | import javax.net.ssl.SSLParameters; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.SystemInfoMonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | /** |
| | | * This class defines a Directory Server monitor provider that can be used to |
| | |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeMonitorProvider( |
| | | SystemInfoMonitorProviderCfg configuration) |
| | | throws ConfigException, InitializationException |
| | |
| | | // No initialization is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name of this monitor provider. It should be unique among all |
| | | * monitor providers, including all instances of the same monitor provider. |
| | | * |
| | | * @return The name of this monitor provider. |
| | | */ |
| | | @Override |
| | | public String getMonitorInstanceName() |
| | | { |
| | | return "System Information"; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a set of attributes containing monitor data that should be |
| | | * returned to the client if the corresponding monitor entry is requested. |
| | | * |
| | | * @return A set of attributes containing monitor data that should be |
| | | * returned to the client if the corresponding monitor entry is |
| | | * requested. |
| | | */ |
| | | public ArrayList<Attribute> getMonitorData() |
| | | @Override |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | ArrayList<Attribute> attrs = new ArrayList<>(13); |
| | | |
| | |
| | | supportedTlsCiphers = Collections.emptyList(); |
| | | } |
| | | |
| | | |
| | | // Add the "supportedTLSProtocols" attribute. |
| | | AttributeType supportedTLSProtocolsAttrType = DirectoryServer |
| | | .getDefaultAttributeType(ATTR_SUPPORTED_TLS_PROTOCOLS); |
| | | AttributeBuilder builder = new AttributeBuilder( |
| | | supportedTLSProtocolsAttrType); |
| | | for (String value : supportedTlsProtocols) |
| | | { |
| | | builder.add(value); |
| | | } |
| | | attrs.add(builder.toAttribute()); |
| | | |
| | | // Add the "supportedTLSCiphers" attribute. |
| | | AttributeType supportedTLSCiphersAttrType = DirectoryServer |
| | | .getDefaultAttributeType(ATTR_SUPPORTED_TLS_CIPHERS); |
| | | builder = new AttributeBuilder(supportedTLSCiphersAttrType); |
| | | for (String value : supportedTlsCiphers) |
| | | { |
| | | builder.add(value); |
| | | } |
| | | attrs.add(builder.toAttribute()); |
| | | addAttribute(attrs, ATTR_SUPPORTED_TLS_PROTOCOLS, supportedTlsProtocols); |
| | | addAttribute(attrs, ATTR_SUPPORTED_TLS_CIPHERS, supportedTlsCiphers); |
| | | |
| | | return attrs; |
| | | } |
| | | |
| | | |
| | | private void addAttribute(ArrayList<Attribute> attrs, String attrName, Collection<String> values) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType(attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | builder.addAllStrings(values); |
| | | attrs.add(builder.toAttribute()); |
| | | } |
| | | |
| | | /** |
| | | * Constructs an attribute using the provided information. It will have the |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | // Encode the object classes (SET OF LDAPString). |
| | | AttributeBuilder builder = new AttributeBuilder( |
| | | DirectoryServer.getObjectClassAttributeType()); |
| | | builder.setInitialCapacity(objectClasses.size()); |
| | | for (String s : objectClasses.values()) |
| | | { |
| | | builder.add(s); |
| | | } |
| | | builder.addAllStrings(objectClasses.values()); |
| | | new LDAPAttribute(builder.toAttribute()).write(writer); |
| | | |
| | | // Encode the user and operational attributes (AttributeList). |
| | |
| | | String.valueOf(md.getApproxDelay(serverId)))); |
| | | |
| | | /* get the Server State */ |
| | | AttributeBuilder builder = new AttributeBuilder("server-state"); |
| | | ServerState state = md.getLDAPServerState(serverId); |
| | | if (state != null) |
| | | { |
| | | for (String str : state.toStringSet()) |
| | | { |
| | | builder.add(str); |
| | | } |
| | | AttributeBuilder builder = new AttributeBuilder("server-state"); |
| | | builder.addAllStrings(state.toStringSet()); |
| | | attributes.add(builder.toAttribute()); |
| | | } |
| | | |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.common.DSInfo; |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.types.Attribute; |
| | |
| | | |
| | | // get the Server State |
| | | AttributeBuilder builder = new AttributeBuilder("server-state"); |
| | | for (String str : remoteState.toStringSet()) |
| | | { |
| | | builder.add(str); |
| | | } |
| | | builder.addAllStrings(remoteState.toStringSet()); |
| | | if (builder.size() == 0) |
| | | { |
| | | builder.add("unknown"); |
| | |
| | | */ |
| | | public class ReplicationServerHandler extends ServerHandler |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** Properties filled only if remote server is a RS. */ |
| | |
| | | String.valueOf(md.getMissingChangesRS(serverId)))); |
| | | |
| | | // get the Server State |
| | | AttributeBuilder builder = new AttributeBuilder("server-state"); |
| | | ServerState state = md.getRSStates(serverId); |
| | | if (state != null) |
| | | { |
| | | for (String str : state.toStringSet()) |
| | | { |
| | | builder.add(str); |
| | | } |
| | | AttributeBuilder builder = new AttributeBuilder("server-state"); |
| | | builder.addAllStrings(state.toStringSet()); |
| | | attributes.add(builder.toAttribute()); |
| | | } |
| | | |
| | |
| | | final String ATTR_SERVER_STATE = "server-state"; |
| | | AttributeType type = DirectoryServer.getDefaultAttributeType(ATTR_SERVER_STATE); |
| | | AttributeBuilder builder = new AttributeBuilder(type, ATTR_SERVER_STATE); |
| | | for (String str : domain.getServerState().toStringSet()) |
| | | { |
| | | builder.add(str); |
| | | } |
| | | builder.addAllStrings(domain.getServerState().toStringSet()); |
| | | attributes.add(builder.toAttribute()); |
| | | |
| | | attributes.add(Attributes.create("ssl-encryption", String.valueOf(domain.isSessionEncrypted()))); |
| | |
| | | return wasModified; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Adds the specified attribute values to this attribute builder if |
| | | * they are not already present. |
| | | * |
| | | * @param values |
| | | * The attribute values to be added to this attribute |
| | | * builder. |
| | | * @return <code>true</code> if this attribute builder was |
| | | * modified. |
| | | * The attribute values to be added to this attribute builder. |
| | | * @return <code>true</code> if this attribute builder was modified. |
| | | */ |
| | | public boolean addAll(Collection<ByteString> values) |
| | | { |
| | |
| | | return wasModified; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Adds the specified attribute values to this attribute builder |
| | | * if they are not already present. |
| | | * |
| | | * @param values |
| | | * The attribute values to be added to this attribute builder. |
| | | * @return <code>true</code> if this attribute builder was modified. |
| | | * @throws NullPointerException if any of the values is null |
| | | */ |
| | | public boolean addAllStrings(Collection<? extends Object> values) |
| | | { |
| | | boolean wasModified = false; |
| | | for (Object v : values) |
| | | { |
| | | wasModified |= add(v.toString()); |
| | | } |
| | | return wasModified; |
| | | } |
| | | |
| | | /** |
| | | * Removes all attribute values from this attribute builder. |
| | |
| | | setAttributeType(getAttributeType(attributeName), attributeName); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the initial capacity of this attribute builders internal set |
| | | * of attribute values. |
| | | * <p> |
| | | * The initial capacity of an attribute builder defaults to one. |
| | | * Applications should override this default if the attribute being |
| | | * built is expected to contain many values. |
| | | * <p> |
| | | * This method should only be called before any attribute values |
| | | * have been added to this attribute builder. If it is called |
| | | * afterwards an {@link IllegalStateException} will be thrown. |
| | | * |
| | | * @param initialCapacity |
| | | * The initial capacity of this attribute builder. |
| | | * @return This attribute builder. |
| | | * @throws IllegalStateException |
| | | * If this attribute builder already contains attribute |
| | | * values. |
| | | */ |
| | | public AttributeBuilder setInitialCapacity(int initialCapacity) |
| | | throws IllegalStateException |
| | | { |
| | | // This is now a no op. |
| | | return this; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Adds the specified option to this attribute builder if it is not |
| | | * already present. |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | |
| | | valueString); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new multi-valued attribute with the specified attribute |
| | | * name and attribute values. |
| | |
| | | * typically be reserved for use in unit tests and places where |
| | | * performance is not an issue. In particular, this method will |
| | | * construct a temporary array containing the attribute's values. |
| | | * For peformance critical purposes, incrementally construct an |
| | | * For performance critical purposes, incrementally construct an |
| | | * attribute using an {@link AttributeBuilder}. |
| | | * |
| | | * @param attributeName |
| | | * The name or OID of the attribute type for this attribute |
| | | * (can be mixed case). |
| | | * @param firstValueString |
| | | * The string representation of the first attribute value. |
| | | * @param otherValueStrings |
| | | * The string representation of the remaining attribute |
| | | * values. |
| | | * @param valueStrings |
| | | * The string representation of the attribute values. |
| | | * @return A new attribute with the specified name and values. |
| | | */ |
| | | public static Attribute create(String attributeName, |
| | | String firstValueString, String... otherValueStrings) |
| | | public static Attribute create(String attributeName, String... valueStrings) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attributeName); |
| | | |
| | | builder.add(firstValueString); |
| | | |
| | | for (String value : otherValueStrings) |
| | | { |
| | | builder.add(value); |
| | | if (valueStrings.length == 0) { |
| | | return empty(attributeName); |
| | | } |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attributeName); |
| | | builder.addAllStrings(Arrays.asList(valueStrings)); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new attribute which has the same attribute type and |
| | | * attribute options as the provided attribute but no attribute |
| | |
| | | { |
| | | AttributeType ocType = DirectoryServer.getObjectClassAttributeType(); |
| | | AttributeBuilder builder = new AttributeBuilder(ocType, ATTR_OBJECTCLASS); |
| | | for (Map.Entry<ObjectClass, String> e : objectClasses.entrySet()) |
| | | { |
| | | builder.add(e.getValue()); |
| | | } |
| | | |
| | | builder.addAllStrings(objectClasses.values()); |
| | | objectClassAttribute = builder.toAttribute(); |
| | | } |
| | | |
| | |
| | | int numValues = entryBuffer.getBERLength(); |
| | | |
| | | // Next, we have the sequence of length-value pairs. |
| | | builder.setInitialCapacity(numValues); |
| | | for (int j=0; j < numValues; j++) |
| | | { |
| | | int valueLength = entryBuffer.getBERLength(); |
| | |
| | | // Reconstruct the object class attribute. |
| | | AttributeType ocType = DirectoryServer.getObjectClassAttributeType(); |
| | | AttributeBuilder builder = new AttributeBuilder(ocType, "objectClass"); |
| | | for (String value : objectClasses.values()) { |
| | | builder.add(value); |
| | | } |
| | | builder.addAllStrings(objectClasses.values()); |
| | | Map<AttributeType, List<Attribute>> attributes = toAttributesMap(attrBuilders); |
| | | if (attributes.get(ocType) == null) |
| | | { |
| | |
| | | List<PasswordStorageScheme<?>> defaultStorageSchemes = |
| | | passwordPolicy.getDefaultPasswordStorageSchemes(); |
| | | AttributeBuilder builder = new AttributeBuilder(passwordAttr, true); |
| | | builder.setInitialCapacity(defaultStorageSchemes.size()); |
| | | for (ByteString value : passwordAttr) |
| | | { |
| | | // See if the password is pre-encoded. |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.OutputStream; |
| | |
| | | import static org.opends.server.backends.pluggable.SuffixContainer.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.types.Attributes.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | Entry entry; |
| | | Entry newEntry; |
| | | EntryID entryID; |
| | | AttributeType attribute; |
| | | AttributeIndex titleIndex; |
| | | AttributeIndex nameIndex; |
| | | Set<ByteString> addKeys; |
| | |
| | | List<Modification> modifications = new ArrayList<>(); |
| | | modifications.add(new Modification(ADD, create("title", "debugger"))); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder("title"); |
| | | builder.setOption("lang-en"); |
| | | builder.add("debugger2"); |
| | | |
| | | modifications.add(new Modification(ADD, builder.toAttribute())); |
| | | Attribute attr = attributeWithOption("title", "debugger2", "lang-en"); |
| | | modifications.add(new Modification(ADD, attr)); |
| | | modifications.add(new Modification(DELETE, create("cn", "Aaren Atp"))); |
| | | modifications.add(new Modification(ADD, create("cn", "Aaren Rigor"))); |
| | | modifications.add(new Modification(ADD, create("cn", "Aarenister Rigor"))); |
| | | |
| | | builder = new AttributeBuilder("givenname"); |
| | | builder.add("test"); |
| | | builder.setOption("lang-de"); |
| | | modifications.add(new Modification(ADD, builder.toAttribute())); |
| | | attr = attributeWithOption("givenname", "test", "lang-de"); |
| | | modifications.add(new Modification(ADD, attr)); |
| | | |
| | | builder = new AttributeBuilder("givenname"); |
| | | builder.add("test2"); |
| | | builder.setOption("lang-cn"); |
| | | modifications.add(new Modification(DELETE, builder.toAttribute())); |
| | | attr = attributeWithOption("givenname", "test2", "lang-cn"); |
| | | modifications.add(new Modification(DELETE, attr)); |
| | | |
| | | builder = new AttributeBuilder("givenname"); |
| | | builder.add("newtest3"); |
| | | builder.setOption("lang-es"); |
| | | modifications.add(new Modification(REPLACE, builder.toAttribute())); |
| | | attr = attributeWithOption("givenname", "newtest3", "lang-es"); |
| | | modifications.add(new Modification(REPLACE, attr)); |
| | | modifications.add(new Modification(REPLACE, create("employeenumber", "222"))); |
| | | |
| | | newEntry = entries.get(1); |
| | |
| | | } |
| | | } |
| | | |
| | | private Attribute attributeWithOption(String attributeName, String value, String option) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attributeName); |
| | | builder.add(value); |
| | | builder.setOption(option); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | @Test(dependsOnMethods = {"testAdd", "testSearchIndex", "testSearchScope", |
| | | "testMatchedDN"}) |
| | | public void testModifyDN() throws Exception { |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.FingerprintCertificateMapperCfgDefn; |
| | | import org.opends.server.admin.std.server.FingerprintCertificateMapperCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the fingerprint certificate mapper. |
| | | */ |
| | |
| | | { |
| | | String mapperDN = "cn=Fingerprint Mapper,cn=Certificate Mappers,cn=config"; |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType("ds-cfg-user-base-dn"); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | if (baseDNs != null) |
| | | { |
| | | for (String baseDN : baseDNs) |
| | | { |
| | | builder.add(baseDN); |
| | | } |
| | | } |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | builder.toAttribute())); |
| | | Attributes.create("ds-cfg-user-base-dn", baseDNs))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.SubjectAttributeToUserAttributeCertificateMapperCfgDefn; |
| | | import org.opends.server.admin.std.server.SubjectAttributeToUserAttributeCertificateMapperCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the Subject Attribute to User Attribute certificate |
| | | * mapper. |
| | | */ |
| | | /** A set of test cases for the Subject Attribute to User Attribute certificate mapper. */ |
| | | public class SubjectAttributeToUserAttributeCertificateMapperTestCase |
| | | extends ExtensionsTestCase |
| | | { |
| | |
| | | String mapperDN = "cn=Subject Attribute to User Attribute," + |
| | | "cn=Certificate Mappers,cn=config"; |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType( |
| | | "ds-cfg-subject-attribute-mapping"); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | if (mappings != null) |
| | | { |
| | | for (String mapping : mappings) |
| | | { |
| | | builder.add(mapping); |
| | | } |
| | | } |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, builder.toAttribute())); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-subject-attribute-mapping", mappings))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | if (baseDNs != null) |
| | | { |
| | | for (String baseDN : baseDNs) |
| | | { |
| | | builder.add(baseDN); |
| | | } |
| | | builder.addAllStrings(Arrays.asList(baseDNs)); |
| | | } |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.SubjectDNToUserAttributeCertificateMapperCfgDefn; |
| | | import org.opends.server.admin.std.server.SubjectDNToUserAttributeCertificateMapperCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the Subject DN to User Attribute certificate mapper. |
| | | */ |
| | |
| | | String mapperDN = |
| | | "cn=Subject DN to User Attribute,cn=Certificate Mappers,cn=config"; |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType("ds-cfg-user-base-dn"); |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType("ds-cfg-user-base-dn"); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | if (baseDNs != null) |
| | | { |
| | | for (String baseDN : baseDNs) |
| | | { |
| | | builder.add(baseDN); |
| | | } |
| | | builder.addAllStrings(Arrays.asList(baseDNs)); |
| | | } |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.BeforeMethod; |
| | |
| | | * Add specified attr type and type values to the entry specified by dn. |
| | | * |
| | | * @param dn The dn of the entry to add the attribute and values to. |
| | | * |
| | | * @param attrTypeString The attribute type to add the values to. |
| | | * |
| | | * @param attrName The attribute type to add the values to. |
| | | * @param attrValStrings The values to add to the entry. |
| | | * |
| | | */ |
| | | private ModifyOperation |
| | | addAttrEntry(DN dn, String attrTypeString, String... attrValStrings) { |
| | | addAttrEntry(DN dn, String attrName, String... attrValStrings) { |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | AttributeType attrType = getAttrType(attrTypeString); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrTypeString); |
| | | for(String valString : attrValStrings) { |
| | | builder.add(valString); |
| | | } |
| | | mods.add(new Modification(ModificationType.ADD, builder.toAttribute())); |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create(attrName, attrValStrings))); |
| | | return getRootConnection().processModify(dn, mods); |
| | | } |
| | | |
| | | /** |
| | | /** |
| | | * Replace specified attr type and type values to the entry specified by dn. |
| | | * |
| | | * @param dn The dn of the entry to replace the attribute and values to. |
| | | * |
| | | * @param attrTypeString The attribute type to replace the values in. |
| | | * |
| | | * @param attrName The attribute type to replace the values in. |
| | | * @param attrValStrings The values to replace in the the entry. |
| | | * |
| | | */ |
| | | private ModifyOperation |
| | | replaceAttrEntry(DN dn, String attrTypeString, String... attrValStrings) { |
| | | private ModifyOperation replaceAttrEntry(DN dn, String attrName, String... attrValStrings) { |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | AttributeType attrType = getAttrType(attrTypeString); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrTypeString); |
| | | for(String valString : attrValStrings) { |
| | | builder.add(valString); |
| | | } |
| | | mods.add(new Modification(ModificationType.REPLACE, builder.toAttribute())); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrName, attrValStrings))); |
| | | return getRootConnection().processModify(dn, mods); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Remove the attributes specified by the attribute type strings from the |
| | | * entry corresponding to the dn argument. |
| | | * |
| | | * @param dn The entry to remove the attributes from. |
| | | * |
| | | * @param attrTypeStrings The attribute type string list to remove from the |
| | | * entry. |
| | | * |
| | | * @param attrTypeStrings The attribute type string list to remove from the entry. |
| | | * @throws Exception If an error occurs. |
| | | * |
| | | */ |
| | | private void |
| | | deleteAttrsEntry(DN dn, String... attrTypeStrings) throws Exception { |
| | |
| | | getRootConnection().processModify(dn, mods); |
| | | } |
| | | |
| | | |
| | | |
| | | private void |
| | | replaceAttrInEntry(DN dn, String attrTypeString, String... attrValStrings) { |
| | | private void replaceAttrInEntry(DN dn, String attrName, String... attrValStrings) { |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | AttributeType attrType = getAttrType(attrTypeString); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrTypeString); |
| | | for(String valString : attrValStrings) { |
| | | builder.add(valString); |
| | | } |
| | | mods.add(new Modification(ModificationType.REPLACE, builder.toAttribute())); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrName, attrValStrings))); |
| | | getRootConnection().processModify(dn, mods); |
| | | } |
| | | |
| | |
| | | * Add an attribute to an entry with specified values. |
| | | * |
| | | * @param entry The entry to add the attribute to. |
| | | * @param attrTypeString The attribute type string name. |
| | | * @param attrName The attribute type string name. |
| | | * @param attrValues The values use in building the attribute. |
| | | */ |
| | | private void |
| | | addAttribute(Entry entry, String attrTypeString, String... attrValues) { |
| | | AttributeType attrType=getAttrType(attrTypeString); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrTypeString); |
| | | for(String attrValue : attrValues) { |
| | | builder.add(attrValue); |
| | | } |
| | | entry.addAttribute(builder.toAttribute(), null); |
| | | private void addAttribute(Entry entry, String attrName, String... attrValues) { |
| | | entry.addAttribute(Attributes.create(attrName, attrValues), null); |
| | | } |
| | | |
| | | /** |
| | |
| | | * type to a list of modifications. |
| | | * |
| | | * @param mods The modification list to add to. |
| | | * @param attrTypeString The attribute type string name. |
| | | * @param attrName The attribute type string name. |
| | | * @param modificationType The modification type. |
| | | * @param attrValues The values to build the modification from. |
| | | */ |
| | | private void |
| | | addMods(LinkedList<Modification> mods, String attrTypeString, |
| | | addMods(LinkedList<Modification> mods, String attrName, |
| | | ModificationType modificationType, String... attrValues) { |
| | | AttributeType attrType=getAttrType(attrTypeString); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrTypeString); |
| | | for(String attrValue : attrValues) { |
| | | builder.add(attrValue); |
| | | } |
| | | mods.add(new Modification(modificationType, |
| | | builder.toAttribute())); |
| | | Attributes.create(attrName, attrValues))); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * Perform modify DN operation. Expect return value of rc. |
| | | * |
| | | * @param dn The DN to renmame or move. |
| | | * @param dn The DN to rename or move. |
| | | * @param rdn RDN value. |
| | | * @param delOld Delete old flag. |
| | | * @param newSuperior New superior to move to. |
| | |
| | | return mods; |
| | | } |
| | | |
| | | private Modification buildMod(String attrName, ModificationType modType, |
| | | String... values) |
| | | private Modification buildMod(String attrName, ModificationType modType, String... values) |
| | | { |
| | | Attribute attr; |
| | | if (values.length == 0) |
| | | { |
| | | attr = Attributes.empty(attrName); |
| | | } |
| | | else |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attrName); |
| | | for (String value : values) |
| | | { |
| | | builder.add(value); |
| | | } |
| | | attr = builder.toAttribute(); |
| | | } |
| | | return new Modification(modType, attr); |
| | | return new Modification(modType, Attributes.create(attrName, values)); |
| | | } |
| | | |
| | | private Attribute buildSyncHist(String attrName, String... values) |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | throw new RuntimeException("Unable to resolve object class top"); |
| | | } |
| | | |
| | | ObjectClass extensible = DirectoryServer |
| | | .getObjectClass("extensibleobject"); |
| | | ObjectClass extensible = DirectoryServer.getObjectClass("extensibleobject"); |
| | | if (extensible == null) { |
| | | throw new RuntimeException( |
| | | "Unable to resolve object class extensibleObject"); |
| | |
| | | Entry testEntry = new Entry(entryDN, objectClasses, null, null); |
| | | |
| | | // Now add the attribute. |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | | for (String value : values) { |
| | | builder.add(value); |
| | | } |
| | | ArrayList<Attribute> attributes = new ArrayList<>(); |
| | | attributes.add(builder.toAttribute()); |
| | | testEntry.putAttribute(type, attributes); |
| | | |
| | | Attribute attr = Attributes.create(type.getNameOrOID(), values); |
| | | testEntry.putAttribute(type, newArrayList(attr)); |
| | | return testEntry; |
| | | } |
| | | |