OPENDJ-3037 inlined DirectoryServer.getTopObjectClass() and getObjectClassAttributeType()
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | |
| | | oid.setText(""); |
| | | description.setText(""); |
| | | aliases.setText(""); |
| | | superiors.setSelectedSuperiors( |
| | | Collections.singleton(schema.getObjectClass("top"))); |
| | | superiors.setSelectedSuperiors(Collections.singleton(CoreSchema.getTopObjectClass())); |
| | | attributes.getAvailableListModel().addAll( |
| | | attributes.getSelectedListModel1().getData()); |
| | | attributes.getAvailableListModel().addAll( |
| | |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JPanel; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedEvent; |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedListener; |
| | |
| | | |
| | | if (this.schema == null) |
| | | { |
| | | singleSuperior.setSelectedItem(schema.getObjectClass("top")); |
| | | singleSuperior.setSelectedItem(CoreSchema.getTopObjectClass()); |
| | | } |
| | | this.schema = schema; |
| | | } |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | |
| | | // Check for shorthands for user attributes "*" or operational "+". |
| | | if ("*".equals(a)) |
| | | { |
| | | // Add objectclass. |
| | | AttributeType ocType = DirectoryServer.getObjectClassAttributeType(); |
| | | nonRightsAttrs.add(ocType); |
| | | nonRightsAttrs.add(CoreSchema.getObjectClassAttributeType()); |
| | | nonRightsAttrs.addAll(e.getUserAttributes().keySet()); |
| | | } |
| | | else if ("+".equals(a)) |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.server.config.server.BackupBackendCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.core.AddOperation; |
| | |
| | | |
| | | // Construct the backup base entry. |
| | | LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(2); |
| | | objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | objectClasses.put(DirectoryServer.getObjectClass(OC_UNTYPED_OBJECT_LC), OC_UNTYPED_OBJECT); |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); |
| | |
| | | |
| | | // Construct the backup directory entry to return. |
| | | LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2); |
| | | ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | |
| | | ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(DirectoryServer.getObjectClass(OC_BACKUP_DIRECTORY), OC_BACKUP_DIRECTORY); |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); |
| | |
| | | |
| | | // Construct the backup entry to return. |
| | | LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<>(3); |
| | | ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(DirectoryServer.getObjectClass(OC_BACKUP_INFO), OC_BACKUP_INFO); |
| | | ocMap.put(DirectoryServer.getObjectClass(OC_EXTENSIBLE_OBJECT_LC), OC_EXTENSIBLE_OBJECT); |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.forgerock.opendj.server.config.server.BackendCfg; |
| | | import org.opends.server.api.Backend; |
| | |
| | | |
| | | // Initialize null entry object classes. |
| | | objectClasses = new HashMap<>(); |
| | | |
| | | objectClasses.put(DirectoryServer.getTopObjectClass(), "top"); |
| | | objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | |
| | | String nulOCName = "nullbackendobject"; |
| | | ObjectClass nulOC = DirectoryServer.getObjectClass(nulOCName); |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.DITContentRule; |
| | | import org.forgerock.opendj.ldap.schema.DITStructureRule; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | |
| | | |
| | | // Construct the set of objectclasses to include in the schema entry. |
| | | schemaObjectClasses = new LinkedHashMap<>(3); |
| | | schemaObjectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | schemaObjectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | schemaObjectClasses.put(DirectoryServer.getObjectClass(OC_LDAP_SUBENTRY_LC), OC_LDAP_SUBENTRY); |
| | | schemaObjectClasses.put(DirectoryServer.getObjectClass(OC_SUBSCHEMA), OC_SUBSCHEMA); |
| | | |
| | |
| | | private Entry createEmptySchemaEntry() |
| | | { |
| | | Map<ObjectClass,String> objectClasses = new LinkedHashMap<>(); |
| | | objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | objectClasses.put(DirectoryServer.getObjectClass(OC_LDAP_SUBENTRY_LC), OC_LDAP_SUBENTRY); |
| | | objectClasses.put(DirectoryServer.getObjectClass(OC_SUBSCHEMA), OC_SUBSCHEMA); |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.server.config.server.TrustStoreBackendCfg; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.api.Backend; |
| | |
| | | |
| | | // Construct the trust store base entry. |
| | | LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(2); |
| | | objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | objectClasses.put(DirectoryServer.getObjectClass("ds-cfg-branch"), "ds-cfg-branch"); |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(1); |
| | |
| | | |
| | | // Construct the certificate entry to return. |
| | | LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2); |
| | | ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(DirectoryServer.getObjectClass(OC_CRYPTO_INSTANCE_KEY), OC_CRYPTO_INSTANCE_KEY); |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); |
| | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.tools.ConfigureWindowsService.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.DynamicConstants.*; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the "top" objectClass, which should be the topmost objectclass in |
| | | * the inheritance chain for most other objectclasses. If no such objectclass |
| | | * could be found, then one will be constructed. |
| | | * |
| | | * @return The "top" objectClass. |
| | | */ |
| | | public static ObjectClass getTopObjectClass() |
| | | { |
| | | return directoryServer.schema.getObjectClass(TOP_OBJECTCLASS_NAME); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the attribute type for the provided name or OID. It can optionally return a generated |
| | | * placeholder version if the requested attribute type is not defined in the schema. |
| | | * |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the attribute type for the "objectClass" attribute. |
| | | * |
| | | * @return The attribute type for the "objectClass" attribute. |
| | | */ |
| | | public static AttributeType getObjectClassAttributeType() |
| | | { |
| | | return directoryServer.schema.getAttributeType(OBJECTCLASS_ATTRIBUTE_TYPE_NAME); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the set of virtual attribute rules registered with the Directory |
| | | * Server. |
| | | * |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.opends.server.api.AccessControlHandler; |
| | | import org.opends.server.api.AuthenticationPolicyState; |
| | | import org.opends.server.api.ClientConnection; |
| | |
| | | |
| | | // NOTE: the objectClass attribute is also present and must be |
| | | // dealt with later. |
| | | AttributeType attrType = DirectoryServer.getObjectClassAttributeType(); |
| | | Iterator<String> ocIterator = |
| | | filteredEntry.getObjectClasses().values().iterator(); |
| | | AttributeType attrType = CoreSchema.getObjectClassAttributeType(); |
| | | Iterator<String> ocIterator = filteredEntry.getObjectClasses().values().iterator(); |
| | | while (ocIterator.hasNext()) |
| | | { |
| | | ByteString ocName = ByteString.valueOfUtf8(ocIterator.next()); |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.forgerock.opendj.config.server.ConfigurationChangeListener; |
| | |
| | | } |
| | | |
| | | final Entry entry = new Entry(entryDN, null, null, null); |
| | | entry.addObjectClass(DirectoryServer.getTopObjectClass()); |
| | | entry.addObjectClass(CoreSchema.getTopObjectClass()); |
| | | entry.addObjectClass(ocCertRequest); |
| | | AddOperation addOperation = icc.processAdd(entry); |
| | | if (ResultCode.SUCCESS != addOperation.getResultCode()) { |
| | |
| | | final InternalSearchOperation searchOp = icc.processSearch(request); |
| | | if (searchOp.getSearchEntries().isEmpty()) { |
| | | final Entry entry = new Entry(entryDN, null, null, null); |
| | | entry.addObjectClass(DirectoryServer.getTopObjectClass()); |
| | | entry.addObjectClass(CoreSchema.getTopObjectClass()); |
| | | entry.addObjectClass(ocInstanceKey); |
| | | |
| | | // Add the key ID attribute. |
| | |
| | | |
| | | // Set the entry object classes. |
| | | LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2); |
| | | ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(ocCipherKey, OC_CRYPTO_CIPHER_KEY); |
| | | |
| | | // Create the user attributes. |
| | |
| | | |
| | | // Set the entry object classes. |
| | | LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2); |
| | | ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(ocMacKey, OC_CRYPTO_MAC_KEY); |
| | | |
| | | // Create the user attributes. |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.BackendInitializationListener; |
| | |
| | | private void addEntry(Entry srcEntry, DN dstDN) |
| | | { |
| | | Map<ObjectClass, String> ocMap = new LinkedHashMap<>(2); |
| | | ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | ocMap.put(ocInstanceKey, OC_CRYPTO_INSTANCE_KEY); |
| | | |
| | | Map<AttributeType, List<Attribute>> userAttrs = new HashMap<>(); |
| | |
| | | import org.forgerock.opendj.ldap.requests.ModifyDNRequest; |
| | | import org.forgerock.opendj.ldap.requests.ModifyRequest; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ConnectionHandler; |
| | | import org.opends.server.core.AddOperation; |
| | |
| | | try |
| | | { |
| | | LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(); |
| | | put(objectClasses, DirectoryServer.getTopObjectClass()); |
| | | put(objectClasses, CoreSchema.getTopObjectClass()); |
| | | put(objectClasses, DirectoryServer.getObjectClass(OC_PERSON)); |
| | | put(objectClasses, DirectoryServer.getObjectClass(OC_ROOT_DN)); |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.AddOperationBasis; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.plugin.EntryHistorical; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.operation.PostOperationAddOperation; |
| | | |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | |
| | | /** |
| | | * This class is used to exchange Add operation between LDAP servers |
| | | * and replication servers. |
| | |
| | | try |
| | | { |
| | | // Encode the object classes (SET OF LDAPString). |
| | | AttributeBuilder builder = new AttributeBuilder( |
| | | DirectoryServer.getObjectClassAttributeType()); |
| | | AttributeBuilder builder = new AttributeBuilder(getObjectClassAttributeType()); |
| | | builder.addAllStrings(objectClasses.values()); |
| | | new LDAPAttribute(builder.toAttribute()).write(writer); |
| | | |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler; |
| | | import org.opends.server.loggers.JDKLogging; |
| | |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | /** |
| | | * This class provides a program that may be used to determine the differences |
| | | * between two LDIF files, generating the output in LDIF change format. There |
| | |
| | | if (!sourceClasses.isEmpty()) |
| | | { |
| | | // Whatever is left must have been deleted. |
| | | AttributeType attrType = DirectoryServer.getObjectClassAttributeType(); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | for (ObjectClass oc : sourceClasses) |
| | | { |
| | | builder.add(oc.getNameOrOID()); |
| | | } |
| | | |
| | | modifications.add(new Modification(ModificationType.DELETE, builder |
| | | .toAttribute())); |
| | | modifications.add(new Modification(DELETE, toObjectClassAttribute(sourceClasses))); |
| | | } |
| | | |
| | | if (! targetClasses.isEmpty()) |
| | | { |
| | | // Whatever is left must have been added. |
| | | AttributeType attrType = DirectoryServer.getObjectClassAttributeType(); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | for (ObjectClass oc : targetClasses) |
| | | { |
| | | builder.add(oc.getNameOrOID()); |
| | | } |
| | | |
| | | modifications.add(new Modification(ModificationType.ADD, builder |
| | | .toAttribute())); |
| | | modifications.add(new Modification(ADD, toObjectClassAttribute(targetClasses))); |
| | | } |
| | | |
| | | |
| | |
| | | // value individually. |
| | | for (Attribute a : sourceAttrs) |
| | | { |
| | | modifications.add(new Modification(ModificationType.DELETE, a)); |
| | | modifications.add(new Modification(DELETE, a)); |
| | | } |
| | | } |
| | | else |
| | |
| | | |
| | | if (targetAttr == null) |
| | | { |
| | | // The attribute doesn't exist in the target list, so it has been |
| | | // deleted. |
| | | modifications.add(new Modification(ModificationType.DELETE, |
| | | sourceAttr)); |
| | | // The attribute doesn't exist in the target list, so it has been deleted. |
| | | modifications.add(new Modification(DELETE, sourceAttr)); |
| | | } |
| | | else |
| | | { |
| | | // Compare the values. |
| | | AttributeBuilder addedValuesBuilder = new AttributeBuilder(targetAttr); |
| | | addedValuesBuilder.removeAll(sourceAttr); |
| | | Attribute addedValues = addedValuesBuilder.toAttribute(); |
| | | Attribute addedValues = minusAttribute(targetAttr, sourceAttr); |
| | | if (!addedValues.isEmpty()) |
| | | { |
| | | modifications.add(new Modification(ModificationType.ADD, addedValues)); |
| | | modifications.add(new Modification(ADD, addedValues)); |
| | | } |
| | | |
| | | AttributeBuilder deletedValuesBuilder = new AttributeBuilder(sourceAttr); |
| | | deletedValuesBuilder.removeAll(targetAttr); |
| | | Attribute deletedValues = deletedValuesBuilder.toAttribute(); |
| | | Attribute deletedValues = minusAttribute(sourceAttr, targetAttr); |
| | | if (!deletedValues.isEmpty()) |
| | | { |
| | | modifications.add(new Modification(ModificationType.DELETE, deletedValues)); |
| | | modifications.add(new Modification(DELETE, deletedValues)); |
| | | } |
| | | } |
| | | } |
| | |
| | | // Any remaining target attributes have been added. |
| | | for (Attribute targetAttr: targetAttrs) |
| | | { |
| | | modifications.add(new Modification(ModificationType.ADD, targetAttr)); |
| | | modifications.add(new Modification(ADD, targetAttr)); |
| | | } |
| | | } |
| | | } |
| | |
| | | // Any remaining target attribute types have been added. |
| | | for (AttributeType type : targetEntry.getUserAttributes().keySet()) |
| | | { |
| | | List<Attribute> targetAttrs = targetEntry.getUserAttribute(type); |
| | | for (Attribute a : targetAttrs) |
| | | for (Attribute a : targetEntry.getUserAttribute(type)) |
| | | { |
| | | modifications.add(new Modification(ModificationType.ADD, a)); |
| | | modifications.add(new Modification(ADD, a)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return true; |
| | | } |
| | | |
| | | private static Attribute toObjectClassAttribute(Collection<ObjectClass> objectClasses) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(getObjectClassAttributeType()); |
| | | for (ObjectClass oc : objectClasses) |
| | | { |
| | | builder.add(oc.getNameOrOID()); |
| | | } |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | private static Attribute minusAttribute(Attribute sourceAttr, Attribute removeAttr) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(sourceAttr); |
| | | builder.removeAll(removeAttr); |
| | | return builder.toAttribute(); |
| | | } |
| | | } |
| | |
| | | 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.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Entry; |
| | | |
| | |
| | | String[] valueStrings = new String[] { ocName }; |
| | | Tag[] tags = new Tag[1]; |
| | | tags[0] = new StaticTextTag(); |
| | | tags[0].initializeForBranch(templateFile, this, valueStrings, 0, |
| | | warnings); |
| | | tags[0].initializeForBranch(templateFile, this, valueStrings, 0, warnings); |
| | | |
| | | TemplateLine l = |
| | | new TemplateLine(DirectoryServer.getObjectClassAttributeType(), 0, |
| | | tags); |
| | | lineList.add(l); |
| | | lineList.add(new TemplateLine(CoreSchema.getObjectClassAttributeType(), 0, tags)); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.DITContentRule; |
| | | import org.forgerock.opendj.ldap.schema.DITStructureRule; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | |
| | | |
| | | if(objectClassAttribute == null) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(DirectoryServer.getObjectClassAttributeType()); |
| | | AttributeBuilder builder = new AttributeBuilder(CoreSchema.getObjectClassAttributeType()); |
| | | builder.addAllStrings(objectClasses.values()); |
| | | objectClassAttribute = builder.toAttribute(); |
| | | } |
| | |
| | | public Entry filterEntry(Set<String> attrNameList, |
| | | boolean omitValues, boolean omitReal, boolean omitVirtual) |
| | | { |
| | | final AttributeType ocType = DirectoryServer.getObjectClassAttributeType(); |
| | | final AttributeType ocType = CoreSchema.getObjectClassAttributeType(); |
| | | |
| | | Map<ObjectClass, String> objectClassesCopy; |
| | | Map<AttributeType, List<Attribute>> userAttrsCopy; |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.opends.messages.UtilityMessages.*; |
| | |
| | | SearchScope.BASE_OBJECT; |
| | | /** The default search filter that will be used if none is provided. */ |
| | | public static final SearchFilter DEFAULT_SEARCH_FILTER = |
| | | SearchFilter.createPresenceFilter( |
| | | DirectoryServer.getObjectClassAttributeType()); |
| | | SearchFilter.createPresenceFilter(CoreSchema.getObjectClassAttributeType()); |
| | | |
| | | |
| | | /** The host for this LDAP URL. */ |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.PluginConfigManager; |
| | |
| | | } |
| | | |
| | | // Reconstruct the object class attribute. |
| | | AttributeType ocType = DirectoryServer.getObjectClassAttributeType(); |
| | | AttributeType ocType = CoreSchema.getObjectClassAttributeType(); |
| | | AttributeBuilder builder = new AttributeBuilder(ocType); |
| | | builder.addAllStrings(objectClasses.values()); |
| | | Map<AttributeType, List<Attribute>> attributes = toAttributesMap(attrBuilders); |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.messages.ToolMessages; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | |
| | | // Get the top and untypedObject classes to include in the entry. |
| | | LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(3); |
| | | |
| | | objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP); |
| | | objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); |
| | | objectClasses.put(structuralClass, structuralClass.getNameOrOID()); |
| | | |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.requests.AddRequest; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.Backend; |
| | |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user,o=test")); |
| | | List<Attribute> attrList = e.getAttribute(DirectoryServer.getObjectClassAttributeType()); |
| | | List<Attribute> attrList = e.getAttribute(CoreSchema.getObjectClassAttributeType()); |
| | | assertTrue(findAttributeValueIgnoreCase(attrList, "top")); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.controls.GenericControl.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.newSearchRequest; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.controls.GenericControl.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for modify operations. |
| | | */ |
| | |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); |
| | | assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("extensibleobject"))); |
| | | assertTrue(e.hasObjectClass(getExtensibleObjectObjectClass())); |
| | | assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("inetOrgPerson"))); |
| | | assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("organizationalPerson"))); |
| | | assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("person"))); |
| | | assertTrue(e.hasObjectClass(DirectoryServer.getObjectClass("top"))); |
| | | assertTrue(e.hasObjectClass(getOrganizationalPersonObjectClass())); |
| | | assertTrue(e.hasObjectClass(getPersonObjectClass())); |
| | | assertTrue(e.hasObjectClass(getTopObjectClass())); |
| | | assertEquals(e.getUserAttributes().size(), 8, "Incorrect number of user attributes"); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | |
| | | /** |
| | | * An abstract base class for all subtree specification tests. |
| | | */ |
| | | /** An abstract base class for all subtree specification tests. */ |
| | | public abstract class SubtreeSpecificationTestCase extends CoreTestCase { |
| | | /** Cached set of entry object classes. */ |
| | | private Set<ObjectClass> objectClasses; |
| | |
| | | * The entry's object classes. |
| | | * @return The created entry. |
| | | */ |
| | | protected final Entry createEntry(DN entryDN, |
| | | Set<ObjectClass> objectClasses) { |
| | | protected final Entry createEntry(DN entryDN, Set<ObjectClass> objectClasses) |
| | | { |
| | | HashMap<ObjectClass, String> map = new HashMap<>(); |
| | | |
| | | for (ObjectClass oc : objectClasses) { |
| | |
| | | // This test suite depends on having the schema available, so we'll start the server. |
| | | TestCaseUtils.startServer(); |
| | | |
| | | // Retrieve required object classes. |
| | | objectClasses = new HashSet<>(); |
| | | |
| | | ObjectClass oc = DirectoryServer.getObjectClass("top"); |
| | | if (oc.isPlaceHolder()) { |
| | | throw new RuntimeException("Unable to resolve object class top"); |
| | | } |
| | | objectClasses.add(oc); |
| | | |
| | | oc = DirectoryServer.getObjectClass("person"); |
| | | if (oc.isPlaceHolder()) { |
| | | throw new RuntimeException("Unable to resolve object class person"); |
| | | } |
| | | objectClasses.add(oc); |
| | | objectClasses = newHashSet(getTopObjectClass(), getPersonObjectClass()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.common.AssuredMode.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.common.AssuredMode.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test the conversions between the various protocol versions. |
| | | */ |
| | |
| | | final DN dn = DN.valueOf(rawDN); |
| | | |
| | | // Create VLAST message |
| | | Attribute objectClass = Attributes.create(DirectoryServer |
| | | .getObjectClassAttributeType(), "organization"); |
| | | HashMap<ObjectClass, String> objectClassList = new HashMap<>(); |
| | | objectClassList.put(DirectoryServer.getObjectClass("organization"), |
| | | "organization"); |
| | | |
| | | Attribute attr = Attributes.create("o", "com"); |
| | | List<Attribute> userAttributes = newArrayList(attr); |
| | | HashMap<AttributeType, List<Attribute>> userAttList = new HashMap<>(); |
| | | userAttList.put(attr.getAttributeDescription().getAttributeType(), userAttributes); |
| | | |
| | | |
| | | attr = Attributes.create("creatorsName", "dc=creator"); |
| | | List<Attribute> operationalAttributes = newArrayList(attr); |
| | | HashMap<AttributeType, List<Attribute>> opList = new HashMap<>(); |
| | | opList.put(attr.getAttributeDescription().getAttributeType(), operationalAttributes); |
| | | Attribute objectClass = Attributes.create(getObjectClassAttributeType(), "organization"); |
| | | List<Attribute> userAttributes = newArrayList(Attributes.create("o", "com")); |
| | | List<Attribute> operationalAttributes = newArrayList(Attributes.create("creatorsName", "dc=creator")); |
| | | |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.replication.common.AssuredMode.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.requests.ModifyDNRequest; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.controls.SubtreeDeleteControl; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.AddOperationBasis; |
| | |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendAddOperation; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.replication.common.AssuredMode.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test the constructors, encoders and decoders of the replication protocol |
| | | * PDUs classes (message classes). |
| | |
| | | { |
| | | final DN dn = DN.valueOf(rawDN); |
| | | |
| | | Attribute objectClass = Attributes.create(DirectoryServer |
| | | .getObjectClassAttributeType(), "organization"); |
| | | Attribute objectClass = Attributes.create(getObjectClassAttributeType(), "organization"); |
| | | Map<ObjectClass, String> objectClassList = new HashMap<>(); |
| | | objectClassList.put(DirectoryServer.getObjectClass("organization"), "organization"); |
| | | objectClassList.put(getOrganizationObjectClass(), "organization"); |
| | | |
| | | Attribute attr = Attributes.create("o", "com"); |
| | | List<Attribute> userAttributes = newArrayList(attr); |
| | | Map<AttributeType, List<Attribute>> userAttList = new HashMap<>(); |
| | | userAttList.put(attr.getAttributeDescription().getAttributeType(), userAttributes); |
| | | Map<AttributeType, List<Attribute>> userAttList = addAttribute(attr, userAttributes); |
| | | |
| | | |
| | | attr = Attributes.create("creatorsname", "dc=creator"); |
| | | List<Attribute> operationalAttributes = newArrayList(attr); |
| | | Map<AttributeType, List<Attribute>> opList = new HashMap<>(); |
| | | opList.put(attr.getAttributeDescription().getAttributeType(), operationalAttributes); |
| | | Map<AttributeType, List<Attribute>> opList = addAttribute(attr, operationalAttributes); |
| | | |
| | | CSN csn = new CSN(TimeThread.getTime(), 123, 45); |
| | | |
| | |
| | | assertEquals(msg.getCSN(), updateMsg.getCSN()); |
| | | } |
| | | |
| | | private Map<AttributeType, List<Attribute>> addAttribute(Attribute attr, List<Attribute> userAttributes) |
| | | { |
| | | Map<AttributeType, List<Attribute>> userAttList = new HashMap<>(); |
| | | userAttList.put(attr.getAttributeDescription().getAttributeType(), userAttributes); |
| | | return userAttList; |
| | | } |
| | | |
| | | private void assertAttributesEqual(List<RawAttribute> actualAttrs, |
| | | List<Attribute> expectedAttrs) throws LDAPException |
| | | { |
| | |
| | | package org.opends.server.types; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | DN entryDN = DN.valueOf("dc=example, dc=com"); |
| | | |
| | | // Get default object classes. |
| | | ObjectClass top = DirectoryServer.getTopObjectClass(); |
| | | ObjectClass extensible = DirectoryServer.getObjectClass("extensibleobject"); |
| | | if (extensible.isPlaceHolder()) { |
| | | throw new RuntimeException( |
| | | "Unable to resolve object class extensibleObject"); |
| | | } |
| | | |
| | | ObjectClass top = CoreSchema.getTopObjectClass(); |
| | | ObjectClass extensible = CoreSchema.getExtensibleObjectObjectClass(); |
| | | HashMap<ObjectClass, String> objectClasses = new HashMap<>(); |
| | | objectClasses.put(top, top.getNameOrOID()); |
| | | objectClasses.put(extensible, extensible.getNameOrOID()); |
| | |
| | | */ |
| | | @Test |
| | | public void testParseAttributeNotFound() throws Exception { |
| | | AttributeType type1 = DirectoryServer.getAttributeType("description"); |
| | | AttributeType type1 = getDescriptionAttributeType(); |
| | | AttributeType type2 = DirectoryServer.getAttributeType("inheritable"); |
| | | |
| | | Entry entry = createTestEntry(type1, "hello world"); |
| | |
| | | @Test |
| | | public void testParseAttributesInteger() throws Exception |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType("supportedldapversion"); |
| | | AttributeType type = getSupportedLDAPVersionAttributeType(); |
| | | String[] values = new String[] { "-4", "-2", "0", "1", "3" }; |
| | | |
| | | HashSet<Integer> expected = new HashSet<>(); |
| | | HashSet<Integer> expected = newHashSet(); |
| | | for (String value : values) { |
| | | expected.add(Integer.valueOf(value)); |
| | | } |
| | | |
| | | Entry entry = createTestEntry(type, values); |
| | | Set<Integer> result = |
| | | entry.parseAttribute("supportedldapversion").asSetOfInteger(); |
| | | Set<Integer> result = entry.parseAttribute("supportedldapversion").asSetOfInteger(); |
| | | Assertions.assertThat(result).isEqualTo(expected); |
| | | } |
| | | |
| | |
| | | @Test(expectedExceptions = LocalizedIllegalArgumentException.class) |
| | | public void testParseAttributeIntegerBad() throws Exception |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType("supportedldapversion"); |
| | | AttributeType type = getSupportedLDAPVersionAttributeType(); |
| | | String[] values = new String[] { "-4", "-2", "xxx", "1", "3" }; |
| | | |
| | | Entry entry = createTestEntry(type, values); |
| | |
| | | assertTrue(e.conformsToSchema(null, false, false, false, |
| | | new LocalizableMessageBuilder())); |
| | | |
| | | AttributeType ocType = DirectoryServer.getAttributeType("objectclass"); |
| | | AttributeType cnType = DirectoryServer.getAttributeType("cn"); |
| | | AttributeType nameType = DirectoryServer.getAttributeType("name"); |
| | | AttributeType uidType = DirectoryServer.getAttributeType("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeType("modifiersname"); |
| | | AttributeType ocType = getObjectClassAttributeType(); |
| | | AttributeType cnType = getCNAttributeType(); |
| | | AttributeType nameType = getNameAttributeType(); |
| | | AttributeType uidType = getUIDAttributeType(); |
| | | AttributeType mnType = getModifiersNameAttributeType(); |
| | | |
| | | assertTrue(e.hasAttribute(ocType)); |
| | | assertTrue(e.hasAttribute(cnType)); |
| | |
| | | assertTrue(e.conformsToSchema(null, false, false, false, |
| | | new LocalizableMessageBuilder())); |
| | | |
| | | AttributeType ocType = DirectoryServer.getAttributeType("objectclass"); |
| | | AttributeType cnType = DirectoryServer.getAttributeType("cn"); |
| | | AttributeType nameType = DirectoryServer.getAttributeType("name"); |
| | | AttributeType uidType = DirectoryServer.getAttributeType("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeType("modifiersname"); |
| | | AttributeType ocType = getObjectClassAttributeType(); |
| | | AttributeType cnType = getCNAttributeType(); |
| | | AttributeType nameType = getNameAttributeType(); |
| | | AttributeType uidType = getUIDAttributeType(); |
| | | AttributeType mnType = getModifiersNameAttributeType(); |
| | | |
| | | assertFalse(e.hasUserAttribute(ocType)); |
| | | assertTrue(e.hasUserAttribute(cnType)); |
| | |
| | | assertTrue(e.conformsToSchema(null, false, false, false, |
| | | new LocalizableMessageBuilder())); |
| | | |
| | | AttributeType ocType = DirectoryServer.getAttributeType("objectclass"); |
| | | AttributeType cnType = DirectoryServer.getAttributeType("cn"); |
| | | AttributeType nameType = DirectoryServer.getAttributeType("name"); |
| | | AttributeType uidType = DirectoryServer.getAttributeType("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeType("modifiersname"); |
| | | AttributeType ocType = getObjectClassAttributeType(); |
| | | AttributeType cnType = getCNAttributeType(); |
| | | AttributeType nameType = getNameAttributeType(); |
| | | AttributeType uidType = getUIDAttributeType(); |
| | | AttributeType mnType = getModifiersNameAttributeType(); |
| | | |
| | | assertFalse(e.hasOperationalAttribute(ocType)); |
| | | assertFalse(e.hasOperationalAttribute(cnType)); |
| | |
| | | assertTrue(e.conformsToSchema(null, false, false, false, |
| | | new LocalizableMessageBuilder())); |
| | | |
| | | AttributeType ocType = DirectoryServer.getAttributeType("objectclass"); |
| | | AttributeType cnType = DirectoryServer.getAttributeType("cn"); |
| | | AttributeType nameType = DirectoryServer.getAttributeType("name"); |
| | | AttributeType uidType = DirectoryServer.getAttributeType("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeType("modifiersname"); |
| | | AttributeType ocType = getObjectClassAttributeType(); |
| | | AttributeType cnType = getCNAttributeType(); |
| | | AttributeType nameType = getNameAttributeType(); |
| | | AttributeType uidType = getUIDAttributeType(); |
| | | AttributeType mnType = getModifiersNameAttributeType(); |
| | | |
| | | assertThat(e.getAttribute(ocType)).hasSize(1); |
| | | assertThat(e.getAttribute(cnType)).hasSize(2); |
| | |
| | | assertTrue(e.conformsToSchema(null, false, false, false, |
| | | new LocalizableMessageBuilder())); |
| | | |
| | | AttributeType ocType = DirectoryServer.getAttributeType("objectclass"); |
| | | AttributeType cnType = DirectoryServer.getAttributeType("cn"); |
| | | AttributeType nameType = DirectoryServer.getAttributeType("name"); |
| | | AttributeType uidType = DirectoryServer.getAttributeType("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeType("modifiersname"); |
| | | AttributeType ocType = getObjectClassAttributeType(); |
| | | AttributeType cnType = getCNAttributeType(); |
| | | AttributeType nameType = getNameAttributeType(); |
| | | AttributeType uidType = getUIDAttributeType(); |
| | | AttributeType mnType = getModifiersNameAttributeType(); |
| | | |
| | | assertThat(e.getUserAttribute(ocType)).isEmpty(); |
| | | assertThat(e.getUserAttribute(cnType)).hasSize(2); |
| | |
| | | assertTrue(e.conformsToSchema(null, false, false, false, |
| | | new LocalizableMessageBuilder())); |
| | | |
| | | AttributeType ocType = DirectoryServer.getAttributeType("objectclass"); |
| | | AttributeType cnType = DirectoryServer.getAttributeType("cn"); |
| | | AttributeType nameType = DirectoryServer.getAttributeType("name"); |
| | | AttributeType uidType = DirectoryServer.getAttributeType("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeType("modifiersname"); |
| | | AttributeType ocType = getObjectClassAttributeType(); |
| | | AttributeType cnType = getCNAttributeType(); |
| | | AttributeType nameType = getNameAttributeType(); |
| | | AttributeType uidType = getUIDAttributeType(); |
| | | AttributeType mnType = getModifiersNameAttributeType(); |
| | | |
| | | assertThat(e.getOperationalAttribute(ocType)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(cnType)).isEmpty(); |
| | |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | | import static org.forgerock.opendj.ldap.schema.CoreSchema.*; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | |
| | | |
| | | 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.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClass; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.opends.server.types.RawModification; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.AfterClass; |
| | |
| | | * {@link org.opends.server.util.LDIFReader} class. |
| | | */ |
| | | public final class TestLDIFReader extends UtilTestCase { |
| | | /** Top object class. */ |
| | | private ObjectClass OC_TOP; |
| | | /** Person object class. */ |
| | | private ObjectClass OC_PERSON; |
| | | |
| | | /** Object class attribute type. */ |
| | | private AttributeType AT_OC; |
| | | /** Common name attribute type. */ |
| | | private AttributeType AT_CN; |
| | | /** Surname attribute type. */ |
| | | private AttributeType AT_SN; |
| | | /** Description attribute type. */ |
| | | private AttributeType AT_DESCR; |
| | | /** Telephone number attribute type. */ |
| | | private AttributeType AT_TELN; |
| | | |
| | | /** Temporary file containing an attribute value. */ |
| | | private File TEMP_FILE; |
| | | |
| | |
| | | */ |
| | | @BeforeClass |
| | | public void setUp() throws Exception { |
| | | // This test suite depends on having the schema available, so we'll |
| | | // start the server. |
| | | TestCaseUtils.startServer(); |
| | | |
| | | // Initialize schema bits. |
| | | OC_TOP = DirectoryServer.getTopObjectClass(); |
| | | OC_PERSON = DirectoryServer.getObjectClass("person"); |
| | | |
| | | AT_OC = DirectoryServer.getObjectClassAttributeType(); |
| | | AT_CN = DirectoryServer.getAttributeType("cn"); |
| | | AT_SN = DirectoryServer.getAttributeType("sn"); |
| | | AT_DESCR = DirectoryServer.getAttributeType("description"); |
| | | AT_TELN = DirectoryServer.getAttributeType("telephonenumber"); |
| | | |
| | | // Create a temporary file containing an attribute value. |
| | | TEMP_FILE = File.createTempFile("tmp", "txt"); |
| | | try (OutputStream out = new FileOutputStream(TEMP_FILE)) { |
| | |
| | | */ |
| | | @Test(dependsOnMethods = { "testReadEntryEmptyStream" }) |
| | | public void testReadEntrySingle() throws Exception { |
| | | final String ldifString = "dn: cn=john, dc=foo, dc=com\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" + "cn: john\n" |
| | | // @formatter:off |
| | | final String ldifString = |
| | | "dn: cn=john, dc=foo, dc=com\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: person\n" |
| | | + "cn: john\n" |
| | | + "sn: smith\n"; |
| | | // @formatter:on |
| | | |
| | | try (LDIFReader reader = createLDIFReader(ldifString)) { |
| | | Entry entry = reader.readEntry(); |
| | | Assert.assertNotNull(entry); |
| | | |
| | | Assert.assertEquals(entry.getName(), DN.valueOf("cn=john, dc=foo, dc=com")); |
| | | Assert.assertTrue(entry.hasObjectClass(OC_TOP)); |
| | | Assert.assertTrue(entry.hasObjectClass(OC_PERSON)); |
| | | Assert.assertTrue(entry.hasValue(AT_CN, ByteString.valueOfUtf8("john"))); |
| | | Assert.assertTrue(entry.hasValue(AT_SN, ByteString.valueOfUtf8("smith"))); |
| | | Assert.assertTrue(entry.hasObjectClass(getTopObjectClass())); |
| | | Assert.assertTrue(entry.hasObjectClass(getPersonObjectClass())); |
| | | Assert.assertTrue(entry.hasValue(getCNAttributeType(), ByteString.valueOfUtf8("john"))); |
| | | Assert.assertTrue(entry.hasValue(getSNAttributeType(), ByteString.valueOfUtf8("smith"))); |
| | | |
| | | Assert.assertNull(reader.readEntry()); |
| | | |
| | |
| | | try (LDIFReader reader = createLDIFReader(ldifString)) { |
| | | Entry entry = reader.readEntry(); |
| | | Assert.assertNotNull(entry); |
| | | Assert.assertTrue(entry.hasValue(AT_DESCR, ByteString.valueOfUtf8("once upon a time in the west"))); |
| | | Assert.assertTrue(entry.hasValue(getDescriptionAttributeType(), ByteString.valueOfUtf8("once upon a time in the west"))); |
| | | } |
| | | } |
| | | |
| | |
| | | try (LDIFReader reader = createLDIFReader(ldifString)) { |
| | | Entry entry = reader.readEntry(); |
| | | Assert.assertNotNull(entry); |
| | | Assert.assertTrue(entry.hasValue(AT_DESCR, ByteString.valueOfUtf8("once upon a time in the west"))); |
| | | Assert.assertTrue(entry.hasValue(getDescriptionAttributeType(), ByteString.valueOfUtf8("once upon a time in the west"))); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Test(dependsOnMethods = { "testReadEntrySingle" }) |
| | | public void testReadEntryMultiple() throws Exception { |
| | | final String ldifString = "dn: cn=john, dc=foo, dc=com\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" + "cn: john\n" |
| | | + "sn: smith\n" + "\n" + "dn: cn=anne, dc=foo, dc=com\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" + "cn: anne\n" |
| | | + "sn: other\n" + "\n"; |
| | | // @formatter:off |
| | | final String ldifString = |
| | | "dn: cn=john, dc=foo, dc=com\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: person\n" |
| | | + "cn: john\n" |
| | | + "sn: smith\n" |
| | | + "\n" |
| | | + "dn: cn=anne, dc=foo, dc=com\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: person\n" |
| | | + "cn: anne\n" |
| | | + "sn: other\n" |
| | | + "\n"; |
| | | // @formatter:on |
| | | |
| | | try (LDIFReader reader = createLDIFReader(ldifString)) { |
| | | reader.readEntry(); |
| | |
| | | Assert.assertNotNull(entry); |
| | | |
| | | Assert.assertEquals(entry.getName(), DN.valueOf("cn=anne, dc=foo, dc=com")); |
| | | Assert.assertTrue(entry.hasObjectClass(OC_TOP)); |
| | | Assert.assertTrue(entry.hasObjectClass(OC_PERSON)); |
| | | Assert.assertTrue(entry.hasValue(AT_CN, ByteString.valueOfUtf8("anne"))); |
| | | Assert.assertTrue(entry.hasValue(AT_SN, ByteString.valueOfUtf8("other"))); |
| | | Assert.assertTrue(entry.hasObjectClass(getTopObjectClass())); |
| | | Assert.assertTrue(entry.hasObjectClass(getPersonObjectClass())); |
| | | Assert.assertTrue(entry.hasValue(getCNAttributeType(), ByteString.valueOfUtf8("anne"))); |
| | | Assert.assertTrue(entry.hasValue(getSNAttributeType(), ByteString.valueOfUtf8("other"))); |
| | | |
| | | Assert.assertNull(reader.readEntry()); |
| | | |
| | |
| | | Assert.assertEquals(add.getDN(), dn); |
| | | |
| | | List<Attribute> attrs = new ArrayList<>(); |
| | | AttributeBuilder builder = new AttributeBuilder(AT_OC); |
| | | AttributeBuilder builder = new AttributeBuilder(getObjectClassAttributeType()); |
| | | builder.add("top"); |
| | | builder.add("person"); |
| | | builder.add("organizationalPerson"); |
| | |
| | | mod = i.next().toModification(); |
| | | Assert.assertEquals(mod.getModificationType(), |
| | | ModificationType.DELETE); |
| | | attr = Attributes.empty(AT_DESCR); |
| | | attr = Attributes.empty(getDescriptionAttributeType()); |
| | | Assert.assertEquals(mod.getAttribute(), attr); |
| | | |
| | | Assert.assertTrue(i.hasNext()); |
| | | mod = i.next().toModification(); |
| | | Assert.assertEquals(mod.getModificationType(), |
| | | ModificationType.REPLACE); |
| | | builder = new AttributeBuilder(AT_TELN); |
| | | builder = new AttributeBuilder(getTelephoneNumberAttributeType()); |
| | | builder.add("+1 408 555 1234"); |
| | | builder.add("+1 408 555 5678"); |
| | | Assert.assertEquals(mod.getAttribute(), builder.toAttribute()); |
| | |
| | | mod = i.next().toModification(); |
| | | Assert.assertEquals(mod.getModificationType(), |
| | | ModificationType.DELETE); |
| | | attr = Attributes.empty(AT_DESCR); |
| | | attr = Attributes.empty(getDescriptionAttributeType()); |
| | | Assert.assertEquals(mod.getAttribute(), attr); |
| | | |
| | | // Change record #8. |
| | |
| | | mod = i.next().toModification(); |
| | | Assert.assertEquals(mod.getModificationType(), |
| | | ModificationType.DELETE); |
| | | attr = Attributes.empty(AT_DESCR); |
| | | attr = Attributes.empty(getDescriptionAttributeType()); |
| | | Assert.assertEquals(mod.getAttribute(), attr); |
| | | |
| | | Assert.assertFalse(i.hasNext()); |