opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
@@ -51,6 +51,7 @@ import org.forgerock.opendj.ldap.responses.Responses; import org.forgerock.opendj.ldap.responses.Result; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn; import org.forgerock.util.Function; import org.forgerock.util.promise.NeverThrowsException; @@ -92,12 +93,13 @@ if (sdkEntry != null) { org.opends.server.types.Entry entry = new org.opends.server.types.Entry(sdkEntry.getName(), null, null, null); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); List<ByteString> duplicateValues = new ArrayList<>(); for (org.opends.server.types.Attribute attribute : toAttributes(sdkEntry.getAllAttributes())) { if (attribute.getAttributeDescription().getAttributeType().isObjectClass()) { for (ByteString attrName : attribute) { try { entry.addObjectClass(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(attrName.toString())); entry.addObjectClass(schema.getObjectClass(attrName.toString())); } catch (DirectoryException e) { throw new IllegalStateException(e.getMessage(), e); } opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java
@@ -16,7 +16,9 @@ */ package org.opends.server.admin; import static org.forgerock.opendj.ldap.ModificationType.*; import static org.opends.server.protocols.internal.Requests.*; import static org.opends.server.util.CollectionUtils.*; import java.net.InetAddress; import java.util.LinkedList; @@ -24,10 +26,10 @@ import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ModificationType; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.SearchScope; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.core.DirectoryServer; import org.opends.server.protocols.internal.InternalClientConnection; import org.opends.server.protocols.internal.InternalSearchOperation; @@ -98,14 +100,14 @@ return; } AttributeType attrType1 = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("adminport"); AttributeType attrType2 = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("adminEnabled"); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attrType1 = schema.getAttributeType("adminport"); AttributeType attrType2 = schema.getAttributeType("adminEnabled"); LinkedList<Modification> mods = new LinkedList<>(); mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrType1, adminPort))); mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrType2, "true"))); LinkedList<Modification> mods = newLinkedList( new Modification(REPLACE, Attributes.create(attrType1, adminPort)), new Modification(REPLACE, Attributes.create(attrType2, "true"))); // Process modification internalConnection.processModify(serverEntryDN, mods); } opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicy.java
@@ -26,7 +26,6 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.opends.server.types.DirectoryException; @@ -69,8 +68,7 @@ { // First check to see if the ds-pwp-password-policy-dn is present. String userDNString = userEntry.getName().toString(); AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_POLICY_DN); for (Attribute a : userEntry.getAllAttributes(type)) for (Attribute a : userEntry.getAllAttributes(OP_ATTR_PWPOLICY_POLICY_DN)) { if (a.isEmpty()) { opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicyState.java
@@ -15,22 +15,22 @@ */ package org.opends.server.api; import static org.opends.messages.CoreMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.util.StaticUtils.*; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.AttributeDescription; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ConditionResult; import org.forgerock.opendj.ldap.GeneralizedTime; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import static org.opends.messages.CoreMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.util.StaticUtils.*; /** * The authentication policy context associated with a user's entry, which is * responsible for managing the user's account, their password, as well as @@ -79,23 +79,24 @@ /** * A utility method which may be used by implementations in order to obtain * the value of the specified attribute from the provided entry as a boolean. * A utility method which may be used by implementations in order to obtain the value of the * specified attribute from the provided entry as a boolean. * * @param entry * The entry whose attribute is to be parsed as a boolean. * @param attributeType * The attribute type whose value should be parsed as a boolean. * @param attributeName * The attribute name whose value should be parsed as a boolean. * @return The attribute's value represented as a ConditionResult value, or * ConditionResult.UNDEFINED if the specified attribute does not exist * in the entry. * ConditionResult.UNDEFINED if the specified attribute does not exist in the entry. * @throws DirectoryException * If the value cannot be decoded as a boolean. */ protected static ConditionResult getBoolean(final Entry entry, final AttributeType attributeType) throws DirectoryException final String attributeName) throws DirectoryException { for (final Attribute a : entry.getAllAttributes(attributeType)) AttributeDescription attrDesc = AttributeDescription.valueOf(attributeName); AttributeType attributeType = attrDesc.getAttributeType(); for (final Attribute a : entry.getAllAttributes(attrDesc)) { if (a.isEmpty()) { @@ -267,10 +268,9 @@ */ public boolean isDisabled() { final AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_ACCOUNT_DISABLED); try { isDisabled = getBoolean(userEntry, type); isDisabled = getBoolean(userEntry, OP_ATTR_ACCOUNT_DISABLED); } catch (final Exception e) { @@ -302,8 +302,6 @@ return result; } /** * Returns {@code true} if this authentication policy state is associated with * a password policy and the method {@link #getAuthenticationPolicy} will opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
@@ -32,6 +32,7 @@ import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.api.plugin.PluginResult; import org.opends.server.core.AuthenticatedUsers; import org.opends.server.core.CoreConfigManager; @@ -1058,7 +1059,8 @@ newPrivileges.addAll(DirectoryServer.getRootPrivileges()); } AttributeType privType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PRIVILEGE_NAME); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType privType = schema.getAttributeType(OP_ATTR_PRIVILEGE_NAME); for (Attribute a : entry.getAllAttributes(privType)) { for (ByteString v : a) opendj-server-legacy/src/main/java/org/opends/server/api/CompressedSchema.java
@@ -513,7 +513,8 @@ private AttributeDescription loadAttributeToMaps(final int id, final String attributeName, final Iterable<String> attributeOptions, final Mappings mappings) { final AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attributeName); Schema schema2 = DirectoryServer.getInstance().getServerContext().getSchema(); final AttributeType type = schema2.getAttributeType(attributeName); final Set<String> options = getOptions(attributeOptions); final AttributeDescription ad = AttributeDescription.create(type, options); exclusiveLock.lock(); opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
@@ -25,6 +25,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.CoreSchema; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.opends.server.types.Attributes; @@ -202,17 +203,18 @@ AciLDAPOperationContainer container, final Entry e, boolean skipCheck) { Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); if (aclRights == null) { aclRights = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(aclRightsAttrStr); aclRights = schema.getAttributeType(aclRightsAttrStr); } if (aclRightsInfo == null) { aclRightsInfo = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(aclRightsInfoAttrStr); aclRightsInfo = schema.getAttributeType(aclRightsInfoAttrStr); } if (dnAttributeType == null) { dnAttributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(dnAttrStr); dnAttributeType = schema.getAttributeType(dnAttrStr); } // Check if the attributes aclRights and aclRightsInfo were requested and @@ -244,7 +246,7 @@ } else { nonRightsAttrs.add(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(a)); nonRightsAttrs.add(schema.getAttributeType(a)); } } } @@ -374,12 +376,11 @@ // Only add the aclRights information if the aclRights attribute type was seen. if(hasAttrMask(mask, ACL_RIGHTS)) { String typeStr = aclRightsAttributeLevelStr + ";" + a.getNameOrOID(); AttributeType attributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(typeStr); Attribute attr = Attributes.create(attributeType, evalInfo.toString()); Attribute attr = Attributes.create(typeStr, evalInfo.toString()); //It is possible that the user might have specified the same attributes //in both the search and the specific attribute part of the control. //Only try to add the attribute type if it already hasn't been added. if(!retEntry.hasAttribute(attributeType)) if (!retEntry.hasAttribute(attr.getAttributeDescription().getAttributeType())) { retEntry.addAttribute(attr,null); } @@ -604,11 +605,10 @@ if(hasAttrMask(mask,ACL_RIGHTS_INFO)) { //Build the attribute type. String typeStr = aclRightsInfoAttrLogsStr + ";" + rightStr + ";" + aType.getNameOrOID(); AttributeType attributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(typeStr); Attribute attr = Attributes.create(attributeType, container.getEvalSummary()); Attribute attr = Attributes.create(typeStr, container.getEvalSummary()); // The attribute type might have already been added, probably // not but it is possible. if(!retEntry.hasAttribute(attributeType)) if (!retEntry.hasAttribute(attr.getAttributeDescription().getAttributeType())) { retEntry.addAttribute(attr,null); } opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
@@ -33,6 +33,7 @@ import org.forgerock.opendj.ldap.RDN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.server.DseeCompatAccessControlHandlerCfg; import org.opends.server.api.AccessControlHandler; import org.opends.server.api.ClientConnection; @@ -69,7 +70,6 @@ import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.schema.SchemaConstants.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; /** The AciHandler class performs the main processing for the dseecompat package. */ public final class AciHandler extends @@ -123,10 +123,11 @@ */ private static void initStatics() { aciType = getInstance().getServerContext().getSchema().getAttributeType("aci"); globalAciType = getInstance().getServerContext().getSchema().getAttributeType(ATTR_AUTHZ_GLOBAL_ACI); debugSearchIndex = getInstance().getServerContext().getSchema().getAttributeType(SuffixContainer.ATTR_DEBUG_SEARCH_INDEX); refAttrType = getInstance().getServerContext().getSchema().getAttributeType(ATTR_REFERRAL_URL); Schema schema = getInstance().getServerContext().getSchema(); aciType = schema.getAttributeType("aci"); globalAciType = schema.getAttributeType(ATTR_AUTHZ_GLOBAL_ACI); debugSearchIndex = schema.getAttributeType(SuffixContainer.ATTR_DEBUG_SEARCH_INDEX); refAttrType = schema.getAttributeType(ATTR_REFERRAL_URL); try { @@ -283,23 +284,9 @@ @Override public boolean isAllowed(LocalBackendCompareOperation operation) { AciContainer container = new AciLDAPOperationContainer(operation, ACI_COMPARE); String baseName; String rawAttributeType = operation.getRawAttributeType(); int semicolonPosition = rawAttributeType.indexOf(';'); if (semicolonPosition > 0) { baseName = toLowerCase(rawAttributeType.substring(0, semicolonPosition)); } else { baseName = toLowerCase(rawAttributeType); } container.setCurrentAttributeType(getInstance().getServerContext().getSchema().getAttributeType(baseName)); AciContainer container = new AciLDAPOperationContainer(operation, ACI_COMPARE); AttributeDescription attrDesc = AttributeDescription.valueOf(operation.getRawAttributeType()); container.setCurrentAttributeType(attrDesc.getAttributeType()); container.setCurrentAttributeValue(operation.getAssertionValue()); return isAllowed(container, operation); } opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
@@ -34,6 +34,7 @@ import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.MatchingRule; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.types.Attribute; import org.opends.server.types.Attributes; import org.opends.server.types.DirectoryException; @@ -144,6 +145,7 @@ */ public boolean matchesRDN(RDN rdn) { ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); if (getNumValues() == 1) { // Check for ",*," matching any RDN. @@ -160,7 +162,7 @@ AVA ava = rdn.getFirstAVA(); if (!typePatterns[0].equals("*")) { AttributeType thisType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(typePatterns[0]); AttributeType thisType = serverContext.getSchema().getAttributeType(typePatterns[0]); if (thisType.isPlaceHolder() || !thisType.equals(ava.getAttributeType())) { return false; @@ -179,7 +181,7 @@ TreeMap<String, List<ByteString>> patternMap = new TreeMap<>(); for (int i = 0; i < typePatterns.length; i++) { AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(typePatterns[i]); AttributeType type = serverContext.getSchema().getAttributeType(typePatterns[i]); if (type.isPlaceHolder()) { return false; opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilterList.java
@@ -26,6 +26,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.types.DirectoryException; import org.opends.server.types.SearchFilter; @@ -108,7 +109,8 @@ attributeName=attributeName.substring(0, semicolon); } String filterString=matcher.group(filterPos); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attributeName); ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); AttributeType attrType = serverContext.getSchema().getAttributeType(attributeName); SearchFilter filter; //Check if it is a valid filter and add it to the list map if ok. try { opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargetAttr.java
@@ -24,6 +24,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.forgerock.opendj.ldap.schema.AttributeType; /** @@ -122,7 +123,8 @@ throw new AciException(message); } } else { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attribute); ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); AttributeType attrType = serverContext.getSchema().getAttributeType(attribute); if(attrType.isOperational()) { opAttributes.add(attrType); opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
@@ -19,7 +19,6 @@ import static org.forgerock.util.Reject.*; import static org.opends.messages.BackendMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; @@ -218,7 +217,7 @@ // Construct the backup base entry. LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(2); objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); objectClasses.put(getInstance().getServerContext().getSchema().getObjectClass(OC_UNTYPED_OBJECT_LC), OC_UNTYPED_OBJECT); objectClasses.put(serverContext.getSchema().getObjectClass(OC_UNTYPED_OBJECT_LC), OC_UNTYPED_OBJECT); LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(1); @@ -274,7 +273,7 @@ { int numEntries = 1; AttributeType backupPathType = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); AttributeType backupPathType = serverContext.getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); for (File dir : backupDirectories.keySet()) { @@ -383,7 +382,7 @@ long count = 0; Entry backupDirEntry = getBackupDirectoryEntry(entryDN); AttributeType t = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); AttributeType t = serverContext.getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); List<Attribute> attrList = backupDirEntry.getAllAttributes(t); for (ByteString v : attrList.get(0)) { @@ -470,7 +469,7 @@ throws DirectoryException { // Make sure that the DN specifies a backup directory. AttributeType t = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); AttributeType t = serverContext.getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); ByteString v = entryDN.rdn().getAttributeValue(t); if (v == null) { @@ -508,13 +507,13 @@ // Construct the backup directory entry to return. LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2); ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); ocMap.put(getInstance().getServerContext().getSchema().getObjectClass(OC_BACKUP_DIRECTORY), OC_BACKUP_DIRECTORY); ocMap.put(serverContext.getSchema().getObjectClass(OC_BACKUP_DIRECTORY), OC_BACKUP_DIRECTORY); LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(3); userAttrs.put(t, asList(t, v)); t = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_BACKEND_DN); t = serverContext.getSchema().getAttributeType(ATTR_BACKUP_BACKEND_DN); userAttrs.put(t, asList(t, ByteString.valueOfUtf8(backupDirectory.getConfigEntryDN().toString()))); Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs); @@ -538,7 +537,7 @@ throws DirectoryException { // First, get the backup ID from the entry DN. AttributeType idType = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_ID); AttributeType idType = serverContext.getSchema().getAttributeType(ATTR_BACKUP_ID); ByteString idValue = entryDN.rdn().getAttributeValue(idType); if (idValue == null) { throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_ID_IN_DN.get(entryDN)); @@ -551,7 +550,7 @@ throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_PARENT_DN.get(entryDN)); } AttributeType t = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); AttributeType t = serverContext.getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); ByteString v = parentDN.rdn().getAttributeValue(t); if (v == null) { throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_DIR_IN_DN.get(entryDN)); @@ -569,22 +568,19 @@ LocalizableMessage message = ERR_BACKUP_ERROR_GETTING_BACKUP_DIRECTORY .get(getExceptionMessage(e)); throw new DirectoryException(DirectoryServer.getCoreConfigManager().getServerErrorResultCode(), message); throw new DirectoryException(serverContext.getCoreConfigManager().getServerErrorResultCode(), message); } BackupInfo backupInfo = backupDirectory.getBackupInfo(backupID); if (backupInfo == null) { LocalizableMessage message = ERR_BACKUP_NO_SUCH_BACKUP.get(backupID, backupDirectory .getPath()); throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, parentDN, null); LocalizableMessage message = ERR_BACKUP_NO_SUCH_BACKUP.get(backupID, backupDirectory.getPath()); throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message, parentDN, null); } // Construct the backup entry to return. LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<>(3); ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); ocMap.put(getInstance().getServerContext().getSchema().getObjectClass(OC_BACKUP_INFO), OC_BACKUP_INFO); ocMap.put(serverContext.getSchema().getObjectClass(OC_BACKUP_INFO), OC_BACKUP_INFO); ocMap.put(CoreSchema.getExtensibleObjectObjectClass(), OC_EXTENSIBLE_OBJECT); LinkedHashMap<AttributeType, List<Attribute>> opAttrs = new LinkedHashMap<>(0); @@ -596,7 +592,7 @@ Date backupDate = backupInfo.getBackupDate(); if (backupDate != null) { t = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DATE); t = serverContext.getSchema().getAttributeType(ATTR_BACKUP_DATE); userAttrs.put(t, asList(t, ByteString.valueOfUtf8(GeneralizedTimeSyntax.format(backupDate)))); } @@ -607,7 +603,7 @@ Set<String> dependencies = backupInfo.getDependencies(); if (dependencies != null && !dependencies.isEmpty()) { t = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DEPENDENCY); t = serverContext.getSchema().getAttributeType(ATTR_BACKUP_DEPENDENCY); AttributeBuilder builder = new AttributeBuilder(t); builder.addAllStrings(dependencies); userAttrs.put(t, builder.toAttributeList()); @@ -626,7 +622,7 @@ Map<String, String> properties = backupInfo.getBackupProperties(); if (properties != null && !properties.isEmpty()) { for (Map.Entry<String, String> e : properties.entrySet()) { t = getInstance().getServerContext().getSchema().getAttributeType(toLowerCase(e.getKey())); t = serverContext.getSchema().getAttributeType(toLowerCase(e.getKey())); userAttrs.put(t, asList(t, ByteString.valueOfUtf8(e.getValue()))); } } @@ -638,13 +634,13 @@ private void putByteString(LinkedHashMap<AttributeType, List<Attribute>> userAttrs, String attrName, byte[] value) { AttributeType t = getInstance().getServerContext().getSchema().getAttributeType(attrName); AttributeType t = serverContext.getSchema().getAttributeType(attrName); userAttrs.put(t, asList(t, ByteString.wrap(value))); } private void putBoolean(LinkedHashMap<AttributeType, List<Attribute>> attrsMap, String attrName, boolean value) { AttributeType t = getInstance().getServerContext().getSchema().getAttributeType(attrName); AttributeType t = serverContext.getSchema().getAttributeType(attrName); attrsMap.put(t, asList(t, SchemaUtils.createBooleanValue(value))); } @@ -715,7 +711,7 @@ if (scope != SearchScope.BASE_OBJECT && !backupDirectories.isEmpty()) { AttributeType backupPathType = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); AttributeType backupPathType = serverContext.getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); for (File dir : backupDirectories.keySet()) { // Check to see if the descriptor file exists. If not, then skip this @@ -766,7 +762,7 @@ if (scope != SearchScope.BASE_OBJECT) { AttributeType t = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); AttributeType t = serverContext.getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); List<Attribute> attrList = backupDirEntry.getAllAttributes(t); returnEntries(searchOperation, baseDN, filter, attrList); } @@ -806,7 +802,7 @@ { File dir = new File(v.toString()); BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory(); AttributeType idType = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_ID); AttributeType idType = serverContext.getSchema().getAttributeType(ATTR_BACKUP_ID); for (String backupID : backupDirectory.getBackups().keySet()) { opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java
@@ -19,7 +19,6 @@ import static org.opends.messages.BackendMessages.*; import static org.opends.messages.ReplicationMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.replication.plugin.MultimasterReplication.*; import static org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy.*; import static org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy.*; @@ -178,7 +177,7 @@ static { CHANGELOG_ROOT_OBJECT_CLASSES.put(CoreSchema.getTopObjectClass(), OC_TOP); CHANGELOG_ROOT_OBJECT_CLASSES.put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass("container"), "container"); CHANGELOG_ROOT_OBJECT_CLASSES.put(getServerContext().getSchema().getObjectClass("container"), "container"); } /** The set of objectclasses that will be used in ECL entries. */ @@ -187,7 +186,8 @@ static { CHANGELOG_ENTRY_OBJECT_CLASSES.put(CoreSchema.getTopObjectClass(), OC_TOP); CHANGELOG_ENTRY_OBJECT_CLASSES.put(getInstance().getServerContext().getSchema().getObjectClass(OC_CHANGELOG_ENTRY), OC_CHANGELOG_ENTRY); CHANGELOG_ENTRY_OBJECT_CLASSES.put(getServerContext().getSchema().getObjectClass( OC_CHANGELOG_ENTRY), OC_CHANGELOG_ENTRY); } /** The base DN for the external change log. */ @@ -241,8 +241,7 @@ @Deprecated public static ChangelogBackend getInstance() { return (ChangelogBackend) DirectoryServer.getInstance().getServerContext().getBackendConfigManager() .findLocalBackendForEntry(CHANGELOG_BASE_DN); return (ChangelogBackend) getServerContext().getBackendConfigManager().findLocalBackendForEntry(CHANGELOG_BASE_DN); } @Override @@ -258,8 +257,7 @@ try { DirectoryServer.getInstance().getServerContext().getBackendConfigManager() .registerBaseDN(CHANGELOG_BASE_DN, this, true); getServerContext().getBackendConfigManager().registerBaseDN(CHANGELOG_BASE_DN, this, true); } catch (final DirectoryException e) { @@ -268,12 +266,17 @@ } } private static ServerContext getServerContext() { return DirectoryServer.getInstance().getServerContext(); } @Override public void closeBackend() { try { DirectoryServer.getInstance().getServerContext().getBackendConfigManager().deregisterBaseDN(CHANGELOG_BASE_DN); getServerContext().getBackendConfigManager().deregisterBaseDN(CHANGELOG_BASE_DN); } catch (final DirectoryException e) { @@ -695,7 +698,7 @@ private SearchFilter buildSearchFilterFrom(final DN baseDN, final String attrName) { final RDN rdn = baseDN.rdn(); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); AttributeType attrType = getServerContext().getSchema().getAttributeType(attrName); final ByteString attrValue = rdn.getAttributeValue(attrType); if (attrValue != null) { @@ -1472,7 +1475,7 @@ final Map<AttributeType, List<Attribute>> operationalAttrs, final boolean addByType) { final Attribute a = addByType ? Attributes.create(getInstance().getServerContext().getSchema().getAttributeType(attrName), attrValue) ? Attributes.create(getServerContext().getSchema().getAttributeType(attrName), attrValue) : Attributes.create(attrName, attrValue); final AttributeType attrType = a.getAttributeDescription().getAttributeType(); final List<Attribute> attrList = Collections.singletonList(a); opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
@@ -192,7 +192,7 @@ // Construct the set of objectclasses to include in the base monitor entry. monitorObjectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); monitorObjectClasses.put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_MONITOR_ENTRY), OC_MONITOR_ENTRY); monitorObjectClasses.put(serverContext.getSchema().getObjectClass(OC_MONITOR_ENTRY), OC_MONITOR_ENTRY); // Create the set of base DNs that we will handle. In this case, it's just // the DN of the base monitor entry. @@ -624,7 +624,7 @@ */ private Entry getBranchMonitorEntry(final DN dn) { final ObjectClass monitorOC = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_MONITOR_BRANCH); final ObjectClass monitorOC = serverContext.getSchema().getObjectClass(OC_MONITOR_BRANCH); final HashMap<ObjectClass, String> monitorClasses = newObjectClasses(monitorOC, OC_MONITOR_BRANCH); final HashMap<AttributeType, List<Attribute>> monitorUserAttrs = new LinkedHashMap<>(); opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -21,9 +21,7 @@ import static org.opends.messages.BackendMessages.*; import static org.opends.messages.ConfigMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.BackendConfigManager.NamingContextFilter.PRIVATE; import static org.opends.server.core.BackendConfigManager.NamingContextFilter.PUBLIC; import static org.opends.server.core.BackendConfigManager.NamingContextFilter.TOP_LEVEL; import static org.opends.server.core.BackendConfigManager.NamingContextFilter.*; import static org.opends.server.util.CollectionUtils.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; @@ -37,6 +35,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; @@ -52,8 +51,8 @@ import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.server.config.server.RootDSEBackendCfg; import org.forgerock.util.Reject; import org.opends.server.api.LocalBackend; import org.opends.server.api.ClientConnection; import org.opends.server.api.LocalBackend; import org.opends.server.core.AddOperation; import org.opends.server.core.BackendConfigManager; import org.opends.server.core.BackendConfigManager.NamingContextFilter; @@ -190,7 +189,7 @@ // Construct the set of objectclasses to include in the root DSE entry. dseObjectClasses = new HashMap<>(2); dseObjectClasses.put(getTopObjectClass(), OC_TOP); dseObjectClasses.put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_ROOT_DSE), OC_ROOT_DSE); dseObjectClasses.put(serverContext.getSchema().getObjectClass(OC_ROOT_DSE), OC_ROOT_DSE); // Set the backend ID for this backend. The identifier needs to be // specific enough to avoid conflict with user backend identifiers. opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
@@ -190,7 +190,7 @@ // Construct the trust store base entry. LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(2); objectClasses.put(CoreSchema.getTopObjectClass(), OC_TOP); objectClasses.put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass("ds-cfg-branch"), "ds-cfg-branch"); objectClasses.put(serverContext.getSchema().getObjectClass("ds-cfg-branch"), "ds-cfg-branch"); LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(1); for (AVA ava : getBaseDN().rdn()) @@ -396,7 +396,7 @@ throws DirectoryException { // Make sure that the DN specifies a certificate alias. AttributeType t = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); AttributeType t = serverContext.getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); ByteString v = entryDN.rdn().getAttributeValue(t); if (v == null) { @@ -428,14 +428,14 @@ // Construct the certificate entry to return. LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2); ocMap.put(CoreSchema.getTopObjectClass(), OC_TOP); ocMap.put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_CRYPTO_INSTANCE_KEY), OC_CRYPTO_INSTANCE_KEY); ocMap.put(serverContext.getSchema().getObjectClass(OC_CRYPTO_INSTANCE_KEY), OC_CRYPTO_INSTANCE_KEY); LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(3); userAttrs.put(t, Attributes.createAsList(t, v)); t = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); t = serverContext.getSchema().getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); AttributeBuilder builder = new AttributeBuilder(t); builder.setOption("binary"); builder.add(certValue); @@ -551,7 +551,7 @@ if (scope != SearchScope.BASE_OBJECT && aliases.length != 0) { AttributeType certAliasType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); AttributeType certAliasType = serverContext.getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); for (String alias : aliases) { DN certDN = makeChildDN(getBaseDN(), certAliasType, alias); @@ -908,7 +908,7 @@ DN entryDN = entry.getName(); // Make sure that the DN specifies a certificate alias. AttributeType t = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); AttributeType t = serverContext.getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); ByteString v = entryDN.rdn().getAttributeValue(t); if (v == null) { @@ -925,7 +925,7 @@ throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, message); } if (entry.hasObjectClass(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_SELF_SIGNED_CERT_REQUEST))) if (entry.hasObjectClass(serverContext.getSchema().getObjectClass(OC_SELF_SIGNED_CERT_REQUEST))) { try { @@ -1024,7 +1024,7 @@ throws DirectoryException { // Make sure that the DN specifies a certificate alias. AttributeType t = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); AttributeType t = serverContext.getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); ByteString v = entryDN.rdn().getAttributeValue(t); if (v == null) { opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
@@ -411,7 +411,7 @@ { try { final MatchingRule rule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(ruleName); final MatchingRule rule = getSchema().getMatchingRule(ruleName); for (Indexer indexer : rule.createIndexers(options)) { indexers.put(indexer, false); @@ -1098,7 +1098,7 @@ return evaluateFilter(indexQueryFactory, IndexFilterType.EQUALITY, filter, debugBuffer, monitor); } MatchingRule rule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(matchRuleOID); MatchingRule rule = getSchema().getMatchingRule(matchRuleOID); if (!ruleHasAtLeastOneIndex(rule)) { if (monitor.isFilterUseEnabled()) @@ -1133,6 +1133,11 @@ } } private static Schema getSchema() { return DirectoryServer.getInstance().getServerContext().getSchema(); } private boolean ruleHasAtLeastOneIndex(MatchingRule rule) { for (Indexer indexer : rule.createIndexers(indexingOptions)) opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
@@ -38,14 +38,12 @@ import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.SearchScope; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.backends.pluggable.spi.Cursor; import org.opends.server.backends.pluggable.spi.ReadableTransaction; import org.opends.server.backends.pluggable.spi.StorageRuntimeException; import org.opends.server.backends.pluggable.spi.TreeName; import org.opends.server.backends.pluggable.spi.UpdateFunction; import org.opends.server.backends.pluggable.spi.WriteableTransaction; import org.opends.server.core.DirectoryServer; import org.opends.server.core.SearchOperation; import org.opends.server.types.Attribute; import org.opends.server.types.DirectoryException; @@ -74,12 +72,6 @@ private final int prefixRDNComponents; /** * The standard attribute type that is used to specify the set of referral * URLs in a referral entry. */ private final AttributeType referralType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_REFERRAL_URL); /** * A flag that indicates whether there are any referrals contained in this * tree. It should only be set to {@code false} when it is known that * there are no referrals. @@ -306,8 +298,7 @@ for (Modification mod : mods) { Attribute modAttr = mod.getAttribute(); AttributeType modAttrType = modAttr.getAttributeDescription().getAttributeType(); if (modAttrType.equals(referralType)) if (modAttr.getAttributeDescription().getAttributeType().hasName(ATTR_REFERRAL_URL)) { Attribute a = mod.getAttribute(); switch (mod.getModificationType().asEnum()) opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VerifyJob.java
@@ -43,6 +43,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ConditionResult; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.backends.VerifyConfig; import org.opends.server.backends.pluggable.AttributeIndex.MatchingRuleIndex; import org.opends.server.backends.pluggable.spi.Cursor; @@ -210,7 +211,8 @@ } else { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(lowerName); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attrType = schema.getAttributeType(lowerName); if (attrType.isPlaceHolder()) { throw new StorageRuntimeException(ERR_ATTRIBUTE_INDEX_NOT_CONFIGURED.get(index).toString()); opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java
@@ -16,6 +16,13 @@ */ package org.opends.server.backends.task; import static java.util.Calendar.*; import static org.opends.messages.BackendMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; @@ -29,24 +36,17 @@ import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.RDN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.types.Attribute; import org.opends.server.types.Attributes; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.InitializationException; import org.forgerock.opendj.ldap.RDN; import static java.util.Calendar.*; import static org.opends.messages.BackendMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; /** * This class defines a information about a recurring task, which will be used @@ -233,7 +233,7 @@ private Attribute getSingleAttribute(Entry taskEntry, String attrName, Arg1<Object> noEntryErrorMsg, Arg1<Object> multipleEntriesErrorMsg, Arg1<Object> noAttrValueErrorMsg) throws DirectoryException { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); AttributeType attrType = serverContext.getSchema().getAttributeType(attrName); List<Attribute> attrList = taskEntry.getAllAttributes(attrType); if (attrList.isEmpty()) { @@ -254,8 +254,6 @@ return attr; } /** * Retrieves the unique ID assigned to this recurring task. * @@ -341,7 +339,7 @@ String nextTaskIDName = NAME_PREFIX_TASK + "id"; nextTaskEntry.replaceAttribute(Attributes.create(nextTaskIDName, nextTaskID)); RDN nextTaskRDN = new RDN(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(nextTaskIDName), nextTaskID); RDN nextTaskRDN = new RDN(serverContext.getSchema().getAttributeType(nextTaskIDName), nextTaskID); DN nextTaskDN = taskScheduler.getTaskBackend().getScheduledTasksParentDN().child(nextTaskRDN); nextTaskEntry.setDN(nextTaskDN); opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
@@ -806,7 +806,7 @@ // We cannot do task logging if the schema is either destroyed or // not initialized eg during in-core restart from Restart task. // Bailing out if there is no schema available saves us from NPE. if (getServerContext().getSchemaHandler() == null) if (serverContext.getSchemaHandler() == null) { return; } @@ -823,7 +823,7 @@ String messageString = buildLogMessage(severity, message, exception); logMessages.add(messageString); final AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_LOG_MESSAGES); final AttributeType type = serverContext.getSchema().getAttributeType(ATTR_TASK_LOG_MESSAGES); final Attribute attr = taskEntry.getAttribute(AttributeDescription.create(type)); final AttributeBuilder builder = attr != null ? new AttributeBuilder(attr) : new AttributeBuilder(type); builder.add(messageString); opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java
@@ -1808,7 +1808,7 @@ throws DirectoryException { // Get the name of the class that implements the task logic. AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_CLASS); AttributeType attrType = serverContext.getSchema().getAttributeType(ATTR_TASK_CLASS); List<Attribute> attrList = entry.getAllAttributes(attrType); if (attrList.isEmpty()) { opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java
@@ -35,6 +35,7 @@ import org.forgerock.opendj.ldap.SortKey; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.MatchingRule; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; import org.opends.server.core.DirectoryServer; import org.opends.server.protocols.ldap.LDAPResultCode; @@ -98,7 +99,8 @@ { reader.readStartSequence(); String attrName = reader.readOctetStringAsString(); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attrType = schema.getAttributeType(attrName); if (attrType.isPlaceHolder()) { //This attribute is not defined in the schema. There is no point @@ -114,7 +116,7 @@ String orderingRuleID = reader.readOctetStringAsString(); try { orderingRule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(orderingRuleID); orderingRule = schema.getMatchingRule(orderingRuleID); } catch (UnknownSchemaElementException e) { @@ -421,7 +423,8 @@ List<SortKey> sortKeys = new ArrayList<>(); for(String[] decodedKey : decodedKeyList) { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(decodedKey[0]); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attrType = schema.getAttributeType(decodedKey[0]); if (attrType.isPlaceHolder()) { //This attribute is not defined in the schema. There is no point @@ -434,7 +437,7 @@ { try { orderingRule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(decodedKey[1]); orderingRule = schema.getMatchingRule(decodedKey[1]); } catch (UnknownSchemaElementException e) { opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
@@ -16,6 +16,13 @@ */ package org.opends.server.core; import static org.opends.messages.CoreMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.loggers.AccessLogger.*; import static org.opends.server.util.CollectionUtils.*; import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -29,6 +36,7 @@ import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.api.ClientConnection; import org.opends.server.protocols.ldap.LDAPAttribute; import org.opends.server.protocols.ldap.LDAPResultCode; @@ -47,13 +55,6 @@ import org.opends.server.types.operation.PreParseAddOperation; import org.opends.server.workflowelement.localbackend.LocalBackendAddOperation; import static org.opends.messages.CoreMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.loggers.AccessLogger.*; import static org.opends.server.util.CollectionUtils.*; import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*; /** * This class defines an operation that may be used to add a new entry to the * Directory Server. @@ -277,6 +278,7 @@ userAttributes = new HashMap<>(); operationalAttributes = new HashMap<>(); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); for (RawAttribute a : rawAttributes) { try @@ -319,7 +321,7 @@ for (ByteString os : a.getValues()) { String ocName = os.toString(); objectClasses.put(getInstance().getServerContext().getSchema().getObjectClass(ocName), ocName); objectClasses.put(schema.getObjectClass(ocName), ocName); } } else if (attrType.isOperational()) opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java
@@ -27,6 +27,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.api.ClientConnection; import org.opends.server.types.AbstractOperation; import org.opends.server.types.CancelResult; @@ -232,7 +233,8 @@ baseName = toLowerCase(rawAttributeType); attributeOptions = null; } return AttributeDescription.create(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(baseName), attributeOptions); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); return AttributeDescription.create(schema.getAttributeType(baseName), attributeOptions); } @Override opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicyState.java
@@ -47,6 +47,7 @@ import org.forgerock.opendj.ldap.ModificationType; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.meta.PasswordPolicyCfgDefn; import org.opends.server.api.AccountStatusNotificationHandler; import org.opends.server.api.AuthenticationPolicyState; @@ -321,7 +322,7 @@ private long getGeneralizedTime0(Entry userEntry, String attrName) throws DirectoryException { return getGeneralizedTime(userEntry, DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName)); return getGeneralizedTime(userEntry, getSchema().getAttributeType(attrName)); } /** @@ -551,7 +552,7 @@ return authFailureTimes; } AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME); AttributeType type = getSchema().getAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME); try { authFailureTimes = getGeneralizedTimes(type); @@ -620,6 +621,11 @@ return authFailureTimes; } private static Schema getSchema() { return DirectoryServer.getInstance().getServerContext().getSchema(); } /** * Updates the set of authentication failure times to include the current time. * If the number of failures reaches the policy configuration limit, lock the account. @@ -642,7 +648,7 @@ failureTimes.add(highestFailureTime); // And the attribute in the user entry AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME); AttributeType type = getSchema().getAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME); Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestFailureTime)); modifications.add(new Modification(ModificationType.ADD, addAttr, true)); @@ -723,7 +729,7 @@ return failureLockedTime; } AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_LOCKED_TIME); AttributeType type = getSchema().getAttributeType(OP_ATTR_PWPOLICY_LOCKED_TIME); try { failureLockedTime = getGeneralizedTime(userEntry, type); @@ -1174,10 +1180,9 @@ return false; } AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_RESET_REQUIRED); try { mustChangePassword = getBoolean(userEntry, type); mustChangePassword = getBoolean(userEntry, OP_ATTR_PWPOLICY_RESET_REQUIRED); } catch (Exception e) { @@ -1234,7 +1239,7 @@ private void clearAttribute(String attrName) { clearAttribute(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName)); clearAttribute(getSchema().getAttributeType(attrName)); } private void clearAttribute(AttributeType type) @@ -1734,7 +1739,7 @@ } this.warnedTime = warnedTime; AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_WARNED_TIME); AttributeType type = getSchema().getAttributeType(OP_ATTR_PWPOLICY_WARNED_TIME); replaceAttribute(Attributes.create(type, GeneralizedTimeSyntax.createGeneralizedTimeValue(currentTime))); if (logger.isTraceEnabled()) @@ -1766,7 +1771,7 @@ { if (graceLoginTimes == null) { AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); AttributeType type = getSchema().getAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); try { graceLoginTimes = getGeneralizedTimes(type); @@ -1813,7 +1818,7 @@ long highestGraceTime = computeHighestTime(graceTimes); graceTimes.add(highestGraceTime); // graceTimes == this.graceLoginTimes AttributeType type = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); AttributeType type = getSchema().getAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestGraceTime)); modifications.add(new Modification(ModificationType.ADD, addAttr, true)); } @@ -2347,7 +2352,7 @@ private TreeMap<Long,ByteString> getSortedHistoryValues(List<Attribute> removeAttrs) { TreeMap<Long, ByteString> historyMap = new TreeMap<>(); AttributeType historyType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC); AttributeType historyType = getSchema().getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC); for (Attribute a : userEntry.getAllAttributes(historyType)) { for (ByteString v : a) @@ -2561,7 +2566,7 @@ // If there is a maximum number of values to retain and we would be over the limit with the new value, // then get rid of enough values (oldest first) to satisfy the count. AttributeType historyType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC); AttributeType historyType = getSchema().getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC); int historyCount = passwordPolicy.getPasswordHistoryCount(); if (historyCount > 0 && historyMap.size() >= historyCount) { @@ -2659,7 +2664,7 @@ public String[] getPasswordHistoryValues() { ArrayList<String> historyValues = new ArrayList<>(); AttributeType historyType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC); AttributeType historyType = getSchema().getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC); for (Attribute a : userEntry.getAllAttributes(historyType)) { for (ByteString v : a) opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java
@@ -36,6 +36,7 @@ import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.meta.PasswordPolicyCfgDefn.StateUpdateFailurePolicy; import org.forgerock.opendj.server.config.server.PasswordValidatorCfg; import org.opends.server.api.AccountStatusNotificationHandler; @@ -140,7 +141,8 @@ public SubentryPasswordPolicy(SubEntry subentry) throws DirectoryException { // Determine if this is a password policy subentry. ObjectClass pwdPolicyOC = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(PWD_OC_POLICY); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); ObjectClass pwdPolicyOC = schema.getObjectClass(PWD_OC_POLICY); Entry entry = subentry.getEntry(); Map<ObjectClass, String> objectClasses = entry.getObjectClasses(); if (pwdPolicyOC.isPlaceHolder()) @@ -177,7 +179,7 @@ String value = getAttrValue(entry, PWD_ATTR_ATTRIBUTE); if (value != null && value.length() > 0) { this.pPasswordAttribute = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(value); this.pPasswordAttribute = schema.getAttributeType(value); if (this.pPasswordAttribute.isPlaceHolder()) { throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, @@ -245,12 +247,12 @@ // Now check for the pwdValidatorPolicy OC and its attribute. // Determine if this is a password validator policy object class. ObjectClass pwdValidatorPolicyOC = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(PWD_OC_VALIDATORPOLICY); ObjectClass pwdValidatorPolicyOC = schema.getObjectClass(PWD_OC_VALIDATORPOLICY); if (!pwdValidatorPolicyOC.isPlaceHolder() && objectClasses.containsKey(pwdValidatorPolicyOC)) { AttributeType pwdAttrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(PWD_ATTR_VALIDATOR); schema.getAttributeType(PWD_ATTR_VALIDATOR); for (Attribute attr : entry.getAllAttributes(pwdAttrType)) { for (ByteString val : attr) @@ -369,8 +371,7 @@ */ private String getAttrValue(Entry entry, String pwdAttrName) { AttributeType pwdAttrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(pwdAttrName); for (Attribute attr : entry.getAllAttributes(pwdAttrType)) for (Attribute attr : entry.getAllAttributes(pwdAttrName)) { for (ByteString value : attr) { opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
@@ -77,6 +77,7 @@ 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.Schema; import org.forgerock.opendj.server.config.server.CryptoManagerCfg; import org.forgerock.util.Reject; import org.opends.admin.ads.ADSContext; @@ -242,20 +243,21 @@ throws ConfigException, InitializationException { this.serverContext = serverContext; if (!schemaInitDone) { final Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); // Initialize various schema references. attrKeyID = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); attrPublicKeyCertificate = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); attrTransformation = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME); attrMacAlgorithm = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_MAC_ALGORITHM_NAME); attrSymmetricKey = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_SYMMETRIC_KEY); attrInitVectorLength = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_INIT_VECTOR_LENGTH_BITS); attrKeyLength = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_LENGTH_BITS); attrCompromisedTime = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_COMPROMISED_TIME); attrKeyID = schema.getAttributeType(ATTR_CRYPTO_KEY_ID); attrPublicKeyCertificate = schema.getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); attrTransformation = schema.getAttributeType(ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME); attrMacAlgorithm = schema.getAttributeType(ATTR_CRYPTO_MAC_ALGORITHM_NAME); attrSymmetricKey = schema.getAttributeType(ATTR_CRYPTO_SYMMETRIC_KEY); attrInitVectorLength = schema.getAttributeType(ATTR_CRYPTO_INIT_VECTOR_LENGTH_BITS); attrKeyLength = schema.getAttributeType(ATTR_CRYPTO_KEY_LENGTH_BITS); attrCompromisedTime = schema.getAttributeType(ATTR_CRYPTO_KEY_COMPROMISED_TIME); // TODO: ConfigConstants ocCertRequest = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass("ds-cfg-self-signed-cert-request"); ocInstanceKey = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_CRYPTO_INSTANCE_KEY); ocCipherKey = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_CRYPTO_CIPHER_KEY); ocMacKey = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_CRYPTO_MAC_KEY); ocCertRequest = schema.getObjectClass("ds-cfg-self-signed-cert-request"); ocInstanceKey = schema.getObjectClass(OC_CRYPTO_INSTANCE_KEY); ocCipherKey = schema.getObjectClass(OC_CRYPTO_CIPHER_KEY); ocMacKey = schema.getObjectClass(OC_CRYPTO_MAC_KEY); localTruststoreDN = DN.valueOf(DN_TRUST_STORE_ROOT); DN adminSuffixDN = ADSContext.getAdministrationSuffixDN(); opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
@@ -19,7 +19,6 @@ import static org.opends.messages.CoreMessages.*; import static org.opends.server.api.plugin.PluginType.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.internal.Requests.*; import static org.opends.server.util.ServerConstants.*; @@ -41,6 +40,7 @@ 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.Schema; import org.opends.admin.ads.ADSContext; import org.opends.server.api.LocalBackend; import org.opends.server.api.LocalBackendInitializationListener; @@ -52,6 +52,7 @@ import org.opends.server.core.AddOperation; import org.opends.server.core.DeleteOperation; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.protocols.internal.InternalSearchOperation; import org.opends.server.protocols.internal.SearchRequest; import org.opends.server.protocols.ldap.LDAPControl; @@ -78,24 +79,22 @@ /** The debug log tracer for this object. */ private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** Dummy configuration DN. */ private static final String CONFIG_DN = "cn=Crypto Manager Sync,cn=config"; /** The DN of the administration suffix. */ private DN adminSuffixDN; /** The DN of the instance keys container within the admin suffix. */ private DN instanceKeysDN; /** The DN of the secret keys container within the admin suffix. */ private DN secretKeysDN; /** The DN of the trust store root. */ private DN trustStoreRootDN; /** The attribute type that is used to specify a server instance certificate. */ private final AttributeType attrCert; /** The attribute type that holds a server certificate identifier. */ private final AttributeType attrAlias; /** The attribute type that holds the time a key was compromised. */ private final AttributeType attrCompromisedTime; @@ -104,16 +103,11 @@ /** The instance key objectclass. */ private final ObjectClass ocInstanceKey; /** The cipher key objectclass. */ private final ObjectClass ocCipherKey; /** The mac key objectclass. */ private final ObjectClass ocMacKey; /** Dummy configuration DN. */ private static final String CONFIG_DN = "cn=Crypto Manager Sync,cn=config"; /** * Creates a new instance of this trust store synchronization thread. * @@ -136,8 +130,8 @@ catch (CryptoManagerException ex) { throw new InitializationException(ex.getMessageObject()); } DirectoryServer.getInstance().getServerContext().getBackendConfigManager() .registerLocalBackendInitializationListener(this); ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); serverContext.getBackendConfigManager().registerLocalBackendInitializationListener(this); try { @@ -156,16 +150,15 @@ { } ocInstanceKey = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_CRYPTO_INSTANCE_KEY); ocCipherKey = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_CRYPTO_CIPHER_KEY); ocMacKey = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_CRYPTO_MAC_KEY); Schema schema = serverContext.getSchema(); ocInstanceKey = schema.getObjectClass(OC_CRYPTO_INSTANCE_KEY); ocCipherKey = schema.getObjectClass(OC_CRYPTO_CIPHER_KEY); ocMacKey = schema.getObjectClass(OC_CRYPTO_MAC_KEY); attrCert = schema.getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); attrAlias = schema.getAttributeType(ATTR_CRYPTO_KEY_ID); attrCompromisedTime = schema.getAttributeType(ATTR_CRYPTO_KEY_COMPROMISED_TIME); attrCert = getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); attrAlias = getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_ID); attrCompromisedTime = getInstance().getServerContext().getSchema().getAttributeType(ATTR_CRYPTO_KEY_COMPROMISED_TIME); if (DirectoryServer.getInstance().getServerContext() .getBackendConfigManager().getLocalBackendWithBaseDN(adminSuffixDN) != null) if (serverContext.getBackendConfigManager().getLocalBackendWithBaseDN(adminSuffixDN) != null) { searchAdminSuffix(); } opendj-server-legacy/src/main/java/org/opends/server/extensions/DynamicGroup.java
@@ -31,7 +31,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.SearchScope; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.server.DynamicGroupImplementationCfg; import org.opends.server.api.Group; import org.opends.server.core.DirectoryServer; @@ -113,8 +113,7 @@ // Get the memberURL attribute from the entry, if there is one, and parse // out the LDAP URLs that it contains. LinkedHashSet<LDAPURL> memberURLs = new LinkedHashSet<>(); AttributeType memberURLType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_MEMBER_URL_LC); for (Attribute a : groupEntry.getAllAttributes(memberURLType)) for (Attribute a : groupEntry.getAllAttributes(ATTR_MEMBER_URL_LC)) { for (ByteString v : a) { @@ -149,7 +148,8 @@ ifNull(entry); // FIXME -- This needs to exclude enhanced groups once we have support for them. return entry.hasObjectClass(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_GROUP_OF_URLS_LC)); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); return entry.hasObjectClass(schema.getObjectClass(OC_GROUP_OF_URLS_LC)); } @Override opendj-server-legacy/src/main/java/org/opends/server/extensions/ExternalSASLMechanismHandler.java
@@ -27,6 +27,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.reactive.LDAPClientConnection2; import org.forgerock.opendj.server.config.server.ExternalSASLMechanismHandlerCfg; import org.forgerock.opendj.server.config.server.SASLMechanismHandlerCfg; @@ -107,7 +108,8 @@ certificateAttributeType = configuration.getCertificateAttribute(); if (certificateAttributeType == null) { certificateAttributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(DEFAULT_VALIDATION_CERT_ATTRIBUTE); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); certificateAttributeType = schema.getAttributeType(DEFAULT_VALIDATION_CERT_ATTRIBUTE); } @@ -346,7 +348,8 @@ AttributeType newCertificateType = configuration.getCertificateAttribute(); if (newCertificateType == null) { newCertificateType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(DEFAULT_VALIDATION_CERT_ATTRIBUTE); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); newCertificateType = schema.getAttributeType(DEFAULT_VALIDATION_CERT_ATTRIBUTE); } opendj-server-legacy/src/main/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
@@ -15,6 +15,12 @@ */ package org.opends.server.extensions; import static org.opends.messages.ExtensionMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.ldap.LDAPConstants.*; import static org.opends.server.util.StaticUtils.*; import java.io.BufferedReader; import java.io.Closeable; import java.io.File; @@ -28,14 +34,14 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; import java.util.IllegalFormatConversionException; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.MissingFormatArgumentException; import java.util.Queue; import java.util.Set; import java.util.IllegalFormatConversionException; import java.util.MissingFormatArgumentException; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -64,12 +70,13 @@ import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.DecodeException; import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; import org.forgerock.opendj.ldap.Filter; import org.forgerock.opendj.ldap.GeneralizedTime; import org.forgerock.opendj.ldap.ModificationType; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.SearchScope; import org.forgerock.opendj.ldap.Filter; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.meta.LDAPPassThroughAuthenticationPolicyCfgDefn.MappingPolicy; import org.forgerock.opendj.server.config.server.LDAPPassThroughAuthenticationPolicyCfg; import org.opends.server.api.AuthenticationPolicy; @@ -106,13 +113,6 @@ import org.opends.server.util.StaticUtils; import org.opends.server.util.TimeThread; import static org.opends.messages.ExtensionMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.ldap.LDAPConstants.*; import static org.opends.server.util.StaticUtils.*; /** LDAP pass through authentication policy implementation. */ public final class LDAPPassThroughAuthenticationPolicyFactory implements AuthenticationPolicyFactory<LDAPPassThroughAuthenticationPolicyCfg> @@ -1367,8 +1367,9 @@ { super(userEntry); this.cachedPasswordAttribute = getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PTAPOLICY_CACHED_PASSWORD); this.cachedPasswordTimeAttribute = getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PTAPOLICY_CACHED_PASSWORD_TIME); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); this.cachedPasswordAttribute = schema.getAttributeType(OP_ATTR_PTAPOLICY_CACHED_PASSWORD); this.cachedPasswordTimeAttribute = schema.getAttributeType(OP_ATTR_PTAPOLICY_CACHED_PASSWORD_TIME); } @Override opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java
@@ -37,6 +37,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.util.Utils; import org.forgerock.opendj.config.server.ConfigurationChangeListener; import org.forgerock.opendj.server.config.server.AccountStatusNotificationHandlerCfg; @@ -366,7 +367,8 @@ else if (lowerTokenStr.startsWith("notification-user-attr:")) { String attrName = lowerTokenStr.substring(23); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attrType = schema.getAttributeType(attrName); if (attrType.isPlaceHolder()) { throw new ConfigException( opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
@@ -40,6 +40,7 @@ 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.Schema; import org.forgerock.opendj.server.config.server.GroupImplementationCfg; import org.forgerock.opendj.server.config.server.StaticGroupImplementationCfg; import org.forgerock.util.Reject; @@ -268,7 +269,8 @@ private boolean hasObjectClass(Entry entry, String ocName) { return entry.hasObjectClass(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName)); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); return entry.hasObjectClass(schema.getObjectClass(ocName)); } @Override opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java
@@ -18,8 +18,7 @@ package org.opends.server.extensions; import static org.opends.messages.ExtensionMessages.*; import static org.opends.server.core.BackendConfigManager.NamingContextFilter.PUBLIC; import static org.opends.server.core.BackendConfigManager.NamingContextFilter.TOP_LEVEL; import static org.opends.server.core.BackendConfigManager.NamingContextFilter.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.internal.Requests.*; import static org.opends.server.util.CollectionUtils.*; @@ -50,10 +49,11 @@ import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.server.config.server.CertificateMapperCfg; import org.forgerock.opendj.server.config.server.SubjectAttributeToUserAttributeCertificateMapperCfg; import org.opends.server.api.LocalBackend; import org.opends.server.api.CertificateMapper; import org.opends.server.api.LocalBackend; import org.opends.server.core.BackendConfigManager; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.protocols.internal.InternalClientConnection; import org.opends.server.protocols.internal.InternalSearchOperation; import org.opends.server.protocols.internal.SearchRequest; @@ -118,8 +118,7 @@ // Make sure that all the user attributes are configured with equality // indexes in all appropriate backends. Set<DN> cfgBaseDNs = getUserBaseDNs(configuration); BackendConfigManager backendConfigManager = DirectoryServer.getInstance().getServerContext().getBackendConfigManager(); BackendConfigManager backendConfigManager = getServerContext().getBackendConfigManager(); for (DN baseDN : cfgBaseDNs) { for (AttributeType t : attributeMap.values()) @@ -138,6 +137,11 @@ requestedAttributes = newLinkedHashSet("*", "+"); } private static ServerContext getServerContext() { return DirectoryServer.getInstance().getServerContext(); } @Override public void finalizeCertificateMapper() { @@ -297,8 +301,7 @@ // Make sure that all the user attributes are configured with equality // indexes in all appropriate backends. Set<DN> cfgBaseDNs = getUserBaseDNs(configuration); BackendConfigManager backendConfigManager = DirectoryServer.getInstance().getServerContext().getBackendConfigManager(); BackendConfigManager backendConfigManager = getServerContext().getBackendConfigManager(); for (DN baseDN : cfgBaseDNs) { for (AttributeType t : newAttributeMap.values()) @@ -332,8 +335,7 @@ Set<DN> baseDNs = config.getUserBaseDN(); if (baseDNs == null || baseDNs.isEmpty()) { baseDNs = DirectoryServer.getInstance().getServerContext().getBackendConfigManager() .getNamingContexts(PUBLIC, TOP_LEVEL); baseDNs = getServerContext().getBackendConfigManager().getNamingContexts(PUBLIC, TOP_LEVEL); } return baseDNs; } @@ -372,7 +374,7 @@ return null; } AttributeType userAttrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(userAttrName); AttributeType userAttrType = getServerContext().getSchema().getAttributeType(userAttrName); if (userAttrType.isPlaceHolder()) { ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); @@ -393,6 +395,6 @@ private static String normalizeAttributeName(String attrName) { return toLowerCase(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName).getNameOrOID()); return toLowerCase(getServerContext().getSchema().getAttributeType(attrName).getNameOrOID()); } } opendj-server-legacy/src/main/java/org/opends/server/extensions/VirtualStaticGroup.java
@@ -30,7 +30,7 @@ import org.forgerock.opendj.ldap.DN; 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.Schema; import org.forgerock.opendj.server.config.server.VirtualStaticGroupImplementationCfg; import org.opends.server.api.Group; import org.opends.server.core.DirectoryServer; @@ -109,8 +109,7 @@ // Get the target group DN attribute from the entry, if there is one. DN targetDN = null; AttributeType targetType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_TARGET_GROUP_DN); for (Attribute a : groupEntry.getAllAttributes(targetType)) for (Attribute a : groupEntry.getAllAttributes(ATTR_TARGET_GROUP_DN)) { for (ByteString v : a) { @@ -160,7 +159,8 @@ ifNull(entry); // FIXME -- This needs to exclude enhanced groups once we have support for them. return entry.hasObjectClass(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_VIRTUAL_STATIC_GROUP)); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); return entry.hasObjectClass(schema.getObjectClass(OC_VIRTUAL_STATIC_GROUP)); } @Override @@ -227,7 +227,7 @@ return false; } Group targetGroup = Group<?> targetGroup = DirectoryServer.getGroupManager().getGroupInstance(targetGroupDN); if (targetGroup == null) { @@ -255,7 +255,7 @@ return false; } Group targetGroup = Group<?> targetGroup = DirectoryServer.getGroupManager().getGroupInstance(targetGroupDN); if (targetGroup == null) { @@ -288,7 +288,7 @@ public MemberList getMembers() throws DirectoryException { Group targetGroup = Group<?> targetGroup = DirectoryServer.getGroupManager().getGroupInstance(targetGroupDN); if (targetGroup == null) { @@ -311,7 +311,7 @@ SearchFilter filter) throws DirectoryException { Group targetGroup = Group<?> targetGroup = DirectoryServer.getGroupManager().getGroupInstance(targetGroupDN); if (targetGroup == null) { opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java
@@ -37,6 +37,7 @@ import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.meta.PluginCfgDefn; import org.forgerock.opendj.server.config.server.PasswordPolicyImportPluginCfg; import org.forgerock.opendj.server.config.server.PluginCfg; @@ -106,7 +107,8 @@ { configuration.addPasswordPolicyImportChangeListener(this); customPolicyAttribute = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PWPOLICY_POLICY_DN); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); customPolicyAttribute = schema.getAttributeType(OP_ATTR_PWPOLICY_POLICY_DN); // Make sure that the plugin has been enabled for the appropriate types. for (PluginType t : pluginTypes) opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -46,6 +46,7 @@ import org.forgerock.opendj.ldap.requests.ModifyRequest; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.api.ClientConnection; import org.opends.server.api.ConnectionHandler; import org.opends.server.core.AddOperation; @@ -152,17 +153,19 @@ String fullDNString = shortDNString + ",cn=Root DNs,cn=config"; try { Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(); put(objectClasses, getTopObjectClass()); put(objectClasses, getPersonObjectClass()); put(objectClasses, DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(OC_ROOT_DN)); put(objectClasses, schema.getObjectClass(OC_ROOT_DN)); LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(); put(userAttrs, ATTR_COMMON_NAME, commonName); put(userAttrs, ATTR_SN, commonName); put(userAttrs, ATTR_ROOTDN_ALTERNATE_BIND_DN, shortDNString); AttributeType privType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PRIVILEGE_NAME); AttributeType privType = schema.getAttributeType(OP_ATTR_PRIVILEGE_NAME); AttributeBuilder builder = new AttributeBuilder(privType); for (Privilege p : Privilege.getDefaultRootPrivileges()) { @@ -198,10 +201,10 @@ objectClasses.put(oc, oc.getNameOrOID()); } private void put(Map<AttributeType, List<Attribute>> Attrs, String attrName, String value) private void put(Map<AttributeType, List<Attribute>> attrsMap, String attrName, String value) { List<Attribute> attrs = newLinkedList(Attributes.create(attrName, value)); Attrs.put(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName), attrs); Attribute attr = Attributes.create(attrName, value); attrsMap.put(attr.getAttributeDescription().getAttributeType(), newLinkedList(attr)); } /** @@ -802,6 +805,7 @@ public AddOperation processAdd(AddChangeRecordEntry addRecord) { Entry e = newEntry(addRecord.getDN()); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); ArrayList<ByteString> duplicateValues = new ArrayList<>(); for (Attribute a : addRecord.getAttributes()) @@ -811,7 +815,7 @@ for (ByteString v : a) { String ocName = v.toString(); e.getObjectClasses().put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName), ocName); e.getObjectClasses().put(schema.getObjectClass(ocName), ocName); } } else opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
@@ -33,6 +33,7 @@ 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.Schema; import org.opends.server.core.DirectoryServer; import org.opends.server.replication.common.CSN; import org.opends.server.replication.protocol.OperationContext; @@ -259,7 +260,8 @@ */ public static void setHistoricalAttrToOperation(PreOperationAddOperation addOperation) { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attrType = schema.getAttributeType(HISTORICAL_ATTRIBUTE_NAME); String attrValue = encodeHistorical(OperationContext.getCSN(addOperation), "add"); List<Attribute> attrs = Attributes.createAsList(attrType, attrValue); addOperation.setAttribute(attrType, attrs); opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -16,6 +16,9 @@ */ package org.opends.server.replication.plugin; import static org.opends.messages.ReplicationMessages.*; import static org.opends.server.replication.plugin.LDAPReplicationDomain.*; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; @@ -26,6 +29,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.config.server.ConfigChangeResult; import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.config.server.ConfigurationChangeListener; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.server.config.server.FractionalLDIFImportPluginCfg; @@ -34,11 +38,9 @@ import org.forgerock.opendj.server.config.server.ReplicationSynchronizationProviderCfg; import org.forgerock.opendj.server.config.server.RootCfg; import org.forgerock.util.Utils; import org.forgerock.opendj.config.server.ConfigurationChangeListener; import org.opends.server.api.plugin.DirectoryServerPlugin; import org.opends.server.api.plugin.PluginResult; import org.opends.server.api.plugin.PluginType; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.replication.plugin.LDAPReplicationDomain.FractionalConfig; import org.opends.server.types.Attribute; @@ -46,9 +48,6 @@ import org.opends.server.types.Entry; import org.opends.server.types.LDIFImportConfig; import static org.opends.messages.ReplicationMessages.*; import static org.opends.server.replication.plugin.LDAPReplicationDomain.*; /** * This class implements a Directory Server plugin that is used in fractional * replication to initialize a just configured fractional domain (when an online @@ -401,8 +400,8 @@ private Attribute getAttribute(String attributeName, Entry entry) { List<Attribute> attrs = entry.getAllAttributes(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attributeName)); return !attrs.isEmpty() ? attrs.get(0) : null; Iterator<Attribute> attrs = entry.getAllAttributes(attributeName).iterator(); return attrs.hasNext() ? attrs.next() : null; } /** opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -98,6 +98,7 @@ import org.opends.server.core.ModifyDNOperationBasis; import org.opends.server.core.ModifyOperation; import org.opends.server.core.ModifyOperationBasis; import org.opends.server.core.ServerContext; import org.opends.server.protocols.internal.InternalClientConnection; import org.opends.server.protocols.internal.InternalSearchListener; import org.opends.server.protocols.internal.InternalSearchOperation; @@ -594,7 +595,7 @@ // register as an AlertGenerator DirectoryServer.registerAlertGenerator(this); DirectoryServer.getInstance().getServerContext().getBackendConfigManager() getServerContext().getBackendConfigManager() .registerLocalBackendInitializationListener(this); DirectoryServer.registerShutdownListener(this); @@ -764,11 +765,10 @@ final SearchResultEntry resultEntry = getFirstResult(searchOperation); if (resultEntry != null) { AttributeType synchronizationGenIDType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(REPLICATION_GENERATION_ID); List<Attribute> attrs = resultEntry.getAllAttributes(synchronizationGenIDType); if (!attrs.isEmpty()) Iterator<Attribute> attrs = resultEntry.getAllAttributes(REPLICATION_GENERATION_ID).iterator(); if (attrs.hasNext()) { Attribute attr = attrs.get(0); Attribute attr = attrs.next(); if (attr.size() == 1) { return resultEntry; @@ -783,9 +783,14 @@ return null; } private static ServerContext getServerContext() { return DirectoryServer.getInstance().getServerContext(); } private Iterator<ByteString> getAttributeValueIterator(SearchResultEntry resultEntry, String attrName) { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); AttributeType attrType = getServerContext().getSchema().getAttributeType(attrName); List<Attribute> exclAttrs = resultEntry.getAllAttributes(attrType); if (!exclAttrs.isEmpty()) { @@ -887,7 +892,7 @@ } // Check consistency of all classes attributes Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); Schema schema = getServerContext().getSchema(); /* * For each attribute in attributes1, check there is the matching * one in attributes2. @@ -965,7 +970,7 @@ */ // Check consistency of specific classes attributes Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); Schema schema = getServerContext().getSchema(); int fractionalMode = newFractionalConfig.fractionalConfigToInt(); for (Map.Entry<String, Set<String>> entry : newFractionalSpecificClassesAttributes.entrySet()) { @@ -1363,7 +1368,7 @@ Set<AttributeType> results = new HashSet<>(); for (String attrName : fractionalConcernedAttributes) { results.add(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName)); results.add(getServerContext().getSchema().getAttributeType(attrName)); } return results; } @@ -1669,7 +1674,7 @@ } DN entryDN = addOperation.getEntryDN(); DN parentDnFromEntryDn = DirectoryServer.getInstance().getServerContext().getBackendConfigManager() DN parentDnFromEntryDn = getServerContext().getBackendConfigManager() .getParentDNInSuffix(entryDN); if (parentDnFromEntryDn != null && !parentDnFromCtx.equals(parentDnFromEntryDn)) @@ -1961,7 +1966,7 @@ final CSN csn = generateCSN(addOperation); final String entryUUID = getEntryUUID(addOperation); final AddContext ctx = new AddContext(csn, entryUUID, findEntryUUID(DirectoryServer.getInstance().getServerContext().getBackendConfigManager() findEntryUUID(getServerContext().getBackendConfigManager() .getParentDNInSuffix(addOperation.getEntryDN()))); addOperation.setAttachment(SYNCHROCONTEXT, ctx); } @@ -2239,7 +2244,7 @@ } DirectoryServer.deregisterAlertGenerator(this); DirectoryServer.getInstance().getServerContext().getBackendConfigManager() getServerContext().getBackendConfigManager() .deregisterLocalBackendInitializationListener(this); DirectoryServer.deregisterShutdownListener(this); @@ -3442,7 +3447,7 @@ Set<AttributeType> includeAttributes = new HashSet<>(); for (String attrName : includeAttributeStrings) { includeAttributes.add(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName)); includeAttributes.add(getServerContext().getSchema().getAttributeType(attrName)); } exportConfig.setIncludeAttributes(includeAttributes); } @@ -3570,7 +3575,7 @@ // Process import preBackendImport(backend); backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); backend.importLDIF(importConfig, getServerContext()); } catch(Exception e) { @@ -3697,7 +3702,7 @@ */ private LocalBackend<?> getBackend() { return DirectoryServer.getInstance().getServerContext().getBackendConfigManager() return getServerContext().getBackendConfigManager() .findLocalBackendForEntry(getBaseDN()); } @@ -3765,7 +3770,7 @@ } // Check that the base DN is configured as a base-dn of the directory server if (DirectoryServer.getInstance().getServerContext().getBackendConfigManager().findLocalBackendForEntry(dn) == null) if (getServerContext().getBackendConfigManager().findLocalBackendForEntry(dn) == null) { unacceptableReasons.add(ERR_UNKNOWN_DN.get(dn)); return false; @@ -4432,7 +4437,7 @@ if (name.startsWith("@")) { String ocName = name.substring(1); ObjectClass objectClass = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName); ObjectClass objectClass = getServerContext().getSchema().getObjectClass(ocName); if (!objectClass.isPlaceHolder()) { for (AttributeType at : objectClass.getRequiredAttributes()) opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
@@ -16,17 +16,21 @@ */ package org.opends.server.replication.plugin; import static org.opends.messages.ReplicationMessages.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.internal.Requests.*; import static org.opends.server.replication.plugin.EntryHistorical.*; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ModificationType; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.SearchScope; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ModifyOperationBasis; import org.opends.server.protocols.internal.InternalSearchOperation; import org.opends.server.protocols.internal.SearchRequest; @@ -35,16 +39,10 @@ import org.opends.server.replication.common.CSN; import org.opends.server.replication.common.ServerState; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.RawModification; import org.opends.server.types.SearchResultEntry; import static org.opends.messages.ReplicationMessages.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.internal.Requests.*; import static org.opends.server.replication.plugin.EntryHistorical.*; /** * This class implements a ServerState that is stored in the backend * used to store the synchronized data and that is therefore persistent @@ -211,11 +209,10 @@ */ private void updateStateFromEntry(SearchResultEntry resultEntry) { AttributeType synchronizationStateType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(REPLICATION_STATE); List<Attribute> attrs = resultEntry.getAllAttributes(synchronizationStateType); if (!attrs.isEmpty()) Iterator<Attribute> attrs = resultEntry.getAllAttributes(REPLICATION_STATE).iterator(); if (attrs.hasNext()) { for (ByteString value : attrs.get(0)) for (ByteString value : attrs.next()) { update(new CSN(value.toString())); } @@ -310,8 +307,6 @@ */ private final void checkAndUpdateServerState() { final AttributeType histType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME); // Retrieves the entries that have changed since the // maxCsn stored in the serverState synchronized (this) @@ -344,7 +339,7 @@ CSN dbMaxCSN = serverStateMaxCSN; for (SearchResultEntry resEntry : op.getSearchEntries()) { for (ByteString attrValue : resEntry.getAllAttributes(histType).get(0)) for (ByteString attrValue : resEntry.getAllAttributes(HISTORICAL_ATTRIBUTE_NAME).iterator().next()) { HistoricalAttributeValue histVal = new HistoricalAttributeValue(attrValue.toString()); opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
@@ -47,6 +47,7 @@ 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.Schema; import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.ConflictBehavior; import org.forgerock.opendj.server.config.server.ReplicationServerCfg; import org.forgerock.opendj.server.config.server.UserDefinedVirtualAttributeCfg; @@ -54,6 +55,7 @@ import org.opends.server.backends.ChangelogBackend; import org.opends.server.core.BackendConfigManager; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.crypto.CryptoSuite; import org.opends.server.replication.common.CSN; import org.opends.server.replication.common.MultiDomainServerState; @@ -174,7 +176,8 @@ this.domainPredicate = predicate; enableExternalChangeLog(); cryptoSuite = DirectoryServer.getInstance().getServerContext().getCryptoManager(). ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); cryptoSuite = serverContext.getCryptoManager(). newCryptoSuite(cfg.getCipherTransformation(), cfg.getCipherKeyLength(), cfg.isConfidentialityEnabled()); this.changelogDB = new FileChangelogDB(this, config.getReplicationDBDirectory(), cryptoSuite); @@ -560,7 +563,8 @@ // create a rule and register it into the DirectoryServer provider.initializeVirtualAttributeProvider(null); AttributeType attributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attributeType = schema.getAttributeType(attrName); return new VirtualAttributeRule(attributeType, provider, baseDNs, SearchScope.BASE_OBJECT, groupDNs, filters, conflictBehavior); opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java
@@ -19,7 +19,6 @@ import static org.opends.messages.TaskMessages.*; import static org.opends.messages.ToolMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; @@ -36,13 +35,12 @@ import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.server.config.server.BackendCfg; import org.opends.messages.Severity; import org.opends.messages.TaskMessages; import org.forgerock.opendj.server.config.server.BackendCfg; import org.opends.server.api.ClientConnection; import org.opends.server.api.LocalBackend; import org.opends.server.api.LocalBackend.BackendOperation; import org.opends.server.api.ClientConnection; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.core.DirectoryServer; @@ -137,34 +135,23 @@ Entry taskEntry = getTaskEntry(); AttributeType typeBackupAll = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_BACKUP_ALL); AttributeType typeCompress = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_BACKUP_COMPRESS); AttributeType typeEncrypt = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_BACKUP_ENCRYPT); AttributeType typeHash = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_BACKUP_HASH); AttributeType typeIncremental = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_BACKUP_INCREMENTAL); AttributeType typeSignHash = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_BACKUP_SIGN_HASH); AttributeType typeBackendID = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_BACKUP_BACKEND_ID); AttributeType typeBackupID = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_ID); AttributeType typeBackupDirectory = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); AttributeType typeIncrementalBaseID = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_BACKUP_INCREMENTAL_BASE_ID); backUpAll = TaskUtils.getBoolean(taskEntry.getAllAttributes(ATTR_TASK_BACKUP_ALL), false); compress = TaskUtils.getBoolean(taskEntry.getAllAttributes(ATTR_TASK_BACKUP_COMPRESS), false); encrypt = TaskUtils.getBoolean(taskEntry.getAllAttributes(ATTR_TASK_BACKUP_ENCRYPT), false); hash = TaskUtils.getBoolean(taskEntry.getAllAttributes(ATTR_TASK_BACKUP_HASH), false); incremental = TaskUtils.getBoolean(taskEntry.getAllAttributes(ATTR_TASK_BACKUP_INCREMENTAL), false); signHash = TaskUtils.getBoolean(taskEntry.getAllAttributes(ATTR_TASK_BACKUP_SIGN_HASH), false); backendIDList = TaskUtils.getMultiValueString(taskEntry.getAllAttributes(ATTR_TASK_BACKUP_BACKEND_ID)); backupID = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(ATTR_BACKUP_ID)); backUpAll = TaskUtils.getBoolean(taskEntry.getAllAttributes(typeBackupAll), false); compress = TaskUtils.getBoolean(taskEntry.getAllAttributes(typeCompress), false); encrypt = TaskUtils.getBoolean(taskEntry.getAllAttributes(typeEncrypt), false); hash = TaskUtils.getBoolean(taskEntry.getAllAttributes(typeHash), false); incremental = TaskUtils.getBoolean(taskEntry.getAllAttributes(typeIncremental), false); signHash = TaskUtils.getBoolean(taskEntry.getAllAttributes(typeSignHash), false); backendIDList = TaskUtils.getMultiValueString(taskEntry.getAllAttributes(typeBackendID)); backupID = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(typeBackupID)); String backupDirectoryPath = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(typeBackupDirectory)); String backupDirectoryPath = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(ATTR_BACKUP_DIRECTORY_PATH)); backupDirectory = new File(backupDirectoryPath); if (! backupDirectory.isAbsolute()) { backupDirectory = new File(DirectoryServer.getInstanceRoot(), backupDirectoryPath); } incrementalBase = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(typeIncrementalBaseID)); incrementalBase = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(ATTR_TASK_BACKUP_INCREMENTAL_BASE_ID)); configEntries = TaskUtils.getBackendConfigEntries(); } opendj-server-legacy/src/main/java/org/opends/server/tasks/DisconnectClientTask.java
@@ -30,7 +30,6 @@ import org.opends.server.backends.task.TaskState; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.types.DirectoryException; import org.opends.server.types.DisconnectReason; import org.opends.server.types.Entry; @@ -93,8 +92,7 @@ private long getConnectionID(Entry taskEntry) throws DirectoryException { final AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_DISCONNECT_CONN_ID); for (Attribute a : taskEntry.getAllAttributes(attrType)) for (Attribute a : taskEntry.getAllAttributes(ATTR_TASK_DISCONNECT_CONN_ID)) { for (ByteString v : a) { @@ -114,8 +112,7 @@ private boolean mustNotifyClient(Entry taskEntry) throws DirectoryException { final AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT); for (Attribute a : taskEntry.getAllAttributes(attrType)) for (Attribute a : taskEntry.getAllAttributes(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT)) { for (ByteString v : a) { @@ -140,8 +137,7 @@ private LocalizableMessage getDisconnectMessage(Entry taskEntry) { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_DISCONNECT_MESSAGE); for (Attribute a : taskEntry.getAllAttributes(attrType)) for (Attribute a : taskEntry.getAllAttributes(ATTR_TASK_DISCONNECT_MESSAGE)) { for (ByteString v : a) { opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
@@ -19,7 +19,6 @@ import static org.opends.messages.TaskMessages.*; import static org.opends.messages.ToolMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.util.StaticUtils.*; import java.io.File; @@ -36,14 +35,13 @@ import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.messages.Severity; import org.opends.messages.TaskMessages; import org.opends.server.api.ClientConnection; import org.opends.server.api.LocalBackend; import org.opends.server.api.LocalBackend.BackendOperation; import org.opends.server.api.ClientConnection; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.core.DirectoryServer; import org.opends.server.core.LockFileManager; import org.opends.server.types.Attribute; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.ExistingFileBehavior; @@ -86,12 +84,12 @@ private boolean encryptLDIF; private boolean signHash; private boolean includeOperationalAttributes; private ArrayList<String> includeAttributeStrings; private ArrayList<String> excludeAttributeStrings; private ArrayList<String> includeFilterStrings; private ArrayList<String> excludeFilterStrings; private ArrayList<String> includeBranchStrings; private ArrayList<String> excludeBranchStrings; private List<String> includeAttributeStrings; private List<String> excludeAttributeStrings; private List<String> includeFilterStrings; private List<String> excludeFilterStrings; private List<String> includeBranchStrings; private List<String> excludeBranchStrings; private LDIFExportConfig exportConfig; @@ -123,7 +121,6 @@ } Entry taskEntry = getTaskEntry(); AttributeType typeWrapColumn = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_EXPORT_WRAP_COLUMN); ldifFile = toString(taskEntry, ATTR_TASK_EXPORT_LDIF_FILE); File f = new File (ldifFile); @@ -152,31 +149,24 @@ includeBranchStrings = toListOfString(taskEntry, ATTR_TASK_EXPORT_INCLUDE_BRANCH); excludeBranchStrings = toListOfString(taskEntry, ATTR_TASK_EXPORT_EXCLUDE_BRANCH); List<Attribute> attrList = taskEntry.getAllAttributes(typeWrapColumn); wrapColumn = TaskUtils.getSingleValueInteger(attrList, 0); wrapColumn = TaskUtils.getSingleValueInteger(taskEntry.getAllAttributes(ATTR_TASK_EXPORT_WRAP_COLUMN), 0); includeOperationalAttributes = toBoolean(taskEntry, true, ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES); } private boolean toBoolean(Entry entry, boolean defaultValue, String attrName) { final AttributeType attrType = getInstance().getServerContext().getSchema().getAttributeType(attrName); final List<Attribute> attrs = entry.getAllAttributes(attrType); return TaskUtils.getBoolean(attrs, defaultValue); return TaskUtils.getBoolean(entry.getAllAttributes(attrName), defaultValue); } private ArrayList<String> toListOfString(Entry entry, String attrName) private List<String> toListOfString(Entry entry, String attrName) { final AttributeType attrType = getInstance().getServerContext().getSchema().getAttributeType(attrName); final List<Attribute> attrs = entry.getAllAttributes(attrType); return TaskUtils.getMultiValueString(attrs); return TaskUtils.getMultiValueString(entry.getAllAttributes(attrName)); } private String toString(Entry entry, String attrName) { final AttributeType attrType = getInstance().getServerContext().getSchema().getAttributeType(attrName); final List<Attribute> attrs = entry.getAllAttributes(attrType); return TaskUtils.getSingleValueString(attrs); return TaskUtils.getSingleValueString(entry.getAllAttributes(attrName)); } @Override @@ -447,7 +437,7 @@ return getFinalTaskState(); } private HashSet<AttributeType> toAttributeTypes(ArrayList<String> attributeStrings) private HashSet<AttributeType> toAttributeTypes(List<String> attributeStrings) { if (attributeStrings == null) { opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
@@ -35,19 +35,19 @@ import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.messages.Severity; import org.opends.messages.TaskMessages; import org.opends.server.api.LocalBackend; import org.opends.server.api.LocalBackend.BackendOperation; import org.opends.server.api.Backend; import org.opends.server.api.ClientConnection; import org.opends.server.api.LocalBackend; import org.opends.server.api.LocalBackend.BackendOperation; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.core.BackendConfigManager; import org.opends.server.core.DirectoryServer; import org.opends.server.core.LockFileManager; import org.opends.server.tools.makeldif.TemplateFile; import org.opends.server.types.Attribute; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.ExistingFileBehavior; @@ -97,13 +97,13 @@ private String backendID; private String rejectFile; private String skipFile; private ArrayList<String> excludeAttributeStrings; private ArrayList<String> excludeBranchStrings; private ArrayList<String> excludeFilterStrings; private ArrayList<String> includeAttributeStrings; private ArrayList<String> includeBranchStrings; private ArrayList<String> includeFilterStrings; private ArrayList<String> ldifFiles; private List<String> excludeAttributeStrings; private List<String> excludeBranchStrings; private List<String> excludeFilterStrings; private List<String> includeAttributeStrings; private List<String> includeBranchStrings; private List<String> includeFilterStrings; private List<String> ldifFiles; private String templateFile; private int randomSeed; private LDIFImportConfig importConfig; @@ -135,27 +135,28 @@ Entry taskEntry = getTaskEntry(); AttributeType typeLdifFile = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_LDIF_FILE); AttributeType typeTemplateFile = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_TEMPLATE_FILE); AttributeType typeBackendID = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_BACKEND_ID); AttributeType typeIncludeBranch = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_INCLUDE_BRANCH); AttributeType typeExcludeBranch = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_EXCLUDE_BRANCH); AttributeType typeIncludeAttribute = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_INCLUDE_ATTRIBUTE); AttributeType typeExcludeAttribute = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_EXCLUDE_ATTRIBUTE); AttributeType typeIncludeFilter = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_INCLUDE_FILTER); AttributeType typeExcludeFilter = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_EXCLUDE_FILTER); AttributeType typeRejectFile = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_REJECT_FILE); AttributeType typeSkipFile = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_SKIP_FILE); AttributeType typeOverwrite = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_OVERWRITE); AttributeType typeSkipSchemaValidation = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_SKIP_SCHEMA_VALIDATION); AttributeType typeIsCompressed = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_IS_COMPRESSED); AttributeType typeIsEncrypted = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_IS_ENCRYPTED); AttributeType typeClearBackend = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_CLEAR_BACKEND); AttributeType typeRandomSeed = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_RANDOM_SEED); AttributeType typeThreadCount = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_THREAD_COUNT); AttributeType typeTmpDirectory = getInstance().getServerContext().getSchema().getAttributeType(ATTR_IMPORT_TMP_DIRECTORY); Schema schema = getInstance().getServerContext().getSchema(); AttributeType typeLdifFile = schema.getAttributeType(ATTR_IMPORT_LDIF_FILE); AttributeType typeTemplateFile = schema.getAttributeType(ATTR_IMPORT_TEMPLATE_FILE); AttributeType typeBackendID = schema.getAttributeType(ATTR_IMPORT_BACKEND_ID); AttributeType typeIncludeBranch = schema.getAttributeType(ATTR_IMPORT_INCLUDE_BRANCH); AttributeType typeExcludeBranch = schema.getAttributeType(ATTR_IMPORT_EXCLUDE_BRANCH); AttributeType typeIncludeAttribute = schema.getAttributeType(ATTR_IMPORT_INCLUDE_ATTRIBUTE); AttributeType typeExcludeAttribute = schema.getAttributeType(ATTR_IMPORT_EXCLUDE_ATTRIBUTE); AttributeType typeIncludeFilter = schema.getAttributeType(ATTR_IMPORT_INCLUDE_FILTER); AttributeType typeExcludeFilter = schema.getAttributeType(ATTR_IMPORT_EXCLUDE_FILTER); AttributeType typeRejectFile = schema.getAttributeType(ATTR_IMPORT_REJECT_FILE); AttributeType typeSkipFile = schema.getAttributeType(ATTR_IMPORT_SKIP_FILE); AttributeType typeOverwrite = schema.getAttributeType(ATTR_IMPORT_OVERWRITE); AttributeType typeSkipSchemaValidation = schema.getAttributeType(ATTR_IMPORT_SKIP_SCHEMA_VALIDATION); AttributeType typeIsCompressed = schema.getAttributeType(ATTR_IMPORT_IS_COMPRESSED); AttributeType typeIsEncrypted = schema.getAttributeType(ATTR_IMPORT_IS_ENCRYPTED); AttributeType typeClearBackend = schema.getAttributeType(ATTR_IMPORT_CLEAR_BACKEND); AttributeType typeRandomSeed = schema.getAttributeType(ATTR_IMPORT_RANDOM_SEED); AttributeType typeThreadCount = schema.getAttributeType(ATTR_IMPORT_THREAD_COUNT); AttributeType typeTmpDirectory = schema.getAttributeType(ATTR_IMPORT_TMP_DIRECTORY); ArrayList<String> ldifFilestmp = asListOfStrings(taskEntry, typeLdifFile); List<String> ldifFilestmp = asListOfStrings(taskEntry, typeLdifFile); ldifFiles = new ArrayList<>(ldifFilestmp.size()); for (String s : ldifFilestmp) { @@ -342,26 +343,22 @@ private int asInt(Entry taskEntry, AttributeType attributeType) { final List<Attribute> attrList = taskEntry.getAllAttributes(attributeType); return TaskUtils.getSingleValueInteger(attrList, 0); return TaskUtils.getSingleValueInteger(taskEntry.getAllAttributes(attributeType), 0); } private boolean asBoolean(Entry taskEntry, AttributeType attributeType) { final List<Attribute> attrList = taskEntry.getAllAttributes(attributeType); return TaskUtils.getBoolean(attrList, false); return TaskUtils.getBoolean(taskEntry.getAllAttributes(attributeType), false); } private String asString(Entry taskEntry, AttributeType attributeType) { final List<Attribute> attrList = taskEntry.getAllAttributes(attributeType); return TaskUtils.getSingleValueString(attrList); return TaskUtils.getSingleValueString(taskEntry.getAllAttributes(attributeType)); } private ArrayList<String> asListOfStrings(Entry taskEntry, AttributeType attributeType) private List<String> asListOfStrings(Entry taskEntry, AttributeType attributeType) { final List<Attribute> attrList = taskEntry.getAllAttributes(attributeType); return TaskUtils.getMultiValueString(attrList); return TaskUtils.getMultiValueString(taskEntry.getAllAttributes(attributeType)); } @Override @@ -721,7 +718,7 @@ return getFinalTaskState(); } private HashSet<AttributeType> toAttributeTypes(ArrayList<String> attrNames) private HashSet<AttributeType> toAttributeTypes(List<String> attrNames) { final HashSet<AttributeType> attrTypes = new HashSet<>(attrNames.size()); for (String attrName : attrNames) opendj-server-legacy/src/main/java/org/opends/server/tasks/InitializeTargetTask.java
@@ -18,22 +18,17 @@ import static org.opends.messages.BackendMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.util.StaticUtils.*; import java.util.List; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.opends.messages.TaskMessages; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.replication.plugin.LDAPReplicationDomain; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; @@ -51,7 +46,6 @@ private int target; private long total; /** {@inheritDoc} */ @Override public LocalizableMessage getDisplayName() { return TaskMessages.INFO_TASK_INITIALIZE_TARGET_NAME.get(); @@ -69,11 +63,7 @@ // FIXME -- Do we need any special authorization here? Entry taskEntry = getTaskEntry(); AttributeType typeDomainBase = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_INITIALIZE_TARGET_DOMAIN_DN); AttributeType typeScope = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_INITIALIZE_TARGET_SCOPE); List<Attribute> attrList = taskEntry.getAllAttributes(typeDomainBase); domainString = TaskUtils.getSingleValueString(attrList); domainString = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(ATTR_TASK_INITIALIZE_TARGET_DOMAIN_DN)); try { @@ -90,14 +80,12 @@ throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, e); } attrList = taskEntry.getAllAttributes(typeScope); String targetString = TaskUtils.getSingleValueString(attrList); target = domain.decodeTarget(targetString); target = domain.decodeTarget(TaskUtils.getSingleValueString( taskEntry.getAllAttributes(ATTR_TASK_INITIALIZE_TARGET_SCOPE))); setTotal(0); } /** {@inheritDoc} */ @Override protected TaskState runTask() { opendj-server-legacy/src/main/java/org/opends/server/tasks/InitializeTask.java
@@ -17,21 +17,16 @@ package org.opends.server.tasks; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import java.util.List; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.opends.messages.TaskMessages; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.replication.plugin.LDAPReplicationDomain; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; @@ -72,12 +67,7 @@ // FIXME -- Do we need any special authorization here? Entry taskEntry = getTaskEntry(); AttributeType typeDomainBase = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_INITIALIZE_DOMAIN_DN); AttributeType typeSourceScope = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_INITIALIZE_SOURCE); List<Attribute> attrList; attrList = taskEntry.getAllAttributes(typeDomainBase); domainString = TaskUtils.getSingleValueString(attrList); domainString = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(ATTR_TASK_INITIALIZE_DOMAIN_DN)); try { @@ -93,15 +83,13 @@ throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, e); } attrList = taskEntry.getAllAttributes(typeSourceScope); String sourceString = TaskUtils.getSingleValueString(attrList); source = domain.decodeSource(sourceString); source = domain.decodeSource( TaskUtils.getSingleValueString(taskEntry.getAllAttributes(ATTR_TASK_INITIALIZE_SOURCE))); replaceAttributeValue(ATTR_TASK_INITIALIZE_LEFT, String.valueOf(0)); replaceAttributeValue(ATTR_TASK_INITIALIZE_DONE, String.valueOf(0)); } /** {@inheritDoc} */ @Override protected TaskState runTask() { opendj-server-legacy/src/main/java/org/opends/server/tasks/PurgeConflictsHistoricalTask.java
@@ -16,25 +16,22 @@ */ package org.opends.server.tasks; import java.util.List; import static org.opends.server.config.ConfigConstants.*; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.opends.messages.TaskMessages; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.opends.server.replication.common.CSN; import org.opends.server.replication.plugin.LDAPReplicationDomain; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.types.*; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.util.TimeThread; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; /** * This class provides an implementation of a Directory Server task that can * be used to purge the replication historical informations stored in the @@ -86,9 +83,8 @@ // FIXME -- Do we need any special authorization here? Entry taskEntry = getTaskEntry(); AttributeType typeDomainBase = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN); List<Attribute> attrList = taskEntry.getAllAttributes(typeDomainBase); domainString = TaskUtils.getSingleValueString(attrList); domainString = TaskUtils.getSingleValueString( taskEntry.getAllAttributes(ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN)); try { @@ -104,9 +100,8 @@ throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, mb.toMessage()); } AttributeType typeMaxDuration = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_CONFLICTS_HIST_PURGE_MAX_DURATION); attrList = taskEntry.getAllAttributes(typeMaxDuration); String maxDurationStringInSec = TaskUtils.getSingleValueString(attrList); String maxDurationStringInSec = TaskUtils.getSingleValueString( taskEntry.getAllAttributes(ATTR_TASK_CONFLICTS_HIST_PURGE_MAX_DURATION)); if (maxDurationStringInSec != null) { opendj-server-legacy/src/main/java/org/opends/server/tasks/RebuildTask.java
@@ -19,29 +19,25 @@ import static org.opends.messages.TaskMessages.*; import static org.opends.messages.ToolMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.util.StaticUtils.*; import java.util.ArrayList; import java.util.List; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizedIllegalArgumentException; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.opends.messages.TaskMessages; import org.opends.server.api.ClientConnection; import org.opends.server.api.LocalBackend; import org.opends.server.api.LocalBackend.BackendOperation; import org.opends.server.api.ClientConnection; import org.opends.server.backends.RebuildConfig; import org.opends.server.backends.RebuildConfig.RebuildMode; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.core.DirectoryServer; import org.opends.server.core.LockFileManager; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.InitializationException; @@ -57,19 +53,17 @@ private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); private String baseDN; private ArrayList<String> indexes; private List<String> indexes; private String tmpDirectory; private RebuildMode rebuildMode = RebuildMode.USER_DEFINED; private boolean isClearDegradedState; /** {@inheritDoc} */ @Override public LocalizableMessage getDisplayName() { return TaskMessages.INFO_TASK_REBUILD_NAME.get(); } /** {@inheritDoc} */ @Override public void initializeTask() throws DirectoryException { @@ -94,10 +88,7 @@ tmpDirectory = asString(taskEntry, ATTR_REBUILD_TMP_DIRECTORY); final String val = asString(taskEntry, ATTR_REBUILD_INDEX_CLEARDEGRADEDSTATE); isClearDegradedState = Boolean.parseBoolean(val); AttributeType typeIndex = getInstance().getServerContext().getSchema().getAttributeType(ATTR_REBUILD_INDEX); List<Attribute> attrList = taskEntry.getAllAttributes(typeIndex); indexes = TaskUtils.getMultiValueString(attrList); indexes = TaskUtils.getMultiValueString(taskEntry.getAllAttributes(ATTR_REBUILD_INDEX)); rebuildMode = getRebuildMode(indexes); if (rebuildMode != RebuildMode.USER_DEFINED) @@ -113,9 +104,7 @@ private String asString(Entry taskEntry, String attrName) { final AttributeType attrType = getInstance().getServerContext().getSchema().getAttributeType(attrName); final List<Attribute> attrList = taskEntry.getAllAttributes(attrType); return TaskUtils.getSingleValueString(attrList); return TaskUtils.getSingleValueString(taskEntry.getAllAttributes(attrName)); } private RebuildMode getRebuildMode(List<String> indexList) opendj-server-legacy/src/main/java/org/opends/server/tasks/ResetChangeNumberTask.java
@@ -15,28 +15,26 @@ */ package org.opends.server.tasks; import static org.forgerock.opendj.ldap.ResultCode.*; import static org.opends.messages.TaskMessages.*; import static org.opends.server.config.ConfigConstants.*; import java.util.List; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.core.DirectoryServer; import org.opends.server.replication.common.CSN; import org.opends.server.replication.server.ReplicationServer; import org.opends.server.replication.server.changelog.api.ChangelogException; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import java.util.List; import static org.forgerock.opendj.ldap.ResultCode.*; import static org.opends.server.config.ConfigConstants.ATTR_TASK_RESET_CHANGE_NUMBER_BASE_DN; import static org.opends.server.config.ConfigConstants.ATTR_TASK_RESET_CHANGE_NUMBER_CSN; import static org.opends.server.config.ConfigConstants.ATTR_TASK_RESET_CHANGE_NUMBER_TO; import static org.opends.server.core.DirectoryServer.getSchema; import static org.opends.messages.TaskMessages.*; /** * This class provides an implementation of a Directory Server task that can * be used to rebuild the change number index with a given change number and a @@ -96,8 +94,8 @@ private List<Attribute> getTaskParameter(Entry taskEntry, String attrTaskResetChangeNumberTo) { AttributeType taskAttr = getInstance().getServerContext().getSchema().getAttributeType(attrTaskResetChangeNumberTo); return taskEntry.getAllAttributes(taskAttr); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); return taskEntry.getAllAttributes(schema.getAttributeType(attrTaskResetChangeNumberTo)); } @Override opendj-server-legacy/src/main/java/org/opends/server/tasks/RestoreTask.java
@@ -19,31 +19,28 @@ import static org.opends.messages.TaskMessages.*; import static org.opends.messages.ToolMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.tasks.TaskUtils.*; import static org.opends.server.util.StaticUtils.*; import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.opends.messages.Severity; import org.opends.messages.TaskMessages; import org.opends.server.api.ClientConnection; import org.opends.server.api.LocalBackend; import org.opends.server.api.LocalBackend.BackendOperation; import org.opends.server.api.ClientConnection; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.core.DirectoryServer; import org.opends.server.core.LockFileManager; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.types.BackupDirectory; import org.opends.server.types.BackupInfo; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.Operation; @@ -108,27 +105,15 @@ Entry taskEntry = getTaskEntry(); AttributeType typeBackupDirectory = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_DIRECTORY_PATH); AttributeType typebackupID = getInstance().getServerContext().getSchema().getAttributeType(ATTR_BACKUP_ID); AttributeType typeVerifyOnly = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_RESTORE_VERIFY_ONLY); List<Attribute> attrList; attrList = taskEntry.getAllAttributes(typeBackupDirectory); String backupDirectoryPath = TaskUtils.getSingleValueString(attrList); String backupDirectoryPath = getSingleValueString(taskEntry.getAllAttributes(ATTR_BACKUP_DIRECTORY_PATH)); backupDirectory = new File(backupDirectoryPath); if (! backupDirectory.isAbsolute()) { backupDirectory = new File(DirectoryServer.getInstanceRoot(), backupDirectoryPath); backupDirectory = new File(DirectoryServer.getInstanceRoot(), backupDirectoryPath); } attrList = taskEntry.getAllAttributes(typebackupID); backupID = TaskUtils.getSingleValueString(attrList); attrList = taskEntry.getAllAttributes(typeVerifyOnly); verifyOnly = TaskUtils.getBoolean(attrList, false); backupID = getSingleValueString(taskEntry.getAllAttributes(ATTR_BACKUP_ID)); verifyOnly = getBoolean(taskEntry.getAllAttributes(ATTR_TASK_RESTORE_VERIFY_ONLY), false); } /** opendj-server-legacy/src/main/java/org/opends/server/tasks/SetGenerationIdTask.java
@@ -17,22 +17,18 @@ package org.opends.server.tasks; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.core.DirectoryServer.*; import java.util.List; import static org.opends.server.tasks.TaskUtils.*; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.opends.messages.TaskMessages; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.replication.plugin.LDAPReplicationDomain; import org.opends.server.replication.service.ReplicationDomain; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; @@ -67,13 +63,12 @@ Entry taskEntry = getTaskEntry(); // Retrieves the eventual generation-ID AttributeType typeNewValue = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_SET_GENERATION_ID_NEW_VALUE); List<Attribute> attrList = taskEntry.getAllAttributes(typeNewValue); if (!attrList.isEmpty()) String singleValue = getSingleValueString(taskEntry.getAllAttributes(ATTR_TASK_SET_GENERATION_ID_NEW_VALUE)); if (singleValue != null) { try { generationId = Long.parseLong(TaskUtils.getSingleValueString(attrList)); generationId = Long.parseLong(singleValue); } catch(Exception e) { @@ -85,9 +80,7 @@ } // Retrieves the replication domain AttributeType typeDomainBase = getInstance().getServerContext().getSchema().getAttributeType(ATTR_TASK_SET_GENERATION_ID_DOMAIN_DN); attrList = taskEntry.getAllAttributes(typeDomainBase); domainString = TaskUtils.getSingleValueString(attrList); domainString = getSingleValueString(taskEntry.getAllAttributes(ATTR_TASK_SET_GENERATION_ID_DOMAIN_DN)); try { @@ -103,7 +96,6 @@ } } /** {@inheritDoc} */ @Override protected TaskState runTask() { opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java
@@ -18,18 +18,13 @@ import static org.opends.messages.TaskMessages.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.util.StaticUtils.*; import java.util.List; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.api.ClientConnection; import org.opends.server.backends.task.Task; import org.opends.server.backends.task.TaskState; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.Operation; @@ -74,30 +69,13 @@ restart = false; shutdownMessage = INFO_TASK_SHUTDOWN_DEFAULT_MESSAGE.get(taskEntry.getName()); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_SHUTDOWN_MESSAGE); List<Attribute> attrList = taskEntry.getAllAttributes(attrType); if (!attrList.isEmpty()) String valueString = TaskUtils.getSingleValueString(taskEntry.getAllAttributes(ATTR_SHUTDOWN_MESSAGE)); if (valueString != null) { Attribute attr = attrList.get(0); if (!attr.isEmpty()) { String valueString = attr.iterator().next().toString(); shutdownMessage = INFO_TASK_SHUTDOWN_CUSTOM_MESSAGE.get(taskEntry.getName(), valueString); } shutdownMessage = INFO_TASK_SHUTDOWN_CUSTOM_MESSAGE.get(taskEntry.getName(), valueString); } attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_RESTART_SERVER); attrList = taskEntry.getAllAttributes(attrType); if (!attrList.isEmpty()) { Attribute attr = attrList.get(0); if (!attr.isEmpty()) { String valueString = toLowerCase(attr.iterator().next().toString()); restart = valueString.equals("true") || valueString.equals("yes") || valueString.equals("on") || valueString.equals("1"); } } restart = TaskUtils.getBoolean(taskEntry.getAllAttributes(ATTR_RESTART_SERVER), false); // If the client connection is available, then make sure the associated opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
@@ -16,10 +16,9 @@ */ package org.opends.server.tasks; import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_ID; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -28,18 +27,18 @@ import org.forgerock.opendj.adapter.server3x.Converters; import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.requests.ModifyRequest; import org.forgerock.opendj.server.config.server.BackendCfg; import org.forgerock.opendj.server.config.server.RootCfg; import org.opends.server.api.LocalBackend; import org.opends.server.types.Entry; import org.opends.server.config.ConfigurationHandler; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ModifyOperation; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import static org.forgerock.opendj.ldap.ModificationType.*; import static org.forgerock.opendj.ldap.requests.Requests.*; @@ -219,16 +218,15 @@ * schema as a single valued boolean attribute, and that is not expected to * have attribute options. * * @param attrList The attribute value of the entry attribute. * @param attrs The attribute values of the entry attribute. * @param defaultValue The default value to be returned if there is no * recognizable boolean attribute value. * @return The boolean value of the attribute, or the provided default value * if there is no value. */ public static boolean getBoolean(List<Attribute> attrList, boolean defaultValue) public static boolean getBoolean(Iterable<Attribute> attrs, boolean defaultValue) { for (Attribute a : attrList) for (Attribute a : attrs) { for (ByteString v : a) { @@ -256,15 +254,16 @@ * schema as a multi-valued string attribute, and that is not expected to * have attribute options. * * @param attrList The attribute values of the entry attribute. * @param attrs The attribute values of the entry attribute. * @return The string values of the attribute, empty if there are none. */ public static ArrayList<String> getMultiValueString(List<Attribute> attrList) public static List<String> getMultiValueString(Iterable<Attribute> attrs) { ArrayList<String> valueStrings = new ArrayList<>(); if (!attrList.isEmpty()) Iterator<Attribute> it = attrs.iterator(); if (it.hasNext()) { Attribute attr = attrList.get(0); Attribute attr = it.next(); if (!attr.isEmpty()) { for (ByteString value : attr) @@ -283,14 +282,15 @@ * schema as a single valued string attribute, and that is not expected to * have attribute options. * * @param attrList The attribute value of the entry attribute. * @param attrs The attribute values of the entry attribute. * @return The string value of the attribute, or null if there is none. */ public static String getSingleValueString(List<Attribute> attrList) public static String getSingleValueString(Iterable<Attribute> attrs) { if (!attrList.isEmpty()) Iterator<Attribute> it = attrs.iterator(); if (it.hasNext()) { Attribute attr = attrList.get(0); Attribute attr = it.next(); if (!attr.isEmpty()) { return attr.iterator().next().toString(); @@ -305,17 +305,18 @@ * schema as a single valued integer attribute, and that is not expected to * have attribute options. * * @param attrList The attribute value of the entry attribute. * @param attrs The attribute values of the entry attribute. * @param defaultValue The default value to be returned if there is no * recognizable integer attribute value. * @return The integer value of the attribute, or the provided default value * if there is no value. */ public static int getSingleValueInteger(List<Attribute> attrList, int defaultValue) public static int getSingleValueInteger(Iterable<Attribute> attrs, int defaultValue) { if (!attrList.isEmpty()) Iterator<Attribute> it = attrs.iterator(); if (it.hasNext()) { Attribute attr = attrList.get(0); Attribute attr = it.next(); if (!attr.isEmpty()) { try opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
@@ -57,6 +57,7 @@ import org.forgerock.opendj.ldap.LinkedHashMapEntry; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.CoreSchema; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.ldap.schema.Syntax; import org.forgerock.opendj.server.config.client.BackendCfgClient; import org.forgerock.opendj.server.config.meta.CryptoManagerCfgDefn; @@ -1137,7 +1138,8 @@ org.forgerock.opendj.ldap.Entry configEntry, String attrName, Syntax syntax, Object...values) { org.forgerock.opendj.ldap.Entry newEntry = LinkedHashMapEntry.deepCopyOfEntry(configEntry); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName, syntax); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attrType = schema.getAttributeType(attrName, syntax); newEntry.replaceAttribute(new LinkedAttribute(AttributeDescription.create(attrType), values)); return newEntry; } opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -36,6 +36,7 @@ import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.server.BackendCfg; import org.opends.server.api.LocalBackend; import org.opends.server.api.LocalBackend.BackendOperation; @@ -474,6 +475,7 @@ HashSet<AttributeType> excludeAttributes; boolean excludeAllUserAttributes = false; boolean excludeAllOperationalAttributes = false; Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); if (excludeAttributeStrings == null) { excludeAttributes = null; @@ -494,7 +496,7 @@ } else { excludeAttributes.add(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName)); excludeAttributes.add(schema.getAttributeType(attrName)); } } } @@ -522,7 +524,7 @@ } else { includeAttributes.add(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName)); includeAttributes.add(schema.getAttributeType(attrName)); } } } opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java
@@ -31,6 +31,7 @@ import org.forgerock.opendj.ldap.RDN; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.opends.server.types.AttributeBuilder; @@ -247,10 +248,11 @@ ArrayList<TemplateValue> valueList = entry.getValue(); if (t.isObjectClass()) { Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); for (TemplateValue v : valueList) { String ocName = v.getValue().toString(); objectClasses.put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName), ocName); objectClasses.put(schema.getObjectClass(ocName), ocName); } } else if (t.isOperational()) opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateFile.java
@@ -34,6 +34,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.core.DirectoryServer; import org.opends.server.types.InitializationException; @@ -830,10 +831,11 @@ // be separated by plus signs. ArrayList<AttributeType> attrList = new ArrayList<>(); String rdnAttrNames = lowerLine.substring(9).trim(); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); StringTokenizer tokenizer = new StringTokenizer(rdnAttrNames, "+"); while (tokenizer.hasMoreTokens()) { attrList.add(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(tokenizer.nextToken())); attrList.add(schema.getAttributeType(tokenizer.nextToken())); } rdnAttributes = new AttributeType[attrList.size()]; @@ -995,7 +997,8 @@ } } AttributeType attributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(lowerLine.substring(0, colonPos)); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attributeType = schema.getAttributeType(lowerLine.substring(0, colonPos)); // First, check whether the value is an URL value: <attrName>:< <url> int length = line.length(); opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java
@@ -26,6 +26,7 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.types.Attribute.RemoveOnceSwitchingAttributes; /** @@ -176,7 +177,7 @@ */ public static Attribute create(String attributeName, String valueString) { return create(getInstance().getServerContext().getSchema().getAttributeType(attributeName), attributeName, valueString); return create(getSchema().getAttributeType(attributeName), attributeName, valueString); } /** @@ -278,7 +279,12 @@ */ public static Attribute empty(String attributeName) { return empty(getInstance().getServerContext().getSchema().getAttributeType(attributeName), attributeName); return empty(getSchema().getAttributeType(attributeName), attributeName); } private static Schema getSchema() { return getInstance().getServerContext().getSchema(); } opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -63,6 +63,7 @@ import org.forgerock.opendj.ldap.schema.NameForm; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.ObjectClassType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.util.Reject; import org.forgerock.util.Utils; import org.opends.server.api.CompressedSchema; @@ -1372,7 +1373,7 @@ for (ByteString v : a) { String ocName = v.toString(); ocs.put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName), ocName); ocs.put(getSchema().getObjectClass(ocName), ocName); } AttributeDescription attrDesc = a.getAttributeDescription(); @@ -1425,6 +1426,11 @@ } } private static Schema getSchema() { return DirectoryServer.getInstance().getServerContext().getSchema(); } private void applyModificationToNonObjectclass(Modification mod, boolean relaxConstraints) throws DirectoryException { Attribute a = mod.getAttribute(); @@ -1619,7 +1625,7 @@ } else { ditContentRule = DirectoryServer.getInstance().getServerContext().getSchema().getDITContentRule(structuralClass); ditContentRule = getSchema().getDITContentRule(structuralClass); if (ditContentRule != null && ditContentRule.isObsolete()) { ditContentRule = null; @@ -1642,7 +1648,7 @@ * DITStructureRules corresponding to other non-acceptable * nameforms are not applied. */ Collection<NameForm> forms = DirectoryServer.getInstance().getServerContext().getSchema().getNameForms(structuralClass); Collection<NameForm> forms = getSchema().getNameForms(structuralClass); if (forms != null) { List<NameForm> listForms = new ArrayList<>(forms); @@ -1678,7 +1684,7 @@ if (validateStructureRules && nameForm != null) { for (DITStructureRule ditRule : DirectoryServer.getInstance().getServerContext().getSchema().getDITStructureRules(nameForm)) for (DITStructureRule ditRule : getSchema().getDITStructureRules(nameForm)) { if (!ditRule.isObsolete()) { @@ -1731,7 +1737,7 @@ // all attributes required by the object classes are present. for (ObjectClass o : objectClasses.keySet()) { if (DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(o.getOID()).isPlaceHolder()) if (getSchema().getObjectClass(o.getOID()).isPlaceHolder()) { invalidReason.append(ERR_ENTRY_SCHEMA_UNKNOWN_OC.get(dn, o.getNameOrOID())); return false; @@ -2191,14 +2197,14 @@ } else { Collection<NameForm> allNFs = DirectoryServer.getInstance().getServerContext().getSchema().getNameForms(parentStructuralClass); Collection<NameForm> allNFs = getSchema().getNameForms(parentStructuralClass); if(allNFs != null) { for(NameForm parentNF : allNFs) { if (!parentNF.isObsolete()) { for (DITStructureRule parentDSR : DirectoryServer.getInstance().getServerContext().getSchema().getDITStructureRules(parentNF)) for (DITStructureRule parentDSR : getSchema().getDITStructureRules(parentNF)) { if (!parentDSR.isObsolete()) { @@ -2494,7 +2500,7 @@ */ private boolean hasObjectClassOrAttribute(String objectClassName, String attrTypeName) { ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(objectClassName); ObjectClass oc = getSchema().getObjectClass(objectClassName); if (oc.isPlaceHolder()) { // This should not happen @@ -2507,7 +2513,7 @@ return false; } AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrTypeName); AttributeType attrType = getSchema().getAttributeType(attrTypeName); if (attrType.isPlaceHolder()) { // This should not happen @@ -2549,7 +2555,7 @@ */ public Set<String> getReferralURLs() { AttributeType referralType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_REFERRAL_URL); AttributeType referralType = getSchema().getAttributeType(ATTR_REFERRAL_URL); if (referralType.isPlaceHolder()) { // This should not happen -- The server doesn't have a ref attribute type defined. @@ -2610,7 +2616,7 @@ */ public DN getAliasedDN() throws DirectoryException { AttributeType aliasType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_REFERRAL_URL); AttributeType aliasType = getSchema().getAttributeType(ATTR_REFERRAL_URL); if (aliasType.isPlaceHolder()) { // This should not happen -- The server doesn't have an aliasedObjectName attribute type defined. @@ -2668,7 +2674,7 @@ */ private boolean hasObjectClass(String objectClassLowerCase) { ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(objectClassLowerCase); ObjectClass oc = getSchema().getObjectClass(objectClassLowerCase); if (oc.isPlaceHolder()) { // This should not happen @@ -2829,7 +2835,7 @@ } // Get collective attribute exclusions. AttributeType exclusionsType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_COLLECTIVE_EXCLUSIONS_LC); AttributeType exclusionsType = getSchema().getAttributeType(ATTR_COLLECTIVE_EXCLUSIONS_LC); List<Attribute> exclusionsAttrList = operationalAttributes.get(exclusionsType); List<String> excludedAttrNames = new ArrayList<>(); if (exclusionsAttrList != null && !exclusionsAttrList.isEmpty()) @@ -3506,7 +3512,7 @@ { entryBuffer.position(startPos); final String ocName = entryBuffer.readStringUtf8(endPos - startPos); objectClasses.put(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName), ocName); objectClasses.put(getSchema().getObjectClass(ocName), ocName); } /** @@ -4224,7 +4230,7 @@ String lowerName = toLowerName(rule, v); // Create a default object class if necessary. ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(lowerName); ObjectClass oc = getSchema().getObjectClass(lowerName); if (replace) { opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
@@ -44,6 +44,7 @@ import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.MatchingRule; import org.forgerock.opendj.ldap.schema.MatchingRuleUse; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; import org.opends.server.core.DirectoryServer; @@ -1984,7 +1985,7 @@ try { DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(matchingRuleID); getSchema().getMatchingRule(matchingRuleID); } catch (UnknownSchemaElementException e) { @@ -3115,7 +3116,7 @@ { try { matchingRule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(matchingRuleID); matchingRule = getSchema().getMatchingRule(matchingRuleID); } catch (UnknownSchemaElementException e) { @@ -3159,7 +3160,7 @@ { try { MatchingRuleUse mru = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRuleUse(matchingRule); MatchingRuleUse mru = getSchema().getMatchingRuleUse(matchingRule); if (!mru.hasAttribute(getAttributeType())) { logger.trace("Attribute type %s is not allowed for use with " @@ -3297,6 +3298,11 @@ return result; } private static Schema getSchema() { return DirectoryServer.getInstance().getServerContext().getSchema(); } private ConditionResult assertionMatchesAnyAttribute(MatchingRule matchingRule, Assertion assertion, Iterable<Attribute> attributes, ConditionResult result, Entry entry, SearchFilter filter) { @@ -3508,7 +3514,7 @@ { try { MatchingRule mrule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(matchingRuleID); MatchingRule mrule = getSchema().getMatchingRule(matchingRuleID); Assertion assertion = mrule.getAssertion(f.assertionValue); return assertion.matches(mrule.normalizeAttributeValue(assertionValue)).toBoolean(); } opendj-server-legacy/src/main/java/org/opends/server/types/SubEntry.java
@@ -24,6 +24,7 @@ import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.core.DirectoryServer; import static org.opends.messages.SchemaMessages.*; @@ -187,13 +188,14 @@ // Process inherited collective attributes. if (this.isInheritedCollective) { Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); if (this.isInheritedFromDNCollective) { for (Attribute attr : entry.getAllAttributes(ATTR_INHERIT_COLLECTIVE_FROM_DN_LC)) { for (ByteString value : attr) { this.inheritFromDNType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(value.toString()); this.inheritFromDNType = schema.getAttributeType(value.toString()); this.inheritFromDNAttrValue = value; break; } @@ -206,7 +208,7 @@ { for (ByteString value : attr) { this.inheritFromRDNAttrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(value.toString()); this.inheritFromRDNAttrType = schema.getAttributeType(value.toString()); this.inheritFromRDNAttrValue = value; break; } @@ -215,7 +217,7 @@ { for (ByteString value : attr) { this.inheritFromRDNType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(value.toString()); this.inheritFromRDNType = schema.getAttributeType(value.toString()); break; } } @@ -265,8 +267,7 @@ { String specString = null; boolean isValidSpec = true; AttributeType specAttrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_SUBTREE_SPEC_LC); for (Attribute attr : entry.getAllAttributes(specAttrType)) for (Attribute attr : entry.getAllAttributes(ATTR_SUBTREE_SPEC_LC)) { for (ByteString value : attr) { opendj-server-legacy/src/main/java/org/opends/server/types/SubtreeSpecification.java
@@ -34,6 +34,7 @@ import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.Schema; import org.opends.server.core.DirectoryServer; import org.opends.server.util.StaticUtils; @@ -271,7 +272,8 @@ @Override public boolean matches(final Entry entry) { final ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(normalizedObjectClass); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); final ObjectClass oc = schema.getObjectClass(normalizedObjectClass); return !oc.isPlaceHolder() && entry.hasObjectClass(oc); } opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java
@@ -59,6 +59,7 @@ 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.Schema; import org.forgerock.util.Reject; import org.opends.messages.ToolMessages; import org.opends.server.core.DirectoryServer; @@ -1997,7 +1998,8 @@ RDN rdn = dn.rdn(); // If there is only one RDN attribute, then see which objectclass we should use. ObjectClass structuralClass = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(getObjectClassName(rdn)); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); ObjectClass structuralClass = schema.getObjectClass(getObjectClassName(rdn)); // Get the top and untypedObject classes to include in the entry. LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(3); opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -58,6 +58,7 @@ import org.opends.server.core.DirectoryServer; import org.opends.server.core.PasswordPolicy; import org.opends.server.core.PersistentSearch; import org.opends.server.core.ServerContext; import org.opends.server.schema.AuthPasswordSyntax; import org.opends.server.schema.UserPasswordSyntax; import org.opends.server.types.Attribute; @@ -231,8 +232,9 @@ return; } ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); BackendConfigManager backendConfigManager = DirectoryServer.getInstance().getServerContext().getBackendConfigManager(); serverContext.getBackendConfigManager(); DN parentDN = backendConfigManager.getParentDNInSuffix(entryDN); if (parentDN == null && !backendConfigManager.containsLocalNamingContext(entryDN)) { @@ -353,7 +355,7 @@ // Check to see if the entry includes a privilege specification. If so, // then the requester must have the PRIVILEGE_CHANGE privilege. AttributeType privType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OP_ATTR_PRIVILEGE_NAME); AttributeType privType = serverContext.getSchema().getAttributeType(OP_ATTR_PRIVILEGE_NAME); if (entry.hasAttribute(privType) && !clientConnection.hasPrivilege(Privilege.PRIVILEGE_CHANGE, this)) { opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
@@ -26,6 +26,7 @@ import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.meta.PasswordPolicyCfgDefn; import org.opends.server.api.AuthenticationPolicyState; import org.opends.server.api.LocalBackend; @@ -1010,7 +1011,8 @@ Arg1<Object> nonUniqueAttributeMessage, Arg2<Object, Object> cannotProcessAttributeMessage) { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attributeTypeName); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType attrType = schema.getAttributeType(attributeTypeName); List<Attribute> attrList = userEntry.getAllAttributes(attrType); if (attrList.size() == 1) { opendj-server-legacy/src/test/java/org/forgerock/opendj/adapter/server3x/ConvertersTestCase.java
@@ -19,7 +19,6 @@ import static org.forgerock.opendj.adapter.server3x.Converters.*; import static org.forgerock.opendj.ldap.schema.CoreSchema.*; import static org.mockito.Mockito.*; import static org.opends.server.core.DirectoryServer.*; import java.net.InetAddress; import java.util.ArrayList; @@ -53,11 +52,13 @@ import org.forgerock.opendj.ldap.responses.Responses; import org.forgerock.opendj.ldap.responses.Result; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn.Scope; import org.opends.server.DirectoryServerTestCase; import org.opends.server.TestCaseUtils; import org.opends.server.core.BindOperation; import org.opends.server.core.CompareOperation; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ExtendedOperation; import org.opends.server.core.SearchOperation; import org.opends.server.protocols.ldap.LDAPControl; @@ -147,7 +148,8 @@ assertThat(result.getName().toString()).isEqualTo(entry.getName().toString()); List<ObjectClass> ocs = new ArrayList<>(result.getObjectClasses().keySet()); assertThat(ocs).hasSize(2); assertThat(ocs.get(0).getOID()).isEqualTo(getInstance().getServerContext().getSchema().getObjectClass("ds-cfg-backend").getOID()); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); assertThat(ocs.get(0).getOID()).isEqualTo(schema.getObjectClass("ds-cfg-backend").getOID()); assertThat(ocs.get(1).getOID()).as("This should be a placeholder").endsWith("-oid"); } opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -20,11 +20,10 @@ import static org.forgerock.opendj.ldap.schema.CoreSchema.*; import static org.mockito.Mockito.*; import static org.opends.server.TestCaseUtils.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.protocols.internal.Requests.*; import static org.opends.server.types.ExistingFileBehavior.*; import static org.opends.server.types.NullOutputStream.nullPrintStream; import static org.opends.server.types.NullOutputStream.*; import static org.opends.server.util.StaticUtils.*; import static org.testng.Assert.*; @@ -47,6 +46,7 @@ import org.forgerock.opendj.ldap.schema.MatchingRule; import org.forgerock.opendj.ldap.schema.MatchingRuleUse; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.ldap.schema.SchemaBuilder; import org.forgerock.opendj.server.config.server.SchemaBackendCfg; import org.forgerock.util.Utils; @@ -56,14 +56,11 @@ import org.opends.server.core.DeleteOperationBasis; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ModifyDNOperationBasis; import org.opends.server.core.ServerContext; 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.schema.SchemaConstants; import org.opends.server.schema.SchemaHandler; import org.opends.server.schema.SchemaHandler.SchemaUpdater; import com.forgerock.opendj.ldap.tools.LDAPModify; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.LDIFExportConfig; @@ -77,6 +74,8 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.forgerock.opendj.ldap.tools.LDAPModify; /** A set of test cases for the schema backend. */ @SuppressWarnings("javadoc") public class SchemaBackendTestCase extends BackendTestCase @@ -90,8 +89,7 @@ { TestCaseUtils.startServer(); schemaBackend = (SchemaBackend) TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackendById("schema"); schemaBackend = (SchemaBackend) getServerContext().getBackendConfigManager().getLocalBackendById("schema"); assertNotNull(schemaBackend); } @@ -506,10 +504,10 @@ "X-ORGIN 'SchemaBackendTestCase' )"); String attrName = "testaddattributetypesuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); } /** @@ -533,10 +531,15 @@ "X-ORGIN 'SchemaBackendTestCase' )"); String attrName = "testaddattributetypesuccessfulnooid"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); } private static Schema getSchema() { return getServerContext().getSchema(); } /** @@ -560,10 +563,10 @@ "SINGLE-VALUE)"); String attrName = "testaddattributetypenospacebeforeparenthesis"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); } /** @@ -587,12 +590,12 @@ "X-SCHEMA-FILE '98-schema-test-attrtype.ldif' )"); String attrName = "testaddattributetypetoaltschemafile"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); assertSchemaFileExists("98-schema-test-attrtype.ldif", false); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); assertSchemaFileExists("98-schema-test-attrtype.ldif", true); } @@ -699,11 +702,11 @@ "NAME '" + initialName + "' " + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + "X-ORIGIN 'SchemaBackendTestCase' )"); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(initialOid)); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(initialName)); assertFalse(getSchema().hasAttributeType(initialOid)); assertFalse(getSchema().hasAttributeType(initialName)); runModify(argsNotPermissive(), ldifAdd1, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(initialOid)); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(initialName)); assertTrue(getSchema().hasAttributeType(initialOid)); assertTrue(getSchema().hasAttributeType(initialName)); // try to add the attribute again, with its new definition String ldifAdd2 = toLdif( @@ -717,7 +720,7 @@ finally { // clean the attribute to put back the schema in its initial state before the test if (DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(initialOid)) if (getSchema().hasAttributeType(initialOid)) { String removalLdif = toLdif( "dn: cn=schema", @@ -759,12 +762,12 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String attrName = "testreplaceattributetypeinaltschemafile"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); assertSchemaFileExists("98-schema-test-replaceattrtype.ldif", false); runModify(argsPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); assertSchemaFileExists("98-schema-test-replaceattrtype.ldif", true); } @@ -1053,10 +1056,10 @@ "'SchemaBackendTestCase' )"); String attrName = "testremoveattributetypesuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); } /** @@ -1093,10 +1096,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String attrName = "testremoveattributetypesuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); } /** @@ -1119,7 +1122,7 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String attrName = "testremoveattributetypeundefined"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, NO_SUCH_ATTRIBUTE); } @@ -1145,10 +1148,10 @@ "X-ORIGIN 'RFC 2256' )"); String attrName = "name"; assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); } /** @@ -1171,10 +1174,10 @@ "X-ORIGIN 'RFC 1274' )"); String attrName = "uid"; assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); } /** @@ -1232,16 +1235,16 @@ try { assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, SUCCESS); runModify(argsNotPermissive(), ldif1, CONSTRAINT_VIOLATION); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); } finally { runModify(argsNotPermissive(), ldif2, SUCCESS); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); } } @@ -1284,10 +1287,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String attrName = "testremoveattributetypereferencedbydcr"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); } /** @@ -1327,17 +1330,17 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String attrName = "testremoveatrefbymruat"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertMatchingRuleUseExistsWithName(matchingRule, "testremoveatrefbymrumru"); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getSchema().hasAttributeType(attrName)); } finally { DirectoryServer.getInstance().getServerContext().getSchema(); getSchema(); deregisterMatchingRuleUse(matchingRule); deregisterAttributeType("testremoveatrefbymruat-oid"); deregisterMatchingRule(matchingRule); @@ -1346,8 +1349,7 @@ private void updateSchema(SchemaUpdater updater) throws DirectoryException { SchemaHandler schemaHandler = DirectoryServer.getInstance().getServerContext().getSchemaHandler(); schemaHandler.updateSchema(updater); getServerContext().getSchemaHandler().updateSchema(updater); } private void deregisterAttributeType(final String nameOrOid) throws DirectoryException @@ -1406,10 +1408,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testaddobjectclasssuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getSchema().hasObjectClass(ocName)); } /** @@ -1433,10 +1435,10 @@ "MUST cn X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testaddobjectclasssuccessfulnooid"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getSchema().hasObjectClass(ocName)); } /** @@ -1459,12 +1461,12 @@ "X-SCHEMA-FILE '98-schema-test-oc.ldif' )"); String ocName = "testaddobjectclasstoaltschemafile"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); assertSchemaFileExists("98-schema-test-oc.ldif", false); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getSchema().hasObjectClass(ocName)); assertSchemaFileExists("98-schema-test-oc.ldif", true); } @@ -1538,11 +1540,11 @@ "NAME '" + initialName + "' " + "SUP top STRUCTURAL " + "MUST cn X-ORIGIN 'SchemaBackendTestCase' )"); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(initialOid)); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(initialName)); assertFalse(getSchema().hasObjectClass(initialOid)); assertFalse(getSchema().hasObjectClass(initialName)); runModify(argsNotPermissive(), ldifAdd1, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(initialOid)); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(initialName)); assertTrue(getSchema().hasObjectClass(initialOid)); assertTrue(getSchema().hasObjectClass(initialName)); // try to add the attribute again, with its new definition String ldifAdd2 = toLdif( @@ -1556,7 +1558,7 @@ finally { // clean the object class to put back the schema in its initial state before the test if (DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(initialOid)) if (getSchema().hasObjectClass(initialOid)) { String removalLdif = toLdif( "dn: cn=schema", @@ -1588,10 +1590,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testaddobjectclassmultipleconflicts"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); } /** @@ -1627,10 +1629,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testremovethenaddobjectclasssuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getSchema().hasObjectClass(ocName)); } /** @@ -1932,10 +1934,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testremoveobjectclasssuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); } /** @@ -1957,10 +1959,10 @@ "seeAlso $ description ) X-ORIGIN 'RFC 2256' )"); String ocName = "person"; assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getSchema().hasObjectClass(ocName)); } /** @@ -2005,16 +2007,16 @@ try { assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsPermissive(), addOCThenNF, SUCCESS); runModify(argsPermissive(), deleteOC, CONSTRAINT_VIOLATION); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getSchema().hasObjectClass(ocName)); } finally { runModify(argsPermissive(), deleteNFThenOC, SUCCESS); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); } } @@ -2049,10 +2051,10 @@ "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')"); String ocName = "testremoveobjectclassreferencedbydcr"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getSchema().hasObjectClass(ocName)); } private static String[] argsNotPermissive() @@ -2104,10 +2106,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformsuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertTrue(getSchema().hasNameForm(nameFormName)); } /** @@ -2136,12 +2138,12 @@ "X-SCHEMA-FILE '98-schema-test-nameform.ldif' )"); String nameFormName = "testaddnameformtoaltschemafile"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); assertSchemaFileExists("98-schema-test-nameform.ldif", false); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertTrue(getSchema().hasNameForm(nameFormName)); assertSchemaFileExists("98-schema-test-nameform.ldif", true); } @@ -2171,10 +2173,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformwithundefinedreqat"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); } /** @@ -2204,10 +2206,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformwithmultipleundefinedreqat"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); } /** @@ -2236,10 +2238,10 @@ "MAY xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformwithundefinedoptat"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); } /** @@ -2269,10 +2271,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformwithmultipleundefinedoptat"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); } /** @@ -2294,10 +2296,10 @@ "OC xxxundefinedxxx MUST cn X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformwithundefinedoc"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); } /** @@ -2325,10 +2327,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformwithauxiliaryoc"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); } /** @@ -2356,10 +2358,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformwithobsoleteoc"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); } /** @@ -2462,10 +2464,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testaddnameformocconflict2"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertTrue(getSchema().hasNameForm(nameFormName)); } /** @@ -2501,10 +2503,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testremovenameformsuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); } /** @@ -2546,10 +2548,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testremovethenaddnameformsuccessful"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertTrue(getSchema().hasNameForm(nameFormName)); } /** @@ -2591,10 +2593,10 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testremovenameformreferencedbydsrnf"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, CONSTRAINT_VIOLATION); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertTrue(getSchema().hasNameForm(nameFormName)); } /** @@ -2621,14 +2623,14 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testaddditcontentrulesuccessfuloc"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName); ObjectClass oc = getSchema().getObjectClass(ocName); assertFalse(oc.isPlaceHolder()); DITContentRule dcr = DirectoryServer.getInstance().getServerContext().getSchema().getDITContentRule(oc); DITContentRule dcr = getSchema().getDITContentRule(oc); assertNotNull(dcr); assertTrue(dcr.hasName("testaddditcontentrulesuccessful")); } @@ -2664,14 +2666,14 @@ "NOT description X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testreplaceditcontentrulesuccessfuloc"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsPermissive(), ldif, System.err, SUCCESS); ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName); ObjectClass oc = getSchema().getObjectClass(ocName); assertFalse(oc.isPlaceHolder()); DITContentRule dcr = DirectoryServer.getInstance().getServerContext().getSchema().getDITContentRule(oc); DITContentRule dcr = getSchema().getDITContentRule(oc); assertNotNull(dcr); assertTrue(dcr.hasName("testreplaceditcontentrulesuccessful")); } @@ -2702,15 +2704,15 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testadddcrtoaltschemafileoc"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); assertSchemaFileExists("98-schema-test-dcr.ldif", false); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName); ObjectClass oc = getSchema().getObjectClass(ocName); assertFalse(oc.isPlaceHolder()); DITContentRule dcr = DirectoryServer.getInstance().getServerContext().getSchema().getDITContentRule(oc); DITContentRule dcr = getSchema().getDITContentRule(oc); assertNotNull(dcr); assertTrue(dcr.hasName("testadddcrtoaltschemafile")); @@ -2753,14 +2755,14 @@ "NOT description X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testremovethenaddditcontentruleoc"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName); ObjectClass oc = getSchema().getObjectClass(ocName); assertFalse(oc.isPlaceHolder()); DITContentRule dcr = DirectoryServer.getInstance().getServerContext().getSchema().getDITContentRule(oc); DITContentRule dcr = getSchema().getDITContentRule(oc); assertNotNull(dcr); assertTrue(dcr.hasName("testremovethenaddditcontentrule")); } @@ -3353,14 +3355,14 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String ocName = "testremoveditcontentrulesuccessfuloc"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getSchema().hasObjectClass(ocName)); runModify(argsNotPermissive(), ldif, System.err, SUCCESS); ObjectClass oc = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocName); ObjectClass oc = getSchema().getObjectClass(ocName); assertFalse(oc.isPlaceHolder()); DITContentRule dcr = DirectoryServer.getInstance().getServerContext().getSchema().getDITContentRule(oc); DITContentRule dcr = getSchema().getDITContentRule(oc); assertNull(dcr); } @@ -3430,7 +3432,7 @@ private void assertSchemaHasDITStructureRule(int ruleID, boolean expected) { boolean hasDITStructureRule = DirectoryServer.getInstance().getServerContext().getSchema().hasDITStructureRule(ruleID); boolean hasDITStructureRule = getSchema().hasDITStructureRule(ruleID); assertEquals(hasDITStructureRule, expected, "Expected to find a DITStructureRule with ruleID " + ruleID); } @@ -4089,7 +4091,7 @@ private void assertMatchingRuleUseExistsWithName(MatchingRule matchingRule, String mruName) { MatchingRuleUse mru = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRuleUse(matchingRule); MatchingRuleUse mru = getSchema().getMatchingRuleUse(matchingRule); assertNotNull(mru); assertTrue(mru.hasName(mruName)); } @@ -4183,7 +4185,7 @@ private void assertSchemaDoesNotHaveMatchingRuleUse(MatchingRule matchingRule) { for (MatchingRuleUse matchingRuleUse : DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRuleUses()) for (MatchingRuleUse matchingRuleUse : getSchema().getMatchingRuleUses()) { assertFalse(matchingRuleUse.getMatchingRule().equals(matchingRule)); } @@ -4277,9 +4279,7 @@ .addToSchema(); } }); SchemaHandler schemaHandler = DirectoryServer.getInstance().getServerContext().getSchemaHandler(); return schemaHandler.getSchema().getMatchingRule(oid); return getSchema().getMatchingRule(oid); } private void runModify(String[] args, String ldifContent, ResultCode expectedRC) @@ -4381,7 +4381,7 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String attrName = "testattributetypesmatchingrule"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, System.err, ATTRIBUTE_OR_VALUE_EXISTS); } @@ -4415,7 +4415,7 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String objectClassName = "testobjectclassesmatchingrule"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(objectClassName)); assertFalse(getSchema().hasObjectClass(objectClassName)); runModify(argsNotPermissive(), ldif, System.err, ATTRIBUTE_OR_VALUE_EXISTS); } @@ -4457,7 +4457,7 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String nameFormName = "testnameformsmatchingrule"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasNameForm(nameFormName)); assertFalse(getSchema().hasNameForm(nameFormName)); runModify(argsNotPermissive(), ldif, System.err, ATTRIBUTE_OR_VALUE_EXISTS); } @@ -4499,7 +4499,7 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String objectClassName = "testditcontentrulesmatchingruleoc"; assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(objectClassName).isPlaceHolder()); assertTrue(getSchema().getObjectClass(objectClassName).isPlaceHolder()); runModify(argsNotPermissive(), ldif, System.err, ATTRIBUTE_OR_VALUE_EXISTS); } @@ -4565,7 +4565,7 @@ "X-ORIGIN 'SchemaBackendTestCase' )"); String objectClassName = "testditcontentrulesmatchingruleoc1"; assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(objectClassName).isPlaceHolder()); assertTrue(getSchema().getObjectClass(objectClassName).isPlaceHolder()); runModify(argsNotPermissive(), ldif, System.err, ATTRIBUTE_OR_VALUE_EXISTS); } @@ -4616,7 +4616,7 @@ String attrName = "testmatchingruleusematchingruleat1"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getSchema().hasAttributeType(attrName)); runModify(argsNotPermissive(), ldif, System.err, ATTRIBUTE_OR_VALUE_EXISTS); } @@ -4742,8 +4742,8 @@ " MAY ( street $ c) X-ORIGIN 'user defined' )"); assertEquals(resultCode, 0); assertFalse(getInstance().getServerContext().getSchema().getObjectClass("testaddanddeletedefinitionwithextraspaces").isPlaceHolder()); assertFalse(getInstance().getServerContext().getSchema().getObjectClass("testaddanddeletedefinitionwithextraspaces-oid").isPlaceHolder()); assertFalse(getSchema().getObjectClass("testaddanddeletedefinitionwithextraspaces").isPlaceHolder()); assertFalse(getSchema().getObjectClass("testaddanddeletedefinitionwithextraspaces-oid").isPlaceHolder()); resultCode = TestCaseUtils.applyModifications(false, "dn: cn=schema", @@ -4754,8 +4754,8 @@ " MAY ( street $ c) X-ORIGIN 'user defined' )"); assertEquals(resultCode, 0); assertTrue(getInstance().getServerContext().getSchema().getObjectClass("testaddanddeletedefinitionwithextraspaces").isPlaceHolder()); assertTrue(getInstance().getServerContext().getSchema().getObjectClass("testaddanddeletedefinitionwithextraspaces-oid").isPlaceHolder()); assertTrue(getSchema().getObjectClass("testaddanddeletedefinitionwithextraspaces").isPlaceHolder()); assertTrue(getSchema().getObjectClass("testaddanddeletedefinitionwithextraspaces-oid").isPlaceHolder()); } /** @@ -4791,9 +4791,8 @@ LDIFExportConfig exportConfig = new LDIFExportConfig(tempFile.getAbsolutePath(), OVERWRITE); schemaBackend.exportLDIF(exportConfig); ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); LDIFImportConfig importConfig = new LDIFImportConfig(tempFile.getAbsolutePath()); LDIFImportResult importResult = schemaBackend.importLDIF(importConfig, serverContext); LDIFImportResult importResult = schemaBackend.importLDIF(importConfig, getServerContext()); assertEquals(importResult.getEntriesRead(), 1); assertEquals(importResult.getEntriesImported(), 0); assertEquals(importResult.getEntriesRejected(), 1); @@ -4813,8 +4812,7 @@ LDIFImportConfig importConfig = new LDIFImportConfig(tempFile.getAbsolutePath()); importConfig.setValidateSchema(false); ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); LDIFImportResult importResult = schemaBackend.importLDIF(importConfig, serverContext); LDIFImportResult importResult = schemaBackend.importLDIF(importConfig, getServerContext()); assertEquals(importResult.getEntriesRead(), 1); assertEquals(importResult.getEntriesImported(), 1); assertEquals(importResult.getEntriesRejected(), 0); opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/OnDiskMergeImporterTest.java
@@ -15,17 +15,19 @@ */ package org.opends.server.backends.pluggable; import static java.util.Arrays.*; import static org.assertj.core.api.Assertions.*; import static org.forgerock.opendj.config.ConfigurationMock.mockCfg; import static org.forgerock.opendj.config.ConfigurationMock.*; import static org.forgerock.opendj.ldap.ResultCode.*; import static org.forgerock.opendj.server.config.meta.BackendIndexCfgDefn.IndexType.*; import static java.util.Arrays.asList; import static org.forgerock.util.Pair.of; import static org.mockito.Matchers.any; import static org.forgerock.util.Pair.*; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import static org.opends.server.backends.pluggable.DnKeyFormat.dnToDNKey; import static org.opends.server.TestCaseUtils.*; import static org.opends.server.backends.pluggable.DnKeyFormat.*; import static org.opends.server.backends.pluggable.EntryIDSet.*; import static org.opends.server.util.CollectionUtils.newTreeSet; import static org.opends.server.util.CollectionUtils.*; import java.io.File; import java.nio.ByteBuffer; @@ -82,7 +84,6 @@ import org.opends.server.backends.pluggable.spi.StorageRuntimeException; import org.opends.server.backends.pluggable.spi.TreeName; import org.opends.server.backends.pluggable.spi.WriteableTransaction; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.crypto.CryptoSuite; import org.opends.server.types.DirectoryException; @@ -118,7 +119,7 @@ // Need the schema to be available, so make sure the server is started. TestCaseUtils.startServer(); serverContext = DirectoryServer.getInstance().getServerContext(); serverContext = getServerContext(); backendCfg = mockCfg(JEBackendCfg.class); when(backendCfg.getBackendId()).thenReturn("OnDiskMergeImporterTest"); @@ -136,7 +137,7 @@ for (Map.Entry<String, IndexType[]> index : backendIndexes.entrySet()) { final String attributeName = index.getKey(); final AttributeType attribute = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attributeName); final AttributeType attribute = getServerContext().getSchema().getAttributeType(attributeName); Reject.ifNull(attribute, "Attribute type '" + attributeName + "' doesn't exists."); BackendIndexCfg indexCfg = mock(BackendIndexCfg.class); @@ -161,7 +162,7 @@ backend = new JEBackend(); backend.setBackendID(backendCfg.getBackendId()); backend.configureBackend(backendCfg, DirectoryServer.getInstance().getServerContext()); backend.configureBackend(backendCfg, getServerContext()); backend.openBackend(); entryContainer = backend.getRootContainer().getEntryContainer(testBaseDN); opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
@@ -38,22 +38,23 @@ import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ConditionResult; import org.forgerock.opendj.ldap.DN; 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.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.opends.server.DirectoryServerTestCase; import org.opends.server.TestCaseUtils; import org.forgerock.opendj.server.config.meta.BackendIndexCfgDefn.IndexType; import org.forgerock.opendj.server.config.meta.BackendVLVIndexCfgDefn.Scope; import org.forgerock.opendj.server.config.server.BackendIndexCfg; import org.forgerock.opendj.server.config.server.BackendVLVIndexCfg; import org.forgerock.opendj.server.config.server.PluggableBackendCfg; import org.opends.server.api.LocalBackend.BackendOperation; import org.forgerock.util.Reject; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.opends.server.DirectoryServerTestCase; import org.opends.server.TestCaseUtils; import org.opends.server.api.ClientConnection; import org.opends.server.api.LocalBackend.BackendOperation; import org.opends.server.backends.RebuildConfig; import org.opends.server.backends.RebuildConfig.RebuildMode; import org.opends.server.backends.VerifyConfig; @@ -67,7 +68,6 @@ import org.opends.server.backends.pluggable.spi.WriteableTransaction; import org.opends.server.core.AddOperation; import org.opends.server.core.DeleteOperation; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ModifyDNOperation; import org.opends.server.core.ModifyOperation; import org.opends.server.core.SearchOperation; @@ -77,7 +77,6 @@ import org.opends.server.protocols.internal.SearchRequest; import org.opends.server.types.BackupConfig; import org.opends.server.types.BackupDirectory; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.LDIFExportConfig; @@ -159,7 +158,7 @@ for (Map.Entry<String, IndexType[]> index : backendIndexes.entrySet()) { final String attributeName = index.getKey(); final AttributeType attribute = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attributeName); final AttributeType attribute = TestCaseUtils.getServerContext().getSchema().getAttributeType(attributeName); Reject.ifNull(attribute, "Attribute type '" + attributeName + "' doesn't exists."); BackendIndexCfg indexCfg = mock(BackendIndexCfg.class); @@ -184,7 +183,7 @@ backend = createBackend(); backend.setBackendID(backendCfg.getBackendId()); backend.configureBackend(backendCfg, DirectoryServer.getInstance().getServerContext()); backend.configureBackend(backendCfg, TestCaseUtils.getServerContext()); backend.openBackend(); topEntries = TestCaseUtils.makeEntries( @@ -621,7 +620,8 @@ { for (IndexType type : index.getValue()) { final AttributeType attributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(index.getKey()); final AttributeType attributeType = TestCaseUtils.getServerContext().getSchema().getAttributeType(index.getKey()); assertTrue(backend.isIndexed(attributeType, org.opends.server.types.IndexType.valueOf(type.toString().toUpperCase()))); } @@ -672,7 +672,7 @@ Entry oldEntry = workEntries.get(0); Entry newEntry = oldEntry.duplicate(false); modifyAttribute = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("jpegphoto"); modifyAttribute = TestCaseUtils.getServerContext().getSchema().getAttributeType("jpegphoto"); List<Modification> mods = Arrays.asList( // unindexed new Modification(ADD, create(modifyAttribute, modifyValue)), @@ -954,7 +954,7 @@ importConf.writeRejectedEntries(rejectedEntries); importConf.setIncludeBranches(Collections.singleton(testBaseDN)); importConf.setThreadCount(0); backend.importLDIF(importConf, DirectoryServer.getInstance().getServerContext()); backend.importLDIF(importConf, TestCaseUtils.getServerContext()); } assertEquals(rejectedEntries.size(), 0, "No entries should be rejected. Content was:\n" + rejectedEntries.toString()); @@ -1025,7 +1025,7 @@ rebuildConf.setRebuildMode(RebuildMode.ALL); backend.closeBackend(); backend.rebuildBackend(rebuildConf, DirectoryServer.getInstance().getServerContext()); backend.rebuildBackend(rebuildConf, TestCaseUtils.getServerContext()); backend.openBackend(); VerifyConfig config = new VerifyConfig(); @@ -1078,7 +1078,7 @@ rebuildConf.setRebuildMode(RebuildMode.DEGRADED); backend.closeBackend(); backend.rebuildBackend(rebuildConf, DirectoryServer.getInstance().getServerContext()); backend.rebuildBackend(rebuildConf, TestCaseUtils.getServerContext()); backend.openBackend(); VerifyConfig config = new VerifyConfig(); @@ -1162,7 +1162,7 @@ when(backendCfg.listBackendIndexes()).thenReturn(new String[0]); when(backendCfg.listBackendVLVIndexes()).thenReturn(new String[0]); ServerContext serverContext = DirectoryServer.getInstance().getServerContext(); ServerContext serverContext = TestCaseUtils.getServerContext(); final Storage storage = backend.configureStorage(backendCfg, serverContext); final RootContainer readOnlyContainer = new RootContainer(backend.getBackendID(), serverContext, storage, backendCfg); opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestDnKeyFormat.java
@@ -17,6 +17,7 @@ package org.opends.server.backends.pluggable; import static org.assertj.core.api.Assertions.*; import static org.opends.server.TestCaseUtils.*; import static org.opends.server.util.StaticUtils.*; import static org.testng.Assert.*; @@ -341,7 +342,7 @@ // check the object classes were not changed for (String ocBefore : entryBefore.getObjectClasses().values()) { ObjectClass objectClass = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(ocBefore); ObjectClass objectClass = getServerContext().getSchema().getObjectClass(ocBefore); String ocAfter = entryAfter.getObjectClasses().get(objectClass); assertEquals(ocBefore, ocAfter); } opendj-server-legacy/src/test/java/org/opends/server/controls/MatchedValuesControlTest.java
@@ -24,7 +24,6 @@ import org.forgerock.opendj.ldap.Base64; import org.forgerock.opendj.ldap.schema.CoreSchema; import org.forgerock.opendj.ldap.schema.MatchingRule; import org.opends.server.core.DirectoryServer; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ByteStringBuilder; @@ -33,6 +32,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.opends.server.TestCaseUtils.*; import static org.testng.Assert.*; /** Test MatchedValuesControl. */ @@ -110,7 +110,7 @@ } AttributeType attType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(type); AttributeType attType = getServerContext().getSchema().getAttributeType(type); ByteString attVal = null; if (attType != null) { @@ -189,7 +189,7 @@ // input parameter String rawAttTypeTest = type; AttributeType attTypeTest = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(type); AttributeType attTypeTest = getServerContext().getSchema().getAttributeType(type); ByteString subInitialTest = ByteString.valueOfUtf8(subInitial); List<ByteString> subAnyTest = new ArrayList<>(subAny.size()); for (String s : subAny) @@ -367,7 +367,7 @@ } // ( AttributeType attributeType, ByteString assertionValue AttributeType attType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(type); AttributeType attType = getServerContext().getSchema().getAttributeType(type); ByteString attVal = null; if (attType != null) { @@ -463,7 +463,7 @@ } AttributeType attType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(type); AttributeType attType = getServerContext().getSchema().getAttributeType(type); ByteString attVal = null ; if (attType != null) { @@ -539,7 +539,7 @@ assertEquals(mvf.getMatchType(), MatchedValuesFilter.PRESENT_TYPE); // ( AttributeType attributeType AttributeType attType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(type); AttributeType attType = getServerContext().getSchema().getAttributeType(type); try { @@ -608,7 +608,7 @@ } // ( AttributeType attributeType, ByteString assertionValue AttributeType attType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(type); AttributeType attType = getServerContext().getSchema().getAttributeType(type); ByteString attVal = null ; if (attType != null) { @@ -680,7 +680,7 @@ // input value String rawAttTypeTest = type ; AttributeType attTypeTest = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(type) ; AttributeType attTypeTest = getServerContext().getSchema().getAttributeType(type) ; String matchingRuleIdTest = matchingRule.getOID() ; ByteString attValueTest = (attTypeTest == null) ? null : ByteString.valueOfUtf8(value); // parameter used for the test. @@ -790,7 +790,7 @@ public void testDifferentNormalization(String type, ByteString value, String assertion) { AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("usercertificate"); AttributeType attrType = getServerContext().getSchema().getAttributeType("usercertificate"); MatchedValuesFilter mvf = MatchedValuesFilter.createEqualityFilter(type, ByteString.valueOfUtf8(assertion)); assertTrue(mvf.valueMatches(attrType, value)); } opendj-server-legacy/src/test/java/org/opends/server/core/ModifyOperationTestCase.java
@@ -98,7 +98,7 @@ for (Object[] backendBaseDN2 : getBaseDNs()) { final DN baseDN = DN.valueOf(backendBaseDN2[0].toString()); LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager().findLocalBackendForEntry(baseDN); LocalBackend<?> b = getServerContext().getBackendConfigManager().findLocalBackendForEntry(baseDN); b.setWritabilityMode(WritabilityMode.ENABLED); } } @@ -1887,7 +1887,7 @@ private AttributeType getEmployeeNumberAttributeType() { return DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("employeenumber"); return getServerContext().getSchema().getAttributeType("employeenumber"); } private void assertIntegerValueExists(List<Attribute> attrList, int expectedValue) @@ -2166,7 +2166,7 @@ Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); assertTrue(e.hasObjectClass(getExtensibleObjectObjectClass())); assertTrue(e.hasObjectClass(DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass("inetOrgPerson"))); assertTrue(e.hasObjectClass(getServerContext().getSchema().getObjectClass("inetOrgPerson"))); assertTrue(e.hasObjectClass(getOrganizationalPersonObjectClass())); assertTrue(e.hasObjectClass(getPersonObjectClass())); assertTrue(e.hasObjectClass(getTopObjectClass())); @@ -2431,7 +2431,7 @@ "mail: foo", "employeeNumber: 1"); LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager() LocalBackend<?> b = getServerContext().getBackendConfigManager() .findLocalBackendForEntry(DN.valueOf(baseDN)); b.setWritabilityMode(WritabilityMode.DISABLED); @@ -2470,7 +2470,7 @@ "mail: foo", "employeeNumber: 1"); LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager() LocalBackend<?> b = getServerContext().getBackendConfigManager() .findLocalBackendForEntry(DN.valueOf(baseDN)); b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); @@ -2509,7 +2509,7 @@ "mail: foo", "employeeNumber: 1"); LocalBackend<?> b = TestCaseUtils.getServerContext().getBackendConfigManager() LocalBackend<?> b = getServerContext().getBackendConfigManager() .findLocalBackendForEntry(DN.valueOf(baseDN)); b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); @@ -2849,7 +2849,7 @@ "X-ORGIN 'SchemaBackendTestCase' )"); String attrName = "testmodifyobsoleteattribute"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertFalse(getServerContext().getSchema().hasAttributeType(attrName)); String[] args = { @@ -2861,7 +2861,7 @@ }; assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasAttributeType(attrName)); assertTrue(getServerContext().getSchema().hasAttributeType(attrName)); path = TestCaseUtils.createTempFile( "dn: " + baseDN, @@ -2907,7 +2907,7 @@ "AUXILIARY MAY description X-ORGIN 'SchemaBackendTestCase' )"); String ocName = "testmodifyaddobsoleteobjectclass"; assertFalse(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertFalse(getServerContext().getSchema().hasObjectClass(ocName)); String[] args = { @@ -2919,7 +2919,7 @@ }; assertEquals(LDAPModify.run(nullPrintStream(), System.err, args), 0); assertTrue(DirectoryServer.getInstance().getServerContext().getSchema().hasObjectClass(ocName)); assertTrue(getServerContext().getSchema().hasObjectClass(ocName)); path = TestCaseUtils.createTempFile( "dn: " + baseDN, @@ -3235,8 +3235,7 @@ "cn: Test User", "userPassword: password", "userPassword;deleted: oldpassword"); LocalBackend<?> backend = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackendById(TEST_BACKEND_ID); LocalBackend<?> backend = getServerContext().getBackendConfigManager().getLocalBackendById(TEST_BACKEND_ID); backend.addEntry(e, null); // Don't use add operation. // Constraint violation. @@ -3277,8 +3276,7 @@ "cn: Test User", "userPassword: password", "userPassword;deleted: oldpassword"); LocalBackend<?> backend = TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackendById(TEST_BACKEND_ID); LocalBackend<?> backend = getServerContext().getBackendConfigManager().getLocalBackendById(TEST_BACKEND_ID); backend.addEntry(e, null); // Don't use add operation. // Constraint violation. opendj-server-legacy/src/test/java/org/opends/server/core/PasswordPolicyTestCase.java
@@ -4299,9 +4299,7 @@ { Entry entry = DirectoryServer.getEntry(DN.valueOf(dn)); assertNotNull(entry); AttributeType pwdHistory = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("pwdhistory"); assertNotNull(pwdHistory); Attribute historyAttr = entry.getAttribute(AttributeDescription.create(pwdHistory)); Attribute historyAttr = entry.getAttribute(AttributeDescription.valueOf("pwdhistory")); assertNotNull(historyAttr); assertThat(historyAttr).hasSize(3); opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java
@@ -319,7 +319,7 @@ private void hasValues(DN dn, String attrName, String... values) throws DirectoryException { Entry entry = DirectoryServer.getEntry(dn); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); AttributeType attrType = getServerContext().getSchema().getAttributeType(attrName); assertTrue(entry.hasAttribute(attrType)); for (String value : values) { @@ -330,7 +330,7 @@ private void doesNotHaveValues(DN dn, String attrName, String... values) throws DirectoryException { Entry entry = DirectoryServer.getEntry(dn); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); AttributeType attrType = getServerContext().getSchema().getAttributeType(attrName); assertTrue(entry.hasAttribute(attrType)); for (String value : values) { @@ -341,7 +341,7 @@ private void hasNoAttribute(DN dn, String attrName) throws Exception { Entry entry = DirectoryServer.getEntry(dn); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); AttributeType attrType = getServerContext().getSchema().getAttributeType(attrName); assertFalse(entry.hasAttribute(attrType)); } @@ -354,7 +354,7 @@ assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); assertEquals(searchOperation.getEntriesSent(), 1); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("collectiveattributesubentries"); AttributeType attrType = getServerContext().getSchema().getAttributeType("collectiveattributesubentries"); Entry e = searchOperation.getSearchEntries().getFirst(); assertTrue(e.hasValue(attrType, ByteString.valueOfObject(collectiveSubentry.getName()))); } opendj-server-legacy/src/test/java/org/opends/server/core/SubentryPasswordPolicyTestCase.java
@@ -405,7 +405,7 @@ Entry testEntry = DirectoryServer.getEntry(DN.valueOf("uid=rogasawara," + BASE)); assertNotNull(testEntry); AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("pwdpolicysubentry"); AttributeType attrType = getServerContext().getSchema().getAttributeType("pwdpolicysubentry"); // Make sure that default policy is in effect // for the user entry. opendj-server-legacy/src/test/java/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java
@@ -134,7 +134,7 @@ "ds-cfg-enabled: true", "ds-cfg-match-attribute: uid"); AttributeType t = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("ds-cfg-match-base-dn"); AttributeType t = TestCaseUtils.getServerContext().getSchema().getAttributeType("ds-cfg-match-base-dn"); e.addAttribute(Attributes.empty(t), new ArrayList<ByteString>()); entries.add(e); opendj-server-legacy/src/test/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProviderTestCase.java
@@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.*; import static org.forgerock.opendj.ldap.SearchScope.*; 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.util.ServerConstants.*; @@ -62,7 +63,7 @@ { TestCaseUtils.startServer(); hasSubordinatesType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("hassubordinates"); hasSubordinatesType = getServerContext().getSchema().getAttributeType("hassubordinates"); entries = TestCaseUtils.makeEntries( "dn: dc=example,dc=com", opendj-server-legacy/src/test/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProviderTestCase.java
@@ -57,7 +57,7 @@ { TestCaseUtils.restartServer(); numSubordinatesType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("numsubordinates"); numSubordinatesType = TestCaseUtils.getServerContext().getSchema().getAttributeType("numsubordinates"); entries = TestCaseUtils.makeEntries( "dn: dc=example,dc=com", opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordModifyExtendedOperationTestCase.java
@@ -16,6 +16,14 @@ */ package org.opends.server.extensions; import static org.forgerock.opendj.ldap.ModificationType.*; import static org.opends.server.TestCaseUtils.*; import static org.opends.server.extensions.ExtensionsConstants.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.types.NullOutputStream.*; import static org.opends.server.util.ServerConstants.*; import static org.testng.Assert.*; import java.util.List; import org.forgerock.opendj.config.server.ConfigException; @@ -23,20 +31,19 @@ import org.forgerock.opendj.io.ASN1Writer; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.ByteStringBuilder; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.requests.ModifyRequest; import org.forgerock.opendj.ldap.requests.Requests; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.TestCaseUtils; import org.forgerock.opendj.server.config.meta.PasswordModifyExtendedOperationHandlerCfgDefn; import org.opends.server.TestCaseUtils; import org.opends.server.core.BindOperation; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ExtendedOperation; import org.opends.server.core.ModifyOperation; import org.opends.server.protocols.internal.InternalClientConnection; import com.forgerock.opendj.ldap.tools.LDAPPasswordModify; import org.opends.server.types.AuthenticationInfo; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; import org.opends.server.types.InitializationException; @@ -44,12 +51,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.forgerock.opendj.ldap.ModificationType.*; import static org.opends.server.extensions.ExtensionsConstants.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.types.NullOutputStream.nullPrintStream; import static org.opends.server.util.ServerConstants.*; import static org.testng.Assert.*; import com.forgerock.opendj.ldap.tools.LDAPPasswordModify; /** * A set of test cases for the password modify extended operation. @@ -1669,7 +1671,7 @@ try { AttributeType lastLoginTimeAttr = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("ds-pwp-last-login-time"); AttributeType lastLoginTimeAttr = getServerContext().getSchema().getAttributeType("ds-pwp-last-login-time"); assertNotNull(lastLoginTimeAttr); DN userDN = DN.valueOf("uid=test.user,o=test"); @@ -1725,7 +1727,7 @@ try { AttributeType authFailureTimesAttr = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("pwdfailuretime"); AttributeType authFailureTimesAttr = getServerContext().getSchema().getAttributeType("pwdfailuretime"); assertNotNull(authFailureTimesAttr); DN userDN = DN.valueOf("uid=test.user,o=test"); @@ -1774,7 +1776,7 @@ try { AttributeType pwdHistoryAttr = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("pwdhistory"); AttributeType pwdHistoryAttr = getServerContext().getSchema().getAttributeType("pwdhistory"); assertNotNull(pwdHistoryAttr); DN userDN = DN.valueOf("uid=test.user,o=test"); opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPConnectionHandler.java
@@ -32,6 +32,7 @@ import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.reactive.LDAPConnectionHandler2; import org.opends.server.types.Attributes; import org.forgerock.opendj.ldap.DN; @@ -229,21 +230,22 @@ "ds-cfg-trust-manager-provider: cn=JKS,cn=Trust Manager Providers,cn=config"); LDAPConnectionHandler2 LDAPConnHandler=getLDAPHandlerInstance(GoodHandlerEntry); //Make attrTypes to remove AttributeType at0=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_LISTEN_PORT); Schema schema = DirectoryServer.getInstance().getServerContext().getSchema(); AttributeType at0=schema.getAttributeType(ATTR_LISTEN_PORT); // AttributeType at1=DirectoryServer.getAttributeType(ATTR_LISTEN_ADDRESS, true); // Attribute rAttr1=new Attribute(at1); // GoodHandlerEntry.removeAttribute(rAttr1, null); AttributeType at2=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_ALLOW_LDAPV2); AttributeType at3=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_ALLOW_LDAPV2); AttributeType at4=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_KEEP_LDAP_STATS); AttributeType at5=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_SEND_REJECTION_NOTICE); AttributeType at6=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_USE_TCP_KEEPALIVE); AttributeType at7=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_USE_TCP_NODELAY); AttributeType at8=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_ALLOW_REUSE_ADDRESS); AttributeType at9=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_USE_SSL); AttributeType at10=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_ALLOW_STARTTLS); AttributeType at11=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_MAX_REQUEST_SIZE); AttributeType at12=DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(ATTR_ACCEPT_BACKLOG); AttributeType at2=schema.getAttributeType(ATTR_ALLOW_LDAPV2); AttributeType at3=schema.getAttributeType(ATTR_ALLOW_LDAPV2); AttributeType at4=schema.getAttributeType(ATTR_KEEP_LDAP_STATS); AttributeType at5=schema.getAttributeType(ATTR_SEND_REJECTION_NOTICE); AttributeType at6=schema.getAttributeType(ATTR_USE_TCP_KEEPALIVE); AttributeType at7=schema.getAttributeType(ATTR_USE_TCP_NODELAY); AttributeType at8=schema.getAttributeType(ATTR_ALLOW_REUSE_ADDRESS); AttributeType at9=schema.getAttributeType(ATTR_USE_SSL); AttributeType at10=schema.getAttributeType(ATTR_ALLOW_STARTTLS); AttributeType at11=schema.getAttributeType(ATTR_MAX_REQUEST_SIZE); AttributeType at12=schema.getAttributeType(ATTR_ACCEPT_BACKLOG); //Remove them Attribute rAttr0=Attributes.empty(at0); GoodHandlerEntry.removeAttribute(rAttr0, null); opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
@@ -35,7 +35,6 @@ import org.forgerock.opendj.ldap.AttributeDescription; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.TestCaseUtils; import org.opends.server.backends.MemoryBackend; import org.opends.server.core.DirectoryServer; @@ -466,8 +465,7 @@ { debugInfo("Entry found <" + baseDN + ">"); AttributeType synchronizationGenIDType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(REPLICATION_GENERATION_ID); Attribute attr = resultEntry.getAttribute(AttributeDescription.create(synchronizationGenIDType)); Attribute attr = resultEntry.getAttribute(AttributeDescription.valueOf(REPLICATION_GENERATION_ID)); return Long.valueOf(attr.iterator().next().toString()); } return -1; @@ -491,8 +489,8 @@ LDIFImportConfig importConfig = new LDIFImportConfig(ldifFile.getAbsolutePath()); MemoryBackend memoryBackend = (MemoryBackend) TestCaseUtils.getServerContext().getBackendConfigManager().getLocalBackendById(TEST_BACKEND_ID); memoryBackend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); (MemoryBackend) getServerContext().getBackendConfigManager().getLocalBackendById(TEST_BACKEND_ID); memoryBackend.importLDIF(importConfig, getServerContext()); } private String createEntry(UUID uid) opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
@@ -433,7 +433,7 @@ { testSetUp("modifyConflicts"); final DN dn1 = DN.valueOf("cn=test1," + baseDN); final AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("displayname"); final AttributeType attrType = getServerContext().getSchema().getAttributeType("displayname"); final AttributeType entryuuidType = getEntryUUIDAttributeType(); String monitorAttr = "resolved-modify-conflicts"; opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -31,6 +31,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.adapter.server3x.Converters; import org.forgerock.opendj.ldap.AttributeDescription; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.ModificationType; @@ -539,7 +540,7 @@ debugInfo("Entry found <" + rootDn + ">"); AttributeType synchronizationGenIDType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(REPLICATION_GENERATION_ID); getServerContext().getSchema().getAttributeType(REPLICATION_GENERATION_ID); List<Attribute> attrs = resultEntry.getAllAttributes(synchronizationGenIDType); if (!attrs.isEmpty()) { @@ -647,7 +648,7 @@ String objectClassStr = fractionalConf[0]; if (!objectClassStr.equals("*")) { ObjectClass objectClass = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(objectClassStr); ObjectClass objectClass = getServerContext().getSchema().getObjectClass(objectClassStr); assertTrue(newEntry.hasObjectClass(objectClass)); } @@ -662,7 +663,7 @@ { if (!first) { assertFalse(newEntry.hasAttribute(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(fracAttr))); assertFalse(newEntry.hasAttribute(AttributeDescription.valueOf(fracAttr))); } first = false; } @@ -679,7 +680,7 @@ } first = false; } assertFalse(newEntry.hasAttribute(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OPTIONAL_ATTR))); assertFalse(newEntry.hasAttribute(AttributeDescription.valueOf(OPTIONAL_ATTR))); break; default: fail("Unexpected fractional mode."); @@ -700,7 +701,7 @@ String objectClassStr = fractionalConf[0]; if (!objectClassStr.equals("*")) { ObjectClass objectClass = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass(objectClassStr); ObjectClass objectClass = getServerContext().getSchema().getObjectClass(objectClassStr); assertTrue(entry.hasObjectClass(objectClass)); } @@ -716,7 +717,7 @@ { if (!first) { assertFalse(entry.hasAttribute(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(fracAttr))); assertFalse(entry.hasAttribute(AttributeDescription.valueOf(fracAttr))); } first = false; } @@ -733,7 +734,7 @@ } first = false; } assertFalse(entry.hasAttribute(DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(OPTIONAL_ATTR))); assertFalse(entry.hasAttribute(AttributeDescription.valueOf(OPTIONAL_ATTR))); break; default: fail("Unexpected fractional mode."); @@ -954,7 +955,7 @@ private Entry waitTillEntryHasSynchroAttribute(String entryDN) throws Exception { AttributeType synchroAttrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(SYNCHRO_OPTIONAL_ATTR); AttributeDescription synchroAttrType = AttributeDescription.valueOf(SYNCHRO_OPTIONAL_ATTR); DN dn = DN.valueOf(entryDN); Entry entry = null; @@ -1523,6 +1524,6 @@ private ObjectClass getInetOrgPersonObjectClass() { return DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass("inetOrgPerson"); return getServerContext().getSchema().getObjectClass("inetOrgPerson"); } } opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
@@ -141,7 +141,7 @@ long startTime = TimeThread.getTime(); final DN dn1 = DN.valueOf("cn=test1," + baseDN); final AttributeType histType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME); getServerContext().getSchema().getAttributeType(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME); logger.error(LocalizableMessage.raw("Starting replication test : changesCmpTest")); opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java
@@ -231,7 +231,7 @@ final DN dn1 = DN.valueOf("cn=test1," + TEST_ROOT_DN_STRING); final DN dn2 = DN.valueOf("cn=test2," + TEST_ROOT_DN_STRING); final DN baseDN = DN.valueOf(TEST_ROOT_DN_STRING); final AttributeType attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType("displayname"); final AttributeType attrType = getServerContext().getSchema().getAttributeType("displayname"); final AttributeDescription attrDesc = AttributeDescription.create(attrType); final AttributeDescription entryuuidDesc = AttributeDescription.create(getEntryUUIDAttributeType()); opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java
@@ -48,7 +48,6 @@ import static org.forgerock.opendj.ldap.ModificationType.*; import static org.forgerock.opendj.ldap.schema.CoreSchema.*; import static org.opends.server.TestCaseUtils.*; import static org.opends.server.core.DirectoryServer.*; import static org.opends.server.protocols.internal.InternalClientConnection.*; import static org.opends.server.replication.plugin.EntryHistorical.*; import static org.opends.server.replication.protocol.OperationContext.*; @@ -1165,7 +1164,7 @@ */ private void assertEntryHistoricalEncodingDecoding(Entry entry, EntryHistorical hist) { entry.removeAttribute(getInstance().getServerContext().getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME)); entry.removeAttribute(getServerContext().getSchema().getAttributeType(HISTORICAL_ATTRIBUTE_NAME)); entry.addAttribute(hist.encodeAndPurge(), null); EntryHistorical hist2 = EntryHistorical.newInstanceFromEntry(entry); assertEquals(hist2.encodeAndPurge(), hist.encodeAndPurge()); @@ -1197,7 +1196,7 @@ private void assertContainsOnlyValues(Entry entry, String attrName, String... expectedValues) { Attribute attr = entry.getAttribute(AttributeDescription.create(getInstance().getServerContext().getSchema().getAttributeType(attrName))); Attribute attr = entry.getAttribute(AttributeDescription.valueOf(attrName)); assertThat(attr).hasSize(expectedValues.length); for (String value : expectedValues) { opendj-server-legacy/src/test/java/org/opends/server/schema/FakeEntryIndex.java
@@ -16,6 +16,7 @@ package org.opends.server.schema; import static org.mockito.Mockito.*; import static org.opends.server.TestCaseUtils.*; import java.util.Collection; import java.util.Collections; @@ -37,7 +38,6 @@ import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.ldap.spi.Indexer; import org.forgerock.opendj.ldap.spi.IndexingOptions; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.opends.server.types.DirectoryException; import org.opends.server.types.Entry; @@ -52,7 +52,7 @@ FakeEntryIndex(String attrName) throws DecodeException { attrType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attrName); attrType = getServerContext().getSchema().getAttributeType(attrName); if (attrType == null) { throw new IllegalArgumentException("Cannot find attribute with name \"" + attrName + "\""); @@ -125,7 +125,7 @@ return matchingRule.getGreaterOrEqualAssertion(filter.getAssertionValue()); case EXTENSIBLE_MATCH: MatchingRule rule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(filter.getMatchingRuleID()); MatchingRule rule = getServerContext().getSchema().getMatchingRule(filter.getMatchingRuleID()); return rule.getAssertion(filter.getAssertionValue()); default: opendj-server-legacy/src/test/java/org/opends/server/schema/TimeBasedMatchingRuleTest.java
@@ -17,6 +17,7 @@ package org.opends.server.schema; import static org.assertj.core.api.Assertions.*; import static org.opends.server.TestCaseUtils.*; import static org.opends.server.schema.GeneralizedTimeSyntax.format; import static org.opends.server.schema.SchemaConstants.*; import static org.testng.Assert.*; @@ -39,7 +40,6 @@ import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.MatchingRule; import org.opends.server.TestCaseUtils; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Attribute; import org.opends.server.types.Entry; import org.opends.server.types.FilterType; @@ -152,7 +152,7 @@ private Collection<DN> getMatchingEntryDNs(SearchFilter filter) throws Exception { AttributeType attrType = filter.getAttributeType(); MatchingRule rule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(filter.getMatchingRuleID()); MatchingRule rule = getServerContext().getSchema().getMatchingRule(filter.getMatchingRuleID()); Assertion assertion = rule.getAssertion(filter.getAssertionValue()); Collection<DN> results = new ArrayList<>(); @@ -199,7 +199,7 @@ public void testPartialDateNTimeMatch(long timeInMillis, String generalizedTime, String assertionValue) throws Exception { MatchingRule partialTimeRule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(EXT_PARTIAL_DATE_TIME_NAME); MatchingRule partialTimeRule = getServerContext().getSchema().getMatchingRule(EXT_PARTIAL_DATE_TIME_NAME); Assertion assertion = partialTimeRule.getAssertion(ByteString.valueOfUtf8(assertionValue)); assertEquals(assertion.matches(ByteString.valueOfLong(timeInMillis)), ConditionResult.TRUE); } @@ -223,7 +223,7 @@ @Test(dataProvider= "relativeTimeValues") public void testRelativeTimeMatchingRuleAssertionSyntax(String assertion,boolean isValid) { MatchingRule relativeTimeLTRule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(EXT_OMR_RELATIVE_TIME_LT_ALT_NAME); MatchingRule relativeTimeLTRule = getServerContext().getSchema().getMatchingRule(EXT_OMR_RELATIVE_TIME_LT_ALT_NAME); try { relativeTimeLTRule.getAssertion(ByteString.valueOfUtf8(assertion)); @@ -243,7 +243,7 @@ @Test(dataProvider= "partialDateTimeSyntaxes") public void testPartialDateTimeMatchingRuleAssertionSyntax(String assertion,boolean isValid) { MatchingRule partialDTRule = DirectoryServer.getInstance().getServerContext().getSchema().getMatchingRule(EXT_PARTIAL_DATE_TIME_OID); MatchingRule partialDTRule = getServerContext().getSchema().getMatchingRule(EXT_PARTIAL_DATE_TIME_OID); try { partialDTRule.getAssertion(ByteString.valueOfUtf8(assertion)); opendj-server-legacy/src/test/java/org/opends/server/tasks/TestBackupAndRestore.java
@@ -23,7 +23,6 @@ import org.opends.server.TestCaseUtils; import org.opends.server.backends.task.TaskState; import org.opends.server.core.DirectoryServer; import org.opends.server.types.Entry; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.testng.annotations.AfterClass; @@ -188,7 +187,7 @@ final int restoreBeginCountStart = restoreBeginCount.get(); final int restoreEndCountStart = restoreEndCount.get(); ObjectClass backupClass = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass("ds-task-backup"); ObjectClass backupClass = TestCaseUtils.getServerContext().getSchema().getObjectClass("ds-task-backup"); testTask(taskEntry, expectedState, 30); if (expectedState == TaskState.COMPLETED_SUCCESSFULLY || opendj-server-legacy/src/test/java/org/opends/server/tasks/TestImportAndExport.java
@@ -356,7 +356,7 @@ int importBeginCount = TestTaskListener.importBeginCount.get(); int importEndCount = TestTaskListener.importEndCount.get(); ObjectClass exportClass = DirectoryServer.getInstance().getServerContext().getSchema().getObjectClass("ds-task-export"); ObjectClass exportClass = TestCaseUtils.getServerContext().getSchema().getObjectClass("ds-task-export"); // Use a big timeout since this test is sensitive to host environment (e.g. // low memory, etc). See issue OPENDJ-256. opendj-server-legacy/src/test/java/org/opends/server/types/SearchFilterTests.java
@@ -28,7 +28,6 @@ import org.forgerock.opendj.ldap.schema.AttributeType; import org.opends.server.DirectoryServerTestCase; import org.opends.server.TestCaseUtils; import org.opends.server.core.DirectoryServer; import org.opends.server.util.StaticUtils; import org.testng.Assert; import org.testng.annotations.BeforeClass; @@ -37,6 +36,7 @@ import static java.util.Arrays.*; import static org.opends.server.TestCaseUtils.*; import static org.testng.Assert.*; /** @@ -567,7 +567,7 @@ FilterDescription description = new FilterDescription(); description.filterType = filterType; description.attributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attributeType); description.attributeType = getServerContext().getSchema().getAttributeType(attributeType); description.assertionValue = ByteString.valueOfUtf8(attributeValue); if (filterType == FilterType.EQUALITY) { @@ -629,7 +629,7 @@ FilterDescription description = new FilterDescription(); description.filterType = FilterType.SUBSTRING; description.attributeType = DirectoryServer.getInstance().getServerContext().getSchema().getAttributeType(attributeType); description.attributeType = getServerContext().getSchema().getAttributeType(attributeType); description.subInitialElement = ByteString.valueOfUtf8(subInitial); description.subAnyElements = new ArrayList<>();