Code cleanup
DirectoryServer.java:
Changed getAttributeType(String lowerName, boolean returnDefault) to getAttributeTypeOrDefault(String lowerName).
Renamed getAttributeType(String lowerName, String upperName) to getAttributeTypeOrDefault(String lowerName, String upperName).
DirectoryConfig.java:
Removed getAttributeType(String lowerName, boolean returnDefault), used DirectoryServer methods instead.
*.java:
Changed all code that was calling DirectoryServer.getAttributeType(lowerName, false) to directly call the more explicit DirectoryServer.getAttributeType(lowerName).
SubjectAttributeToUserAttributeCertificateMapper.java:
In initializeCertificateMapper(), isConfigurationChangeAcceptable() and applyConfigurationChange(), extracted methods buildAttributeMap() and getUserBaseDNs() to remove code duplication
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName, attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attribute, true); |
| | | for (Object value : getAttributeValues(attrName)) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName, attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName); |
| | | AttributeBuilder builder = new AttributeBuilder(attribute, true); |
| | | for (Object value : csr.getAttributeValues(attrName)) |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | AttributeType attrType1 = DirectoryServer.getAttributeType("adminport".toLowerCase(), true); |
| | | AttributeType attrType2 = DirectoryServer.getAttributeType("adminEnabled".toLowerCase(), true); |
| | | AttributeType attrType1 = DirectoryServer.getAttributeTypeOrDefault("adminport".toLowerCase()); |
| | | AttributeType attrType2 = DirectoryServer.getAttributeTypeOrDefault("adminEnabled".toLowerCase()); |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrType1, adminPort))); |
| | |
| | | adminConnectorEntry = result.getFirst(); |
| | | } |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | List<Attribute> attrs = adminConnectorEntry.getAttribute(attrType); |
| | | if (attrs != null) |
| | | { |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import static org.forgerock.util.Reject.ifNull; |
| | | |
| | | import java.util.EnumSet; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Attribute type property definition. |
| | | */ |
| | | /** Attribute type property definition. */ |
| | | public final class AttributeTypePropertyDefinition extends |
| | | PropertyDefinition<AttributeType> { |
| | | |
| | |
| | | ifNull(value); |
| | | |
| | | String name = value.trim().toLowerCase(); |
| | | AttributeType type = DirectoryServer.getAttributeType(name, |
| | | !isCheckSchema); |
| | | |
| | | AttributeType type = isCheckSchema |
| | | ? DirectoryServer.getAttributeType(name) |
| | | : DirectoryServer.getAttributeTypeOrDefault(name); |
| | | if (type == null) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } else { |
| | | try { |
| | | validateValue(type); |
| | | return type; |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | try { |
| | | validateValue(type); |
| | | return type; |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // Now add the single RDN representing the named instance. |
| | | String type = profile.getRelationChildRDNType(r); |
| | | AttributeType atype = DirectoryServer.getAttributeType( |
| | | type.toLowerCase(), true); |
| | | AttributeType atype = DirectoryServer.getAttributeTypeOrDefault(type.toLowerCase()); |
| | | ByteString avalue = ByteString.valueOf(name); |
| | | dn = dn.child(RDN.create(atype, avalue)); |
| | | } |
| | |
| | | |
| | | // Now add the single RDN representing the instance. |
| | | String type = profile.getRelationChildRDNType(r); |
| | | AttributeType atype = DirectoryServer.getAttributeType( |
| | | type.toLowerCase(), true); |
| | | AttributeType atype = DirectoryServer.getAttributeTypeOrDefault(type.toLowerCase()); |
| | | ByteString avalue = ByteString.valueOf(d.getName()); |
| | | dn = dn.child(RDN.create(atype, avalue)); |
| | | } |
| | |
| | | // undefined. We should log a warning here if this is the case |
| | | // since the attribute should have been defined. |
| | | String attrID = LDAPProfile.getInstance().getAttributeName(d, pd); |
| | | AttributeType type = DirectoryServer.getAttributeType(attrID, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(attrID); |
| | | List<Attribute> attributes = configEntry.getEntry().getAttribute(type, true); |
| | | |
| | | List<ByteString> results = new LinkedList<>(); |
| | |
| | | { |
| | | // First check to see if the ds-pwp-password-policy-dn is present. |
| | | String userDNString = userEntry.getName().toString(); |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PWPOLICY_POLICY_DN, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_POLICY_DN); |
| | | List<Attribute> attrList = userEntry.getAttribute(type); |
| | | |
| | | if (attrList != null) |
| | |
| | | */ |
| | | public boolean isDisabled() |
| | | { |
| | | final AttributeType type = DirectoryServer.getAttributeType( |
| | | OP_ATTR_ACCOUNT_DISABLED, true); |
| | | final AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_ACCOUNT_DISABLED); |
| | | try |
| | | { |
| | | isDisabled = getBoolean(userEntry, type); |
| | |
| | | final byte[] encodedAttribute, final String attributeName, |
| | | final Collection<String> attributeOptions) |
| | | { |
| | | final AttributeType type = DirectoryServer.getAttributeType( |
| | | toLowerCase(attributeName), true); |
| | | final Set<String> options; |
| | | switch (attributeOptions.size()) |
| | | { |
| | | case 0: |
| | | options = Collections.emptySet(); |
| | | break; |
| | | case 1: |
| | | options = Collections.singleton(attributeOptions.iterator().next()); |
| | | break; |
| | | default: |
| | | options = new LinkedHashSet<>(attributeOptions); |
| | | break; |
| | | } |
| | | final AttributeType type = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName)); |
| | | final Set<String> options = getOptions(attributeOptions); |
| | | final Entry<AttributeType, Set<String>> ad = new SimpleImmutableEntry<>(type, options); |
| | | final int id = decodeId(encodedAttribute); |
| | | synchronized (adEncodeMap) |
| | |
| | | return ad; |
| | | } |
| | | |
| | | |
| | | private Set<String> getOptions(final Collection<String> attributeOptions) |
| | | { |
| | | switch (attributeOptions.size()) |
| | | { |
| | | case 0: |
| | | return Collections.emptySet(); |
| | | case 1: |
| | | return Collections.singleton(attributeOptions.iterator().next()); |
| | | default: |
| | | return new LinkedHashSet<>(attributeOptions); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Loads an encoded object class into this compressed schema. This method may |
| | |
| | | } |
| | | else |
| | | { |
| | | nonRightsAttrs.add(DirectoryServer.getAttributeType(a.toLowerCase(), true)); |
| | | nonRightsAttrs.add(DirectoryServer.getAttributeTypeOrDefault(a.toLowerCase())); |
| | | } |
| | | } |
| | | } |
| | |
| | | import static org.opends.server.authorization.dseecompat.Aci.*; |
| | | import static org.opends.server.authorization.dseecompat.EnumEvalReason.*; |
| | | 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.schema.SchemaConstants.*; |
| | |
| | | */ |
| | | private static void initStatics() |
| | | { |
| | | aciType = getAttributeType("aci"); |
| | | globalAciType = getAttributeType(ATTR_AUTHZ_GLOBAL_ACI); |
| | | debugSearchIndex = getAttributeType(SuffixContainer.ATTR_DEBUG_SEARCH_INDEX); |
| | | refAttrType = getAttributeType(ATTR_REFERRAL_URL); |
| | | aciType = getAttributeTypeOrDefault("aci"); |
| | | globalAciType = getAttributeTypeOrDefault(ATTR_AUTHZ_GLOBAL_ACI); |
| | | debugSearchIndex = getAttributeTypeOrDefault(SuffixContainer.ATTR_DEBUG_SEARCH_INDEX); |
| | | refAttrType = getAttributeTypeOrDefault(ATTR_REFERRAL_URL); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private static AttributeType getAttributeType(String name) |
| | | { |
| | | return DirectoryServer.getAttributeType(name, true); |
| | | } |
| | | |
| | | |
| | | |
| | | /** The list that holds that ACIs keyed by the DN of the entry holding the ACI. */ |
| | | private AciList aciList; |
| | | |
| | |
| | | baseName = toLowerCase(rawAttributeType); |
| | | } |
| | | |
| | | container.setCurrentAttributeType(getAttributeType(baseName)); |
| | | container.setCurrentAttributeType(getAttributeTypeOrDefault(baseName)); |
| | | container.setCurrentAttributeValue(operation.getAssertionValue()); |
| | | return isAllowed(container, operation); |
| | | } |
| | |
| | | // Check to make sure that the backend has a presence index defined |
| | | // for the ACI attribute. If it does not, then log a warning message |
| | | // because this processing could be very expensive. |
| | | AttributeType aciType = |
| | | DirectoryServer.getAttributeType("aci", true); |
| | | AttributeType aciType = DirectoryServer.getAttributeTypeOrDefault("aci"); |
| | | if (backend.getEntryCount() > 0 |
| | | && !backend.isIndexed(aciType, IndexType.PRESENCE)) |
| | | { |
| | |
| | | * @return The attribute type. |
| | | */ |
| | | public AttributeType getAttributeType() { |
| | | return DirectoryServer.getAttributeType(attrTypeStr.toLowerCase(), true); |
| | | return DirectoryServer.getAttributeTypeOrDefault(attrTypeStr.toLowerCase()); |
| | | } |
| | | |
| | | /** |
| | |
| | | attributeName=attributeName.substring(0, semicolon); |
| | | } |
| | | String filterString=matcher.group(filterPos); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attributeName, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attributeName); |
| | | SearchFilter filter; |
| | | //Check if it is a valid filter and add it to the list map if ok. |
| | | try { |
| | |
| | | throw new AciException(message); |
| | | } |
| | | } else { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attribute, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attribute); |
| | | if(attrType.isOperational()) |
| | | { |
| | | opAttributes.add(attrType); |
| | |
| | | private EnumEvalResult evalVAL(AciEvalContext evalCtx) { |
| | | EnumEvalResult matched= EnumEvalResult.FALSE; |
| | | boolean undefined=false; |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrStr, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrStr); |
| | | final SearchRequest request = newSearchRequest(evalCtx.getClientDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | LinkedList<SearchResultEntry> result = op.getSearchEntries(); |
| | |
| | | private EnumEvalResult evalURL(AciEvalContext evalCtx) { |
| | | EnumEvalResult matched= EnumEvalResult.FALSE; |
| | | boolean undefined=false; |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrStr, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrStr); |
| | | List<Attribute> attrs=evalCtx.getResourceEntry().getAttribute(attrType); |
| | | if(!attrs.isEmpty()) { |
| | | for(Attribute a : attrs) { |
| | |
| | | int numEntries = 1; |
| | | |
| | | AttributeType backupPathType = |
| | | DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | |
| | | for (File dir : backupDirectories.keySet()) |
| | | { |
| | |
| | | Entry backupDirEntry = getBackupDirectoryEntry(entryDN); |
| | | |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | List<Attribute> attrList = backupDirEntry.getAttribute(t); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | |
| | | throws DirectoryException |
| | | { |
| | | // Make sure that the DN specifies a backup directory. |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | ByteString v = entryDN.rdn().getAttributeValue(t); |
| | | if (v == null) |
| | | { |
| | |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(3); |
| | | userAttrs.put(t, asList(t, v)); |
| | | |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_BACKEND_DN, true); |
| | | t = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_BACKEND_DN); |
| | | userAttrs.put(t, asList(t, ByteString.valueOf(backupDirectory.getConfigEntryDN().toString()))); |
| | | |
| | | Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs); |
| | |
| | | throws DirectoryException |
| | | { |
| | | // First, get the backup ID from the entry DN. |
| | | AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID, true); |
| | | AttributeType idType = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_ID); |
| | | ByteString idValue = entryDN.rdn().getAttributeValue(idType); |
| | | if (idValue == null) { |
| | | throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_ID_IN_DN.get(entryDN)); |
| | |
| | | throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_PARENT_DN.get(entryDN)); |
| | | } |
| | | |
| | | AttributeType t = DirectoryServer.getAttributeType( |
| | | ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | ByteString v = parentDN.rdn().getAttributeValue(t); |
| | | if (v == null) { |
| | | throw newConstraintViolation(ERR_BACKUP_NO_BACKUP_DIR_IN_DN.get(entryDN)); |
| | |
| | | |
| | | Date backupDate = backupInfo.getBackupDate(); |
| | | if (backupDate != null) { |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_DATE, true); |
| | | t = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DATE); |
| | | userAttrs.put(t, |
| | | asList(t, ByteString.valueOf(GeneralizedTimeSyntax.format(backupDate)))); |
| | | } |
| | |
| | | |
| | | HashSet<String> dependencies = backupInfo.getDependencies(); |
| | | if (dependencies != null && !dependencies.isEmpty()) { |
| | | t = DirectoryServer.getAttributeType(ATTR_BACKUP_DEPENDENCY, true); |
| | | t = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DEPENDENCY); |
| | | AttributeBuilder builder = new AttributeBuilder(t); |
| | | builder.addAllStrings(dependencies); |
| | | userAttrs.put(t, builder.toAttributeList()); |
| | |
| | | HashMap<String, String> properties = backupInfo.getBackupProperties(); |
| | | if (properties != null && !properties.isEmpty()) { |
| | | for (Map.Entry<String, String> e : properties.entrySet()) { |
| | | t = DirectoryServer.getAttributeType(toLowerCase(e.getKey()), true); |
| | | t = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(e.getKey())); |
| | | userAttrs.put(t, asList(t, ByteString.valueOf(e.getValue()))); |
| | | } |
| | | } |
| | |
| | | |
| | | private void putByteString(LinkedHashMap<AttributeType, List<Attribute>> userAttrs, String attrName, byte[] value) |
| | | { |
| | | AttributeType t = DirectoryServer.getAttributeType(attrName, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | userAttrs.put(t, asList(t, ByteString.wrap(value))); |
| | | } |
| | | |
| | | private void putBoolean(LinkedHashMap<AttributeType, List<Attribute>> attrsMap, String attrName, boolean value) |
| | | { |
| | | AttributeType t = DirectoryServer.getAttributeType(attrName, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | attrsMap.put(t, asList(t, createBooleanValue(value))); |
| | | } |
| | | |
| | |
| | | if (scope != SearchScope.BASE_OBJECT && !backupDirectories.isEmpty()) |
| | | { |
| | | AttributeType backupPathType = |
| | | DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | for (File dir : backupDirectories.keySet()) |
| | | { |
| | | // Check to see if the descriptor file exists. If not, then skip this |
| | |
| | | if (scope != SearchScope.BASE_OBJECT) |
| | | { |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | List<Attribute> attrList = backupDirEntry.getAttribute(t); |
| | | returnEntries(searchOperation, baseDN, filter, attrList); |
| | | } |
| | |
| | | { |
| | | File dir = new File(v.toString()); |
| | | BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory(); |
| | | AttributeType idType = DirectoryServer.getAttributeType(ATTR_BACKUP_ID, true); |
| | | AttributeType idType = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_ID); |
| | | |
| | | for (String backupID : backupDirectory.getBackups().keySet()) |
| | | { |
| | |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.FilterType; |
| | |
| | | |
| | | /** The attribute type for the "creatorsName" attribute. */ |
| | | private static final AttributeType CREATORS_NAME_TYPE = |
| | | DirectoryConfig.getAttributeType(OP_ATTR_CREATORS_NAME_LC, true); |
| | | |
| | | DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_CREATORS_NAME_LC); |
| | | /** The attribute type for the "modifiersName" attribute. */ |
| | | private static final AttributeType MODIFIERS_NAME_TYPE = |
| | | DirectoryConfig.getAttributeType(OP_ATTR_MODIFIERS_NAME_LC, true); |
| | | DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_MODIFIERS_NAME_LC); |
| | | |
| | | /** The base DN for the external change log. */ |
| | | public static final DN CHANGELOG_BASE_DN; |
| | |
| | | private SearchFilter buildSearchFilterFrom(final DN baseDN, final String lowerCaseAttr, final String upperCaseAttr) |
| | | { |
| | | final RDN rdn = baseDN.rdn(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerCaseAttr, upperCaseAttr); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerCaseAttr, upperCaseAttr); |
| | | final ByteString attrValue = rdn.getAttributeValue(attrType); |
| | | if (attrValue != null) |
| | | { |
| | |
| | | final Map<AttributeType, List<Attribute>> userAttrs, |
| | | final Map<AttributeType, List<Attribute>> operationalAttrs, final boolean addByType) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrNameLowercase, attrNameUppercase); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrNameLowercase, attrNameUppercase); |
| | | final Attribute a = addByType |
| | | ? Attributes.create(attrType, attrValue) |
| | | : Attributes.create(attrNameUppercase, attrValue); |
| | |
| | | private Attribute createAttribute(String name, String lowerName, |
| | | Collection<? extends Object> values) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType(lowerName, name); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(lowerName, name); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(type, name); |
| | | builder.addAllStrings(values); |
| | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | |
| | | configEntryDN = configEntry.getDN(); |
| | | |
| | | // Get all of the attribute types that we will use for schema elements. |
| | | attributeTypesType = |
| | | DirectoryServer.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC, true); |
| | | objectClassesType = |
| | | DirectoryServer.getAttributeType(ATTR_OBJECTCLASSES_LC, true); |
| | | matchingRulesType = |
| | | DirectoryServer.getAttributeType(ATTR_MATCHING_RULES_LC, true); |
| | | ldapSyntaxesType = |
| | | DirectoryServer.getAttributeType(ATTR_LDAP_SYNTAXES_LC, true); |
| | | ditContentRulesType = |
| | | DirectoryServer.getAttributeType(ATTR_DIT_CONTENT_RULES_LC, true); |
| | | ditStructureRulesType = |
| | | DirectoryServer.getAttributeType(ATTR_DIT_STRUCTURE_RULES_LC, true); |
| | | matchingRuleUsesType = |
| | | DirectoryServer.getAttributeType(ATTR_MATCHING_RULE_USE_LC, true); |
| | | nameFormsType = DirectoryServer.getAttributeType(ATTR_NAME_FORMS_LC, true); |
| | | attributeTypesType = getAttributeTypeOrDefault(ATTR_ATTRIBUTE_TYPES_LC); |
| | | objectClassesType = getAttributeTypeOrDefault(ATTR_OBJECTCLASSES_LC); |
| | | matchingRulesType = getAttributeTypeOrDefault(ATTR_MATCHING_RULES_LC); |
| | | ldapSyntaxesType = getAttributeTypeOrDefault(ATTR_LDAP_SYNTAXES_LC); |
| | | ditContentRulesType = getAttributeTypeOrDefault(ATTR_DIT_CONTENT_RULES_LC); |
| | | ditStructureRulesType = getAttributeTypeOrDefault(ATTR_DIT_STRUCTURE_RULES_LC); |
| | | matchingRuleUsesType = getAttributeTypeOrDefault(ATTR_MATCHING_RULE_USE_LC); |
| | | nameFormsType = getAttributeTypeOrDefault(ATTR_NAME_FORMS_LC); |
| | | |
| | | // Initialize the lastmod attributes. |
| | | creatorsNameType = |
| | | DirectoryServer.getAttributeType(OP_ATTR_CREATORS_NAME_LC, true); |
| | | createTimestampType = |
| | | DirectoryServer.getAttributeType(OP_ATTR_CREATE_TIMESTAMP_LC, true); |
| | | modifiersNameType = |
| | | DirectoryServer.getAttributeType(OP_ATTR_MODIFIERS_NAME_LC, true); |
| | | modifyTimestampType = |
| | | DirectoryServer.getAttributeType(OP_ATTR_MODIFY_TIMESTAMP_LC, true); |
| | | creatorsNameType = getAttributeTypeOrDefault(OP_ATTR_CREATORS_NAME_LC); |
| | | createTimestampType = getAttributeTypeOrDefault(OP_ATTR_CREATE_TIMESTAMP_LC); |
| | | modifiersNameType = getAttributeTypeOrDefault(OP_ATTR_MODIFIERS_NAME_LC); |
| | | modifyTimestampType = getAttributeTypeOrDefault(OP_ATTR_MODIFY_TIMESTAMP_LC); |
| | | |
| | | // Construct the set of objectclasses to include in the schema entry. |
| | | schemaObjectClasses = new LinkedHashMap<>(3); |
| | |
| | | throws DirectoryException |
| | | { |
| | | // Make sure that the DN specifies a certificate alias. |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(ATTR_CRYPTO_KEY_ID); |
| | | ByteString v = entryDN.rdn().getAttributeValue(t); |
| | | if (v == null) |
| | | { |
| | |
| | | userAttrs.put(t, Attributes.createAsList(t, v)); |
| | | |
| | | |
| | | t = DirectoryServer.getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE, true); |
| | | t = DirectoryServer.getAttributeTypeOrDefault(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); |
| | | AttributeBuilder builder = new AttributeBuilder(t); |
| | | builder.setOption("binary"); |
| | | builder.add(certValue); |
| | |
| | | |
| | | if (scope != SearchScope.BASE_OBJECT && aliases.length != 0) |
| | | { |
| | | AttributeType certAliasType = |
| | | DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true); |
| | | AttributeType certAliasType = DirectoryServer.getAttributeTypeOrDefault(ATTR_CRYPTO_KEY_ID); |
| | | for (String alias : aliases) |
| | | { |
| | | DN certDN = makeChildDN(this.baseDN, certAliasType, |
| | | alias); |
| | | DN certDN = makeChildDN(this.baseDN, certAliasType, alias); |
| | | |
| | | Entry certEntry; |
| | | try |
| | |
| | | DN entryDN = entry.getName(); |
| | | |
| | | // Make sure that the DN specifies a certificate alias. |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(ATTR_CRYPTO_KEY_ID); |
| | | ByteString v = entryDN.rdn().getAttributeValue(t); |
| | | if (v == null) |
| | | { |
| | |
| | | throws DirectoryException |
| | | { |
| | | // Make sure that the DN specifies a certificate alias. |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(ATTR_CRYPTO_KEY_ID); |
| | | ByteString v = entryDN.rdn().getAttributeValue(t); |
| | | if (v == null) |
| | | { |
| | |
| | | private static final int MINIMUM_AVAILABLE_MEMORY = 32 * MB; |
| | | |
| | | /** The DN attribute type. */ |
| | | private static final AttributeType dnType = DirectoryServer.getAttributeType("dn", true); |
| | | private static final AttributeType dnType = DirectoryServer.getAttributeTypeOrDefault("dn"); |
| | | static final IndexOutputBuffer.IndexComparator indexComparator = |
| | | new IndexOutputBuffer.IndexComparator(); |
| | | |
| | |
| | | private static final int SMALL_HEAP_SIZE = 256 * MB; |
| | | |
| | | /** The DN attribute type. */ |
| | | private static final AttributeType DN_TYPE = DirectoryServer.getAttributeType("dn", true); |
| | | private static final AttributeType DN_TYPE = DirectoryServer.getAttributeTypeOrDefault("dn"); |
| | | |
| | | /** Root container. */ |
| | | private final RootContainer rootContainer; |
| | |
| | | this.recurringTaskEntryDN = recurringTaskEntry.getName(); |
| | | |
| | | // Get the recurring task ID from the entry. If there isn't one, then fail. |
| | | AttributeType attrType = DirectoryServer.getAttributeType( |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_RECURRING_TASK_ID.toLowerCase(), ATTR_RECURRING_TASK_ID); |
| | | List<Attribute> attrList = recurringTaskEntry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | |
| | | String messageString = buffer.toString(); |
| | | logMessages.add(messageString); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_TASK_LOG_MESSAGES.toLowerCase(), ATTR_TASK_LOG_MESSAGES); |
| | | |
| | | List<Attribute> attrList = taskEntry.getAttribute(type); |
| | |
| | | throws DirectoryException |
| | | { |
| | | // Get the name of the class that implements the task logic. |
| | | AttributeType attrType = DirectoryServer.getAttributeType(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | { |
| | |
| | | throws ConfigException |
| | | { |
| | | String attrName = stub.getName(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | |
| | | { |
| | | // It's possible that this is a monitor attribute rather than a configurable |
| | | // one. Check all of those. |
| | | AttributeType attrType = DirectoryServer.getAttributeType(name.toLowerCase(), name); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(name.toLowerCase(), name); |
| | | for (MonitorProvider<? extends MonitorProviderCfg> monitor : monitorProviders) |
| | | { |
| | | for (org.opends.server.types.Attribute a : monitor.getMonitorData()) |
| | |
| | | |
| | | // It's possible that this is a monitor attribute rather than a |
| | | // configurable one. Check all of those. |
| | | AttributeType attrType = DirectoryServer.getAttributeType(name.toLowerCase(), name); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(name.toLowerCase(), name); |
| | | |
| | | monitorLoop: |
| | | for (MonitorProvider<? extends MonitorProviderCfg> monitor : |
| | |
| | | reader.readStartSequence(); |
| | | while(reader.hasNextElement()) { |
| | | String attrStr = reader.readOctetStringAsString(); |
| | | attrs.add(DirectoryServer.getAttributeType(attrStr, true)); |
| | | attrs.add(DirectoryServer.getAttributeTypeOrDefault(attrStr)); |
| | | } |
| | | reader.readEndSequence(); |
| | | } |
| | |
| | | if (attributeType == null && rawAttributeType != null) |
| | | { |
| | | String lowerName = toLowerCase(rawAttributeType); |
| | | attributeType = DirectoryServer.getAttributeType(lowerName, rawAttributeType); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(lowerName, rawAttributeType); |
| | | } |
| | | return attributeType; |
| | | } |
| | |
| | | { |
| | | reader.readStartSequence(); |
| | | String attrName = toLowerCase(reader.readOctetStringAsString()); |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(attrName, false); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName); |
| | | if (attrType == null) |
| | | { |
| | | //This attribute is not defined in the schema. There is no point |
| | | //iterating over the next attribute and return a partially sorted |
| | | //result. |
| | | //iterating over the next attribute and return a partially sorted result. |
| | | return new ServerSideSortRequestControl(isCritical, |
| | | new SortOrder(sortKeys.toArray(new SortKey[0]))); |
| | | } |
| | |
| | | ArrayList<SortKey> sortKeys = new ArrayList<>(); |
| | | for(String[] decodedKey : decodedKeyList) |
| | | { |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(decodedKey[0].toLowerCase(), false); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(decodedKey[0].toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | //This attribute is not defined in the schema. There is no point |
| | | //iterating over the next attribute and return a partially sorted |
| | | //result. |
| | | //iterating over the next attribute and return a partially sorted result. |
| | | return new SortOrder(sortKeys.toArray(new SortKey[0])); |
| | | } |
| | | |
| | | MatchingRule orderingRule = null; |
| | | if(decodedKey[1] != null) |
| | | { |
| | | orderingRule = |
| | | DirectoryServer.getMatchingRule(decodedKey[1].toLowerCase()); |
| | | orderingRule = DirectoryServer.getMatchingRule(decodedKey[1].toLowerCase()); |
| | | if (orderingRule == null) |
| | | { |
| | | LocalizableMessage message = |
| | | INFO_SORTREQ_CONTROL_UNDEFINED_ORDERING_RULE. |
| | | get(decodedKey[1]); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, |
| | | message); |
| | | LocalizableMessage message = INFO_SORTREQ_CONTROL_UNDEFINED_ORDERING_RULE.get(decodedKey[1]); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | baseName = toLowerCase(rawAttributeType); |
| | | attributeOptions = null; |
| | | } |
| | | attributeType = DirectoryServer.getAttributeType(baseName, true); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(baseName); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | * |
| | | * @param lowerName The lowercase name or OID for the attribute type to |
| | | * retrieve. |
| | | * @param returnDefault Indicates whether to generate a default version if |
| | | * the requested attribute type is not defined in the |
| | | * server schema. |
| | | * |
| | | * @return The requested attribute type, or <CODE>null</CODE> if there is no |
| | | * attribute with the specified type defined in the server schema and |
| | | * a default type should not be returned. |
| | | */ |
| | | public static AttributeType getAttributeType(String lowerName, |
| | | boolean returnDefault) |
| | | public static AttributeType getAttributeTypeOrDefault(String lowerName) |
| | | { |
| | | AttributeType type = directoryServer.schema.getAttributeType(lowerName); |
| | | if (returnDefault && type == null) |
| | | if (type == null) |
| | | { |
| | | type = getDefaultAttributeType(lowerName); |
| | | } |
| | |
| | | * @return The requested attribute type, or a generated "default" version if there is no attribute |
| | | * with the specified type defined in the server schema |
| | | */ |
| | | public static AttributeType getAttributeType(String lowerName, String upperName) |
| | | public static AttributeType getAttributeTypeOrDefault(String lowerName, String upperName) |
| | | { |
| | | AttributeType type = directoryServer.schema.getAttributeType(lowerName); |
| | | if (type == null) |
| | |
| | | if (passwordChangedTime < 0) |
| | | { |
| | | // Get the password changed time for the user. |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_CHANGED_TIME_LC, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_CHANGED_TIME_LC); |
| | | try |
| | | { |
| | | passwordChangedTime = getGeneralizedTime(userEntry, type); |
| | |
| | | if (passwordChangedTime < 0) |
| | | { |
| | | // Get the time that the user's account was created. |
| | | AttributeType createTimeType = DirectoryServer.getAttributeType(OP_ATTR_CREATE_TIMESTAMP_LC, true); |
| | | AttributeType createTimeType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_CREATE_TIMESTAMP_LC); |
| | | try |
| | | { |
| | | passwordChangedTime = getGeneralizedTime(userEntry, createTimeType); |
| | |
| | | logger.trace("Clearing password changed time for user %s", userDNString); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_CHANGED_TIME_LC, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_CHANGED_TIME_LC); |
| | | Attribute a = Attributes.empty(type); |
| | | modifications.add(new Modification(ModificationType.REPLACE, a, true)); |
| | | |
| | | |
| | | // Fall back to using the entry creation time as the password changed time, if it's defined. |
| | | // Otherwise, use a value of zero. |
| | | AttributeType createTimeType = DirectoryServer.getAttributeType(OP_ATTR_CREATE_TIMESTAMP_LC, true); |
| | | AttributeType createTimeType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_CREATE_TIMESTAMP_LC); |
| | | try |
| | | { |
| | | passwordChangedTime = getGeneralizedTime(userEntry, createTimeType); |
| | |
| | | |
| | | this.isDisabled = ConditionResult.not(this.isDisabled); |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_ACCOUNT_DISABLED, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_ACCOUNT_DISABLED); |
| | | |
| | | if (isDisabled) |
| | | { |
| | |
| | | return isAccountExpired == ConditionResult.TRUE; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_ACCOUNT_EXPIRATION_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_ACCOUNT_EXPIRATION_TIME); |
| | | |
| | | try { |
| | | accountExpirationTime = getGeneralizedTime(userEntry, type); |
| | |
| | | } |
| | | |
| | | this.accountExpirationTime = accountExpirationTime; |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_ACCOUNT_EXPIRATION_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_ACCOUNT_EXPIRATION_TIME); |
| | | |
| | | Attribute a = Attributes.create(type, timeStr); |
| | | modifications.add(new Modification(ModificationType.REPLACE, a, true)); |
| | |
| | | |
| | | accountExpirationTime = -1; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_ACCOUNT_EXPIRATION_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_ACCOUNT_EXPIRATION_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | return authFailureTimes; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | try |
| | | { |
| | |
| | | failureTimes.add(highestFailureTime); |
| | | |
| | | // And the attribute in the user entry |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestFailureTime)); |
| | | modifications.add(new Modification(ModificationType.ADD, addAttr, true)); |
| | |
| | | return; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_FAILURE_TIME_LC, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_FAILURE_TIME_LC); |
| | | this.authFailureTimes = authFailureTimes; |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | |
| | | |
| | | failureTimes.clear(); // Note: failureTimes != this.authFailureTimes |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_FAILURE_TIME_LC, OP_ATTR_PWPOLICY_FAILURE_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | |
| | | return failureLockedTime; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | try |
| | | { |
| | |
| | | |
| | | failureLockedTime = time; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | Attribute a = Attributes.create(type, GeneralizedTimeSyntax.format(failureLockedTime)); |
| | | modifications.add(new Modification(ModificationType.REPLACE, a, true)); |
| | |
| | | |
| | | failureLockedTime = -1L; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_LOCKED_TIME_LC, OP_ATTR_PWPOLICY_LOCKED_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | |
| | | |
| | | lastLoginTime = -1; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_LAST_LOGIN_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_LAST_LOGIN_TIME); |
| | | |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_RESET_REQUIRED_LC, OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | try |
| | | { |
| | |
| | | return; // requested state matches current state |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_RESET_REQUIRED_LC, OP_ATTR_PWPOLICY_RESET_REQUIRED); |
| | | this.mustChangePassword = ConditionResult.not(this.mustChangePassword); |
| | | if (mustChangePassword) |
| | |
| | | return requiredChangeTime; |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_CHANGED_BY_REQUIRED_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_CHANGED_BY_REQUIRED_TIME); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | this.requiredChangeTime = requiredChangeTime; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_CHANGED_BY_REQUIRED_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_CHANGED_BY_REQUIRED_TIME); |
| | | |
| | | String timeValue = GeneralizedTimeSyntax.format(requiredChangeTime); |
| | | Attribute a = Attributes.create(type, timeValue); |
| | |
| | | |
| | | this.requiredChangeTime = Long.MIN_VALUE; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_CHANGED_BY_REQUIRED_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_CHANGED_BY_REQUIRED_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | { |
| | | if (warnedTime == Long.MIN_VALUE) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_WARNED_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_WARNED_TIME); |
| | | try |
| | | { |
| | | warnedTime = getGeneralizedTime(userEntry, type); |
| | |
| | | |
| | | this.warnedTime = warnedTime; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_WARNED_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_WARNED_TIME); |
| | | Attribute a = Attributes.create(type, GeneralizedTimeSyntax.createGeneralizedTimeValue(currentTime)); |
| | | |
| | | modifications.add(new Modification(ModificationType.REPLACE, a, true)); |
| | |
| | | } |
| | | warnedTime = -1; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_WARNED_TIME, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_WARNED_TIME); |
| | | Attribute a = Attributes.empty(type); |
| | | modifications.add(new Modification(ModificationType.REPLACE, a, true)); |
| | | |
| | |
| | | { |
| | | if (graceLoginTimes == null) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | try |
| | | { |
| | |
| | | } |
| | | graceTimes.add(highestGraceTime); // graceTimes == this.graceLoginTimes |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | Attribute addAttr = Attributes.create(type, GeneralizedTimeSyntax.format(highestGraceTime)); |
| | | modifications.add(new Modification(ModificationType.ADD, addAttr, true)); |
| | |
| | | |
| | | this.graceLoginTimes = graceLoginTimes; |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC); |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | | for (Long l : graceLoginTimes) |
| | | { |
| | |
| | | } |
| | | graceTimes.clear(); // graceTimes == this.graceLoginTimes |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC, OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | |
| | | private TreeMap<Long,ByteString> getSortedHistoryValues(List<Attribute> removeAttrs) |
| | | { |
| | | TreeMap<Long, ByteString> historyMap = new TreeMap<>(); |
| | | AttributeType historyType = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC, true); |
| | | AttributeType historyType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_HISTORY_LC); |
| | | List<Attribute> attrList = userEntry.getAttribute(historyType); |
| | | if (attrList != null) |
| | | { |
| | |
| | | |
| | | // 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.getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC, true); |
| | | AttributeType historyType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_HISTORY_LC); |
| | | int historyCount = passwordPolicy.getPasswordHistoryCount(); |
| | | if (historyCount > 0 && historyMap.size() >= historyCount) |
| | | { |
| | |
| | | public String[] getPasswordHistoryValues() |
| | | { |
| | | ArrayList<String> historyValues = new ArrayList<>(); |
| | | AttributeType historyType = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC, true); |
| | | AttributeType historyType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_HISTORY_LC); |
| | | List<Attribute> attrList = userEntry.getAttribute(historyType); |
| | | if (attrList != null) |
| | | { |
| | |
| | | logger.trace("Clearing password history for user %s", userDNString); |
| | | } |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_HISTORY_LC, true); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_HISTORY_LC); |
| | | modifications.add(new Modification(ModificationType.REPLACE, Attributes.empty(type), true)); |
| | | } |
| | | |
| | |
| | | String value = getAttrValue(entry, PWD_ATTR_ATTRIBUTE); |
| | | if (value != null && value.length() > 0) |
| | | { |
| | | this.pPasswordAttribute = |
| | | DirectoryServer.getAttributeType(value.toLowerCase(), false); |
| | | this.pPasswordAttribute = DirectoryServer.getAttributeType(value.toLowerCase()); |
| | | if (this.pPasswordAttribute == null) |
| | | { |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, |
| | |
| | | objectClasses.containsKey(pwdValidatorPolicyOC)) |
| | | { |
| | | AttributeType pwdAttrType = |
| | | DirectoryServer.getAttributeType(PWD_ATTR_VALIDATOR, true); |
| | | DirectoryServer.getAttributeTypeOrDefault(PWD_ATTR_VALIDATOR); |
| | | List<Attribute> pwdAttrList = entry.getAttribute(pwdAttrType); |
| | | if ((pwdAttrList != null) && (!pwdAttrList.isEmpty())) |
| | | { |
| | |
| | | */ |
| | | private String getAttrValue(Entry entry, String pwdAttrName) |
| | | { |
| | | AttributeType pwdAttrType = DirectoryServer.getAttributeType(pwdAttrName, |
| | | true); |
| | | AttributeType pwdAttrType = DirectoryServer.getAttributeTypeOrDefault(pwdAttrName); |
| | | List<Attribute> pwdAttrList = entry.getAttribute(pwdAttrType); |
| | | if (pwdAttrList != null && !pwdAttrList.isEmpty()) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.crypto; |
| | | |
| | | 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.*; |
| | |
| | | ocCipherKey = DirectoryServer.getObjectClass(OC_CRYPTO_CIPHER_KEY, true); |
| | | ocMacKey = DirectoryServer.getObjectClass(OC_CRYPTO_MAC_KEY, true); |
| | | |
| | | attrCert = DirectoryServer.getAttributeType( |
| | | ConfigConstants.ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE, true); |
| | | attrAlias = DirectoryServer.getAttributeType( |
| | | ConfigConstants.ATTR_CRYPTO_KEY_ID, true); |
| | | attrCompromisedTime = DirectoryServer.getAttributeType( |
| | | ConfigConstants.ATTR_CRYPTO_KEY_COMPROMISED_TIME, true); |
| | | attrCert = getAttributeTypeOrDefault(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); |
| | | attrAlias = getAttributeTypeOrDefault(ATTR_CRYPTO_KEY_ID); |
| | | attrCompromisedTime = getAttributeTypeOrDefault(ATTR_CRYPTO_KEY_COMPROMISED_TIME); |
| | | |
| | | if (DirectoryServer.getBackendWithBaseDN(adminSuffixDN) != null) |
| | | { |
| | |
| | | } |
| | | |
| | | AttributeType privType = |
| | | DirectoryServer.getAttributeType(ATTR_DEFAULT_ROOT_PRIVILEGE_NAME, |
| | | true); |
| | | DirectoryServer.getAttributeTypeOrDefault(ATTR_DEFAULT_ROOT_PRIVILEGE_NAME); |
| | | for (Modification m : modifyOperation.getModifications()) |
| | | { |
| | | if (m.getAttribute().getAttributeType().equals(privType)) |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CONFIG_FILE_MODIFY_PRIVS_INSUFFICIENT_PRIVILEGES.get(); |
| | | throw new DirectoryException(ResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | message); |
| | | throw new DirectoryException(ResultCode.INSUFFICIENT_ACCESS_RIGHTS, message); |
| | | } |
| | | |
| | | break; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.std.server.DynamicGroupImplementationCfg; |
| | | import org.opends.server.api.Group; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | // 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 = |
| | | DirectoryConfig.getAttributeType(ATTR_MEMBER_URL_LC, true); |
| | | AttributeType memberURLType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MEMBER_URL_LC); |
| | | List<Attribute> attrList = groupEntry.getAttribute(memberURLType); |
| | | if (attrList != null) |
| | | { |
| | |
| | | if (certificateAttributeType == null) |
| | | { |
| | | certificateAttributeType = |
| | | DirectoryServer.getAttributeType(DEFAULT_VALIDATION_CERT_ATTRIBUTE, |
| | | true); |
| | | DirectoryServer.getAttributeTypeOrDefault(DEFAULT_VALIDATION_CERT_ATTRIBUTE); |
| | | } |
| | | |
| | | |
| | |
| | | if (newCertificateType == null) |
| | | { |
| | | newCertificateType = |
| | | DirectoryServer.getAttributeType(DEFAULT_VALIDATION_CERT_ATTRIBUTE, |
| | | true); |
| | | DirectoryServer.getAttributeTypeOrDefault(DEFAULT_VALIDATION_CERT_ATTRIBUTE); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | super(userEntry); |
| | | |
| | | this.cachedPasswordAttribute = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PTAPOLICY_CACHED_PASSWORD, true); |
| | | this.cachedPasswordTimeAttribute = DirectoryServer.getAttributeType( |
| | | OP_ATTR_PTAPOLICY_CACHED_PASSWORD_TIME, true); |
| | | this.cachedPasswordAttribute = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PTAPOLICY_CACHED_PASSWORD); |
| | | this.cachedPasswordTimeAttribute = DirectoryServer.getAttributeTypeOrDefault( |
| | | OP_ATTR_PTAPOLICY_CACHED_PASSWORD_TIME); |
| | | } |
| | | |
| | | |
| | |
| | | else if (lowerTokenStr.startsWith("notification-user-attr:")) |
| | | { |
| | | String attrName = lowerTokenStr.substring(23); |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(attrName, false); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName); |
| | | if (attrType == null) |
| | | { |
| | | throw new ConfigException( |
| | |
| | | throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message); |
| | | } |
| | | |
| | | someMemberAttributeType = DirectoryConfig.getAttributeType(ATTR_MEMBER, true); |
| | | someMemberAttributeType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MEMBER); |
| | | } |
| | | else if (hasGroupOfNamesClass) |
| | | { |
| | |
| | | throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message); |
| | | } |
| | | |
| | | someMemberAttributeType = DirectoryConfig.getAttributeType(ATTR_MEMBER, true); |
| | | someMemberAttributeType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MEMBER); |
| | | } |
| | | else if (hasGroupOfUniqueNamesClass) |
| | | { |
| | | someMemberAttributeType = DirectoryConfig.getAttributeType(ATTR_UNIQUE_MEMBER_LC, true); |
| | | someMemberAttributeType = DirectoryServer.getAttributeTypeOrDefault(ATTR_UNIQUE_MEMBER_LC); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | |
| | | /** The DN of the configuration entry for this certificate mapper. */ |
| | | private DN configEntryDN; |
| | | |
| | | /** The mappings between certificate attribute names and user attribute types. */ |
| | | private LinkedHashMap<String,AttributeType> attributeMap; |
| | | |
| | | /** The current configuration for this certificate mapper. */ |
| | | private SubjectAttributeToUserAttributeCertificateMapperCfg currentConfig; |
| | | |
| | | /** The set of attributes to return in search result entries. */ |
| | | private LinkedHashSet<String> requestedAttributes; |
| | | |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeCertificateMapper( |
| | | SubjectAttributeToUserAttributeCertificateMapperCfg |
| | | configuration) |
| | | SubjectAttributeToUserAttributeCertificateMapperCfg configuration) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | configuration |
| | | .addSubjectAttributeToUserAttributeChangeListener(this); |
| | | configuration.addSubjectAttributeToUserAttributeChangeListener(this); |
| | | |
| | | currentConfig = configuration; |
| | | configEntryDN = configuration.dn(); |
| | | |
| | | // Get and validate the subject attribute to user attribute mappings. |
| | | attributeMap = new LinkedHashMap<>(); |
| | | for (String mapStr : configuration.getSubjectAttributeMapping()) |
| | | ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | attributeMap = buildAttributeMap(configuration, configEntryDN, ccr); |
| | | List<LocalizableMessage> messages = ccr.getMessages(); |
| | | if (!messages.isEmpty()) |
| | | { |
| | | String lowerMap = toLowerCase(mapStr); |
| | | int colonPos = lowerMap.indexOf(':'); |
| | | if (colonPos <= 0) |
| | | { |
| | | LocalizableMessage message = ERR_SATUACM_INVALID_MAP_FORMAT.get(configEntryDN, mapStr); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | String certAttrName = lowerMap.substring(0, colonPos).trim(); |
| | | String userAttrName = lowerMap.substring(colonPos+1).trim(); |
| | | if ((certAttrName.length() == 0) || (userAttrName.length() == 0)) |
| | | { |
| | | LocalizableMessage message = ERR_SATUACM_INVALID_MAP_FORMAT.get(configEntryDN, mapStr); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | // Try to normalize the provided certAttrName |
| | | certAttrName = normalizeAttributeName(certAttrName); |
| | | |
| | | |
| | | if (attributeMap.containsKey(certAttrName)) |
| | | { |
| | | LocalizableMessage message = ERR_SATUACM_DUPLICATE_CERT_ATTR.get(configEntryDN, certAttrName); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | AttributeType userAttrType = |
| | | DirectoryServer.getAttributeType(userAttrName, false); |
| | | if (userAttrType == null) |
| | | { |
| | | LocalizableMessage message = ERR_SATUACM_NO_SUCH_ATTR.get(mapStr, configEntryDN, userAttrName); |
| | | throw new ConfigException(message); |
| | | } |
| | | |
| | | for (AttributeType attrType : attributeMap.values()) |
| | | { |
| | | if (attrType.equals(userAttrType)) |
| | | { |
| | | throw new ConfigException(ERR_SATUACM_DUPLICATE_USER_ATTR.get(configEntryDN, attrType.getNameOrOID())); |
| | | } |
| | | } |
| | | |
| | | attributeMap.put(certAttrName, userAttrType); |
| | | throw new ConfigException(messages.iterator().next()); |
| | | } |
| | | |
| | | // Make sure that all the user attributes are configured with equality |
| | | // indexes in all appropriate backends. |
| | | Set<DN> cfgBaseDNs = configuration.getUserBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | | |
| | | Set<DN> cfgBaseDNs = getUserBaseDNs(configuration); |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | for (AttributeType t : attributeMap.values()) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | Backend<?> b = DirectoryServer.getBackend(baseDN); |
| | | if (b != null && ! b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | logger.warn(WARN_SATUACM_ATTR_UNINDEXED, configuration.dn(), |
| | | t.getNameOrOID(), b.getBackendID()); |
| | |
| | | } |
| | | } |
| | | |
| | | // Create the attribute list to include in search requests. We want to |
| | | // Create the attribute list to include in search requests. We want to |
| | | // include all user and operational attributes. |
| | | requestedAttributes = new LinkedHashSet<>(2); |
| | | requestedAttributes.add("*"); |
| | | requestedAttributes.add("+"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finalizeCertificateMapper() |
| | | { |
| | | currentConfig |
| | | .removeSubjectAttributeToUserAttributeChangeListener(this); |
| | | currentConfig.removeSubjectAttributeToUserAttributeChangeListener(this); |
| | | } |
| | | |
| | | |
| | |
| | | public Entry mapCertificateToUser(Certificate[] certificateChain) |
| | | throws DirectoryException |
| | | { |
| | | SubjectAttributeToUserAttributeCertificateMapperCfg config = |
| | | currentConfig; |
| | | SubjectAttributeToUserAttributeCertificateMapperCfg config = currentConfig; |
| | | LinkedHashMap<String,AttributeType> theAttributeMap = this.attributeMap; |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = ERR_SATUACM_CANNOT_DECODE_SUBJECT_AS_DN.get( |
| | | peerName, de.getMessageObject()); |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, message, |
| | | de); |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, message, de); |
| | | } |
| | | |
| | | LinkedList<SearchFilter> filterComps = new LinkedList<>(); |
| | |
| | | AttributeType attrType = theAttributeMap.get(lowerName); |
| | | if (attrType != null) |
| | | { |
| | | filterComps.add(SearchFilter.createEqualityFilter(attrType, |
| | | rdn.getAttributeValue(j))); |
| | | filterComps.add(SearchFilter.createEqualityFilter(attrType, rdn.getAttributeValue(j))); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | SearchFilter filter = SearchFilter.createANDFilter(filterComps); |
| | | Collection<DN> baseDNs = getUserBaseDNs(config); |
| | | |
| | | |
| | | // If we have an explicit set of base DNs, then use it. Otherwise, use the |
| | | // set of public naming contexts in the server. |
| | | Collection<DN> baseDNs = config.getUserBaseDN(); |
| | | if ((baseDNs == null) || baseDNs.isEmpty()) |
| | | { |
| | | baseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | | |
| | | |
| | | // For each base DN, issue an internal search in an attempt to map the |
| | | // certificate. |
| | | // For each base DN, issue an internal search in an attempt to map the certificate. |
| | | Entry userEntry = null; |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (DN baseDN : baseDNs) |
| | |
| | | return userEntry; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAcceptable(CertificateMapperCfg configuration, |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | SubjectAttributeToUserAttributeCertificateMapperCfg |
| | | configuration, |
| | | SubjectAttributeToUserAttributeCertificateMapperCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | | boolean configAcceptable = true; |
| | | DN cfgEntryDN = configuration.dn(); |
| | | |
| | | // Get and validate the subject attribute to user attribute mappings. |
| | | LinkedHashMap<String,AttributeType> newAttributeMap = new LinkedHashMap<>(); |
| | | mapLoop: |
| | | for (String mapStr : configuration.getSubjectAttributeMapping()) |
| | | { |
| | | String lowerMap = toLowerCase(mapStr); |
| | | int colonPos = lowerMap.indexOf(':'); |
| | | if (colonPos <= 0) |
| | | { |
| | | unacceptableReasons.add(ERR_SATUACM_INVALID_MAP_FORMAT.get(cfgEntryDN, mapStr)); |
| | | configAcceptable = false; |
| | | break; |
| | | } |
| | | |
| | | String certAttrName = lowerMap.substring(0, colonPos).trim(); |
| | | String userAttrName = lowerMap.substring(colonPos+1).trim(); |
| | | if ((certAttrName.length() == 0) || (userAttrName.length() == 0)) |
| | | { |
| | | unacceptableReasons.add(ERR_SATUACM_INVALID_MAP_FORMAT.get(cfgEntryDN, mapStr)); |
| | | configAcceptable = false; |
| | | break; |
| | | } |
| | | |
| | | // Try to normalize the provided certAttrName |
| | | certAttrName = normalizeAttributeName(certAttrName); |
| | | |
| | | if (newAttributeMap.containsKey(certAttrName)) |
| | | { |
| | | unacceptableReasons.add(ERR_SATUACM_DUPLICATE_CERT_ATTR.get(cfgEntryDN, certAttrName)); |
| | | configAcceptable = false; |
| | | break; |
| | | } |
| | | |
| | | AttributeType userAttrType = |
| | | DirectoryServer.getAttributeType(userAttrName, false); |
| | | if (userAttrType == null) |
| | | { |
| | | unacceptableReasons.add(ERR_SATUACM_NO_SUCH_ATTR.get(mapStr, cfgEntryDN, userAttrName)); |
| | | configAcceptable = false; |
| | | break; |
| | | } |
| | | |
| | | for (AttributeType attrType : newAttributeMap.values()) |
| | | { |
| | | if (attrType.equals(userAttrType)) |
| | | { |
| | | unacceptableReasons.add(ERR_SATUACM_DUPLICATE_USER_ATTR.get(cfgEntryDN, attrType.getNameOrOID())); |
| | | configAcceptable = false; |
| | | break mapLoop; |
| | | } |
| | | } |
| | | |
| | | newAttributeMap.put(certAttrName, userAttrType); |
| | | } |
| | | |
| | | return configAcceptable; |
| | | ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | buildAttributeMap(configuration, configuration.dn(), ccr); |
| | | unacceptableReasons.addAll(ccr.getMessages()); |
| | | return ResultCode.SUCCESS.equals(ccr.getResultCode()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | SubjectAttributeToUserAttributeCertificateMapperCfg |
| | | configuration) |
| | | public ConfigChangeResult applyConfigurationChange(SubjectAttributeToUserAttributeCertificateMapperCfg configuration) |
| | | { |
| | | final ConfigChangeResult ccr = new ConfigChangeResult(); |
| | | |
| | | |
| | | // Get and validate the subject attribute to user attribute mappings. |
| | | LinkedHashMap<String,AttributeType> newAttributeMap = new LinkedHashMap<>(); |
| | | mapLoop: |
| | | for (String mapStr : configuration.getSubjectAttributeMapping()) |
| | | { |
| | | String lowerMap = toLowerCase(mapStr); |
| | | int colonPos = lowerMap.indexOf(':'); |
| | | if (colonPos <= 0) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | |
| | | |
| | | ccr.addMessage(ERR_SATUACM_INVALID_MAP_FORMAT.get(configEntryDN, mapStr)); |
| | | break; |
| | | } |
| | | |
| | | String certAttrName = lowerMap.substring(0, colonPos).trim(); |
| | | String userAttrName = lowerMap.substring(colonPos+1).trim(); |
| | | if ((certAttrName.length() == 0) || (userAttrName.length() == 0)) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | |
| | | |
| | | ccr.addMessage(ERR_SATUACM_INVALID_MAP_FORMAT.get(configEntryDN, mapStr)); |
| | | break; |
| | | } |
| | | |
| | | // Try to normalize the provided certAttrName |
| | | certAttrName = normalizeAttributeName(certAttrName); |
| | | |
| | | if (newAttributeMap.containsKey(certAttrName)) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | ccr.addMessage(ERR_SATUACM_DUPLICATE_CERT_ATTR.get(configEntryDN, certAttrName)); |
| | | break; |
| | | } |
| | | |
| | | AttributeType userAttrType = |
| | | DirectoryServer.getAttributeType(userAttrName, false); |
| | | if (userAttrType == null) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | ccr.addMessage(ERR_SATUACM_NO_SUCH_ATTR.get(mapStr, configEntryDN, userAttrName)); |
| | | break; |
| | | } |
| | | |
| | | for (AttributeType attrType : newAttributeMap.values()) |
| | | { |
| | | if (attrType.equals(userAttrType)) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | |
| | | |
| | | ccr.addMessage(ERR_SATUACM_DUPLICATE_USER_ATTR.get(configEntryDN, attrType.getNameOrOID())); |
| | | break mapLoop; |
| | | } |
| | | } |
| | | |
| | | newAttributeMap.put(certAttrName, userAttrType); |
| | | } |
| | | LinkedHashMap<String, AttributeType> newAttributeMap = buildAttributeMap(configuration, configEntryDN, ccr); |
| | | |
| | | // Make sure that all the user attributes are configured with equality |
| | | // indexes in all appropriate backends. |
| | | Set<DN> cfgBaseDNs = configuration.getUserBaseDN(); |
| | | if ((cfgBaseDNs == null) || cfgBaseDNs.isEmpty()) |
| | | { |
| | | cfgBaseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | | |
| | | Set<DN> cfgBaseDNs = getUserBaseDNs(configuration); |
| | | for (DN baseDN : cfgBaseDNs) |
| | | { |
| | | for (AttributeType t : newAttributeMap.values()) |
| | | { |
| | | Backend b = DirectoryServer.getBackend(baseDN); |
| | | if ((b != null) && (! b.isIndexed(t, IndexType.EQUALITY))) |
| | | Backend<?> b = DirectoryServer.getBackend(baseDN); |
| | | if (b != null && !b.isIndexed(t, IndexType.EQUALITY)) |
| | | { |
| | | LocalizableMessage message = WARN_SATUACM_ATTR_UNINDEXED.get( |
| | | configuration.dn(), t.getNameOrOID(), b.getBackendID()); |
| | | LocalizableMessage message = |
| | | WARN_SATUACM_ATTR_UNINDEXED.get(configuration.dn(), t.getNameOrOID(), b.getBackendID()); |
| | | ccr.addMessage(message); |
| | | logger.error(message); |
| | | } |
| | |
| | | |
| | | if (ccr.getResultCode() == ResultCode.SUCCESS) |
| | | { |
| | | attributeMap = newAttributeMap; |
| | | attributeMap = newAttributeMap; |
| | | currentConfig = configuration; |
| | | } |
| | | |
| | | return ccr; |
| | | } |
| | | |
| | | return ccr; |
| | | /** |
| | | * If we have an explicit set of base DNs, then use it. |
| | | * Otherwise, use the set of public naming contexts in the server. |
| | | */ |
| | | private Set<DN> getUserBaseDNs(SubjectAttributeToUserAttributeCertificateMapperCfg config) |
| | | { |
| | | Set<DN> baseDNs = config.getUserBaseDN(); |
| | | if ((baseDNs == null) || baseDNs.isEmpty()) |
| | | { |
| | | baseDNs = DirectoryServer.getPublicNamingContexts().keySet(); |
| | | } |
| | | return baseDNs; |
| | | } |
| | | |
| | | /** Get and validate the subject attribute to user attribute mappings. */ |
| | | private LinkedHashMap<String, AttributeType> buildAttributeMap( |
| | | SubjectAttributeToUserAttributeCertificateMapperCfg configuration, DN cfgEntryDN, ConfigChangeResult ccr) |
| | | { |
| | | LinkedHashMap<String, AttributeType> results = new LinkedHashMap<>(); |
| | | for (String mapStr : configuration.getSubjectAttributeMapping()) |
| | | { |
| | | String lowerMap = toLowerCase(mapStr); |
| | | int colonPos = lowerMap.indexOf(':'); |
| | | if (colonPos <= 0) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | ccr.addMessage(ERR_SATUACM_INVALID_MAP_FORMAT.get(cfgEntryDN, mapStr)); |
| | | return null; |
| | | } |
| | | |
| | | String certAttrName = lowerMap.substring(0, colonPos).trim(); |
| | | String userAttrName = lowerMap.substring(colonPos+1).trim(); |
| | | if ((certAttrName.length() == 0) || (userAttrName.length() == 0)) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | ccr.addMessage(ERR_SATUACM_INVALID_MAP_FORMAT.get(cfgEntryDN, mapStr)); |
| | | return null; |
| | | } |
| | | |
| | | // Try to normalize the provided certAttrName |
| | | certAttrName = normalizeAttributeName(certAttrName); |
| | | if (results.containsKey(certAttrName)) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | ccr.addMessage(ERR_SATUACM_DUPLICATE_CERT_ATTR.get(cfgEntryDN, certAttrName)); |
| | | return null; |
| | | } |
| | | |
| | | AttributeType userAttrType = DirectoryServer.getAttributeType(userAttrName); |
| | | if (userAttrType == null) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | ccr.addMessage(ERR_SATUACM_NO_SUCH_ATTR.get(mapStr, cfgEntryDN, userAttrName)); |
| | | return null; |
| | | } |
| | | if (results.values().contains(userAttrType)) |
| | | { |
| | | ccr.setResultCodeIfSuccess(ResultCode.CONSTRAINT_VIOLATION); |
| | | ccr.addMessage(ERR_SATUACM_DUPLICATE_USER_ATTR.get(cfgEntryDN, userAttrType.getNameOrOID())); |
| | | return null; |
| | | } |
| | | |
| | | results.put(certAttrName, userAttrType); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | private static String normalizeAttributeName(String attrName) |
| | | { |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(attrName, false); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attrName); |
| | | if (attrType != null) |
| | | { |
| | | String attrNameNormalized = attrType.getNormalizedPrimaryName(); |
| | |
| | | return attrName; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // Get the target group DN attribute from the entry, if there is one. |
| | | DN targetDN = null; |
| | | AttributeType targetType = |
| | | DirectoryServer.getAttributeType(ATTR_TARGET_GROUP_DN, true); |
| | | AttributeType targetType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TARGET_GROUP_DN); |
| | | List<Attribute> attrList = groupEntry.getAttribute(targetType); |
| | | if (attrList != null) |
| | | { |
| | |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.schema.BooleanSyntax; |
| | | import org.opends.server.types.*; |
| | | |
| | |
| | | { |
| | | monitorName = backend.getBackendID() + " Backend"; |
| | | |
| | | backendIDType = DirectoryConfig.getAttributeType(ATTR_MONITOR_BACKEND_ID, true); |
| | | baseDNType = DirectoryConfig.getAttributeType(ATTR_MONITOR_BACKEND_BASE_DN, true); |
| | | entryCountType = |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_BACKEND_ENTRY_COUNT, true); |
| | | baseDNEntryCountType = |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_BASE_DN_ENTRY_COUNT, true); |
| | | isPrivateType = |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_BACKEND_IS_PRIVATE, true); |
| | | writabilityModeType = |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_BACKEND_WRITABILITY_MODE, true); |
| | | backendIDType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_BACKEND_ID); |
| | | baseDNType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_BACKEND_BASE_DN); |
| | | entryCountType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_BACKEND_ENTRY_COUNT); |
| | | baseDNEntryCountType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_BASE_DN_ENTRY_COUNT); |
| | | isPrivateType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_BACKEND_IS_PRIVATE); |
| | | writabilityModeType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_BACKEND_WRITABILITY_MODE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ConnectionHandler; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | |
| | | /** |
| | |
| | | { |
| | | monitorName = connectionHandler.getConnectionHandlerName(); |
| | | |
| | | connectionsType = |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_CONNHANDLER_CONNECTION, |
| | | true); |
| | | |
| | | listenerType = |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_CONNHANDLER_LISTENER, |
| | | true); |
| | | |
| | | numConnectionsType = |
| | | DirectoryConfig.getAttributeType( |
| | | ATTR_MONITOR_CONNHANDLER_NUMCONNECTIONS, true); |
| | | |
| | | protocolType = |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_CONNHANDLER_PROTOCOL, |
| | | true); |
| | | |
| | | configDnType = |
| | | DirectoryConfig.getAttributeType(ATTR_MONITOR_CONFIG_DN, |
| | | true); |
| | | connectionsType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_CONNHANDLER_CONNECTION); |
| | | listenerType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_CONNHANDLER_LISTENER); |
| | | numConnectionsType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_CONNHANDLER_NUMCONNECTIONS); |
| | | protocolType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_CONNHANDLER_PROTOCOL); |
| | | configDnType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MONITOR_CONFIG_DN); |
| | | } |
| | | |
| | | |
| | |
| | | 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.types.*; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | |
| | |
| | | |
| | | // Get the entryUUID attribute type. This needs to be done in the |
| | | // constructor in order to make the associated variables "final". |
| | | AttributeType at = DirectoryConfig.getAttributeType(ENTRYUUID, false); |
| | | AttributeType at = DirectoryServer.getAttributeType(ENTRYUUID); |
| | | if (at == null) |
| | | { |
| | | String definition = |
| | |
| | | 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.types.*; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyDNOperation; |
| | |
| | | |
| | | |
| | | // Get the attribute types for the attributes that we will use. This needs |
| | | // to be done in the constructor in order to make the associated variables |
| | | // "final". |
| | | createTimestampType = |
| | | DirectoryConfig.getAttributeType(OP_ATTR_CREATE_TIMESTAMP_LC, true); |
| | | creatorsNameType = |
| | | DirectoryConfig.getAttributeType(OP_ATTR_CREATORS_NAME_LC, true); |
| | | modifiersNameType = |
| | | DirectoryConfig.getAttributeType(OP_ATTR_MODIFIERS_NAME_LC, true); |
| | | modifyTimestampType = |
| | | DirectoryConfig.getAttributeType(OP_ATTR_MODIFY_TIMESTAMP_LC, true); |
| | | // to be done in the constructor in order to make the associated variables "final". |
| | | createTimestampType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_CREATE_TIMESTAMP_LC); |
| | | creatorsNameType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_CREATORS_NAME_LC); |
| | | modifiersNameType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_MODIFIERS_NAME_LC); |
| | | modifyTimestampType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_MODIFY_TIMESTAMP_LC); |
| | | } |
| | | |
| | | |
| | |
| | | configuration.addPasswordPolicyImportChangeListener(this); |
| | | |
| | | customPolicyAttribute = |
| | | DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_POLICY_DN, true); |
| | | DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_POLICY_DN); |
| | | |
| | | |
| | | // Make sure that the plugin has been enabled for the appropriate types. |
| | |
| | | |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(); |
| | | AttributeType cnAT = |
| | | DirectoryServer.getAttributeType(ATTR_COMMON_NAME, true); |
| | | AttributeType snAT = DirectoryServer.getAttributeType(ATTR_SN, true); |
| | | AttributeType altDNAT = |
| | | DirectoryServer.getAttributeType( |
| | | ATTR_ROOTDN_ALTERNATE_BIND_DN, true); |
| | | AttributeType cnAT = DirectoryServer.getAttributeTypeOrDefault(ATTR_COMMON_NAME); |
| | | AttributeType snAT = DirectoryServer.getAttributeTypeOrDefault(ATTR_SN); |
| | | AttributeType altDNAT = DirectoryServer.getAttributeTypeOrDefault(ATTR_ROOTDN_ALTERNATE_BIND_DN); |
| | | |
| | | LinkedList<Attribute> attrList = new LinkedList<>(); |
| | | attrList.add(Attributes.create(ATTR_COMMON_NAME, commonName)); |
| | |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> operationalAttrs = new LinkedHashMap<>(); |
| | | |
| | | AttributeType privType = |
| | | DirectoryServer.getAttributeType(OP_ATTR_PRIVILEGE_NAME, true); |
| | | |
| | | AttributeType privType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PRIVILEGE_NAME); |
| | | AttributeBuilder builder = new AttributeBuilder(privType); |
| | | for (Privilege p : Privilege.getDefaultRootPrivileges()) |
| | | { |
| | |
| | | if (semicolonPos > 0) |
| | | { |
| | | String baseName = attributeType.substring(0, semicolonPos); |
| | | attrType = DirectoryServer.getAttributeType(toLowerCase(baseName), baseName); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(baseName), baseName); |
| | | options = new HashSet<>(); |
| | | StringTokenizer tokenizer = |
| | | new StringTokenizer(attributeType.substring(semicolonPos+1), ";"); |
| | |
| | | else |
| | | { |
| | | options = null; |
| | | attrType = DirectoryServer.getAttributeType(toLowerCase(attributeType), attributeType); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeType), attributeType); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | // This HistVal was used to store the date when some |
| | | // modifications were done to the entries. |
| | | attrType = DirectoryServer.getAttributeType(attrString, true); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(attrString); |
| | | } |
| | | else |
| | | { |
| | |
| | | conn, nextOperationID(), nextMessageID(), new ArrayList<Control>(0), |
| | | targetDN, newRDN, false, parentDN); |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(DS_SYNC_CONFLICT, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(DS_SYNC_CONFLICT); |
| | | if (markConflict) |
| | | { |
| | | Attribute attr = |
| | |
| | | private void markConflictEntry(Operation op, DN currentDN, DN conflictDN) |
| | | { |
| | | // create new internal modify operation and run it. |
| | | AttributeType attrType = DirectoryServer.getAttributeType(DS_SYNC_CONFLICT, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(DS_SYNC_CONFLICT); |
| | | Attribute attr = Attributes.create(attrType, conflictDN.toString()); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | |
| | |
| | | Set<AttributeType> includeAttributes = new HashSet<>(); |
| | | for (String attrName : includeAttributeStrings) |
| | | { |
| | | includeAttributes.add(DirectoryServer.getAttributeType(attrName, true)); |
| | | includeAttributes.add(DirectoryServer.getAttributeTypeOrDefault(attrName)); |
| | | } |
| | | exportConfig.setIncludeAttributes(includeAttributes); |
| | | } |
| | |
| | | // create a rule and register it into the DirectoryServer |
| | | provider.initializeVirtualAttributeProvider(null); |
| | | |
| | | AttributeType attributeType = DirectoryServer.getAttributeType( |
| | | attrName, false); |
| | | |
| | | AttributeType attributeType = DirectoryServer.getAttributeType(attrName); |
| | | return new VirtualAttributeRule(attributeType, provider, |
| | | baseDNs, SearchScope.BASE_OBJECT, |
| | | groupDNs, filters, conflictBehavior); |
| | |
| | | |
| | | // Get the attribute that specifies which schema file(s) to add. |
| | | Entry taskEntry = getTaskEntry(); |
| | | AttributeType attrType = DirectoryServer.getAttributeType( |
| | | ATTR_TASK_ADDSCHEMAFILE_FILENAME, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_ADDSCHEMAFILE_FILENAME); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | { |
| | |
| | | |
| | | Entry taskEntry = getTaskEntry(); |
| | | |
| | | AttributeType typeBackupAll; |
| | | AttributeType typeCompress; |
| | | AttributeType typeEncrypt; |
| | | AttributeType typeHash; |
| | | AttributeType typeIncremental; |
| | | AttributeType typeSignHash; |
| | | AttributeType typeBackendID; |
| | | AttributeType typeBackupID; |
| | | AttributeType typeBackupDirectory; |
| | | AttributeType typeIncrementalBaseID; |
| | | |
| | | |
| | | typeBackupAll = |
| | | getAttributeType(ATTR_TASK_BACKUP_ALL, true); |
| | | typeCompress = |
| | | getAttributeType(ATTR_TASK_BACKUP_COMPRESS, true); |
| | | typeEncrypt = |
| | | getAttributeType(ATTR_TASK_BACKUP_ENCRYPT, true); |
| | | typeHash = |
| | | getAttributeType(ATTR_TASK_BACKUP_HASH, true); |
| | | typeIncremental = |
| | | getAttributeType(ATTR_TASK_BACKUP_INCREMENTAL, true); |
| | | typeSignHash = |
| | | getAttributeType(ATTR_TASK_BACKUP_SIGN_HASH, true); |
| | | typeBackendID = |
| | | getAttributeType(ATTR_TASK_BACKUP_BACKEND_ID, true); |
| | | typeBackupID = |
| | | getAttributeType(ATTR_BACKUP_ID, true); |
| | | typeBackupDirectory = |
| | | getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | typeIncrementalBaseID = |
| | | getAttributeType(ATTR_TASK_BACKUP_INCREMENTAL_BASE_ID, true); |
| | | AttributeType typeBackupAll = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_ALL); |
| | | AttributeType typeCompress = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_COMPRESS); |
| | | AttributeType typeEncrypt = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_ENCRYPT); |
| | | AttributeType typeHash = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_HASH); |
| | | AttributeType typeIncremental = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_INCREMENTAL); |
| | | AttributeType typeSignHash = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_SIGN_HASH); |
| | | AttributeType typeBackendID = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_BACKEND_ID); |
| | | AttributeType typeBackupID = getAttributeTypeOrDefault(ATTR_BACKUP_ID); |
| | | AttributeType typeBackupDirectory = getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | AttributeType typeIncrementalBaseID = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_INCREMENTAL_BASE_ID); |
| | | |
| | | |
| | | List<Attribute> attrList; |
| | |
| | | |
| | | private long getConnectionID(Entry taskEntry) throws DirectoryException |
| | | { |
| | | final AttributeType attrType = DirectoryServer.getAttributeType(ATTR_TASK_DISCONNECT_CONN_ID, true); |
| | | final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_CONN_ID); |
| | | final List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | { |
| | |
| | | |
| | | private boolean mustNotifyClient(Entry taskEntry) throws DirectoryException |
| | | { |
| | | final AttributeType attrType = DirectoryServer.getAttributeType(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT, true); |
| | | final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT); |
| | | final List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | { |
| | |
| | | |
| | | private LocalizableMessage getDisconnectMessage(Entry taskEntry) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(ATTR_TASK_DISCONNECT_MESSAGE, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_MESSAGE); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | { |
| | |
| | | |
| | | |
| | | Entry taskEntry = getTaskEntry(); |
| | | AttributeType typeWrapColumn = getAttributeType(ATTR_TASK_EXPORT_WRAP_COLUMN, true); |
| | | AttributeType typeWrapColumn = getAttributeTypeOrDefault(ATTR_TASK_EXPORT_WRAP_COLUMN); |
| | | |
| | | ldifFile = toString(taskEntry, ATTR_TASK_EXPORT_LDIF_FILE); |
| | | File f = new File (ldifFile); |
| | |
| | | |
| | | private boolean toBoolean(Entry entry, boolean defaultValue, String attrName) |
| | | { |
| | | final AttributeType attrType = getAttributeType(attrName, true); |
| | | final AttributeType attrType = getAttributeTypeOrDefault(attrName); |
| | | final List<Attribute> attrs = entry.getAttribute(attrType); |
| | | return TaskUtils.getBoolean(attrs, defaultValue); |
| | | } |
| | | |
| | | private ArrayList<String> toListOfString(Entry entry, String attrName) |
| | | { |
| | | final AttributeType attrType = getAttributeType(attrName, true); |
| | | final AttributeType attrType = getAttributeTypeOrDefault(attrName); |
| | | final List<Attribute> attrs = entry.getAttribute(attrType); |
| | | return TaskUtils.getMultiValueString(attrs); |
| | | } |
| | | |
| | | private String toString(Entry entry, String attrName) |
| | | { |
| | | final AttributeType attrType = getAttributeType(attrName, true); |
| | | final AttributeType attrType = getAttributeTypeOrDefault(attrName); |
| | | final List<Attribute> attrs = entry.getAttribute(attrType); |
| | | return TaskUtils.getSingleValueString(attrs); |
| | | } |
| | |
| | | HashSet<AttributeType> attributes = new HashSet<>(); |
| | | for (String attrName : attributeStrings) |
| | | { |
| | | attributes.add(DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName)); |
| | | attributes.add(DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName)); |
| | | } |
| | | return attributes; |
| | | } |
| | |
| | | |
| | | Entry taskEntry = getTaskEntry(); |
| | | |
| | | AttributeType typeLdifFile = getAttributeType(ATTR_IMPORT_LDIF_FILE, true); |
| | | AttributeType typeTemplateFile = getAttributeType(ATTR_IMPORT_TEMPLATE_FILE, true); |
| | | AttributeType typeAppend = getAttributeType(ATTR_IMPORT_APPEND, true); |
| | | AttributeType typeReplaceExisting = getAttributeType(ATTR_IMPORT_REPLACE_EXISTING, true); |
| | | AttributeType typeBackendID = getAttributeType(ATTR_IMPORT_BACKEND_ID, true); |
| | | AttributeType typeIncludeBranch = getAttributeType(ATTR_IMPORT_INCLUDE_BRANCH, true); |
| | | AttributeType typeExcludeBranch = getAttributeType(ATTR_IMPORT_EXCLUDE_BRANCH, true); |
| | | AttributeType typeIncludeAttribute = getAttributeType(ATTR_IMPORT_INCLUDE_ATTRIBUTE, true); |
| | | AttributeType typeExcludeAttribute = getAttributeType(ATTR_IMPORT_EXCLUDE_ATTRIBUTE, true); |
| | | AttributeType typeIncludeFilter = getAttributeType(ATTR_IMPORT_INCLUDE_FILTER, true); |
| | | AttributeType typeExcludeFilter = getAttributeType(ATTR_IMPORT_EXCLUDE_FILTER, true); |
| | | AttributeType typeRejectFile = getAttributeType(ATTR_IMPORT_REJECT_FILE, true); |
| | | AttributeType typeSkipFile = getAttributeType(ATTR_IMPORT_SKIP_FILE, true); |
| | | AttributeType typeOverwrite = getAttributeType(ATTR_IMPORT_OVERWRITE, true); |
| | | AttributeType typeSkipSchemaValidation = getAttributeType(ATTR_IMPORT_SKIP_SCHEMA_VALIDATION, true); |
| | | AttributeType typeIsCompressed = getAttributeType(ATTR_IMPORT_IS_COMPRESSED, true); |
| | | AttributeType typeIsEncrypted = getAttributeType(ATTR_IMPORT_IS_ENCRYPTED, true); |
| | | AttributeType typeClearBackend = getAttributeType(ATTR_IMPORT_CLEAR_BACKEND, true); |
| | | AttributeType typeRandomSeed = getAttributeType(ATTR_IMPORT_RANDOM_SEED, true); |
| | | AttributeType typeThreadCount = getAttributeType(ATTR_IMPORT_THREAD_COUNT, true); |
| | | AttributeType typeTmpDirectory = getAttributeType(ATTR_IMPORT_TMP_DIRECTORY, true); |
| | | AttributeType typeDNCheckPhase2 = getAttributeType(ATTR_IMPORT_SKIP_DN_VALIDATION, true); |
| | | AttributeType typeLdifFile = getAttributeTypeOrDefault(ATTR_IMPORT_LDIF_FILE); |
| | | AttributeType typeTemplateFile = getAttributeTypeOrDefault(ATTR_IMPORT_TEMPLATE_FILE); |
| | | AttributeType typeAppend = getAttributeTypeOrDefault(ATTR_IMPORT_APPEND); |
| | | AttributeType typeReplaceExisting = getAttributeTypeOrDefault(ATTR_IMPORT_REPLACE_EXISTING); |
| | | AttributeType typeBackendID = getAttributeTypeOrDefault(ATTR_IMPORT_BACKEND_ID); |
| | | AttributeType typeIncludeBranch = getAttributeTypeOrDefault(ATTR_IMPORT_INCLUDE_BRANCH); |
| | | AttributeType typeExcludeBranch = getAttributeTypeOrDefault(ATTR_IMPORT_EXCLUDE_BRANCH); |
| | | AttributeType typeIncludeAttribute = getAttributeTypeOrDefault(ATTR_IMPORT_INCLUDE_ATTRIBUTE); |
| | | AttributeType typeExcludeAttribute = getAttributeTypeOrDefault(ATTR_IMPORT_EXCLUDE_ATTRIBUTE); |
| | | AttributeType typeIncludeFilter = getAttributeTypeOrDefault(ATTR_IMPORT_INCLUDE_FILTER); |
| | | AttributeType typeExcludeFilter = getAttributeTypeOrDefault(ATTR_IMPORT_EXCLUDE_FILTER); |
| | | AttributeType typeRejectFile = getAttributeTypeOrDefault(ATTR_IMPORT_REJECT_FILE); |
| | | AttributeType typeSkipFile = getAttributeTypeOrDefault(ATTR_IMPORT_SKIP_FILE); |
| | | AttributeType typeOverwrite = getAttributeTypeOrDefault(ATTR_IMPORT_OVERWRITE); |
| | | AttributeType typeSkipSchemaValidation = getAttributeTypeOrDefault(ATTR_IMPORT_SKIP_SCHEMA_VALIDATION); |
| | | AttributeType typeIsCompressed = getAttributeTypeOrDefault(ATTR_IMPORT_IS_COMPRESSED); |
| | | AttributeType typeIsEncrypted = getAttributeTypeOrDefault(ATTR_IMPORT_IS_ENCRYPTED); |
| | | AttributeType typeClearBackend = getAttributeTypeOrDefault(ATTR_IMPORT_CLEAR_BACKEND); |
| | | AttributeType typeRandomSeed = getAttributeTypeOrDefault(ATTR_IMPORT_RANDOM_SEED); |
| | | AttributeType typeThreadCount = getAttributeTypeOrDefault(ATTR_IMPORT_THREAD_COUNT); |
| | | AttributeType typeTmpDirectory = getAttributeTypeOrDefault(ATTR_IMPORT_TMP_DIRECTORY); |
| | | AttributeType typeDNCheckPhase2 = getAttributeTypeOrDefault(ATTR_IMPORT_SKIP_DN_VALIDATION); |
| | | |
| | | ArrayList<String> ldifFilestmp = asListOfStrings(taskEntry, typeLdifFile); |
| | | ldifFiles = new ArrayList<>(ldifFilestmp.size()); |
| | |
| | | final HashSet<AttributeType> attrTypes = new HashSet<>(attrNames.size()); |
| | | for (String attrName : attrNames) |
| | | { |
| | | attrTypes.add(DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName)); |
| | | attrTypes.add(DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName)); |
| | | } |
| | | return attrTypes; |
| | | } |
| | |
| | | // FIXME -- Do we need any special authorization here? |
| | | Entry taskEntry = getTaskEntry(); |
| | | |
| | | AttributeType typeDomainBase = getAttributeType(ATTR_TASK_INITIALIZE_TARGET_DOMAIN_DN, true); |
| | | AttributeType typeScope = getAttributeType(ATTR_TASK_INITIALIZE_TARGET_SCOPE, true); |
| | | AttributeType typeDomainBase = getAttributeTypeOrDefault(ATTR_TASK_INITIALIZE_TARGET_DOMAIN_DN); |
| | | AttributeType typeScope = getAttributeTypeOrDefault(ATTR_TASK_INITIALIZE_TARGET_SCOPE); |
| | | |
| | | List<Attribute> attrList = taskEntry.getAttribute(typeDomainBase); |
| | | domainString = TaskUtils.getSingleValueString(attrList); |
| | |
| | | // FIXME -- Do we need any special authorization here? |
| | | Entry taskEntry = getTaskEntry(); |
| | | |
| | | AttributeType typeDomainBase; |
| | | AttributeType typeSourceScope; |
| | | |
| | | typeDomainBase = |
| | | getAttributeType(ATTR_TASK_INITIALIZE_DOMAIN_DN, true); |
| | | typeSourceScope = |
| | | getAttributeType(ATTR_TASK_INITIALIZE_SOURCE, true); |
| | | AttributeType typeDomainBase = getAttributeTypeOrDefault(ATTR_TASK_INITIALIZE_DOMAIN_DN); |
| | | AttributeType typeSourceScope = getAttributeTypeOrDefault(ATTR_TASK_INITIALIZE_SOURCE); |
| | | |
| | | List<Attribute> attrList; |
| | | attrList = taskEntry.getAttribute(typeDomainBase); |
| | |
| | | // FIXME -- Do we need any special authorization here? |
| | | Entry taskEntry = getTaskEntry(); |
| | | |
| | | AttributeType typeDomainBase = getAttributeType(ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN, true); |
| | | AttributeType typeDomainBase = getAttributeTypeOrDefault(ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN); |
| | | List<Attribute> attrList = taskEntry.getAttribute(typeDomainBase); |
| | | domainString = TaskUtils.getSingleValueString(attrList); |
| | | |
| | |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, mb.toMessage()); |
| | | } |
| | | |
| | | AttributeType typeMaxDuration = getAttributeType(ATTR_TASK_CONFLICTS_HIST_PURGE_MAX_DURATION, true); |
| | | AttributeType typeMaxDuration = getAttributeTypeOrDefault(ATTR_TASK_CONFLICTS_HIST_PURGE_MAX_DURATION); |
| | | attrList = taskEntry.getAttribute(typeMaxDuration); |
| | | String maxDurationStringInSec = TaskUtils.getSingleValueString(attrList); |
| | | |
| | |
| | | final String val = asString(taskEntry, ATTR_REBUILD_INDEX_CLEARDEGRADEDSTATE); |
| | | isClearDegradedState = Boolean.parseBoolean(val); |
| | | |
| | | AttributeType typeIndex = getAttributeType(ATTR_REBUILD_INDEX, true); |
| | | AttributeType typeIndex = getAttributeTypeOrDefault(ATTR_REBUILD_INDEX); |
| | | List<Attribute> attrList = taskEntry.getAttribute(typeIndex); |
| | | indexes = TaskUtils.getMultiValueString(attrList); |
| | | |
| | |
| | | |
| | | private String asString(Entry taskEntry, String attrName) |
| | | { |
| | | final AttributeType attrType = getAttributeType(attrName, true); |
| | | final AttributeType attrType = getAttributeTypeOrDefault(attrName); |
| | | final List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | return TaskUtils.getSingleValueString(attrList); |
| | | } |
| | |
| | | |
| | | Entry taskEntry = getTaskEntry(); |
| | | |
| | | AttributeType typeBackupDirectory; |
| | | AttributeType typebackupID; |
| | | AttributeType typeVerifyOnly; |
| | | |
| | | |
| | | typeBackupDirectory = getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); |
| | | typebackupID = getAttributeType(ATTR_BACKUP_ID, true); |
| | | typeVerifyOnly = getAttributeType(ATTR_TASK_RESTORE_VERIFY_ONLY, true); |
| | | AttributeType typeBackupDirectory = getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | AttributeType typebackupID = getAttributeTypeOrDefault(ATTR_BACKUP_ID); |
| | | AttributeType typeVerifyOnly = getAttributeTypeOrDefault(ATTR_TASK_RESTORE_VERIFY_ONLY); |
| | | |
| | | List<Attribute> attrList; |
| | | |
| | |
| | | Entry taskEntry = getTaskEntry(); |
| | | |
| | | // Retrieves the eventual generation-ID |
| | | AttributeType typeNewValue = getAttributeType(ATTR_TASK_SET_GENERATION_ID_NEW_VALUE, true); |
| | | AttributeType typeNewValue = getAttributeTypeOrDefault(ATTR_TASK_SET_GENERATION_ID_NEW_VALUE); |
| | | List<Attribute> attrList = taskEntry.getAttribute(typeNewValue); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | |
| | | } |
| | | |
| | | // Retrieves the replication domain |
| | | AttributeType typeDomainBase = getAttributeType(ATTR_TASK_SET_GENERATION_ID_DOMAIN_DN, true); |
| | | AttributeType typeDomainBase = getAttributeTypeOrDefault(ATTR_TASK_SET_GENERATION_ID_DOMAIN_DN); |
| | | attrList = taskEntry.getAttribute(typeDomainBase); |
| | | domainString = TaskUtils.getSingleValueString(attrList); |
| | | |
| | |
| | | restart = false; |
| | | shutdownMessage = INFO_TASK_SHUTDOWN_DEFAULT_MESSAGE.get(taskEntry.getName()); |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(ATTR_SHUTDOWN_MESSAGE, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_SHUTDOWN_MESSAGE); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | attrType = DirectoryServer.getAttributeType(ATTR_RESTART_SERVER, true); |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_RESTART_SERVER); |
| | | attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | |
| | | // See if there were any user-defined sets of include/exclude attributes or |
| | | // filters. If so, then process them. |
| | | HashSet<AttributeType> excludeAttributes; |
| | | if (excludeAttributeStrings == null) |
| | | { |
| | | excludeAttributes = null; |
| | | } |
| | | else |
| | | { |
| | | excludeAttributes = new HashSet<>(); |
| | | for (String attrName : excludeAttributeStrings.getValues()) |
| | | { |
| | | excludeAttributes.add( |
| | | DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName)); |
| | | } |
| | | } |
| | | |
| | | HashSet<AttributeType> includeAttributes; |
| | | if (includeAttributeStrings == null) |
| | | { |
| | | includeAttributes = null; |
| | | } |
| | | else |
| | | { |
| | | includeAttributes = new HashSet<>(); |
| | | for (String attrName : includeAttributeStrings.getValues()) |
| | | { |
| | | includeAttributes.add( |
| | | DirectoryServer.getAttributeType(attrName.toLowerCase(), attrName)); |
| | | } |
| | | } |
| | | Set<AttributeType> excludeAttributes = toAttributeTypes(excludeAttributeStrings); |
| | | Set<AttributeType> includeAttributes = toAttributeTypes(includeAttributeStrings); |
| | | |
| | | ArrayList<SearchFilter> excludeFilters; |
| | | if (excludeFilterStrings == null) |
| | |
| | | |
| | | // Clean up after the export by closing the export config. |
| | | exportConfig.close(); |
| | | if (!errorOccurred) |
| | | return !errorOccurred ? 0 : 1; |
| | | } |
| | | |
| | | private Set<AttributeType> toAttributeTypes(StringArgument attributeArg) |
| | | { |
| | | if (attributeArg == null) |
| | | { |
| | | return 0; |
| | | return null; |
| | | } |
| | | else |
| | | |
| | | Set<AttributeType> results = new HashSet<>(); |
| | | for (String attrName : attributeArg.getValues()) |
| | | { |
| | | return 1; |
| | | results.add(DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName)); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | } |
| | | else |
| | | { |
| | | excludeAttributes.add(DirectoryServer.getAttributeType(lowerName, attrName)); |
| | | excludeAttributes.add(DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | includeAttributes.add(DirectoryServer.getAttributeType(lowerName, attrName)); |
| | | includeAttributes.add(DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName)); |
| | | } |
| | | } |
| | | } |
| | |
| | | LinkedHashSet<AttributeType> operationalAttributeTypes = new LinkedHashSet<>(); |
| | | for (String attributeName : attributeNames) |
| | | { |
| | | AttributeType t = DirectoryServer.getAttributeType(attributeName, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(attributeName); |
| | | if (t.isOperational()) |
| | | { |
| | | operationalAttributeTypes.add(t); |
| | |
| | | } |
| | | |
| | | String lowerName = toLowerCase(arguments[0]); |
| | | attributeType = DirectoryServer.getAttributeType(lowerName, true); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(lowerName); |
| | | if (! branch.hasAttribute(attributeType)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | } |
| | | |
| | | String lowerName = toLowerCase(arguments[0]); |
| | | attributeType = DirectoryServer.getAttributeType(lowerName, true); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(lowerName); |
| | | if (! template.hasAttribute(attributeType)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | } |
| | | |
| | | String lowerName = toLowerCase(arguments[0]); |
| | | AttributeType t = DirectoryServer.getAttributeType(lowerName, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(lowerName); |
| | | if (! branch.hasAttribute(t)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | } |
| | | |
| | | String lowerName = toLowerCase(arguments[0]); |
| | | attributeType = DirectoryServer.getAttributeType(lowerName, true); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(lowerName); |
| | | if (! template.hasAttribute(attributeType)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | } |
| | | |
| | | String lowerName = toLowerCase(arguments[0]); |
| | | AttributeType t = DirectoryServer.getAttributeType(lowerName, true); |
| | | AttributeType t = DirectoryServer.getAttributeTypeOrDefault(lowerName); |
| | | if (! branch.hasAttribute(t)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | } |
| | | |
| | | String lowerName = toLowerCase(arguments[0]); |
| | | attributeType = DirectoryServer.getAttributeType(lowerName, true); |
| | | attributeType = DirectoryServer.getAttributeTypeOrDefault(lowerName); |
| | | if (! template.hasAttribute(attributeType)) |
| | | { |
| | | LocalizableMessage message = |
| | |
| | | StringTokenizer tokenizer = new StringTokenizer(rdnAttrNames, "+"); |
| | | while (tokenizer.hasMoreTokens()) |
| | | { |
| | | attrList.add(DirectoryServer.getAttributeType(tokenizer.nextToken(), |
| | | true)); |
| | | attrList.add(DirectoryServer.getAttributeTypeOrDefault(tokenizer.nextToken())); |
| | | } |
| | | |
| | | rdnAttributes = new AttributeType[attrList.size()]; |
| | |
| | | } |
| | | } |
| | | |
| | | AttributeType attributeType = |
| | | DirectoryServer.getAttributeType(lowerLine.substring(0, colonPos), |
| | | true); |
| | | |
| | | AttributeType attributeType = DirectoryServer.getAttributeTypeOrDefault(lowerLine.substring(0, colonPos)); |
| | | |
| | | // First, check whether the value is an URL value: <attrName>:< <url> |
| | | int length = line.length(); |
| | |
| | | */ |
| | | private static AttributeType getAttributeType(String attributeName) |
| | | { |
| | | return DirectoryServer.getAttributeType(toLowerCase(attributeName), attributeName); |
| | | return DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName), attributeName); |
| | | } |
| | | |
| | | /** The attribute type for this attribute. */ |
| | |
| | | public static Attribute create(String attributeName, |
| | | String valueString) |
| | | { |
| | | return create(getAttributeType(attributeName), attributeName, |
| | | valueString); |
| | | return create(getAttributeType(attributeName), attributeName, valueString); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets the named attribute type, creating a default attribute if |
| | | * necessary. |
| | | * Gets the named attribute type, creating a default attribute if necessary. |
| | | * |
| | | * @param attributeName |
| | | * The name of the attribute type. |
| | | * @return The attribute type associated with the provided attribute |
| | | * name. |
| | | * @return The attribute type associated with the provided attribute name. |
| | | */ |
| | | private static AttributeType getAttributeType(String attributeName) |
| | | { |
| | | return DirectoryServer.getAttributeType(toLowerCase(attributeName), attributeName); |
| | | return DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName), attributeName); |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.ConfigHandler; |
| | | import org.opends.server.api.ExtendedOperationHandler; |
| | | import org.opends.server.api.InvokableComponent; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.SASLMechanismHandler; |
| | | import org.opends.server.api.ServerShutdownListener; |
| | | import org.opends.server.config.ConfigEntry; |
| | |
| | | return DirectoryServer.getAttributeTypes(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the attribute type for the provided lowercase name or |
| | | * OID. It can optionally return a generated "default" version if |
| | | * the requested attribute type is not defined in the schema. |
| | | * |
| | | * @param lowerName The lowercase name or OID for the |
| | | * attribute type to retrieve. |
| | | * @param returnDefault Indicates whether to generate a default |
| | | * version if the requested attribute type is |
| | | * not defined in the server schema. |
| | | * |
| | | * @return The requested attribute type, or <CODE>null</CODE> if |
| | | * there is no attribute with the specified type defined in |
| | | * the server schema and a default type should not be |
| | | * returned. |
| | | */ |
| | | public static AttributeType |
| | | getAttributeType(String lowerName, boolean returnDefault) |
| | | { |
| | | return DirectoryServer.getAttributeType(lowerName, returnDefault); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the attribute type for the "objectClass" attribute. |
| | | * |
| | |
| | | AttributeType elementType, |
| | | List<Modification> mods) |
| | | { |
| | | AttributeType attributeTypesType = |
| | | DirectoryServer.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC, true); |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(elementType); |
| | | for (String s : oldElements) |
| | | { |
| | |
| | | this.subTreeSpec = null; |
| | | String specString = null; |
| | | boolean isValidSpec = true; |
| | | AttributeType specAttrType = DirectoryServer.getAttributeType( |
| | | ATTR_SUBTREE_SPEC_LC, true); |
| | | List<Attribute> specAttrList = |
| | | entry.getAttribute(specAttrType); |
| | | AttributeType specAttrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_SUBTREE_SPEC_LC); |
| | | List<Attribute> specAttrList = entry.getAttribute(specAttrType); |
| | | if (specAttrList != null) |
| | | { |
| | | for (Attribute attr : specAttrList) |
| | |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromDNType = |
| | | DirectoryServer.getAttributeType( |
| | | value.toString().toLowerCase(), |
| | | true); |
| | | this.inheritFromDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | this.inheritFromDNAttrValue = value; |
| | | break; |
| | | } |
| | |
| | | |
| | | if (this.isInheritedFromRDNCollective) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute( |
| | | ATTR_INHERIT_COLLECTIVE_FROM_RDN); |
| | | List<Attribute> attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromRDNAttrType = |
| | | DirectoryServer.getAttributeType( |
| | | value.toString().toLowerCase(), |
| | | true); |
| | | this.inheritFromRDNAttrType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | this.inheritFromRDNAttrValue = value; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | attrList = entry.getAttribute( |
| | | ATTR_INHERIT_COLLECTIVE_FROM_RDN_TYPE); |
| | | attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN_TYPE); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromRDNType = |
| | | DirectoryServer.getAttributeType( |
| | | value.toString().toLowerCase(), |
| | | true); |
| | | this.inheritFromRDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | attrList = entry.getAttribute( |
| | | ATTR_INHERIT_COLLECTIVE_FROM_BASE); |
| | | attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_BASE); |
| | | if ((attrList != null) && !attrList.isEmpty()) |
| | | { |
| | | for (Attribute attr : attrList) |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeType(lowerName, attrName); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, attrName); |
| | | if (! importConfig.includeAttribute(attrType)) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | |
| | | |
| | | // Check to see if the entry includes a privilege specification. If so, |
| | | // then the requester must have the PRIVILEGE_CHANGE privilege. |
| | | AttributeType privType = |
| | | DirectoryServer.getAttributeType(OP_ATTR_PRIVILEGE_NAME, true); |
| | | AttributeType privType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PRIVILEGE_NAME); |
| | | if (entry.hasAttribute(privType) |
| | | && !clientConnection.hasPrivilege(Privilege.PRIVILEGE_CHANGE, this)) |
| | | { |
| | | appendErrorMessage(ERR_ADD_CHANGE_PRIVILEGE_INSUFFICIENT_PRIVILEGES |
| | | .get()); |
| | | appendErrorMessage(ERR_ADD_CHANGE_PRIVILEGE_INSUFFICIENT_PRIVILEGES.get()); |
| | | setResultCode(ResultCode.INSUFFICIENT_ACCESS_RIGHTS); |
| | | return; |
| | | } |
| | |
| | | Arg1<Object> nonUniqueAttributeMessage, |
| | | Arg2<Object, Object> cannotProcessAttributeMessage) |
| | | { |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(attributeTypeName, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attributeTypeName); |
| | | List<Attribute> attrList = userEntry.getAttribute(attrType); |
| | | if ((attrList != null) && (attrList.size() == 1)) |
| | | { |
| | |
| | | { |
| | | EnumTargetOperator op = EnumTargetOperator.createOperator(eqOperator); |
| | | TargetAttr targetAttr = TargetAttr.decode(op, targetAttrString); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attribute, true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attribute); |
| | | assertEquals(TargetAttr.isApplicable(attrType, targetAttr), expectedResult); |
| | | } |
| | | } |
| | |
| | | Entry schemaEntry = DirectoryServer.getEntry(DN.valueOf("cn=schema")); |
| | | assertNotNull(schemaEntry); |
| | | |
| | | AttributeType cnType = |
| | | DirectoryServer.getAttributeType("creatorsname", true); |
| | | AttributeType ctType = |
| | | DirectoryServer.getAttributeType("createtimestamp", true); |
| | | AttributeType mnType = |
| | | DirectoryServer.getAttributeType("modifiersname", true); |
| | | AttributeType mtType = |
| | | DirectoryServer.getAttributeType("modifytimestamp", true); |
| | | AttributeType cnType = DirectoryServer.getAttributeTypeOrDefault("creatorsname"); |
| | | AttributeType ctType = DirectoryServer.getAttributeTypeOrDefault("createtimestamp"); |
| | | AttributeType mnType = DirectoryServer.getAttributeTypeOrDefault("modifiersname"); |
| | | AttributeType mtType = DirectoryServer.getAttributeTypeOrDefault("modifytimestamp"); |
| | | |
| | | assertTrue(schemaEntry.hasAttribute(cnType)); |
| | | assertTrue(schemaEntry.hasAttribute(ctType)); |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | |
| | | givenNameType = DirectoryServer.getAttributeType("givenname", false); |
| | | givenNameType = DirectoryServer.getAttributeType("givenname"); |
| | | assertNotNull(givenNameType); |
| | | |
| | | snType = DirectoryServer.getAttributeType("sn", false); |
| | | snType = DirectoryServer.getAttributeType("sn"); |
| | | assertNotNull(snType); |
| | | |
| | | aaccfJohnsonDN = DN.valueOf("uid=aaccf.johnson,dc=example,dc=com"); |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | |
| | | givenNameType = DirectoryServer.getAttributeType("givenname", false); |
| | | givenNameType = DirectoryServer.getAttributeType("givenname"); |
| | | assertNotNull(givenNameType); |
| | | |
| | | snType = DirectoryServer.getAttributeType("sn", false); |
| | | snType = DirectoryServer.getAttributeType("sn"); |
| | | assertNotNull(snType); |
| | | |
| | | aaccfJohnsonDN = DN.valueOf("uid=aaccf.johnson,dc=example,dc=com"); |
| | |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType("description", |
| | | true); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault("description"); |
| | | UpdatePreOpPlugin.addAttributeToRemove(attrType); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(entry); |
| | |
| | | public void testGetAndAddModifications() throws Exception |
| | | { |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | assertNull(e.getAttribute(DirectoryServer.getAttributeType("description", true))); |
| | | assertNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | UpdatePreOpPlugin.addModification( |
| | |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | assertNotNull(e.getAttribute(DirectoryServer.getAttributeType("description", true))); |
| | | assertNotNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | } |
| | |
| | | public void testSuccessAddAttribute() throws Exception |
| | | { |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | assertNull(e.getAttribute(DirectoryServer.getAttributeType("description", true))); |
| | | assertNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))); |
| | | |
| | | LDAPAttribute attr = newLDAPAttribute("description", "foo"); |
| | | ModifyOperation modifyOperation = processModify("o=test", replace(attr)); |
| | |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | assertNotNull(e.getAttribute(DirectoryServer.getAttributeType("description", true))); |
| | | assertNotNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))); |
| | | } |
| | | |
| | | |
| | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeType("o", true)); |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o")); |
| | | assertEquals(countValues(attrList), 1); |
| | | |
| | | LDAPAttribute attr = newLDAPAttribute("o", "test2"); |
| | |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | attrList = e.getAttribute(DirectoryServer.getAttributeType("o", true)); |
| | | attrList = e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o")); |
| | | assertEquals(countValues(attrList), 2); |
| | | } |
| | | |
| | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf(baseDN)); |
| | | |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeType("o", true)); |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o")); |
| | | assertEquals(countValues(attrList), 1); |
| | | |
| | | LDAPAttribute attr = newLDAPAttribute("o;lang-en-us", "test"); |
| | |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | e = DirectoryServer.getEntry(DN.valueOf(baseDN)); |
| | | attrList = e.getAttribute(DirectoryServer.getAttributeType("o", true)); |
| | | attrList = e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o")); |
| | | assertEquals(countValues(attrList), 2); |
| | | } |
| | | |
| | |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeType("employeenumber", true)); |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("employeenumber")); |
| | | assertNotNull(attrList); |
| | | assertIntegerValueExists(attrList, 2); |
| | | } |
| | |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeType("employeenumber", true)); |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("employeenumber")); |
| | | assertNotNull(attrList); |
| | | assertIntegerValueExists(attrList, 11); |
| | | } |
| | |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeType("employeenumber", true)); |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("employeenumber")); |
| | | assertNotNull(attrList); |
| | | assertIntegerValueExists(attrList, 0); |
| | | } |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(DirectoryServer.entryExists(DN.valueOf("o=test"))); |
| | | assertFalse(DirectoryServer.getEntry(DN.valueOf("o=test")).hasAttribute( |
| | | DirectoryServer.getAttributeType("description", true))); |
| | | DirectoryServer.getAttributeTypeOrDefault("description"))); |
| | | } |
| | | |
| | | |
| | |
| | | "userPassword: password"); |
| | | |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeType("userpassword", true)); |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("userpassword")); |
| | | assertNotNull(attrList); |
| | | |
| | | String passwd = null; |
| | |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeType("usercertificate", true)); |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("usercertificate")); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | Attribute a = attrList.get(0); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.clearJEBackend("userRoot", "dc=example,dc=com"); |
| | | |
| | | entryDNType = DirectoryServer.getAttributeType("entrydn", false); |
| | | entryDNType = DirectoryServer.getAttributeType("entrydn"); |
| | | assertNotNull(entryDNType); |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | |
| | | entryUUIDType = DirectoryServer.getAttributeType("entryuuid", false); |
| | | entryUUIDType = DirectoryServer.getAttributeType("entryuuid"); |
| | | assertNotNull(entryUUIDType); |
| | | } |
| | | |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.clearJEBackend("userRoot", "dc=example,dc=com"); |
| | | |
| | | governingStructureRuleType = |
| | | DirectoryServer.getAttributeType("governingstructurerule", false); |
| | | governingStructureRuleType = DirectoryServer.getAttributeType("governingstructurerule"); |
| | | assertNotNull(governingStructureRuleType); |
| | | int resultCode = TestCaseUtils.applyModifications(true, |
| | | "dn: cn=schema", |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | |
| | | hasSubordinatesType = |
| | | DirectoryServer.getAttributeType("hassubordinates", false); |
| | | hasSubordinatesType = DirectoryServer.getAttributeType("hassubordinates"); |
| | | assertNotNull(hasSubordinatesType); |
| | | |
| | | entries = TestCaseUtils.makeEntries( |
| | |
| | | { |
| | | TestCaseUtils.restartServer(); |
| | | |
| | | isMemberOfType = DirectoryServer.getAttributeType("ismemberof", false); |
| | | isMemberOfType = DirectoryServer.getAttributeType("ismemberof"); |
| | | assertNotNull(isMemberOfType); |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.server.extensions.LDAPPassThroughAuthenticationPolicyFactory.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | MockPolicyCfg withMappedAttribute(final String atype) |
| | | { |
| | | mappedAttributes.add(DirectoryServer.getAttributeType( |
| | | StaticUtils.toLowerCase(atype), true)); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(atype)); |
| | | mappedAttributes.add(attrType); |
| | | return this; |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.restartServer(); |
| | | |
| | | numSubordinatesType = |
| | | DirectoryServer.getAttributeType("numsubordinates", false); |
| | | numSubordinatesType = DirectoryServer.getAttributeType("numsubordinates"); |
| | | assertNotNull(numSubordinatesType); |
| | | |
| | | entries = TestCaseUtils.makeEntries( |
| | |
| | | |
| | | try |
| | | { |
| | | AttributeType lastLoginTimeAttr = |
| | | DirectoryServer.getAttributeType("ds-pwp-last-login-time", false); |
| | | AttributeType lastLoginTimeAttr = DirectoryServer.getAttributeType("ds-pwp-last-login-time"); |
| | | assertNotNull(lastLoginTimeAttr); |
| | | |
| | | DN userDN = DN.valueOf("uid=test.user,o=test"); |
| | |
| | | |
| | | try |
| | | { |
| | | AttributeType authFailureTimesAttr = |
| | | DirectoryServer.getAttributeType("pwdfailuretime", false); |
| | | AttributeType authFailureTimesAttr = DirectoryServer.getAttributeType("pwdfailuretime"); |
| | | assertNotNull(authFailureTimesAttr); |
| | | |
| | | DN userDN = DN.valueOf("uid=test.user,o=test"); |
| | |
| | | |
| | | try |
| | | { |
| | | AttributeType pwdHistoryAttr = DirectoryServer.getAttributeType("pwdhistory", false); |
| | | AttributeType pwdHistoryAttr = DirectoryServer.getAttributeType("pwdhistory"); |
| | | assertNotNull(pwdHistoryAttr); |
| | | |
| | | DN userDN = DN.valueOf("uid=test.user,o=test"); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.clearJEBackend("userRoot", "dc=example,dc=com"); |
| | | |
| | | structuralObjectClassType = |
| | | DirectoryServer.getAttributeType("structuralobjectclass", false); |
| | | structuralObjectClassType = DirectoryServer.getAttributeType("structuralobjectclass"); |
| | | assertNotNull(structuralObjectClassType); |
| | | } |
| | | |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | TestCaseUtils.clearJEBackend("userRoot", "dc=example,dc=com"); |
| | | |
| | | subschemaSubentryType = |
| | | DirectoryServer.getAttributeType("subschemasubentry", false); |
| | | subschemaSubentryType = DirectoryServer.getAttributeType("subschemasubentry"); |
| | | assertNotNull(subschemaSubentryType); |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | |
| | | descriptionType = DirectoryServer.getAttributeType("description", false); |
| | | descriptionType = DirectoryServer.getAttributeType("description"); |
| | | assertNotNull(descriptionType); |
| | | |
| | | pwPolicyDNType = |
| | | DirectoryServer.getAttributeType("ds-pwp-password-policy-dn", false); |
| | | pwPolicyDNType = DirectoryServer.getAttributeType("ds-pwp-password-policy-dn"); |
| | | assertNotNull(pwPolicyDNType); |
| | | |
| | | privNameType = DirectoryServer.getAttributeType("ds-privilege-name", false); |
| | | privNameType = DirectoryServer.getAttributeType("ds-privilege-name"); |
| | | assertNotNull(privNameType); |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | |
| | | memberType = DirectoryServer.getAttributeType("member", false); |
| | | memberType = DirectoryServer.getAttributeType("member"); |
| | | assertNotNull(memberType); |
| | | |
| | | uniqueMemberType = DirectoryServer.getAttributeType("uniquemember", false); |
| | | uniqueMemberType = DirectoryServer.getAttributeType("uniquemember"); |
| | | assertNotNull(uniqueMemberType); |
| | | |
| | | groupManager = DirectoryServer.getGroupManager(); |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | public void testInitializeWithValidConfigsWithoutSchema(Entry e) |
| | | throws Exception |
| | | { |
| | | AttributeType entryUUIDType = DirectoryConfig.getAttributeType("entryuuid", |
| | | false); |
| | | AttributeType entryUUIDType = DirectoryServer.getAttributeType("entryuuid"); |
| | | DirectoryServer.deregisterAttributeType(entryUUIDType); |
| | | |
| | | HashSet<PluginType> pluginTypes = TestCaseUtils.getPluginTypes(e); |
| | |
| | | public void testInitializeWithValidConfigsWithoutSchema(Entry e) |
| | | throws Exception |
| | | { |
| | | AttributeType ctType = DirectoryConfig.getAttributeType("createtimestamp", false); |
| | | AttributeType cnType = DirectoryConfig.getAttributeType("creatorsname", false); |
| | | AttributeType mtType = DirectoryConfig.getAttributeType("modifytimestamp", false); |
| | | AttributeType mnType = DirectoryConfig.getAttributeType("modifiersname", false); |
| | | AttributeType ctType = DirectoryServer.getAttributeType("createtimestamp"); |
| | | AttributeType cnType = DirectoryServer.getAttributeType("creatorsname"); |
| | | AttributeType mtType = DirectoryServer.getAttributeType("modifytimestamp"); |
| | | AttributeType mnType = DirectoryServer.getAttributeType("modifiersname"); |
| | | |
| | | DirectoryServer.deregisterAttributeType(ctType); |
| | | DirectoryServer.deregisterAttributeType(cnType); |
| | |
| | | } |
| | | |
| | | private AttributeType getAttrType(String attrTypeString) { |
| | | return DirectoryServer.getAttributeType(attrTypeString, true); |
| | | return DirectoryServer.getAttributeTypeOrDefault(attrTypeString); |
| | | } |
| | | |
| | | private void deleteEntries(String... dns) throws Exception{ |
| | |
| | | } |
| | | |
| | | private AttributeType getAttrType(String attrTypeString) { |
| | | return DirectoryServer.getAttributeType(attrTypeString, true); |
| | | return DirectoryServer.getAttributeTypeOrDefault(attrTypeString); |
| | | } |
| | | |
| | | /** |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | CompareOperation compareOperation = |
| | | conn.processCompare(DN.valueOf("cn=test,o=test"), |
| | | DirectoryServer.getAttributeType("cn", true), |
| | | DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("test")); |
| | | assertEquals(compareOperation.getResultCode(), ResultCode.COMPARE_TRUE); |
| | | } |
| | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis(conn, conn.nextOperationID(), |
| | | conn.nextMessageID(), controls, targetDN, |
| | | DirectoryServer.getAttributeType("cn", true), |
| | | DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("PWReset Target")); |
| | | compareOperation.run(); |
| | | |
| | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis(conn, conn.nextOperationID(), |
| | | conn.nextMessageID(), controls, targetDN, |
| | | DirectoryServer.getAttributeType("cn", true), |
| | | DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("PWReset Target")); |
| | | compareOperation.run(); |
| | | |
| | |
| | | //Reset some things for the SSL handler |
| | | Attribute useSSL=Attributes.create(ATTR_USE_SSL, String.valueOf(false)); |
| | | Attribute startTls=Attributes.create(ATTR_ALLOW_STARTTLS, String.valueOf(false)); |
| | | AttributeType attrType=DirectoryServer.getAttributeType(ATTR_LISTEN_PORT, true); |
| | | AttributeType attrType=DirectoryServer.getAttributeTypeOrDefault(ATTR_LISTEN_PORT); |
| | | Attribute a=Attributes.empty(attrType); |
| | | LDAPHandlerEntry.removeAttribute(a, null); |
| | | LDAPHandlerEntry.removeAttribute(useSSL, null); |
| | |
| | | "ds-cfg-trust-manager-provider: cn=JKS,cn=Trust Manager Providers,cn=config"); |
| | | LDAPConnectionHandler LDAPConnHandler=getLDAPHandlerInstance(GoodHandlerEntry); |
| | | //Make attrTypes to remove |
| | | AttributeType at0=DirectoryServer.getAttributeType(ATTR_LISTEN_PORT, true); |
| | | AttributeType at0=DirectoryServer.getAttributeTypeOrDefault(ATTR_LISTEN_PORT); |
| | | // AttributeType at1=DirectoryServer.getAttributeType(ATTR_LISTEN_ADDRESS, true); |
| | | // Attribute rAttr1=new Attribute(at1); |
| | | // GoodHandlerEntry.removeAttribute(rAttr1, null); |
| | | AttributeType at2=DirectoryServer.getAttributeType(ATTR_ALLOW_LDAPV2, true); |
| | | AttributeType at3=DirectoryServer.getAttributeType(ATTR_ALLOW_LDAPV2, true); |
| | | AttributeType at4=DirectoryServer.getAttributeType(ATTR_KEEP_LDAP_STATS, true); |
| | | AttributeType at5=DirectoryServer.getAttributeType(ATTR_SEND_REJECTION_NOTICE,true); |
| | | AttributeType at6=DirectoryServer.getAttributeType(ATTR_USE_TCP_KEEPALIVE,true); |
| | | AttributeType at7=DirectoryServer.getAttributeType(ATTR_USE_TCP_NODELAY,true); |
| | | AttributeType at8=DirectoryServer.getAttributeType(ATTR_ALLOW_REUSE_ADDRESS,true); |
| | | AttributeType at9=DirectoryServer.getAttributeType(ATTR_USE_SSL,true); |
| | | AttributeType at10=DirectoryServer.getAttributeType(ATTR_ALLOW_STARTTLS,true); |
| | | AttributeType at11=DirectoryServer.getAttributeType(ATTR_MAX_REQUEST_SIZE,true); |
| | | AttributeType at12=DirectoryServer.getAttributeType(ATTR_ACCEPT_BACKLOG,true); |
| | | AttributeType at2=DirectoryServer.getAttributeTypeOrDefault(ATTR_ALLOW_LDAPV2); |
| | | AttributeType at3=DirectoryServer.getAttributeTypeOrDefault(ATTR_ALLOW_LDAPV2); |
| | | AttributeType at4=DirectoryServer.getAttributeTypeOrDefault(ATTR_KEEP_LDAP_STATS); |
| | | AttributeType at5=DirectoryServer.getAttributeTypeOrDefault(ATTR_SEND_REJECTION_NOTICE); |
| | | AttributeType at6=DirectoryServer.getAttributeTypeOrDefault(ATTR_USE_TCP_KEEPALIVE); |
| | | AttributeType at7=DirectoryServer.getAttributeTypeOrDefault(ATTR_USE_TCP_NODELAY); |
| | | AttributeType at8=DirectoryServer.getAttributeTypeOrDefault(ATTR_ALLOW_REUSE_ADDRESS); |
| | | AttributeType at9=DirectoryServer.getAttributeTypeOrDefault(ATTR_USE_SSL); |
| | | AttributeType at10=DirectoryServer.getAttributeTypeOrDefault(ATTR_ALLOW_STARTTLS); |
| | | AttributeType at11=DirectoryServer.getAttributeTypeOrDefault(ATTR_MAX_REQUEST_SIZE); |
| | | AttributeType at12=DirectoryServer.getAttributeTypeOrDefault(ATTR_ACCEPT_BACKLOG); |
| | | //Remove them |
| | | Attribute rAttr0=Attributes.empty(at0); |
| | | GoodHandlerEntry.removeAttribute(rAttr0, null); |
| | |
| | | continue; |
| | | } |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType("attributetypes", false); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("attributetypes"); |
| | | assertNotNull(attrType); |
| | | List<Attribute> attrList = e.getAttribute(attrType); |
| | | if (attrList == null) |
| | |
| | | continue; |
| | | } |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType("objectclasses", false); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("objectclasses"); |
| | | assertNotNull(attrType); |
| | | List<Attribute> attrList = e.getAttribute(attrType); |
| | | if (attrList == null) |
| | |
| | | continue; |
| | | } |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType("nameforms", false); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("nameforms"); |
| | | assertNotNull(attrType); |
| | | List<Attribute> attrList = e.getAttribute(attrType); |
| | | if (attrList == null) |
| | |
| | | CompareOperation compareOperation = new CompareOperationBasis(conn, |
| | | nextOperationID(), nextMessageID(), |
| | | controls, targetDN, |
| | | DirectoryServer.getAttributeType("cn", true), |
| | | DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("PWReset Target")); |
| | | compareOperation.run(); |
| | | if (hasProxyPrivilege) |
| | |
| | | // Test a compare operation against the PWReset Target user. |
| | | CompareOperation compareOperation = new CompareOperationBasis(conn, nextOperationID(), |
| | | nextMessageID(), controls, targetDN, |
| | | DirectoryServer.getAttributeType("cn", true), |
| | | DirectoryServer.getAttributeTypeOrDefault("cn"), |
| | | ByteString.valueOf("PWReset Target")); |
| | | compareOperation.run(); |
| | | if (hasProxyPrivilege) |
| | |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn.ConflictBehavior; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.EntryDNVirtualAttributeProvider; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | |
| | | entryDNType = DirectoryConfig.getAttributeType("entrydn", false); |
| | | entryDNType = DirectoryServer.getAttributeType("entrydn"); |
| | | assertNotNull(entryDNType); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn.ConflictBehavior; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.extensions.EntryDNVirtualAttributeProvider; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | |
| | | entryDNType = DirectoryConfig.getAttributeType("entrydn", false); |
| | | entryDNType = DirectoryServer.getAttributeType("entrydn"); |
| | | assertNotNull(entryDNType); |
| | | |
| | | EntryDNVirtualAttributeProvider provider = |