Remove null checks on returned values of Entry.get*Attribute*() methods.
TODO CryptoManagerSync.modifyEntry()
Entry.java:
In get*Attribute*(), made sure the methods never return null.
Removed unused methods
*.java:
Removed now unnecessary null checks
| | |
| | | |
| | | private static boolean find(List<org.opends.server.types.Attribute> attrs, String attrName) |
| | | { |
| | | if (attrs != null) |
| | | for (org.opends.server.types.Attribute attr : attrs) |
| | | { |
| | | for (org.opends.server.types.Attribute attr : attrs) |
| | | if (attr.getNameWithOptions().equalsIgnoreCase(attrName)) |
| | | { |
| | | if (attr.getNameWithOptions().equalsIgnoreCase(attrName)) |
| | | { |
| | | return true; |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | |
| | | import javax.swing.JLabel; |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.guitools.controlpanel.datamodel.BinaryValue; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.ObjectClassValue; |
| | |
| | | import org.opends.guitools.controlpanel.event.LDAPEntryChangedListener; |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.Schema; |
| | |
| | | { |
| | | String attrName = rdn.getAttributeName(i); |
| | | ByteString value = rdn.getAttributeValue(i); |
| | | List<org.opends.server.types.Attribute> attrs = |
| | | entry.getAttribute(attrName.toLowerCase()); |
| | | List<org.opends.server.types.Attribute> attrs = entry.getAttribute(attrName.toLowerCase()); |
| | | boolean done = false; |
| | | if (attrs != null) |
| | | for (org.opends.server.types.Attribute attr : attrs) |
| | | { |
| | | for (org.opends.server.types.Attribute attr : attrs) |
| | | if (attr.getNameWithOptions().equals(attrName)) |
| | | { |
| | | if (attr.getNameWithOptions().equals(attrName)) |
| | | ArrayList<ByteString> newValues = new ArrayList<>(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | ArrayList<ByteString> newValues = new ArrayList<>(); |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | while (it.hasNext()) |
| | | { |
| | | newValues.add(it.next()); |
| | | } |
| | | newValues.add(value); |
| | | entry.addAttribute(attr, newValues); |
| | | done = true; |
| | | break; |
| | | newValues.add(it.next()); |
| | | } |
| | | newValues.add(value); |
| | | entry.addAttribute(attr, newValues); |
| | | done = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!done) |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | |
| | | /** |
| | | * Check if information found in "cn=admin data" is coherent with |
| | | * cn=config. If and inconsistency is detected, we log a warning |
| | |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName); |
| | | List<Attribute> attrs = adminConnectorEntry.getAttribute(attrType); |
| | | if (attrs != null) |
| | | if (!attrs.isEmpty()) |
| | | { |
| | | // Get the attribute value |
| | | return attrs.get(0).iterator().next().toString(); |
| | | } |
| | | |
| | | // can not happen |
| | | // best effort. |
| | | // Can not happen. Best effort. |
| | | // TODO Log an Error. |
| | | return null; |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.admin.AbsoluteInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | | import org.opends.server.admin.AliasDefaultBehaviorProvider; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefaultBehaviorProviderVisitor; |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.admin.DefinitionResolver; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.LDAPProfile; |
| | |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionVisitor; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyNotFoundException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.Reference; |
| | |
| | | import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.admin.std.meta.RootCfgDefn; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | |
| | | /** |
| | |
| | | // since the attribute should have been defined. |
| | | String attrID = LDAPProfile.getInstance().getAttributeName(d, pd); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(attrID); |
| | | List<Attribute> attributes = configEntry.getEntry().getAttribute(type, true); |
| | | List<Attribute> attributes = configEntry.getEntry().getAttribute(type); |
| | | |
| | | List<ByteString> results = new LinkedList<>(); |
| | | if (attributes != null) |
| | | for (Attribute a : attributes) |
| | | { |
| | | for (Attribute a : attributes) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | results.add(v); |
| | | } |
| | | results.add(v); |
| | | } |
| | | } |
| | | return results; |
| | |
| | | // First check to see if the ds-pwp-password-policy-dn is present. |
| | | String userDNString = userEntry.getName().toString(); |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_POLICY_DN); |
| | | List<Attribute> attrList = userEntry.getAttribute(type); |
| | | |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(type)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | if (a.isEmpty()) |
| | | { |
| | | if (a.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | ByteString v = a.iterator().next(); |
| | | DN subentryDN; |
| | | try |
| | | { |
| | | subentryDN = DN.decode(v); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | logger.trace("Could not parse password policy subentry DN %s for user %s", |
| | | v, userDNString, e); |
| | | |
| | | if (useDefaultOnError) |
| | | { |
| | | logger.error(ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN, |
| | | v, userDNString, e.getMessage()); |
| | | return DirectoryServer.getDefaultPasswordPolicy(); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN |
| | | .get(v, userDNString, e.getMessage()); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message, e); |
| | | } |
| | | } |
| | | |
| | | AuthenticationPolicy policy = DirectoryServer |
| | | .getAuthenticationPolicy(subentryDN); |
| | | if (policy == null) |
| | | { |
| | | logger.trace("Password policy subentry %s for user %s is not defined in the Directory Server.", |
| | | subentryDN, userDNString); |
| | | |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_SUCH_POLICY.get(userDNString, subentryDN); |
| | | if (useDefaultOnError) |
| | | { |
| | | logger.error(message); |
| | | return DirectoryServer.getDefaultPasswordPolicy(); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | | } |
| | | |
| | | logger.trace("Using password policy subentry %s for user %s.", |
| | | subentryDN, userDNString); |
| | | |
| | | return policy; |
| | | continue; |
| | | } |
| | | |
| | | ByteString v = a.iterator().next(); |
| | | DN subentryDN; |
| | | try |
| | | { |
| | | subentryDN = DN.decode(v); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | logger.trace("Could not parse password policy subentry DN %s for user %s", |
| | | v, userDNString, e); |
| | | |
| | | if (useDefaultOnError) |
| | | { |
| | | logger.error(ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN, |
| | | v, userDNString, e.getMessage()); |
| | | return DirectoryServer.getDefaultPasswordPolicy(); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_SUBENTRY_VALUE_AS_DN |
| | | .get(v, userDNString, e.getMessage()); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message, e); |
| | | } |
| | | } |
| | | |
| | | AuthenticationPolicy policy = DirectoryServer |
| | | .getAuthenticationPolicy(subentryDN); |
| | | if (policy == null) |
| | | { |
| | | logger.trace("Password policy subentry %s for user %s is not defined in the Directory Server.", |
| | | subentryDN, userDNString); |
| | | |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_SUCH_POLICY.get(userDNString, subentryDN); |
| | | if (useDefaultOnError) |
| | | { |
| | | logger.error(message); |
| | | return DirectoryServer.getDefaultPasswordPolicy(); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException( |
| | | DirectoryServer.getServerErrorResultCode(), message); |
| | | } |
| | | } |
| | | |
| | | logger.trace("Using password policy subentry %s for user %s.", |
| | | subentryDN, userDNString); |
| | | |
| | | return policy; |
| | | } |
| | | |
| | | // The ds-pwp-password-policy-dn attribute was not present, so instead |
| | |
| | | import org.forgerock.opendj.ldap.GeneralizedTime; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | |
| | | final AttributeType attributeType) throws DirectoryException |
| | | { |
| | | final List<Attribute> attrList = entry.getAttribute(attributeType); |
| | | if (attrList != null) |
| | | for (final Attribute a : attrList) |
| | | { |
| | | for (final Attribute a : attrList) |
| | | if (a.isEmpty()) |
| | | { |
| | | if (a.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | final String valueString = toLowerCase(a.iterator().next().toString()); |
| | | |
| | | if (valueString.equals("true") || valueString.equals("yes") |
| | | || valueString.equals("on") || valueString.equals("1")) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Attribute %s resolves to true for user entry %s", |
| | | attributeType.getNameOrOID(), entry.getName()); |
| | | } |
| | | |
| | | return ConditionResult.TRUE; |
| | | } |
| | | |
| | | if (valueString.equals("false") || valueString.equals("no") |
| | | || valueString.equals("off") || valueString.equals("0")) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Attribute %s resolves to false for user entry %s", |
| | | attributeType.getNameOrOID(), entry.getName()); |
| | | } |
| | | |
| | | return ConditionResult.FALSE; |
| | | } |
| | | |
| | | final String valueString = toLowerCase(a.iterator().next().toString()); |
| | | if (valueString.equals("true") || valueString.equals("yes") || valueString.equals("on") |
| | | || valueString.equals("1")) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Unable to resolve value %s for attribute %s " |
| | | + "in user entry %s as a Boolean.", valueString, |
| | | logger |
| | | .trace("Attribute %s resolves to true for user entry %s", attributeType.getNameOrOID(), entry.getName()); |
| | | } |
| | | |
| | | return ConditionResult.TRUE; |
| | | } |
| | | |
| | | if (valueString.equals("false") || valueString.equals("no") || valueString.equals("off") |
| | | || valueString.equals("0")) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Attribute %s resolves to false for user entry %s", |
| | | attributeType.getNameOrOID(), entry.getName()); |
| | | } |
| | | |
| | | final LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_BOOLEAN |
| | | .get(valueString, attributeType.getNameOrOID(), entry.getName()); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message); |
| | | return ConditionResult.FALSE; |
| | | } |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Unable to resolve value %s for attribute %s " + "in user entry %s as a Boolean.", valueString, |
| | | attributeType.getNameOrOID(), entry.getName()); |
| | | } |
| | | |
| | | final LocalizableMessage message = |
| | | ERR_PWPSTATE_CANNOT_DECODE_BOOLEAN.get(valueString, attributeType.getNameOrOID(), entry.getName()); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | if (logger.isTraceEnabled()) |
| | |
| | | { |
| | | long timeValue = -1; |
| | | |
| | | final List<Attribute> attrList = entry.getAttribute(attributeType); |
| | | if (attrList != null) |
| | | for (final Attribute a : entry.getAttribute(attributeType)) |
| | | { |
| | | for (final Attribute a : attrList) |
| | | if (a.isEmpty()) |
| | | { |
| | | if (a.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | final ByteString v = a.iterator().next(); |
| | | try |
| | | { |
| | | timeValue = GeneralizedTime.valueOf(v.toString()).getTimeInMillis(); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s", |
| | | v, attributeType.getNameOrOID(), entry.getName()); |
| | | |
| | | final LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME |
| | | .get(v, attributeType.getNameOrOID(), entry.getName(), e); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message, e); |
| | | } |
| | | break; |
| | | continue; |
| | | } |
| | | |
| | | final ByteString v = a.iterator().next(); |
| | | try |
| | | { |
| | | timeValue = GeneralizedTime.valueOf(v.toString()).getTimeInMillis(); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s", |
| | | v, attributeType.getNameOrOID(), entry.getName()); |
| | | |
| | | final LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME |
| | | .get(v, attributeType.getNameOrOID(), entry.getName(), e); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | if (timeValue == -1 && logger.isTraceEnabled()) |
| | |
| | | } |
| | | |
| | | AttributeType privType = DirectoryServer.getAttributeTypeOrNull(OP_ATTR_PRIVILEGE_NAME); |
| | | List<Attribute> attrList = entry.getAttribute(privType); |
| | | if (attrList != null) |
| | | for (Attribute a : entry.getAttribute(privType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | String privName = toLowerCase(v.toString()); |
| | | |
| | | // If the name of the privilege is prefixed with a minus sign, |
| | | // then we will take away that privilege from the user. |
| | | // We'll handle that at the end so that we can make sure it's not added back later. |
| | | if (privName.startsWith("-")) |
| | | { |
| | | String privName = toLowerCase(v.toString()); |
| | | |
| | | // If the name of the privilege is prefixed with a minus |
| | | // sign, then we will take away that privilege from the |
| | | // user. We'll handle that at the end so that we can make |
| | | // sure it's not added back later. |
| | | if (privName.startsWith("-")) |
| | | privName = privName.substring(1); |
| | | Privilege p = Privilege.privilegeForName(privName); |
| | | if (p == null) |
| | | { |
| | | privName = privName.substring(1); |
| | | Privilege p = Privilege.privilegeForName(privName); |
| | | if (p == null) |
| | | { |
| | | // FIXME -- Generate an administrative alert. |
| | | // FIXME -- Generate an administrative alert. |
| | | |
| | | // We don't know what privilege to remove, so we'll |
| | | // remove all of them. |
| | | newPrivileges.clear(); |
| | | return newPrivileges; |
| | | } |
| | | else |
| | | { |
| | | removePrivileges.add(p); |
| | | } |
| | | // We don't know what privilege to remove, so we'll remove all of them. |
| | | newPrivileges.clear(); |
| | | return newPrivileges; |
| | | } |
| | | else |
| | | { |
| | | Privilege p = Privilege.privilegeForName(privName); |
| | | if (p == null) |
| | | { |
| | | // FIXME -- Generate an administrative alert. |
| | | } |
| | | else |
| | | { |
| | | newPrivileges.add(p); |
| | | } |
| | | removePrivileges.add(p); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Privilege p = Privilege.privilegeForName(privName); |
| | | if (p == null) |
| | | { |
| | | // FIXME -- Generate an administrative alert. |
| | | } |
| | | else |
| | | { |
| | | newPrivileges.add(p); |
| | | } |
| | | } |
| | | } |
| | |
| | | && resourceEntry.hasAttribute(modAttrType)) |
| | | { |
| | | container.setCurrentAttributeType(modAttrType); |
| | | List<Attribute> attrList = |
| | | resourceEntry.getAttribute(modAttrType, modAttr.getOptions()); |
| | | if (attrList != null) |
| | | for (Attribute a : resourceEntry.getAttribute(modAttrType, modAttr.getOptions())) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | container.setCurrentAttributeValue(v); |
| | | container.setRights(ACI_WRITE_DELETE); |
| | | if (!skipAccessCheck && !accessAllowed(container)) |
| | | { |
| | | container.setCurrentAttributeValue(v); |
| | | container.setRights(ACI_WRITE_DELETE); |
| | | if (!skipAccessCheck && !accessAllowed(container)) |
| | | { |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | |
| | | break; |
| | | case INCREMENT: |
| | | Entry modifiedEntry = operation.getModifiedEntry(); |
| | | List<Attribute> modifiedAttrs = |
| | | modifiedEntry.getAttribute(modAttrType, modAttr.getOptions()); |
| | | if (modifiedAttrs != null) |
| | | for (Attribute attr : modifiedEntry.getAttribute(modAttrType, modAttr.getOptions())) |
| | | { |
| | | for (Attribute attr : modifiedAttrs) |
| | | for (ByteString val : attr) |
| | | { |
| | | for (ByteString val : attr) |
| | | container.setCurrentAttributeValue(val); |
| | | container.setRights(ACI_WRITE_ADD); |
| | | if (!skipAccessCheck && !accessAllowed(container)) |
| | | { |
| | | container.setCurrentAttributeValue(val); |
| | | container.setRights(ACI_WRITE_ADD); |
| | | if (!skipAccessCheck && !accessAllowed(container)) |
| | | { |
| | | return false; |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.authorization.dseecompat.AciHandler.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.ReentrantReadWriteLock; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.DITCacheMap; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.RDN; |
| | | |
| | | /** |
| | | * The AciList class performs caching of the ACI attribute values |
| | |
| | | DN dn, DN configDN, |
| | | List<Attribute> attributeList, |
| | | List<LocalizableMessage> failedACIMsgs) { |
| | | |
| | | if (attributeList == null) { |
| | | if (attributeList.isEmpty()) { |
| | | return 0; |
| | | } |
| | | |
| | |
| | | //attributes are skipped. |
| | | if(hasGlobalAci && oldEntry.getName().equals(configDN)) { |
| | | aciList.remove(DN.rootDN()); |
| | | List<Attribute> attributeList = |
| | | newEntry.getAttribute(globalAciType); |
| | | List<Attribute> attributeList = newEntry.getAttribute(globalAciType); |
| | | addAciAttributeList(aciList, DN.rootDN(), configDN, |
| | | attributeList, failedACIMsgs); |
| | | } |
| | |
| | | AttributeType t = |
| | | DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | List<Attribute> attrList = backupDirEntry.getAttribute(t); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | for (ByteString v : attrList.get(0)) |
| | | { |
| | |
| | | |
| | | private void returnEntries(SearchOperation searchOperation, DN baseDN, SearchFilter filter, List<Attribute> attrList) |
| | | { |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | for (ByteString v : attrList.get(0)) |
| | | { |
| | | for (ByteString v : attrList.get(0)) |
| | | try |
| | | { |
| | | try |
| | | { |
| | | File dir = new File(v.toString()); |
| | | BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory(); |
| | | AttributeType idType = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_ID); |
| | | File dir = new File(v.toString()); |
| | | BackupDirectory backupDirectory = backupDirectories.get(dir).getBackupDirectory(); |
| | | AttributeType idType = DirectoryServer.getAttributeTypeOrDefault(ATTR_BACKUP_ID); |
| | | |
| | | for (String backupID : backupDirectory.getBackups().keySet()) |
| | | for (String backupID : backupDirectory.getBackups().keySet()) |
| | | { |
| | | DN backupEntryDN = makeChildDN(baseDN, idType, backupID); |
| | | Entry backupEntry = getBackupEntry(backupEntryDN); |
| | | if (filter.matchesEntry(backupEntry)) |
| | | { |
| | | DN backupEntryDN = makeChildDN(baseDN, idType, backupID); |
| | | Entry backupEntry = getBackupEntry(backupEntryDN); |
| | | if (filter.matchesEntry(backupEntry)) |
| | | { |
| | | searchOperation.returnEntry(backupEntry, null); |
| | | } |
| | | searchOperation.returnEntry(backupEntry, null); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | continue; |
| | | } |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getSupportedControls() |
| | | { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Set<String> getSupportedFeatures() |
| | | { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean supports(BackendOperation backendOperation) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void exportLDIF(LDIFExportConfig exportConfig) |
| | | throws DirectoryException |
| | |
| | | |
| | | // loop on the attribute types in the entry just received |
| | | // and add them in the existing schema. |
| | | List<Attribute> attrList = newSchemaEntry.getAttribute(attributeAttrType); |
| | | Set<String> oidList = new HashSet<>(1000); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | for (Attribute a : newSchemaEntry.getAttribute(attributeAttrType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | // Look for attribute types that could have been added to the schema |
| | | // or modified in the schema |
| | | for (ByteString v : a) |
| | | { |
| | | // Look for attribute types that could have been added to the schema |
| | | // or modified in the schema |
| | | for (ByteString v : a) |
| | | // Parse the attribute type. |
| | | AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false); |
| | | String schemaFile = getSchemaFile(attrType); |
| | | if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile)) |
| | | { |
| | | // Parse the attribute type. |
| | | AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false); |
| | | String schemaFile = getSchemaFile(attrType); |
| | | if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile)) |
| | | { |
| | | // Don't import the file containing the definitions of the |
| | | // Schema elements used for configuration because these |
| | | // definitions may vary between versions of OpenDJ. |
| | | continue; |
| | | } |
| | | // Don't import the file containing the definitions of the |
| | | // Schema elements used for configuration because these |
| | | // definitions may vary between versions of OpenDJ. |
| | | continue; |
| | | } |
| | | |
| | | oidList.add(attrType.getOID()); |
| | | try |
| | | oidList.add(attrType.getOID()); |
| | | try |
| | | { |
| | | // Register this attribute type in the new schema |
| | | // unless it is already defined with the same syntax. |
| | | AttributeType oldAttrType = schema.getAttributeType(attrType.getOID()); |
| | | if (oldAttrType == null || !oldAttrType.toString().equals(attrType.toString())) |
| | | { |
| | | // Register this attribute type in the new schema |
| | | // unless it is already defined with the same syntax. |
| | | AttributeType oldAttrType = |
| | | schema.getAttributeType(attrType.getOID()); |
| | | if (oldAttrType == null || |
| | | !oldAttrType.toString().equals(attrType.toString())) |
| | | newSchema.registerAttributeType(attrType, true); |
| | | |
| | | if (schemaFile != null) |
| | | { |
| | | newSchema.registerAttributeType(attrType, true); |
| | | |
| | | if (schemaFile != null) |
| | | { |
| | | modifiedSchemaFiles.add(schemaFile); |
| | | } |
| | | modifiedSchemaFiles.add(schemaFile); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.info(NOTE_SCHEMA_IMPORT_FAILED, attrType, e.getMessage()); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.info(NOTE_SCHEMA_IMPORT_FAILED, attrType, e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.CertificateManager; |
| | | import org.opends.server.util.SetupUtils; |
| | | import org.opends.server.util.Platform.KeyType; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | /** |
| | | * This class defines a backend used to provide an LDAP view of public keys |
| | |
| | | { |
| | | List<Attribute> certAttrs = entry.getAttribute( |
| | | ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); |
| | | if (certAttrs == null) |
| | | if (certAttrs.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_TRUSTSTORE_ENTRY_MISSING_CERT_ATTR.get(entryDN, ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE); |
| | |
| | | this.indexer = indexer; |
| | | } |
| | | |
| | | void indexEntry(Entry entry, Set<ByteString> keys) |
| | | { |
| | | List<Attribute> attributes = entry.getAttribute(attributeType, true); |
| | | indexAttribute(attributes, keys); |
| | | } |
| | | |
| | | Set<ByteString> indexEntry(Entry entry) |
| | | { |
| | | final Set<ByteString> keys = new HashSet<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void indexAttribute(List<Attribute> attributes, Set<ByteString> keys) |
| | | void indexEntry(Entry entry, Set<ByteString> keys) |
| | | { |
| | | if (attributes == null) |
| | | { |
| | | return; |
| | | } |
| | | for (Attribute attr : attributes) |
| | | for (Attribute attr : entry.getAttribute(attributeType)) |
| | | { |
| | | if (!attr.isVirtual()) |
| | | { |
| | |
| | | { |
| | | final AttributeType attributeType = sortKey.getAttributeType(); |
| | | final MatchingRule matchingRule = sortKey.getEffectiveOrderingRule(); |
| | | final List<Attribute> attrList = entry.getAttribute(attributeType); |
| | | ByteString sortValue = null; |
| | | if (attrList != null) |
| | | for (Attribute a : entry.getAttribute(attributeType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | try |
| | | { |
| | | try |
| | | /* |
| | | * The RFC states that the lowest value of a multi-valued attribute should be used, |
| | | * regardless of the sort order. |
| | | */ |
| | | final ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | if (sortValue == null || nv.compareTo(sortValue) < 0) |
| | | { |
| | | /* |
| | | * The RFC states that the lowest value of a multi-valued attribute should be used, |
| | | * regardless of the sort order. |
| | | */ |
| | | final ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | if (sortValue == null || nv.compareTo(sortValue) < 0) |
| | | { |
| | | sortValue = nv; |
| | | } |
| | | sortValue = nv; |
| | | } |
| | | catch (final DecodeException e) |
| | | { |
| | | /* |
| | | * This shouldn't happen because the attribute should have already been validated. If |
| | | * it does then treat the value as missing. |
| | | */ |
| | | continue; |
| | | } |
| | | } |
| | | catch (final DecodeException e) |
| | | { |
| | | /* |
| | | * This shouldn't happen because the attribute should have already been validated. |
| | | * If it does then treat the value as missing. |
| | | */ |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | this.recurringTaskEntryDN = recurringTaskEntry.getName(); |
| | | |
| | | // Get the recurring task ID from the entry. If there isn't one, then fail. |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_RECURRING_TASK_ID.toLowerCase(), ATTR_RECURRING_TASK_ID); |
| | | List<Attribute> attrList = recurringTaskEntry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_RECURRINGTASK_NO_ID_ATTRIBUTE.get(ATTR_RECURRING_TASK_ID); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | if (attrList.size() > 1) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_RECURRINGTASK_MULTIPLE_ID_TYPES.get(ATTR_RECURRING_TASK_ID); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | Attribute attr = attrList.get(0); |
| | | if (attr.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_RECURRINGTASK_NO_ID.get(ATTR_RECURRING_TASK_ID); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | Iterator<ByteString> iterator = attr.iterator(); |
| | | ByteString value = iterator.next(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_RECURRINGTASK_MULTIPLE_ID_VALUES.get(ATTR_RECURRING_TASK_ID); |
| | | throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message); |
| | | } |
| | | |
| | | recurringTaskID = value.toString(); |
| | | |
| | | Attribute attr = getSingleAttribute(recurringTaskEntry, ATTR_RECURRING_TASK_ID, |
| | | ERR_RECURRINGTASK_NO_ID_ATTRIBUTE, ERR_RECURRINGTASK_MULTIPLE_ID_TYPES, ERR_RECURRINGTASK_NO_ID); |
| | | recurringTaskID = getSingleAttributeValue(attr, |
| | | ResultCode.OBJECTCLASS_VIOLATION, ERR_RECURRINGTASK_MULTIPLE_ID_VALUES, ATTR_RECURRING_TASK_ID); |
| | | |
| | | // Get the schedule for this task. |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_RECURRING_TASK_SCHEDULE.toLowerCase(), ATTR_RECURRING_TASK_SCHEDULE); |
| | | |
| | | attrList = recurringTaskEntry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_RECURRINGTASK_NO_SCHEDULE_ATTRIBUTE.get( |
| | | ATTR_RECURRING_TASK_SCHEDULE); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | if (attrList.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_RECURRINGTASK_MULTIPLE_SCHEDULE_TYPES.get( |
| | | ATTR_RECURRING_TASK_SCHEDULE); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | attr = attrList.get(0); |
| | | if (attr.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_RECURRINGTASK_NO_SCHEDULE_VALUES.get( |
| | | ATTR_RECURRING_TASK_SCHEDULE); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | iterator = attr.iterator(); |
| | | value = iterator.next(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_RECURRINGTASK_MULTIPLE_SCHEDULE_VALUES.get(ATTR_RECURRING_TASK_SCHEDULE); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | String taskScheduleTab = value.toString(); |
| | | attr = getSingleAttribute(recurringTaskEntry, ATTR_RECURRING_TASK_SCHEDULE,ERR_RECURRINGTASK_NO_SCHEDULE_ATTRIBUTE, |
| | | ERR_RECURRINGTASK_MULTIPLE_SCHEDULE_TYPES, ERR_RECURRINGTASK_NO_SCHEDULE_VALUES); |
| | | String taskScheduleTab = getSingleAttributeValue(attr, |
| | | ResultCode.CONSTRAINT_VIOLATION, ERR_RECURRINGTASK_MULTIPLE_SCHEDULE_VALUES, ATTR_RECURRING_TASK_SCHEDULE); |
| | | |
| | | boolean[][] taskArrays = new boolean[][]{null, null, null, null, null}; |
| | | |
| | |
| | | weekdayArray = taskArrays[WEEKDAY_INDEX]; |
| | | |
| | | // Get the class name from the entry. If there isn't one, then fail. |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | |
| | | attrList = recurringTaskEntry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_TASKSCHED_NO_CLASS_ATTRIBUTE.get(ATTR_TASK_CLASS); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | if (attrList.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_TASKSCHED_MULTIPLE_CLASS_TYPES.get(ATTR_TASK_CLASS); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | attr = attrList.get(0); |
| | | if (attr.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_TASKSCHED_NO_CLASS_VALUES.get(ATTR_TASK_CLASS); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | iterator = attr.iterator(); |
| | | value = iterator.next(); |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_TASKSCHED_MULTIPLE_CLASS_VALUES.get(ATTR_TASK_CLASS); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | |
| | | taskClassName = value.toString(); |
| | | attr = getSingleAttribute(recurringTaskEntry, ATTR_TASK_CLASS, ERR_TASKSCHED_NO_CLASS_ATTRIBUTE, |
| | | ERR_TASKSCHED_MULTIPLE_CLASS_TYPES, ERR_TASKSCHED_NO_CLASS_VALUES); |
| | | taskClassName = getSingleAttributeValue(attr, |
| | | ResultCode.CONSTRAINT_VIOLATION, ERR_TASKSCHED_MULTIPLE_CLASS_VALUES, ATTR_TASK_CLASS); |
| | | |
| | | |
| | | // Make sure that the specified class can be loaded. |
| | |
| | | task.initializeTask(); |
| | | } |
| | | |
| | | private String getSingleAttributeValue(Attribute attr, ResultCode erorrRc, Arg1<Object> multipleAttrValueErrorMsg, |
| | | String attrName) throws DirectoryException |
| | | { |
| | | Iterator<ByteString> it = attr.iterator(); |
| | | ByteString value = it.next(); |
| | | if (it.hasNext()) |
| | | { |
| | | throw new DirectoryException(erorrRc, multipleAttrValueErrorMsg.get(attrName)); |
| | | } |
| | | return value.toString(); |
| | | } |
| | | |
| | | private Attribute getSingleAttribute(Entry taskEntry, String attrName, Arg1<Object> noEntryErrorMsg, |
| | | Arg1<Object> multipleEntriesErrorMsg, Arg1<Object> noAttrValueErrorMsg) throws DirectoryException |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = noEntryErrorMsg.get(attrName); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | if (attrList.size() > 1) |
| | | { |
| | | LocalizableMessage message = multipleEntriesErrorMsg.get(attrName); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | Attribute attr = attrList.get(0); |
| | | if (attr.isEmpty()) |
| | | { |
| | | LocalizableMessage message = noAttrValueErrorMsg.get(attrName); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | | } |
| | | return attr; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | throws InitializationException |
| | | { |
| | | List<Attribute> attrList = taskEntry.getAttribute(attributeName.toLowerCase()); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | if (isRequired) |
| | | { |
| | |
| | | { |
| | | LinkedList<String> valueStrings = new LinkedList<>(); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attributeName.toLowerCase()); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | return valueStrings; |
| | | } |
| | |
| | | |
| | | final List<Attribute> attrList = taskEntry.getAttribute(type); |
| | | ByteString value = ByteString.valueOfUtf8(messageString); |
| | | if (attrList == null) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | taskEntry.putAttribute(type, newArrayList(Attributes.create(type, value))); |
| | | } |
| | | else if (attrList.isEmpty()) |
| | | { |
| | | attrList.add(Attributes.create(type, value)); |
| | | } |
| | | else |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attrList.get(0)); |
| | |
| | | // Get the name of the class that implements the task logic. |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_CLASS.toLowerCase(), ATTR_TASK_CLASS); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_TASKSCHED_NO_CLASS_ATTRIBUTE.get(ATTR_TASK_ID); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); |
| | |
| | | * interpreted as the specified type of |
| | | * configuration attribute. |
| | | */ |
| | | public ConfigAttribute getConfigAttribute(ConfigAttribute stub) |
| | | throws ConfigException |
| | | public ConfigAttribute getConfigAttribute(ConfigAttribute stub) throws ConfigException |
| | | { |
| | | String attrName = stub.getName(); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName); |
| | | List<Attribute> attrList = entry.getAttribute(attrType); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | return stub.getConfigAttribute(attrList); |
| | | } |
| | | return null; |
| | | return !attrList.isEmpty() ? stub.getConfigAttribute(attrList) : null; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | private Attribute getFirstAttributeNotEmpty(AttributeType attributeType) |
| | | { |
| | | List<Attribute> attrList = userEntry.getAttribute(attributeType); |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(attributeType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | if (!a.isEmpty()) |
| | | { |
| | | if (!a.isEmpty()) |
| | | { |
| | | return a; |
| | | } |
| | | return a; |
| | | } |
| | | } |
| | | return null; |
| | |
| | | { |
| | | ArrayList<Long> timeValues = new ArrayList<>(); |
| | | |
| | | List<Attribute> attrList = userEntry.getAttribute(attributeType); |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(attributeType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | try |
| | | { |
| | | try |
| | | { |
| | | timeValues.add(GeneralizedTime.valueOf(v.toString()).getTimeInMillis()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s", |
| | | v, attributeType.getNameOrOID(), userDNString); |
| | | timeValues.add(GeneralizedTime.valueOf(v.toString()).getTimeInMillis()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e, "Unable to decode value %s for attribute %s in user entry %s", |
| | | v, attributeType.getNameOrOID(), userDNString); |
| | | |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME.get(v, attributeType.getNameOrOID(), userDNString, e), |
| | | e); |
| | | } |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | ERR_PWPSTATE_CANNOT_DECODE_GENERALIZED_TIME.get(v, attributeType.getNameOrOID(), userDNString, e), |
| | | e); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | boolean isGeneralizedTime = SYNTAX_GENERALIZED_TIME_NAME.equals(type.getSyntax().getName()); |
| | | lastLoginTime = -1; |
| | | List<Attribute> attrList = userEntry.getAttribute(type); |
| | | |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(type)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | if (a.isEmpty()) |
| | | { |
| | | if (a.isEmpty()) |
| | | continue; |
| | | } |
| | | |
| | | String valueString = a.iterator().next().toString(); |
| | | try |
| | | { |
| | | lastLoginTime = parseTime(format, valueString, isGeneralizedTime); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | continue; |
| | | logger.trace("Returning last login time of %d for user %s, decoded using current last login time format.", |
| | | lastLoginTime, userDNString); |
| | | } |
| | | |
| | | String valueString = a.iterator().next().toString(); |
| | | try |
| | | return lastLoginTime; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | // This could mean that the last login time was encoded using a previous format. |
| | | for (String f : passwordPolicy.getPreviousLastLoginTimeFormats()) |
| | | { |
| | | lastLoginTime = parseTime(format, valueString, isGeneralizedTime); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | try |
| | | { |
| | | logger.trace("Returning last login time of %d for user %s, decoded using current last login time format.", |
| | | lastLoginTime, userDNString); |
| | | } |
| | | lastLoginTime = parseTime(f, valueString, isGeneralizedTime); |
| | | |
| | | return lastLoginTime; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | // This could mean that the last login time was encoded using a previous format. |
| | | for (String f : passwordPolicy.getPreviousLastLoginTimeFormats()) |
| | | { |
| | | try |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | lastLoginTime = parseTime(f, valueString, isGeneralizedTime); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Returning last login time of %d for user %s decoded using previous last login time " + |
| | | "format of %s.", lastLoginTime, userDNString, f); |
| | | } |
| | | |
| | | return lastLoginTime; |
| | | logger.trace("Returning last login time of %d for user %s decoded using previous last login time " |
| | | + "format of %s.", lastLoginTime, userDNString, f); |
| | | } |
| | | catch (Exception e2) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | |
| | | return lastLoginTime; |
| | | } |
| | | |
| | | assert lastLoginTime == -1; |
| | | if (logger.isTraceEnabled()) |
| | | catch (Exception e2) |
| | | { |
| | | logger.trace("Returning -1 for user %s because the last login time value %s could not be parsed " + |
| | | "using any known format.", userDNString, valueString); |
| | | logger.traceException(e); |
| | | } |
| | | |
| | | return lastLoginTime; |
| | | } |
| | | |
| | | assert lastLoginTime == -1; |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Returning -1 for user %s because the last login time value %s could not be parsed " |
| | | + "using any known format.", userDNString, valueString); |
| | | } |
| | | |
| | | return lastLoginTime; |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | LinkedList<ByteString> clearPasswords = new LinkedList<>(); |
| | | |
| | | List<Attribute> attrList = userEntry.getAttribute(passwordPolicy.getPasswordAttribute()); |
| | | |
| | | if (attrList == null) |
| | | final List<Attribute> attrList = userEntry.getAttribute(passwordPolicy.getPasswordAttribute()); |
| | | if (attrList.isEmpty()) |
| | | { |
| | | return clearPasswords; |
| | | } |
| | |
| | | public boolean passwordMatches(ByteString password) |
| | | { |
| | | List<Attribute> attrList = userEntry.getAttribute(passwordPolicy.getPasswordAttribute()); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | |
| | | AttributeType type = passwordPolicy.getPasswordAttribute(); |
| | | List<Attribute> attrList = userEntry.getAttribute(type); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Doing nothing for entry %s because no password values were found.", userDNString); |
| | | } |
| | | |
| | | logger.trace("Doing nothing for entry %s because no password values were found.", userDNString); |
| | | return; |
| | | } |
| | | |
| | |
| | | { |
| | | TreeMap<Long, ByteString> historyMap = new TreeMap<>(); |
| | | AttributeType historyType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_HISTORY_LC); |
| | | List<Attribute> attrList = userEntry.getAttribute(historyType); |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(historyType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | String histStr = v.toString(); |
| | | int hashPos = histStr.indexOf('#'); |
| | | if (hashPos <= 0) |
| | | { |
| | | String histStr = v.toString(); |
| | | int hashPos = histStr.indexOf('#'); |
| | | if (hashPos <= 0) |
| | | logger.trace("Found value %s in the history with no timestamp. Marking it for removal.", histStr); |
| | | |
| | | if (removeAttrs != null) |
| | | { |
| | | removeAttrs.add(Attributes.create(a.getAttributeType(), v)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | ByteString timeValue = ByteString.valueOfUtf8(histStr.substring(0, hashPos)); |
| | | long timestamp = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(timeValue); |
| | | historyMap.put(timestamp, v); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Found value " + histStr + " in the history with no timestamp. Marking it for removal."); |
| | | logger.traceException(e); |
| | | logger.trace("Could not decode the timestamp in history value %s -- %s. Marking it for removal.", |
| | | histStr, e.getLocalizedMessage()); |
| | | } |
| | | |
| | | if (removeAttrs != null) |
| | |
| | | removeAttrs.add(Attributes.create(a.getAttributeType(), v)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | ByteString timeValue = ByteString.valueOfUtf8(histStr.substring(0, hashPos)); |
| | | long timestamp = GeneralizedTimeSyntax.decodeGeneralizedTimeValue(timeValue); |
| | | historyMap.put(timestamp, v); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.traceException(e); |
| | | logger.trace("Could not decode the timestamp in history value " + histStr + " -- " + e + |
| | | ". Marking it for removal."); |
| | | } |
| | | |
| | | if (removeAttrs != null) |
| | | { |
| | | removeAttrs.add(Attributes.create(a.getAttributeType(), v)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public void updatePasswordHistory() |
| | | { |
| | | List<Attribute> attrList = userEntry.getAttribute(passwordPolicy.getPasswordAttribute()); |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(passwordPolicy.getPasswordAttribute())) |
| | | { |
| | | for (Attribute a : attrList) |
| | | ByteString insecurePassword = null; |
| | | for (ByteString v : a) |
| | | { |
| | | ByteString insecurePassword = null; |
| | | for (ByteString v : a) |
| | | try |
| | | { |
| | | try |
| | | { |
| | | PasswordStorageScheme<?> scheme = getPasswordStorageScheme(v); |
| | | PasswordStorageScheme<?> scheme = getPasswordStorageScheme(v); |
| | | |
| | | if (scheme.isStorageSchemeSecure()) |
| | | { |
| | | addPasswordToHistory(v.toString()); |
| | | insecurePassword = null; |
| | | // no need to check any more values for this attribute |
| | | break; |
| | | } |
| | | else if (insecurePassword == null) |
| | | { |
| | | insecurePassword = v; |
| | | } |
| | | } |
| | | catch (DirectoryException e) |
| | | if (scheme.isStorageSchemeSecure()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Encoded password " + v + " cannot be decoded and cannot be added to history."); |
| | | } |
| | | addPasswordToHistory(v.toString()); |
| | | insecurePassword = null; |
| | | // no need to check any more values for this attribute |
| | | break; |
| | | } |
| | | else if (insecurePassword == null) |
| | | { |
| | | insecurePassword = v; |
| | | } |
| | | } |
| | | // If we get here we haven't found a password encoded securely, so we have to use one of the other values. |
| | | if (insecurePassword != null) |
| | | catch (DirectoryException e) |
| | | { |
| | | addPasswordToHistory(insecurePassword.toString()); |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Encoded password " + v + " cannot be decoded and cannot be added to history."); |
| | | } |
| | | } |
| | | } |
| | | // If we get here we haven't found a password encoded securely, so we have to use one of the |
| | | // other values. |
| | | if (insecurePassword != null) |
| | | { |
| | | addPasswordToHistory(insecurePassword.toString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | ArrayList<String> historyValues = new ArrayList<>(); |
| | | AttributeType historyType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_HISTORY_LC); |
| | | List<Attribute> attrList = userEntry.getAttribute(historyType); |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(historyType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | historyValues.add(v.toString()); |
| | | } |
| | | historyValues.add(v.toString()); |
| | | } |
| | | } |
| | | |
| | | return historyValues.toArray(new String[historyValues.size()]); |
| | | } |
| | | |
| | |
| | | List<Modification> mods, AttributeType attrType) |
| | | { |
| | | List<Attribute> attributes = entry.getAttribute(attrType); |
| | | if (attributes != null && !attributes.isEmpty()) |
| | | for (Attribute a : attributes) |
| | | { |
| | | for (Attribute a : attributes) |
| | | { |
| | | mods.add(new Modification(ModificationType.ADD, a)); |
| | | } |
| | | mods.add(new Modification(ModificationType.ADD, a)); |
| | | } |
| | | return attributes; |
| | | } |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.*; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.StateUpdateFailurePolicy; |
| | | import org.opends.server.admin.std.server.PasswordValidatorCfg; |
| | | import org.opends.server.api.AccountStatusNotificationHandler; |
| | | import org.opends.server.api.PasswordGenerator; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.opends.server.api.PasswordValidator; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * This class represents subentry password policy based on Password Policy for |
| | |
| | | { |
| | | AttributeType pwdAttrType = |
| | | DirectoryServer.getAttributeTypeOrDefault(PWD_ATTR_VALIDATOR); |
| | | List<Attribute> pwdAttrList = entry.getAttribute(pwdAttrType); |
| | | if (pwdAttrList != null && !pwdAttrList.isEmpty()) |
| | | for (Attribute attr : entry.getAttribute(pwdAttrType)) |
| | | { |
| | | for (Attribute attr : pwdAttrList) |
| | | for (ByteString val : attr) |
| | | { |
| | | for (ByteString val : attr) |
| | | DN validatorDN = DN.decode(val); |
| | | if (DirectoryServer.getPasswordValidator(validatorDN) == null) |
| | | { |
| | | DN validatorDN = DN.decode(val); |
| | | if (DirectoryServer.getPasswordValidator(validatorDN) == null) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PWPOLICY_UNKNOWN_VALIDATOR.get(this.passwordPolicySubentryDN, validatorDN, PWD_ATTR_VALIDATOR)); |
| | | } |
| | | pValidatorNames.add(validatorDN); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PWPOLICY_UNKNOWN_VALIDATOR.get(this.passwordPolicySubentryDN, validatorDN, PWD_ATTR_VALIDATOR)); |
| | | } |
| | | pValidatorNames.add(validatorDN); |
| | | } |
| | | } |
| | | } |
| | |
| | | private String getAttrValue(Entry entry, String pwdAttrName) |
| | | { |
| | | AttributeType pwdAttrType = DirectoryServer.getAttributeTypeOrDefault(pwdAttrName); |
| | | List<Attribute> pwdAttrList = entry.getAttribute(pwdAttrType); |
| | | if (pwdAttrList != null && !pwdAttrList.isEmpty()) |
| | | for (Attribute attr : entry.getAttribute(pwdAttrType)) |
| | | { |
| | | for (Attribute attr : pwdAttrList) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | return value.toString(); |
| | | } |
| | | return value.toString(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAllowExpiredPasswordChanges() |
| | | { |
| | | return getDefaultPasswordPolicy().isAllowExpiredPasswordChanges(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAllowMultiplePasswordValues() |
| | | { |
| | | return getDefaultPasswordPolicy().isAllowMultiplePasswordValues(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAllowPreEncodedPasswords() |
| | | { |
| | | return getDefaultPasswordPolicy().isAllowPreEncodedPasswords(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAllowUserPasswordChanges() |
| | | { |
| | |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performBackendPreInitializationProcessing(Backend<?> backend) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performBackendPostFinalizationProcessing(Backend<?> backend) |
| | | { |
| | |
| | | List<Attribute> dstList = dstEntry.getAttribute(attrCert); |
| | | |
| | | // Check for changes to the certificate value. |
| | | boolean differ = false; |
| | | if (srcList == null) |
| | | if (!srcList.equals(dstList)) |
| | | { |
| | | if (dstList != null) |
| | | { |
| | | differ = true; |
| | | } |
| | | } |
| | | else if (dstList == null |
| | | || srcList.size() != dstList.size() |
| | | || !srcList.equals(dstList)) |
| | | { |
| | | differ = true; |
| | | } |
| | | |
| | | if (differ) |
| | | { |
| | | // The trust store backend does not implement modify so we need to |
| | | // delete then add. |
| | | // The trust store backend does not implement modify so we need to delete then add. |
| | | // FIXME implement TrustStoreBackend.replaceEntry() as deleteEntry() + addEntry() and stop this madness |
| | | DN dstDN = dstEntry.getName(); |
| | | deleteEntry(dstDN); |
| | | addEntry(srcEntry, dstDN); |
| | |
| | | */ |
| | | private static void deleteEntry(DN dstDN) |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | DeleteOperation delOperation = conn.processDelete(dstDN); |
| | | |
| | | DeleteOperation delOperation = getRootConnection().processDelete(dstDN); |
| | | if (delOperation.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | logger.debug(INFO_TRUSTSTORESYNC_DELETE_FAILED, dstDN, delOperation.getErrorMessage()); |
| | |
| | | |
| | | List<Attribute> attrList; |
| | | attrList = srcEntry.getAttribute(attrAlias); |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | userAttrs.put(attrAlias, attrList); |
| | | } |
| | | attrList = srcEntry.getAttribute(attrCert); |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | userAttrs.put(attrCert, attrList); |
| | | } |
| | | |
| | | Entry addEntry = new Entry(dstDN, ocMap, userAttrs, null); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | AddOperation addOperation = conn.processAdd(addEntry); |
| | | AddOperation addOperation = getRootConnection().processAdd(addEntry); |
| | | if (addOperation.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | logger.debug(INFO_TRUSTSTORESYNC_ADD_FAILED, dstDN, addOperation.getErrorMessage()); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PostResponse doPostResponse(PostResponseAddOperation op) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PostResponse doPostResponse(PostResponseDeleteOperation op) |
| | | { |
| | |
| | | return PostResponse.continueOperationProcessing(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PostResponse doPostResponse(PostResponseModifyOperation op) |
| | | { |
| | |
| | | AttributeValuePasswordValidatorCfg config = currentConfig; |
| | | |
| | | |
| | | // Get the string representation (both forward and reversed) for the |
| | | // password. |
| | | String password = newPassword.toString(); |
| | | String reversed = new StringBuilder(password).reverse().toString(); |
| | | // Get the string representation (both forward and reversed) for the password. |
| | | final String password = newPassword.toString(); |
| | | final String reversed = new StringBuilder(password).reverse().toString(); |
| | | |
| | | // Check to see if we should verify the whole password or the substrings. |
| | | int minSubstringLength = password.length(); |
| | |
| | | matchAttributes = userEntry.getUserAttributes().keySet(); |
| | | } |
| | | |
| | | final ByteString vf = ByteString.valueOfUtf8(password); |
| | | final ByteString vr = ByteString.valueOfUtf8(reversed); |
| | | for (AttributeType t : matchAttributes) |
| | | { |
| | | List<Attribute> attrList = userEntry.getAttribute(t); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | ByteString vf = ByteString.valueOfUtf8(password); |
| | | ByteString vr = ByteString.valueOfUtf8(reversed); |
| | | |
| | | for (Attribute a : attrList) |
| | | for (Attribute a : userEntry.getAttribute(t)) |
| | | { |
| | | if (a.contains(vf) || |
| | | (config.isTestReversedPassword() && a.contains(vr)) || |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | 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; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDAPURL; |
| | | import org.opends.server.types.MemberList; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class provides a dynamic group implementation, in which |
| | |
| | | // out the LDAP URLs that it contains. |
| | | LinkedHashSet<LDAPURL> memberURLs = new LinkedHashSet<>(); |
| | | AttributeType memberURLType = DirectoryServer.getAttributeTypeOrDefault(ATTR_MEMBER_URL_LC); |
| | | List<Attribute> attrList = groupEntry.getAttribute(memberURLType); |
| | | if (attrList != null) |
| | | for (Attribute a : groupEntry.getAttribute(memberURLType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | try |
| | | { |
| | | try |
| | | { |
| | | memberURLs.add(LDAPURL.decode(v.toString(), true)); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | logger.error(ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL, v, |
| | | groupEntry.getName(), de.getMessageObject()); |
| | | } |
| | | memberURLs.add(LDAPURL.decode(v.toString(), true)); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | logger.error(ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL, v, groupEntry.getName(), de.getMessageObject()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | 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.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.ExternalSASLMechanismHandlerCfg; |
| | | import org.opends.server.admin.std.server.SASLMechanismHandlerCfg; |
| | | import org.opends.server.api.CertificateMapper; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.SASLMechanismHandler; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.protocols.ldap.LDAPClientConnection; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | bindOperation.setAuthFailureReason(message); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | bindOperation.setSASLAuthUserEntry(userEntry); |
| | | } |
| | | |
| | | bindOperation.setSASLAuthUserEntry(userEntry); |
| | | |
| | | |
| | | // Get the userCertificate attribute from the user's entry for use in the |
| | | // validation process. |
| | | List<Attribute> certAttrList = |
| | | userEntry.getAttribute(certificateAttributeType); |
| | | List<Attribute> certAttrList = userEntry.getAttribute(certificateAttributeType); |
| | | switch (validationPolicy) |
| | | { |
| | | case ALWAYS: |
| | | if (certAttrList == null) |
| | | if (certAttrList.isEmpty()) |
| | | { |
| | | if (validationPolicy == CertificateValidationPolicy.ALWAYS) |
| | | { |
| | |
| | | break; |
| | | |
| | | case IFPRESENT: |
| | | if (certAttrList != null) |
| | | if (!certAttrList.isEmpty()) |
| | | { |
| | | try |
| | | { |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | 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.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.GeneralizedTime; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.opends.server.api.TrustManagerProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ServerContext; |
| | |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | // The bind DN is contained in an attribute in the user's entry. |
| | | mapBind: for (final AttributeType at : cfg.getMappedAttribute()) |
| | | { |
| | | final List<Attribute> attributes = userEntry.getAttribute(at); |
| | | if (attributes != null && !attributes.isEmpty()) |
| | | for (final Attribute attribute : userEntry.getAttribute(at)) |
| | | { |
| | | for (final Attribute attribute : attributes) |
| | | if (!attribute.isEmpty()) |
| | | { |
| | | if (!attribute.isEmpty()) |
| | | { |
| | | username = attribute.iterator().next(); |
| | | break mapBind; |
| | | } |
| | | username = attribute.iterator().next(); |
| | | break mapBind; |
| | | } |
| | | } |
| | | } |
| | |
| | | final LinkedList<SearchFilter> filterComponents = new LinkedList<>(); |
| | | for (final AttributeType at : cfg.getMappedAttribute()) |
| | | { |
| | | final List<Attribute> attributes = userEntry.getAttribute(at); |
| | | if (attributes != null && !attributes.isEmpty()) |
| | | for (final Attribute attribute : userEntry.getAttribute(at)) |
| | | { |
| | | for (final Attribute attribute : attributes) |
| | | for (final ByteString value : attribute) |
| | | { |
| | | for (final ByteString value : attribute) |
| | | { |
| | | filterComponents.add(SearchFilter.createEqualityFilter(at, |
| | | value)); |
| | | } |
| | | filterComponents.add(SearchFilter.createEqualityFilter(at, value)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // Now perform the bind. |
| | | Connection connection = null; |
| | | try |
| | | try (Connection connection = bindFactory.getConnection()) |
| | | { |
| | | connection = bindFactory.getConnection(); |
| | | connection.simpleBind(username, password); |
| | | |
| | | // The password matched, so cache it, it will be stored in the |
| | |
| | | userEntry.getName(), cfg.dn(), e.getMessageObject()), e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | StaticUtils.close(connection); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | // First determine if the cached password time is present and valid. |
| | | boolean foundValidCachedPasswordTime = false; |
| | | |
| | | List<Attribute> cptlist = userEntry |
| | | .getAttribute(cachedPasswordTimeAttribute); |
| | | if (cptlist != null && !cptlist.isEmpty()) |
| | | foundCachedPasswordTime: |
| | | for (Attribute attribute : userEntry.getAttribute(cachedPasswordTimeAttribute)) |
| | | { |
| | | foundCachedPasswordTime: |
| | | // Ignore any attributes with options. |
| | | if (!attribute.hasOptions()) |
| | | { |
| | | for (Attribute attribute : cptlist) |
| | | for (ByteString value : attribute) |
| | | { |
| | | // Ignore any attributes with options. |
| | | if (!attribute.hasOptions()) |
| | | try |
| | | { |
| | | for (ByteString value : attribute) |
| | | { |
| | | try |
| | | { |
| | | long cachedPasswordTime = GeneralizedTime.valueOf(value.toString()).getTimeInMillis(); |
| | | long currentTime = provider.getCurrentTimeMS(); |
| | | long expiryTime = cachedPasswordTime + (cfg.getCachedPasswordTTL() * 1000); |
| | | foundValidCachedPasswordTime = expiryTime > currentTime; |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | // Fall-through and give up immediately. |
| | | logger.traceException(e); |
| | | } |
| | | break foundCachedPasswordTime; |
| | | } |
| | | long cachedPasswordTime = GeneralizedTime.valueOf(value.toString()).getTimeInMillis(); |
| | | long currentTime = provider.getCurrentTimeMS(); |
| | | long expiryTime = cachedPasswordTime + (cfg.getCachedPasswordTTL() * 1000); |
| | | foundValidCachedPasswordTime = expiryTime > currentTime; |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | // Fall-through and give up immediately. |
| | | logger.traceException(e); |
| | | } |
| | | break foundCachedPasswordTime; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // Next determine if there is a cached password. |
| | | ByteString cachedPassword = null; |
| | | |
| | | List<Attribute> cplist = userEntry |
| | | .getAttribute(cachedPasswordAttribute); |
| | | if (cplist != null && !cplist.isEmpty()) |
| | | foundCachedPassword: |
| | | for (Attribute attribute : userEntry.getAttribute(cachedPasswordAttribute)) |
| | | { |
| | | foundCachedPassword: |
| | | // Ignore any attributes with options. |
| | | if (!attribute.hasOptions()) |
| | | { |
| | | for (Attribute attribute : cplist) |
| | | for (ByteString value : attribute) |
| | | { |
| | | // Ignore any attributes with options. |
| | | if (!attribute.hasOptions()) |
| | | { |
| | | for (ByteString value : attribute) |
| | | { |
| | | cachedPassword = value; |
| | | break foundCachedPassword; |
| | | } |
| | | } |
| | | cachedPassword = value; |
| | | break foundCachedPassword; |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | 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.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | |
| | | import org.opends.server.types.AccountStatusNotificationType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.EMailMessage; |
| | |
| | | Entry userEntry = notification.getUserEntry(); |
| | | for (AttributeType t : addressAttrs) |
| | | { |
| | | List<Attribute> attrList = userEntry.getAttribute(t); |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(t)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Adding end user recipient %s from attr %s", |
| | | v, a.getNameWithOptions()); |
| | | } |
| | | logger.trace("Adding end user recipient %s from attr %s", v, a.getNameWithOptions()); |
| | | |
| | | recipients.add(v.toString()); |
| | | } |
| | | recipients.add(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | // There are no recipients at all, so there's no point in generating |
| | | // the message. Return without doing anything. |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("No end user recipients, and no explicit " + |
| | | "recipients"); |
| | | } |
| | | |
| | | logger.trace("No end user recipients, and no explicit recipients"); |
| | | return; |
| | | } |
| | | else |
| | |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | | /** |
| | | * A static group implementation, in which the DNs of all members are explicitly |
| | |
| | | |
| | | List<Attribute> memberAttrList = groupEntry.getAttribute(someMemberAttributeType); |
| | | int membersCount = 0; |
| | | if (memberAttrList != null) |
| | | for (Attribute a : memberAttrList) |
| | | { |
| | | for (Attribute a : memberAttrList) |
| | | { |
| | | membersCount += a.size(); |
| | | } |
| | | membersCount += a.size(); |
| | | } |
| | | LinkedHashSet<CompactDn> someMemberDNs = new LinkedHashSet<>(membersCount); |
| | | if (memberAttrList != null) |
| | | for (Attribute a : memberAttrList) |
| | | { |
| | | for (Attribute a : memberAttrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | try |
| | | { |
| | | try |
| | | { |
| | | someMemberDNs.add(org.forgerock.opendj.ldap.DN.valueOf(v.toString()).compact()); |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | logger.traceException(e); |
| | | logger.error(ERR_STATICGROUP_CANNOT_DECODE_MEMBER_VALUE_AS_DN, v, |
| | | someMemberAttributeType.getNameOrOID(), groupEntry.getName(), e.getMessageObject()); |
| | | } |
| | | someMemberDNs.add(org.forgerock.opendj.ldap.DN.valueOf(v.toString()).compact()); |
| | | } |
| | | catch (LocalizedIllegalArgumentException e) |
| | | { |
| | | logger.traceException(e); |
| | | logger.error(ERR_STATICGROUP_CANNOT_DECODE_MEMBER_VALUE_AS_DN, |
| | | v, someMemberAttributeType.getNameOrOID(), groupEntry.getName(), e.getMessageObject()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.AccountStatusNotification; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements a notification message template element that will |
| | | * generate a value that is the value of a specified attribute from the target |
| | |
| | | /** The attribute type for which to obtain the value. */ |
| | | private AttributeType attributeType; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new user DN notification message template element. |
| | | * |
| | | * @param attributeType The attribute type for which to obtain the value. |
| | | */ |
| | | public UserAttributeNotificationMessageTemplateElement(AttributeType |
| | | attributeType) |
| | | public UserAttributeNotificationMessageTemplateElement(AttributeType attributeType) |
| | | { |
| | | this.attributeType = attributeType; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void generateValue(LocalizableMessageBuilder buffer, |
| | | AccountStatusNotification notification) |
| | | { |
| | | Entry userEntry = notification.getUserEntry(); |
| | | |
| | | List<Attribute> attrList = userEntry.getAttribute(attributeType); |
| | | if (attrList != null) |
| | | for (Attribute a : userEntry.getAttribute(attributeType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | buffer.append(v); |
| | | return; |
| | | } |
| | | buffer.append(v); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.std.server.VirtualStaticGroupImplementationCfg; |
| | | 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; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.MemberList; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class provides a virtual static group implementation, in which |
| | |
| | | // Get the target group DN attribute from the entry, if there is one. |
| | | DN targetDN = null; |
| | | AttributeType targetType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TARGET_GROUP_DN); |
| | | List<Attribute> attrList = groupEntry.getAttribute(targetType); |
| | | if (attrList != null) |
| | | for (Attribute a : groupEntry.getAttribute(targetType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | if (targetDN != null) |
| | | { |
| | | if (targetDN != null) |
| | | { |
| | | LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_MULTIPLE_TARGETS.get(groupEntry.getName()); |
| | | throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message); |
| | | } |
| | | LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_MULTIPLE_TARGETS.get(groupEntry.getName()); |
| | | throw new DirectoryException(ResultCode.OBJECTCLASS_VIOLATION, message); |
| | | } |
| | | |
| | | try |
| | | { |
| | | targetDN = DN.decode(v); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | try |
| | | { |
| | | targetDN = DN.decode(v); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | logger.traceException(de); |
| | | |
| | | LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_CANNOT_DECODE_TARGET. |
| | | get(v, groupEntry.getName(), de.getMessageObject()); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, |
| | | message, de); |
| | | } |
| | | LocalizableMessage message = ERR_VIRTUAL_STATIC_GROUP_CANNOT_DECODE_TARGET. |
| | | get(v, groupEntry.getName(), de.getMessageObject()); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final PluginResult.ImportLDIF |
| | | doLDIFImport(LDIFImportConfig importConfig, Entry entry) |
| | |
| | | // See if the entry being imported already contains an entryUUID attribute. |
| | | // If so, then leave it alone. |
| | | List<Attribute> uuidList = entry.getAttribute(entryUUIDType); |
| | | if (uuidList != null) |
| | | if (!uuidList.isEmpty()) |
| | | { |
| | | return PluginResult.ImportLDIF.continueEntryProcessing(); |
| | | } |
| | |
| | | import java.util.Set; |
| | | |
| | | 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.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.PluginCfgDefn; |
| | | import org.opends.server.admin.std.server.PasswordPolicyImportPluginCfg; |
| | |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.PasswordPolicy; |
| | | import org.opends.server.core.SubentryPasswordPolicy; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.schema.AuthPasswordSyntax; |
| | | import org.opends.server.schema.UserPasswordSyntax; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * This class implements a Directory Server plugin that performs various |
| | |
| | | // See if the entry explicitly states the password policy that it should |
| | | // use. If so, then only use it to perform the encoding. |
| | | List<Attribute> attrList = entry.getAttribute(customPolicyAttribute); |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | DN policyDN = null; |
| | | PasswordPolicy policy = null; |
| | |
| | | if (schemes != null) |
| | | { |
| | | attrList = entry.getAttribute(policy.getPasswordAttribute()); |
| | | if (attrList == null) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | return PluginResult.ImportLDIF.continueEntryProcessing(); |
| | | } |
| | |
| | | for (AttributeType t : authPasswordTypes) |
| | | { |
| | | attrList = entry.getAttribute(t); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | for (AttributeType t : userPasswordTypes) |
| | | { |
| | | attrList = entry.getAttribute(t); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PluginResult.PreOperation doPreOperation( |
| | | PreOperationAddOperation addOperation) |
| | | public PluginResult.PreOperation doPreOperation(PreOperationAddOperation addOperation) |
| | | { |
| | | /* Skip the integrity checks if the enforcing is not enabled. |
| | | */ |
| | | |
| | | // Skip the integrity checks if the enforcing is not enabled. |
| | | if (!currentConfiguration.isCheckReferences()) |
| | | { |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | |
| | | |
| | | final Entry entry = addOperation.getEntryToAdd(); |
| | | |
| | | /* Make sure the entry belongs to one of the configured naming |
| | | * contexts. |
| | | */ |
| | | // Make sure the entry belongs to one of the configured naming contexts. |
| | | DN entryDN = entry.getName(); |
| | | DN entryBaseDN = getEntryBaseDN(entryDN); |
| | | if (entryBaseDN == null) |
| | |
| | | for (AttributeType attrType : attributeTypes) |
| | | { |
| | | final List<Attribute> attrs = entry.getAttribute(attrType, false); |
| | | |
| | | if (attrs != null) |
| | | PluginResult.PreOperation result = isIntegrityMaintained(attrs, entryDN, entryBaseDN); |
| | | if (result.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | PluginResult.PreOperation result = |
| | | isIntegrityMaintained(attrs, entryDN, entryBaseDN); |
| | | if (result.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | return result; |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /* If we reahed this point, everything is fine. |
| | | */ |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | | |
| | |
| | | // Make sure all configured attributes have clean values. |
| | | for (AttributeType t : config.getAttributeType()) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(t); |
| | | if (attrList != null) |
| | | for (Attribute a : entry.getAttribute(t)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | if (!is7BitClean(v)) |
| | | { |
| | | if (!is7BitClean(v)) |
| | | { |
| | | LocalizableMessage rejectMessage = |
| | | ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(a.getNameWithOptions()); |
| | | return PluginResult.ImportLDIF.stopEntryProcessing(rejectMessage); |
| | | } |
| | | LocalizableMessage rejectMessage = |
| | | ERR_PLUGIN_7BIT_IMPORT_ATTR_NOT_CLEAN.get(a.getNameWithOptions()); |
| | | return PluginResult.ImportLDIF.stopEntryProcessing(rejectMessage); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.opends.server.admin.std.server.UniqueAttributePluginCfg; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.plugin.*; |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginResult.PostOperation; |
| | | import org.opends.server.api.plugin.PluginResult.PreOperation; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.*; |
| | | |
| | | import static org.opends.messages.PluginMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | /** |
| | |
| | | List<ByteString> recordedValues = new LinkedList<>(); |
| | | for (AttributeType t : config.getType()) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(t); |
| | | if (attrList != null) |
| | | for (Attribute a : entry.getAttribute(t)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | PreOperation stop = checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config); |
| | | if (stop != null) |
| | | { |
| | | PreOperation stop = |
| | | checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config); |
| | | if (stop != null) |
| | | { |
| | | return stop; |
| | | } |
| | | return stop; |
| | | } |
| | | } |
| | | } |
| | |
| | | break; |
| | | |
| | | case INCREMENT: |
| | | // We could calculate the new value, but we'll just take it from the |
| | | // updated entry. |
| | | List<Attribute> attrList = |
| | | modifyOperation.getModifiedEntry().getAttribute(t, |
| | | a.getOptions()); |
| | | if (attrList != null) |
| | | // We could calculate the new value, but we'll just take it from the updated entry. |
| | | for (Attribute updatedAttr : modifyOperation.getModifiedEntry().getAttribute(t, a.getOptions())) |
| | | { |
| | | for (Attribute updatedAttr : attrList) |
| | | if (! updatedAttr.optionsEqual(a.getOptions())) |
| | | { |
| | | if (! updatedAttr.optionsEqual(a.getOptions())) |
| | | { |
| | | continue; |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | for (ByteString v : updatedAttr) |
| | | for (ByteString v : updatedAttr) |
| | | { |
| | | PreOperation stop = checkUniqueness(entryDN, t, v, baseDNs, recordedValues, config); |
| | | if (stop != null) |
| | | { |
| | | PreOperation stop = checkUniqueness( |
| | | entryDN, t, v, baseDNs, recordedValues, config); |
| | | if (stop != null) |
| | | { |
| | | return stop; |
| | | } |
| | | return stop; |
| | | } |
| | | } |
| | | } |
| | |
| | | DN entryDN = entry.getName(); |
| | | for (AttributeType t : config.getType()) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(t); |
| | | if (attrList != null) |
| | | for (Attribute a : entry.getAttribute(t)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | sendAlertForUnresolvedConflict(addOperation, entryDN, entryDN, t, |
| | | v, baseDNs, config); |
| | | } |
| | | sendAlertForUnresolvedConflict(addOperation, entryDN, entryDN, t, v, baseDNs, config); |
| | | } |
| | | } |
| | | } |
| | |
| | | break; |
| | | |
| | | case INCREMENT: |
| | | // We could calculate the new value, but we'll just take it from the |
| | | // updated entry. |
| | | List<Attribute> attrList = |
| | | modifyOperation.getModifiedEntry().getAttribute(t, |
| | | a.getOptions()); |
| | | if (attrList != null) |
| | | // We could calculate the new value, but we'll just take it from the updated entry. |
| | | for (Attribute updatedAttr : modifyOperation.getModifiedEntry().getAttribute(t, a.getOptions())) |
| | | { |
| | | for (Attribute updatedAttr : attrList) |
| | | if (! updatedAttr.optionsEqual(a.getOptions())) |
| | | { |
| | | if (! updatedAttr.optionsEqual(a.getOptions())) |
| | | { |
| | | continue; |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | for (ByteString v : updatedAttr) |
| | | { |
| | | sendAlertForUnresolvedConflict(modifyOperation, entryDN, |
| | | entryDN, t, v, baseDNs, config); |
| | | } |
| | | for (ByteString v : updatedAttr) |
| | | { |
| | | sendAlertForUnresolvedConflict(modifyOperation, entryDN, |
| | | entryDN, t, v, baseDNs, config); |
| | | } |
| | | } |
| | | break; |
| | |
| | | //Remove the attribute value from the map. |
| | | for (AttributeType t : config.getType()) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(t); |
| | | if (attrList != null) |
| | | for (Attribute a : entry.getAttribute(t)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v); |
| | | } |
| | | uniqueAttrValue2Dn.remove(v); |
| | | } |
| | | } |
| | | } |
| | |
| | | break; |
| | | |
| | | case INCREMENT: |
| | | // We could calculate the new value, but we'll just take it from the |
| | | // updated entry. |
| | | List<Attribute> attrList = |
| | | modifyOperation.getModifiedEntry().getAttribute(t, |
| | | a.getOptions()); |
| | | if (attrList != null) |
| | | // We could calculate the new value, but we'll just take it from the updated entry. |
| | | for (Attribute updatedAttr : modifyOperation.getModifiedEntry().getAttribute(t, a.getOptions())) |
| | | { |
| | | for (Attribute updatedAttr : attrList) |
| | | if (!updatedAttr.optionsEqual(a.getOptions())) |
| | | { |
| | | if (! updatedAttr.optionsEqual(a.getOptions())) |
| | | { |
| | | continue; |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | for (ByteString v : updatedAttr) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v); |
| | | } |
| | | for (ByteString v : updatedAttr) |
| | | { |
| | | uniqueAttrValue2Dn.remove(v); |
| | | } |
| | | } |
| | | break; |
| | |
| | | |
| | | // Now we'll build the Historical object we want to construct |
| | | final EntryHistorical newHistorical = new EntryHistorical(); |
| | | if (histAttrWithOptionsFromEntry == null) |
| | | if (histAttrWithOptionsFromEntry.isEmpty()) |
| | | { |
| | | // No historical attribute in the entry, return empty object |
| | | return newHistorical; |
| | |
| | | public static Iterable<FakeOperation> generateFakeOperations(Entry entry) |
| | | { |
| | | TreeMap<CSN, FakeOperation> operations = new TreeMap<>(); |
| | | List<Attribute> attrs = getHistoricalAttr(entry); |
| | | if (attrs != null) |
| | | for (Attribute attr : getHistoricalAttr(entry)) |
| | | { |
| | | for (Attribute attr : attrs) |
| | | for (ByteString val : attr) |
| | | { |
| | | for (ByteString val : attr) |
| | | HistoricalAttributeValue histVal = new HistoricalAttributeValue(val.toString()); |
| | | if (histVal.isADDOperation()) |
| | | { |
| | | HistoricalAttributeValue histVal = new HistoricalAttributeValue(val.toString()); |
| | | if (histVal.isADDOperation()) |
| | | // Found some historical information indicating that this entry was just added. |
| | | // Create the corresponding ADD operation. |
| | | operations.put(histVal.getCSN(), new FakeAddOperation(histVal.getCSN(), entry)); |
| | | } |
| | | else if (histVal.isMODDNOperation()) |
| | | { |
| | | // Found some historical information indicating that this entry was just renamed. |
| | | // Create the corresponding ADD operation. |
| | | operations.put(histVal.getCSN(), new FakeModdnOperation(histVal.getCSN(), entry)); |
| | | } |
| | | else |
| | | { |
| | | // Found some historical information for modify operation. |
| | | // Generate the corresponding ModifyOperation or update |
| | | // the already generated Operation if it can be found. |
| | | CSN csn = histVal.getCSN(); |
| | | Modification mod = histVal.generateMod(); |
| | | FakeOperation fakeOperation = operations.get(csn); |
| | | |
| | | if (fakeOperation instanceof FakeModifyOperation) |
| | | { |
| | | // Found some historical information indicating that this entry was just added. |
| | | // Create the corresponding ADD operation. |
| | | operations.put(histVal.getCSN(), new FakeAddOperation(histVal.getCSN(), entry)); |
| | | } |
| | | else if (histVal.isMODDNOperation()) |
| | | { |
| | | // Found some historical information indicating that this entry was just renamed. |
| | | // Create the corresponding ADD operation. |
| | | operations.put(histVal.getCSN(), new FakeModdnOperation(histVal.getCSN(), entry)); |
| | | FakeModifyOperation modifyFakeOperation = (FakeModifyOperation) fakeOperation; |
| | | modifyFakeOperation.addModification(mod); |
| | | } |
| | | else |
| | | { |
| | | // Found some historical information for modify operation. |
| | | // Generate the corresponding ModifyOperation or update |
| | | // the already generated Operation if it can be found. |
| | | CSN csn = histVal.getCSN(); |
| | | Modification mod = histVal.generateMod(); |
| | | FakeOperation fakeOperation = operations.get(csn); |
| | | |
| | | if (fakeOperation instanceof FakeModifyOperation) |
| | | { |
| | | FakeModifyOperation modifyFakeOperation = (FakeModifyOperation) fakeOperation; |
| | | modifyFakeOperation.addModification(mod); |
| | | } |
| | | else |
| | | { |
| | | String uuidString = getEntryUUID(entry); |
| | | FakeModifyOperation modifyFakeOperation = |
| | | new FakeModifyOperation(entry.getName(), csn, uuidString); |
| | | modifyFakeOperation.addModification(mod); |
| | | operations.put(histVal.getCSN(), modifyFakeOperation); |
| | | } |
| | | String uuidString = getEntryUUID(entry); |
| | | FakeModifyOperation modifyFakeOperation = new FakeModifyOperation(entry.getName(), csn, uuidString); |
| | | modifyFakeOperation.addModification(mod); |
| | | operations.put(histVal.getCSN(), modifyFakeOperation); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | private static String extractEntryUUID(List<Attribute> entryUUIDAttributes, DN entryDN) |
| | | { |
| | | if (entryUUIDAttributes != null) |
| | | if (!entryUUIDAttributes.isEmpty()) |
| | | { |
| | | Attribute uuidAttr = entryUUIDAttributes.get(0); |
| | | if (!uuidAttr.isEmpty()) |
| | |
| | | import java.util.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ServerManagementContext; |
| | |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain.*; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain.AttributeValueStringIterator; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain.FractionalConfig; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.plugin.LDAPReplicationDomain.*; |
| | | |
| | |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attributeName); |
| | | List<Attribute> inclAttrs = entry.getAttribute(attrType); |
| | | if (inclAttrs != null) |
| | | { |
| | | return inclAttrs.get(0); |
| | | } |
| | | return null; |
| | | return !inclAttrs.isEmpty() ? inclAttrs.get(0) : null; |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.IsolationPolicy; |
| | | import org.opends.server.admin.std.server.ExternalChangelogDomainCfg; |
| | | import org.opends.server.admin.std.server.ReplicationDomainCfg; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.api.SynchronizationProvider; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.Backend.BackendOperation; |
| | | import org.opends.server.api.BackendInitializationListener; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.api.ServerShutdownListener; |
| | | import org.opends.server.api.SynchronizationProvider; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | { |
| | | AttributeType synchronizationGenIDType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_GENERATION_ID); |
| | | List<Attribute> attrs = resultEntry.getAttribute(synchronizationGenIDType); |
| | | if (attrs != null) |
| | | if (!attrs.isEmpty()) |
| | | { |
| | | Attribute attr = attrs.get(0); |
| | | if (attr.size() == 1) |
| | |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrName); |
| | | List<Attribute> exclAttrs = resultEntry.getAttribute(attrType); |
| | | if (exclAttrs != null) |
| | | if (!exclAttrs.isEmpty()) |
| | | { |
| | | Attribute exclAttr = exclAttrs.get(0); |
| | | if (exclAttr != null) |
| | |
| | | { |
| | | AttributeType synchronizationGenIDType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_GENERATION_ID); |
| | | List<Attribute> attrs = resultEntry.getAttribute(synchronizationGenIDType); |
| | | if (attrs != null) |
| | | if (!attrs.isEmpty()) |
| | | { |
| | | Attribute attr = attrs.get(0); |
| | | if (attr.size()>1) |
| | |
| | | /** |
| | | * Update this ServerState from the provided entry. |
| | | * |
| | | * @param resultEntry The entry that should be used to update this |
| | | * ServerState. |
| | | * @param resultEntry |
| | | * The entry that should be used to update this ServerState. |
| | | */ |
| | | private void updateStateFromEntry(SearchResultEntry resultEntry) |
| | | { |
| | | AttributeType synchronizationStateType = DirectoryServer.getAttributeTypeOrNull(REPLICATION_STATE); |
| | | List<Attribute> attrs = resultEntry.getAttribute(synchronizationStateType); |
| | | if (attrs != null) |
| | | if (!attrs.isEmpty()) |
| | | { |
| | | for (ByteString value : attrs.get(0)) |
| | | { |
| | |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.SynchronizationProviderCfg; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.SynchronizationProvider; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.TaskMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.core.DirectoryServer.getSchemaDN; |
| | | import static org.opends.server.core.DirectoryServer.getServerErrorResultCode; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | Entry taskEntry = getTaskEntry(); |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_ADDSCHEMAFILE_FILENAME); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_ADDSCHEMAFILE_NO_FILENAME.get( |
| | | ATTR_TASK_ADDSCHEMAFILE_FILENAME, taskEntry.getName()); |
| | |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | |
| | | AttributeType typeBackupDirectory = getAttributeTypeOrDefault(ATTR_BACKUP_DIRECTORY_PATH); |
| | | AttributeType typeIncrementalBaseID = getAttributeTypeOrDefault(ATTR_TASK_BACKUP_INCREMENTAL_BASE_ID); |
| | | |
| | | backUpAll = TaskUtils.getBoolean(taskEntry.getAttribute(typeBackupAll), false); |
| | | compress = TaskUtils.getBoolean(taskEntry.getAttribute(typeCompress), false); |
| | | encrypt = TaskUtils.getBoolean(taskEntry.getAttribute(typeEncrypt), false); |
| | | hash = TaskUtils.getBoolean(taskEntry.getAttribute(typeHash), false); |
| | | incremental = TaskUtils.getBoolean(taskEntry.getAttribute(typeIncremental), false); |
| | | signHash = TaskUtils.getBoolean(taskEntry.getAttribute(typeSignHash), false); |
| | | backendIDList = TaskUtils.getMultiValueString(taskEntry.getAttribute(typeBackendID)); |
| | | backupID = TaskUtils.getSingleValueString(taskEntry.getAttribute(typeBackupID)); |
| | | |
| | | List<Attribute> attrList; |
| | | |
| | | attrList = taskEntry.getAttribute(typeBackupAll); |
| | | backUpAll = TaskUtils.getBoolean(attrList, false); |
| | | |
| | | attrList = taskEntry.getAttribute(typeCompress); |
| | | compress = TaskUtils.getBoolean(attrList, false); |
| | | |
| | | attrList = taskEntry.getAttribute(typeEncrypt); |
| | | encrypt = TaskUtils.getBoolean(attrList, false); |
| | | |
| | | attrList = taskEntry.getAttribute(typeHash); |
| | | hash = TaskUtils.getBoolean(attrList, false); |
| | | |
| | | attrList = taskEntry.getAttribute(typeIncremental); |
| | | incremental = TaskUtils.getBoolean(attrList, false); |
| | | |
| | | attrList = taskEntry.getAttribute(typeSignHash); |
| | | signHash = TaskUtils.getBoolean(attrList, false); |
| | | |
| | | attrList = taskEntry.getAttribute(typeBackendID); |
| | | backendIDList = TaskUtils.getMultiValueString(attrList); |
| | | |
| | | attrList = taskEntry.getAttribute(typeBackupID); |
| | | backupID = TaskUtils.getSingleValueString(attrList); |
| | | |
| | | attrList = taskEntry.getAttribute(typeBackupDirectory); |
| | | String backupDirectoryPath = TaskUtils.getSingleValueString(attrList); |
| | | String backupDirectoryPath = TaskUtils.getSingleValueString(taskEntry.getAttribute(typeBackupDirectory)); |
| | | backupDirectory = new File(backupDirectoryPath); |
| | | if (! backupDirectory.isAbsolute()) |
| | | { |
| | | backupDirectory = |
| | | new File(DirectoryServer.getInstanceRoot(), backupDirectoryPath); |
| | | backupDirectory = new File(DirectoryServer.getInstanceRoot(), backupDirectoryPath); |
| | | } |
| | | |
| | | attrList = taskEntry.getAttribute(typeIncrementalBaseID); |
| | | incrementalBase = TaskUtils.getSingleValueString(attrList); |
| | | incrementalBase = TaskUtils.getSingleValueString(taskEntry.getAttribute(typeIncrementalBaseID)); |
| | | |
| | | configEntries = TaskUtils.getBackendConfigEntries(); |
| | | } |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | private long getConnectionID(Entry taskEntry) throws DirectoryException |
| | | { |
| | | final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_CONN_ID); |
| | | final List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | for (Attribute a : taskEntry.getAttribute(attrType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | try |
| | | { |
| | | try |
| | | { |
| | | return Long.parseLong(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e); |
| | | } |
| | | return Long.parseLong(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e); |
| | | } |
| | | } |
| | | } |
| | |
| | | private boolean mustNotifyClient(Entry taskEntry) throws DirectoryException |
| | | { |
| | | final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT); |
| | | final List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | for (Attribute a : taskEntry.getAttribute(attrType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | final String stringValue = toLowerCase(v.toString()); |
| | | if ("true".equals(stringValue)) |
| | | { |
| | | final String stringValue = toLowerCase(v.toString()); |
| | | if ("true".equals(stringValue)) |
| | | { |
| | | return true; |
| | | } |
| | | else if ("false".equals(stringValue)) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_NOTIFY_CLIENT.get(stringValue); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | return true; |
| | | } |
| | | else if ("false".equals(stringValue)) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_NOTIFY_CLIENT.get(stringValue); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | private LocalizableMessage getDisconnectMessage(Entry taskEntry) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_MESSAGE); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | for (Attribute a : taskEntry.getAttribute(attrType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | return LocalizableMessage.raw(v.toString()); |
| | | } |
| | | return LocalizableMessage.raw(v.toString()); |
| | | } |
| | | } |
| | | return INFO_TASK_DISCONNECT_GENERIC_MESSAGE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected TaskState runTask() |
| | | { |
| | |
| | | // Retrieves the eventual generation-ID |
| | | AttributeType typeNewValue = getAttributeTypeOrDefault(ATTR_TASK_SET_GENERATION_ID_NEW_VALUE); |
| | | List<Attribute> attrList = taskEntry.getAttribute(typeNewValue); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_SHUTDOWN_MESSAGE); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | |
| | | |
| | | attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_RESTART_SERVER); |
| | | attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | backendID = idAttr.activeValue(); |
| | | } |
| | | backendID = idAttr.activeValue(); |
| | | } |
| | | catch (org.opends.server.config.ConfigException ce) |
| | | { |
| | |
| | | * @return The configuration entry of the backend, or null if it could not |
| | | * be found. |
| | | */ |
| | | public static BackendCfg getConfigEntry(Backend backend) |
| | | public static BackendCfg getConfigEntry(Backend<?> backend) |
| | | { |
| | | RootCfg root = ServerManagementContext.getInstance(). |
| | | getRootConfiguration(); |
| | |
| | | * @param backendID Identifies the backend to be disabled. |
| | | * @throws DirectoryException If the internal modify operation failed. |
| | | */ |
| | | public static void disableBackend(String backendID) |
| | | throws DirectoryException |
| | | public static void disableBackend(String backendID) throws DirectoryException |
| | | { |
| | | DN configEntryDN; |
| | | RootCfg root = ServerManagementContext.getInstance().getRootConfiguration(); |
| | |
| | | public static boolean getBoolean(List<Attribute> attrList, |
| | | boolean defaultValue) |
| | | { |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | |
| | | for (Attribute a : attrList) |
| | | { |
| | | for (ByteString v : a) |
| | |
| | | public static ArrayList<String> getMultiValueString(List<Attribute> attrList) |
| | | { |
| | | ArrayList<String> valueStrings = new ArrayList<>(); |
| | | |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | |
| | | */ |
| | | public static String getSingleValueString(List<Attribute> attrList) |
| | | { |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | |
| | | * @return The integer value of the attribute, or the provided default value |
| | | * if there is no value. |
| | | */ |
| | | public static int getSingleValueInteger(List<Attribute> attrList, |
| | | int defaultValue) |
| | | public static int getSingleValueInteger(List<Attribute> attrList, int defaultValue) |
| | | { |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) |
| | |
| | | |
| | | private String getSingleStringValue(Entry entry, String attrName) { |
| | | List<Attribute> attrList = entry.getAttribute(attrName); |
| | | if (attrList != null && attrList.size() == 1) { |
| | | if (attrList.size() == 1) { |
| | | Attribute attr = attrList.get(0); |
| | | if (!attr.isEmpty()) { |
| | | return attr.iterator().next().toString(); |
| | |
| | | |
| | | private List<String> getMultiStringValue(Entry entry, String attrName) { |
| | | List<String> valuesList = new ArrayList<>(); |
| | | List<Attribute> attrList = entry.getAttribute(attrName); |
| | | if (attrList != null) { |
| | | for (Attribute attr : attrList) { |
| | | for (ByteString value : attr) { |
| | | valuesList.add(value.toString()); |
| | | } |
| | | for (Attribute attr : entry.getAttribute(attrName)) { |
| | | for (ByteString value : attr) { |
| | | valuesList.add(value.toString()); |
| | | } |
| | | } |
| | | return valuesList; |
| | |
| | | if (!includeSubordinates) |
| | | { |
| | | // It's possible that there could be an attribute without any |
| | | // values, which we should treat as not having the requested |
| | | // attribute. |
| | | // values, which we should treat as not having the requested attribute. |
| | | Attribute attribute = getExactAttribute(attributeType, options); |
| | | return attribute != null && !attribute.isEmpty(); |
| | | } |
| | |
| | | for (Attribute attribute : attributes) |
| | | { |
| | | // It's possible that there could be an attribute without any |
| | | // values, which we should treat as not having the requested |
| | | // attribute. |
| | | // values, which we should treat as not having the requested attribute. |
| | | if (!attribute.isEmpty() && attribute.hasAllOptions(options)) |
| | | { |
| | | return true; |
| | |
| | | * @param attributeType |
| | | * The attribute type to retrieve. |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if the specified |
| | | * attribute type, or an empty list if the specified |
| | | * attribute type is not present in this entry. |
| | | */ |
| | | public List<Attribute> getAttribute(AttributeType attributeType) |
| | |
| | | * being retrieved. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if the specified |
| | | * attribute type, or an empty list if the specified |
| | | * attribute type is not present in this entry. |
| | | */ |
| | | public List<Attribute> getAttribute(AttributeType attributeType, |
| | |
| | | addAllIfNotNull(attributes, operationalAttributes.get(at)); |
| | | } |
| | | |
| | | if (!attributes.isEmpty()) |
| | | { |
| | | return attributes; |
| | | } |
| | | return null; |
| | | return attributes; |
| | | } |
| | | |
| | | List<Attribute> attributes = userAttributes.get(attributeType); |
| | |
| | | { |
| | | return newArrayList(getObjectClassAttribute()); |
| | | } |
| | | return null; |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * formatted in all lowercase characters. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if the specified |
| | | * attribute type, or an empty list if the specified |
| | | * attribute type is not present in this entry. |
| | | */ |
| | | public List<Attribute> getAttribute(String lowerName) |
| | |
| | | { |
| | | return newLinkedList(getObjectClassAttribute()); |
| | | } |
| | | return null; |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * include in matching elements. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if the specified |
| | | * attribute type, or an empty list if the specified |
| | | * attribute type is not present in this entry with the |
| | | * provided set of options. |
| | | */ |
| | | public List<Attribute> getAttribute(AttributeType attributeType, |
| | | Set<String> options) |
| | | { |
| | | return getAttribute(attributeType, true, options); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the requested attribute element(s) for the specified |
| | | * attribute type. The list returned may include multiple elements |
| | | * if the same attribute exists in the entry multiple times with |
| | | * different sets of options. |
| | | * |
| | | * @param attributeType The attribute type to retrieve. |
| | | * @param includeSubordinates Whether to include any subordinate |
| | | * attributes of the attribute type |
| | | * being retrieved. |
| | | * @param options The set of attribute options to |
| | | * include in matching elements. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if the specified |
| | | * attribute type is not present in this entry with the |
| | | * provided set of options. |
| | | */ |
| | | public List<Attribute> getAttribute(AttributeType attributeType, |
| | | boolean includeSubordinates, |
| | | Set<String> options) |
| | | { |
| | | List<Attribute> attributes = new LinkedList<>(); |
| | | if (includeSubordinates && attributeType.mayHaveSubordinateTypes()) |
| | | if (attributeType.mayHaveSubordinateTypes()) |
| | | { |
| | | addAllIfNotNull(attributes, userAttributes.get(attributeType)); |
| | | addAllIfNotNull(attributes, operationalAttributes.get(attributeType)); |
| | |
| | | attributes.add(getObjectClassAttribute()); |
| | | return attributes; |
| | | } |
| | | return null; |
| | | return Collections.emptyList(); |
| | | } |
| | | } |
| | | attributes.addAll(attrs); |
| | |
| | | |
| | | onlyKeepAttributesWithAllOptions(attributes, options); |
| | | |
| | | if (!attributes.isEmpty()) |
| | | { |
| | | return attributes; |
| | | } |
| | | return null; |
| | | return attributes; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the requested attribute element(s) for the attribute |
| | | * with the specified name or OID and set of options. The list |
| | | * returned may include multiple elements if the same attribute |
| | | * exists in the entry multiple times with different sets of |
| | | * matching options. |
| | | * <BR><BR> |
| | | * Note that this method should only be used in cases in which the |
| | | * Directory Server schema has no reference of an attribute type |
| | | * with the specified name. It is not as accurate or efficient as |
| | | * the version of this method that takes an |
| | | * <CODE>AttributeType</CODE> argument. |
| | | * |
| | | * @param lowerName The name or OID of the attribute to return, |
| | | * formatted in all lowercase characters. |
| | | * @param options The set of attribute options to include in |
| | | * matching elements. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if the specified |
| | | * attribute type is not present in this entry. |
| | | */ |
| | | public List<Attribute> getAttribute(String lowerName, |
| | | Set<String> options) |
| | | { |
| | | for (AttributeType attr : userAttributes.keySet()) |
| | | { |
| | | if (attr.hasNameOrOID(lowerName)) |
| | | { |
| | | return getAttribute(attr, options); |
| | | } |
| | | } |
| | | |
| | | for (AttributeType attr : operationalAttributes.keySet()) |
| | | { |
| | | if (attr.hasNameOrOID(lowerName)) |
| | | { |
| | | return getAttribute(attr, options); |
| | | } |
| | | } |
| | | |
| | | if (lowerName.equals(OBJECTCLASS_ATTRIBUTE_TYPE_NAME) && |
| | | (options == null || options.isEmpty())) |
| | | { |
| | | return newLinkedList(getObjectClassAttribute()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns a parser for the named attribute contained in this entry. |
| | | * <p> |
| | |
| | | throws LocalizedIllegalArgumentException, NullPointerException |
| | | { |
| | | final List<Attribute> attribute = getAttribute(attributeDescription); |
| | | boolean notEmpty = attribute != null && !attribute.isEmpty(); |
| | | return AttributeParser.parseAttribute(notEmpty ? attribute.get(0) : null); |
| | | return AttributeParser.parseAttribute(!attribute.isEmpty() ? attribute.get(0) : null); |
| | | } |
| | | |
| | | |
| | |
| | | * @param attributeType The attribute type to retrieve. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if there is no such |
| | | * attribute type, or an empty list if there is no such |
| | | * user attribute. |
| | | */ |
| | | public List<Attribute> getUserAttribute(AttributeType attributeType) |
| | |
| | | { |
| | | addAllIfNotNull(attributes, attrs.get(at)); |
| | | } |
| | | |
| | | if (!attributes.isEmpty()) |
| | | { |
| | | return attributes; |
| | | } |
| | | return null; |
| | | return attributes; |
| | | } |
| | | return attrs.get(attributeType); |
| | | List<Attribute> results = attrs.get(attributeType); |
| | | return results != null ? results : Collections.<Attribute> emptyList(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the requested user attribute element(s) for the |
| | | * specified attribute type. The list returned may include multiple |
| | | * elements if the same attribute exists in the entry multiple times |
| | | * with different sets of options. |
| | | * |
| | | * @param attributeType The attribute type to retrieve. |
| | | * @param options The set of attribute options to include in |
| | | * matching elements. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if there is no such |
| | | * user attribute with the specified set of options. |
| | | */ |
| | | public List<Attribute> getUserAttribute(AttributeType attributeType, |
| | | Set<String> options) |
| | | { |
| | | return getAttribute(attributeType, options, userAttributes); |
| | | } |
| | | |
| | | /** |
| | | * Returns the List of attributes for a given attribute type having all the |
| | | * required options. |
| | | * |
| | |
| | | } |
| | | |
| | | onlyKeepAttributesWithAllOptions(attributes, options); |
| | | |
| | | if (!attributes.isEmpty()) |
| | | { |
| | | return attributes; |
| | | } |
| | | return null; |
| | | return attributes; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param attributeType The attribute type to retrieve. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if there is no such |
| | | * attribute type, or an empty list if there is no such |
| | | * operational attribute. |
| | | */ |
| | | public List<Attribute> getOperationalAttribute(AttributeType attributeType) |
| | |
| | | * matching elements. |
| | | * |
| | | * @return The requested attribute element(s) for the specified |
| | | * attribute type, or <CODE>null</CODE> if there is no such |
| | | * attribute type, or an empty list if there is no such |
| | | * operational attribute with the specified set of options. |
| | | */ |
| | | public List<Attribute> getOperationalAttribute( |
| | |
| | | * @return <CODE>true</CODE> if this entry contains the specified |
| | | * attribute value, or <CODE>false</CODE> if it does not. |
| | | */ |
| | | public boolean hasValue(AttributeType attributeType, |
| | | Set<String> options, ByteString value) |
| | | public boolean hasValue(AttributeType attributeType, Set<String> options, ByteString value) |
| | | { |
| | | List<Attribute> attrList = getAttribute(attributeType, true); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | for (Attribute a : attrList) |
| | | for (Attribute a : getAttribute(attributeType)) |
| | | { |
| | | if (a.optionsEqual(options) && a.contains(value)) |
| | | { |
| | |
| | | try |
| | | { |
| | | DN inheritFromDN = null; |
| | | for (Attribute attr : getAttribute( |
| | | subEntry.getInheritFromDNType())) |
| | | for (Attribute attr : getAttribute(subEntry.getInheritFromDNType())) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | for (Attribute attr : getAttribute( |
| | | subEntry.getInheritFromRDNAttrType())) |
| | | for (Attribute attr : getAttribute(subEntry.getInheritFromRDNAttrType())) |
| | | { |
| | | inheritFromDN = subEntry.getInheritFromBaseDN(); |
| | | for (ByteString value : attr) |
| | |
| | | else |
| | | { |
| | | List<Attribute> attrList = getUserAttribute(attrType); |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | mergeAttributeLists(attrList, userAttrsCopy, attrType, |
| | | attrName, options, omitValues, omitReal, omitVirtual); |
| | |
| | | else |
| | | { |
| | | attrList = getOperationalAttribute(attrType); |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | mergeAttributeLists(attrList, operationalAttrsCopy, |
| | | attrType, attrName, options, omitValues, omitReal, |
| | |
| | | } |
| | | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, |
| | | attributeOptions); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | if (attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | if (attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | return ConditionResult.FALSE; |
| | | } |
| | | |
| | | // Iterate through all the attributes and see if we can find a |
| | | // match. |
| | | // Iterate through all the attributes and see if we can find a match. |
| | | ConditionResult result = ConditionResult.FALSE; |
| | | for (Attribute a : attrs) |
| | | { |
| | |
| | | } |
| | | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = |
| | | entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | } |
| | | |
| | | // See if the entry has an attribute with the requested type. |
| | | List<Attribute> attrs = |
| | | entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | List<Attribute> attrs = entry.getAttribute(attributeType, attributeOptions); |
| | | if (attrs.isEmpty()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(attributeType, |
| | | attributeOptions); |
| | | if (attrList != null) |
| | | for (Attribute a : entry.getAttribute(attributeType, attributeOptions)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | try |
| | | { |
| | | try |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | | ByteString nv = matchingRule.normalizeAttributeValue(v); |
| | | ConditionResult r = assertion.matches(nv); |
| | | switch (r) |
| | | { |
| | | case TRUE: |
| | | return ConditionResult.TRUE; |
| | | case FALSE: |
| | | break; |
| | | case UNDEFINED: |
| | | result = ConditionResult.UNDEFINED; |
| | | break; |
| | | default: |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_RESULT_TYPE. |
| | | get(entry.getName(), completeFilter, r); |
| | | throw new DirectoryException( |
| | | ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | // We couldn't normalize one of the values. If we don't |
| | | // find a definite match, then we should return |
| | | // undefined. |
| | | case TRUE: |
| | | return ConditionResult.TRUE; |
| | | case FALSE: |
| | | break; |
| | | case UNDEFINED: |
| | | result = ConditionResult.UNDEFINED; |
| | | break; |
| | | default: |
| | | LocalizableMessage message = |
| | | ERR_SEARCH_FILTER_INVALID_RESULT_TYPE.get(entry.getName(), completeFilter, r); |
| | | throw new DirectoryException(ResultCode.PROTOCOL_ERROR, message); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | // We couldn't normalize one of the values. |
| | | // If we don't find a definite match, then we should return undefined. |
| | | result = ConditionResult.UNDEFINED; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | String specString = null; |
| | | boolean isValidSpec = true; |
| | | AttributeType specAttrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_SUBTREE_SPEC_LC); |
| | | List<Attribute> specAttrList = entry.getAttribute(specAttrType); |
| | | if (specAttrList != null) |
| | | for (Attribute attr : entry.getAttribute(specAttrType)) |
| | | { |
| | | for (Attribute attr : specAttrList) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (ByteString value : attr) |
| | | specString = value.toString(); |
| | | try |
| | | { |
| | | specString = value.toString(); |
| | | try |
| | | { |
| | | this.subTreeSpec = SubtreeSpecification.valueOf( |
| | | entry.getName().parent(), specString); |
| | | isValidSpec = true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | isValidSpec = false; |
| | | } |
| | | if (this.subTreeSpec != null) |
| | | { |
| | | break; |
| | | } |
| | | this.subTreeSpec = SubtreeSpecification.valueOf(entry.getName().parent(), specString); |
| | | isValidSpec = true; |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | isValidSpec = false; |
| | | } |
| | | if (this.subTreeSpec != null) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if (this.subTreeSpec != null) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // Check that the subtree spec is flagged as valid. If it is not |
| | |
| | | { |
| | | if (this.isInheritedFromDNCollective) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute( |
| | | ATTR_INHERIT_COLLECTIVE_FROM_DN); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_DN)) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | this.inheritFromDNAttrValue = value; |
| | | break; |
| | | } |
| | | this.inheritFromDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | this.inheritFromDNAttrValue = value; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (this.isInheritedFromRDNCollective) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN)) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromRDNAttrType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | this.inheritFromRDNAttrValue = value; |
| | | break; |
| | | } |
| | | this.inheritFromRDNAttrType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | this.inheritFromRDNAttrValue = value; |
| | | break; |
| | | } |
| | | } |
| | | attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN_TYPE); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_RDN_TYPE)) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | this.inheritFromRDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | break; |
| | | } |
| | | this.inheritFromRDNType = DirectoryServer.getAttributeTypeOrDefault(value.toString().toLowerCase()); |
| | | break; |
| | | } |
| | | } |
| | | attrList = entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_BASE); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_FROM_BASE)) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | // Has to have a parent since subentry itself |
| | | // cannot be a suffix entry within the server. |
| | | this.inheritFromBaseDN = getDN().parent().child(DN.decode(value)); |
| | | break; |
| | | } |
| | | // Has to have a parent since subentry itself |
| | | // cannot be a suffix entry within the server. |
| | | this.inheritFromBaseDN = getDN().parent().child(DN.decode(value)); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<Attribute> attrList = entry.getAttribute( |
| | | ATTR_INHERIT_COLLECTIVE_ATTR); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | for (Attribute attr : entry.getAttribute(ATTR_INHERIT_COLLECTIVE_ATTR)) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (ByteString value : attr) |
| | | { |
| | | CollectiveVirtualAttribute collectiveAttr = |
| | | new CollectiveVirtualAttribute( |
| | | Attributes.empty(value.toString())); |
| | | this.collectiveAttributes.add(collectiveAttr); |
| | | } |
| | | CollectiveVirtualAttribute collectiveAttr = |
| | | new CollectiveVirtualAttribute(Attributes.empty(value.toString())); |
| | | this.collectiveAttributes.add(collectiveAttr); |
| | | } |
| | | } |
| | | } |
| | |
| | | // Establish collective attribute conflict behavior. |
| | | if (this.isCollective || this.isInheritedCollective) |
| | | { |
| | | List<Attribute> attrList = entry.getAttribute( |
| | | ATTR_COLLECTIVE_CONFLICT_BEHAVIOR); |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | for (Attribute attr : entry.getAttribute(ATTR_COLLECTIVE_CONFLICT_BEHAVIOR)) |
| | | { |
| | | for (Attribute attr : attrList) |
| | | for (ByteString value : attr) |
| | | { |
| | | for (ByteString value : attr) |
| | | for (CollectiveConflictBehavior behavior : CollectiveConflictBehavior.values()) |
| | | { |
| | | for (CollectiveConflictBehavior behavior : |
| | | CollectiveConflictBehavior.values()) |
| | | if (behavior.toString().equals(value.toString())) |
| | | { |
| | | if (behavior.toString().equals(value.toString())) |
| | | { |
| | | this.conflictBehavior = behavior; |
| | | break; |
| | | } |
| | | this.conflictBehavior = behavior; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | // See if a password was specified. |
| | | AttributeType passwordAttribute = passwordPolicy.getPasswordAttribute(); |
| | | List<Attribute> attrList = entry.getAttribute(passwordAttribute); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | // The entry doesn't have a password, so no action is required. |
| | | return; |
| | |
| | | PasswordPolicy policy = pwPolicyState.getAuthenticationPolicy(); |
| | | |
| | | AttributeType pwType = policy.getPasswordAttribute(); |
| | | List<Attribute> pwAttr = userEntry.getAttribute(pwType); |
| | | if (pwAttr == null || pwAttr.isEmpty()) |
| | | if (userEntry.getAttribute(pwType).isEmpty()) |
| | | { |
| | | throw new DirectoryException(ResultCode.INVALID_CREDENTIALS, |
| | | ERR_BIND_OPERATION_NO_PASSWORD.get()); |
| | |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attributeTypeName); |
| | | List<Attribute> attrList = userEntry.getAttribute(attrType); |
| | | if (attrList != null && attrList.size() == 1) |
| | | if (attrList.size() == 1) |
| | | { |
| | | Attribute a = attrList.get(0); |
| | | if (a.size() == 1) |
| | |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | |
| | | |
| | | // Actually perform the compare operation. |
| | | List<Attribute> attrList = entry.getAttribute(attrType, options); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | setResultCode(ResultCode.NO_SUCH_ATTRIBUTE); |
| | | Arg2<Object, Object> errorMsg = options == null |
| | |
| | | // We still need to check if the pre-encoded password matches |
| | | // an existing value, to decrease the number of passwords. |
| | | List<Attribute> attrList = currentEntry.getAttribute(pwAttr.getAttributeType()); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_NO_EXISTING_VALUES.get()); |
| | | } |
| | |
| | | else |
| | | { |
| | | List<Attribute> attrList = currentEntry.getAttribute(pwAttr.getAttributeType()); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, |
| | | ERR_MODIFY_NO_EXISTING_VALUES.get()); |
| | | throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, ERR_MODIFY_NO_EXISTING_VALUES.get()); |
| | | } |
| | | |
| | | if (addIfAttributeValueExistsNoPreEncodedPassword(builder, attrList, v)) |
| | |
| | | public static HashSet<PluginType> getPluginTypes(Entry e) |
| | | { |
| | | HashSet<PluginType> pluginTypes = new HashSet<>(); |
| | | List<Attribute> attrList = e.getAttribute("ds-cfg-plugin-type"); |
| | | if (attrList != null) |
| | | for (Attribute a : e.getAttribute("ds-cfg-plugin-type")) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | pluginTypes.add(PluginType.forName(v.toString().toLowerCase())); |
| | | } |
| | | pluginTypes.add(PluginType.forName(v.toString().toLowerCase())); |
| | | } |
| | | } |
| | | return pluginTypes; |
| | |
| | | |
| | | // Save Global ACI. |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf(ACCESS_HANDLER_DN)); |
| | | List<Attribute> attrs = |
| | | e.getAttribute(ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI); |
| | | if (attrs != null && !attrs.isEmpty()) |
| | | List<Attribute> attrs = e.getAttribute(ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI); |
| | | if (!attrs.isEmpty()) |
| | | { |
| | | Reporter.log("Saved global ACI attribute"); |
| | | |
| | |
| | | private static String getAttributeValue(Entry entry, String attrName) |
| | | { |
| | | List<Attribute> attrs = entry.getAttribute(attrName.toLowerCase()); |
| | | if (attrs == null) |
| | | if (attrs.isEmpty()) |
| | | { |
| | | return null; |
| | | } |
| | |
| | | } |
| | | |
| | | // check the user attributes were not changed |
| | | for (AttributeType attrType : entryBefore.getUserAttributes() |
| | | .keySet()) { |
| | | for (AttributeType attrType : entryBefore.getUserAttributes().keySet()) { |
| | | List<Attribute> listBefore = entryBefore.getAttribute(attrType); |
| | | List<Attribute> listAfter = entryAfter.getAttribute(attrType); |
| | | |
| | | assertNotNull(listAfter); |
| | | assertEquals(listBefore.size(), listAfter.size()); |
| | | assertThat(listBefore).hasSameSizeAs(listAfter); |
| | | |
| | | for (Attribute attrBefore : listBefore) { |
| | | boolean found = false; |
| | |
| | | for (Attribute attrAfter : listAfter) { |
| | | if (attrAfter.optionsEqual(attrBefore.getOptions())) { |
| | | // Found the corresponding attribute |
| | | |
| | | assertEquals(attrBefore, attrAfter); |
| | | found = true; |
| | | } |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test")); |
| | | List<Attribute> attrList = e.getAttribute(a.getAttributeType()); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | |
| | | boolean foundFoo = false; |
| | |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test")); |
| | | List<Attribute> attrList = e.getAttribute(a.getAttributeType()); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(e.getAttribute(a.getAttributeType())).isNotEmpty(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | } |
| | |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test")); |
| | | List<Attribute> attrList = e.getAttribute(attrType); |
| | | assertNull(attrList); |
| | | assertThat(e.getAttribute(attrType)).isEmpty(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | } |
| | |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("ou=People,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("ou"); |
| | | assertNotNull(attrList); |
| | | assertThat(attrList).isNotEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | retrieveCompletedOperationElements(addOperation); |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user,o=test")); |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getObjectClassAttributeType()); |
| | | assertNotNull(attrList); |
| | | List<Attribute> attrList = e.getAttribute(DirectoryServer.getObjectClassAttributeType()); |
| | | |
| | | boolean found = false; |
| | | for (Attribute a : attrList) |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | |
| | | public void testGetAndAddModifications() throws Exception |
| | | { |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | assertNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))); |
| | | assertThat(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))).isEmpty(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | UpdatePreOpPlugin.addModification( |
| | |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | assertNotNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))); |
| | | assertThat(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))).isNotEmpty(); |
| | | |
| | | UpdatePreOpPlugin.reset(); |
| | | } |
| | |
| | | public void testSuccessAddAttribute() throws Exception |
| | | { |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | assertNull(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))); |
| | | assertThat(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))).isEmpty(); |
| | | |
| | | 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.getAttributeTypeOrDefault("description"))); |
| | | assertThat(e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("description"))).isNotEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("o=test")); |
| | | |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o")); |
| | | List<Attribute> attrList = e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o")); |
| | | assertEquals(countValues(attrList), 1); |
| | | |
| | | LDAPAttribute attr = newLDAPAttribute("o", "test2"); |
| | |
| | | { |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf(baseDN)); |
| | | |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o")); |
| | | List<Attribute> attrList = e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("o")); |
| | | assertEquals(countValues(attrList), 1); |
| | | |
| | | LDAPAttribute attr = newLDAPAttribute("o;lang-en-us", "test"); |
| | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); |
| | | List<Attribute> attrList = |
| | | 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.getAttributeTypeOrDefault("employeenumber")); |
| | | assertNotNull(attrList); |
| | | assertIntegerValueExists(attrList, 11); |
| | | } |
| | | |
| | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("employeenumber")); |
| | | assertNotNull(attrList); |
| | | assertIntegerValueExists(attrList, 0); |
| | | } |
| | | |
| | |
| | | |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("userpassword")); |
| | | assertNotNull(attrList); |
| | | |
| | | String passwd = null; |
| | | for (Attribute a : attrList) |
| | |
| | | |
| | | e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("userpassword"); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | assertFalse(attrList.get(0).hasOptions()); |
| | | assertEquals(attrList.get(0).size(), 1); |
| | |
| | | |
| | | e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("userpassword"); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | assertFalse(attrList.get(0).hasOptions()); |
| | | assertEquals(attrList.get(0).size(), 1); |
| | |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("userpassword"); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | assertFalse(attrList.get(0).hasOptions()); |
| | | assertEquals(attrList.get(0).size(), 1); |
| | |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test")); |
| | | List<Attribute> attrList = e.getAttribute("userpassword"); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | assertFalse(attrList.get(0).hasOptions()); |
| | | assertEquals(attrList.get(0).size(), 1); |
| | |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | Entry e = DirectoryServer.getEntry(DN.valueOf("uid=test.user," + baseDN)); |
| | | List<Attribute> attrList = |
| | | e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("usercertificate")); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | List<Attribute> attrList = e.getAttribute(DirectoryServer.getAttributeTypeOrDefault("usercertificate")); |
| | | assertThat(attrList).hasSize(1); |
| | | Attribute a = attrList.get(0); |
| | | assertTrue(a.hasOption("binary")); |
| | | assertEquals(a.size(), 1); |
| | |
| | | |
| | | if (stripVirtualAttributes) |
| | | { |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | messages.add("Unexpected virtual attribute: " + attrType); |
| | | } |
| | | } |
| | | else if (filterType == AttributeFilterType.DEFAULT) |
| | | { |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | messages.add("Unexpected operational attribute: " + attrType); |
| | | } |
| | |
| | | else if ("ismemberof".equals(attrType)) |
| | | { |
| | | // isMemberOf should never be returned as user is not in any groups. |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | messages.add("Unexpected isMemberOf attribute"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (attrList == null) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | messages.add("Missing virtual attribute: " + attrType); |
| | | } |
| | |
| | | |
| | | if (stripRealAttributes) |
| | | { |
| | | if (attrList != null) |
| | | if (!attrList.isEmpty()) |
| | | { |
| | | messages.add("Unexpected real attribute: " + attrType); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (attrList == null) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | messages.add("Missing real attribute: " + attrType); |
| | | } |
| | |
| | | assertNotNull(e); |
| | | |
| | | List<Attribute> description = e.getAttribute("description"); |
| | | assertNull(description); |
| | | assertThat(description).isEmpty(); |
| | | |
| | | // Collective user will inherit the collective description attribute. |
| | | e = DirectoryServer.getEntry(DN.valueOf("uid=collective user,ou=people,o=test")); |
| | | assertNotNull(e); |
| | | |
| | | description = e.getAttribute("description"); |
| | | assertNotNull(description); |
| | | assertEquals(description.size(), 1); |
| | | assertThat(description).hasSize(1); |
| | | Attribute attribute = description.get(0); |
| | | assertEquals(attribute.size(), 1); |
| | | assertFalse(attribute.hasOptions()); |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | { |
| | | AttributeType at = DirectoryServer.getAttributeTypeOrNull(attrName); |
| | | List<Attribute> attrList = newEntry.getAttribute(at); |
| | | assertEquals(attrList.size(), 1); |
| | | assertThat(attrList).hasSize(1); |
| | | |
| | | // Because deleteOldRDN is true, the values from RDN and the entry have to be identical |
| | | ByteString valueFromEntry = attrList.get(0).iterator().next(); |
| | |
| | | runModifyDNOperation(oldEntryDN, "cn=Aaccf Amar Test", true, "dc=example,dc=com"); |
| | | assertSuccess(modifyDNOperation); |
| | | Entry entry = assertCnAttrValues(newEntryDN, oldEntryDN); |
| | | assertNull(entry.getAttribute("uid")); |
| | | assertThat(entry.getAttribute("uid")).isEmpty(); |
| | | examineCompletedOPNoExtraPluginCounts(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | |
| | | assertTrue(e.hasAttribute(entryDNType)); |
| | | |
| | | List<Attribute> attrList = e.getAttribute(entryDNType); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(attrList).isNotEmpty(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | assertTrue(e.hasAttribute(entryUUIDType)); |
| | | |
| | | List<Attribute> attrList = e.getAttribute(entryUUIDType); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(attrList).isNotEmpty(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | |
| | | assertTrue(e.hasAttribute(entryUUIDType)); |
| | | |
| | | List<Attribute> attrList = e.getAttribute(entryUUIDType); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(attrList).isNotEmpty(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | assertTrue(e.hasAttribute(governingStructureRuleType)); |
| | | |
| | | List<Attribute> attrList = e.getAttribute(governingStructureRuleType); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(attrList).isNotEmpty(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | assertTrue(e.hasAttribute(hasSubordinatesType)); |
| | | |
| | | List<Attribute> attrList = e.getAttribute(hasSubordinatesType); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(attrList).isNotEmpty(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | assertTrue(e.hasAttribute(numSubordinatesType)); |
| | | |
| | | List<Attribute> attrList = e.getAttribute(numSubordinatesType); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(attrList).isNotEmpty(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | |
| | | assertNotNull(entry); |
| | | |
| | | List<Attribute> attrs = entry.getAttribute(attributeName); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | Attribute attr = attrs.get(0); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | assertTrue(e.hasAttribute(structuralObjectClassType)); |
| | | |
| | | List<Attribute> attrList = e.getAttribute(structuralObjectClassType); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(attrList).isNotEmpty(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | assertTrue(e.hasAttribute(subschemaSubentryType)); |
| | | |
| | | List<Attribute> attrList = e.getAttribute(subschemaSubentryType); |
| | | assertNotNull(attrList); |
| | | assertFalse(attrList.isEmpty()); |
| | | assertThat(attrList).isNotEmpty(); |
| | | for (Attribute a : attrList) |
| | | { |
| | | assertFalse(a.isEmpty()); |
| | |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | | descriptionType); |
| | | assertNotNull(attrList); |
| | | List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType); |
| | | assertEquals(attrList.size(), 1); |
| | | |
| | | Attribute attr = attrList.get(0); |
| | |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | | descriptionType); |
| | | assertNotNull(attrList); |
| | | List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType); |
| | | assertEquals(attrList.size(), 1); |
| | | |
| | | Attribute attr = attrList.get(0); |
| | |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | | descriptionType); |
| | | assertNotNull(attrList); |
| | | List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType); |
| | | assertEquals(attrList.size(), 1); |
| | | |
| | | Attribute attr = attrList.get(0); |
| | |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | | descriptionType); |
| | | assertNotNull(attrList); |
| | | List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType); |
| | | assertEquals(attrList.size(), 1); |
| | | |
| | | Attribute attr = attrList.get(0); |
| | |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | | descriptionType); |
| | | assertNotNull(attrList); |
| | | List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType); |
| | | assertEquals(attrList.size(), 1); |
| | | |
| | | Attribute a = attrList.get(0); |
| | |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | |
| | | Attribute a = attrList.get(0); |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.util.ArrayList; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.plugins.EntryUUIDPlugin class. |
| | |
| | | DirectoryServer.getPluginConfigManager().getRegisteredPlugin(dn); |
| | | plugin.doLDIFImport(importConfig, e); |
| | | |
| | | assertNotNull(e.getAttribute("entryuuid")); |
| | | assertThat(e.getAttribute("entryuuid")).isNotEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | DirectoryServer.getPluginConfigManager().getRegisteredPlugin(dn); |
| | | plugin.doLDIFImport(importConfig, e); |
| | | |
| | | assertNotNull(e.getAttribute("entryuuid")); |
| | | assertThat(e.getAttribute("entryuuid")).isNotEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | "objectClass: top", |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | assertNotNull(e.getAttribute("entryuuid")); |
| | | assertThat(e.getAttribute("entryuuid")).isNotEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | "objectClass: device", |
| | | "cn: test", |
| | | "entryUUID: " + UUID.randomUUID()); |
| | | assertNotNull(e.getAttribute("entryuuid")); |
| | | assertThat(e.getAttribute("entryuuid")).isNotEmpty(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.plugins.LDAPADListPlugin class. |
| | |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e.getAttribute("o")); |
| | | assertThat(e.getAttribute("o")).isNotEmpty(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.plugins.LastModPlugin class. |
| | |
| | | "objectClass: top", |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | assertNotNull(e.getAttribute("creatorsname")); |
| | | assertNotNull(e.getAttribute("createtimestamp")); |
| | | assertThat(e.getAttribute("creatorsname")).isNotEmpty(); |
| | | assertThat(e.getAttribute("createtimestamp")).isNotEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Entry e = DirectoryConfig.getEntry(DN.valueOf("o=test")); |
| | | assertNotNull(e); |
| | | assertNotNull(e.getAttribute("modifiersname")); |
| | | assertNotNull(e.getAttribute("modifytimestamp")); |
| | | assertThat(e.getAttribute("modifiersname")).isNotEmpty(); |
| | | assertThat(e.getAttribute("modifytimestamp")).isNotEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | e = DirectoryConfig.getEntry(DN.valueOf("cn=test2,o=test")); |
| | | assertNotNull(e); |
| | | assertNotNull(e.getAttribute("modifiersname")); |
| | | assertNotNull(e.getAttribute("modifytimestamp")); |
| | | assertThat(e.getAttribute("modifiersname")).isNotEmpty(); |
| | | assertThat(e.getAttribute("modifytimestamp")).isNotEmpty(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | assertNotNull(entry); |
| | | |
| | | List<Attribute> sambaAttribute = entry.getAttribute("sambantpassword"); |
| | | assertNotNull(sambaAttribute); |
| | | boolean foundNTPassword = false; |
| | | for (Attribute a : sambaAttribute) |
| | | { |
| | |
| | | assertTrue(foundNTPassword, "NT password not found in test entry"); |
| | | |
| | | sambaAttribute = entry.getAttribute("sambalmpassword"); |
| | | assertNotNull(sambaAttribute); |
| | | boolean foundLMPassword = false; |
| | | for (Attribute a : sambaAttribute) |
| | | { |
| | |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | assertNotNull(entry); |
| | | assertNull(entry.getAttribute("sambantpassword")); |
| | | assertNull(entry.getAttribute("sambalmpassword")); |
| | | assertThat(entry.getAttribute("sambantpassword")).isEmpty(); |
| | | assertThat(entry.getAttribute("sambalmpassword")).isEmpty(); |
| | | |
| | | TestCaseUtils.deleteEntry(entry); |
| | | } |
| | |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | assertNotNull(entry); |
| | | |
| | | List<Attribute> sambaAttribute = entry.getAttribute("sambantpassword"); |
| | | |
| | | assertNull(sambaAttribute); |
| | | |
| | | sambaAttribute = entry.getAttribute("sambalmpassword"); |
| | | |
| | | assertNull(sambaAttribute); |
| | | assertThat(entry.getAttribute("sambantpassword")).isEmpty(); |
| | | assertThat(entry.getAttribute("sambalmpassword")).isEmpty(); |
| | | |
| | | TestCaseUtils.deleteEntry(entry); |
| | | } |
| | |
| | | */ |
| | | private boolean assertConflictAttributeExists(Entry entry) |
| | | { |
| | | return entry.getAttribute("ds-sync-confict") != null; |
| | | return !entry.getAttribute("ds-sync-confict").isEmpty(); |
| | | } |
| | | |
| | | @DataProvider(name="assured") |
| | |
| | | } |
| | | |
| | | List<Attribute> attrs = entry.getAttribute(assuredAttr); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | if (attrs.isEmpty()) |
| | | { |
| | | return Collections.emptyMap(); |
| | | } |
| | |
| | | |
| | | private List<ByteString> getValues(List<Attribute> attributes) |
| | | { |
| | | if (attributes != null) |
| | | if (!attributes.isEmpty()) |
| | | { |
| | | assertThat(attributes).hasSize(1); |
| | | return getValues(attributes.get(0)); |
| | |
| | | |
| | | private ByteString getActualValue(List<Attribute> attributes) |
| | | { |
| | | if (attributes != null) |
| | | if (!attributes.isEmpty()) |
| | | { |
| | | assertThat(attributes).hasSize(1); |
| | | Attribute attribute = attributes.get(0); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.fail; |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | |
| | | AttributeType synchronizationGenIDType = |
| | | DirectoryServer.getAttributeTypeOrNull(REPLICATION_GENERATION_ID); |
| | | List<Attribute> attrs = |
| | | resultEntry.getAttribute(synchronizationGenIDType); |
| | | if (attrs != null) |
| | | List<Attribute> attrs = resultEntry.getAttribute(synchronizationGenIDType); |
| | | if (!attrs.isEmpty()) |
| | | { |
| | | Attribute attr = attrs.get(0); |
| | | if (attr.size() == 1) |
| | |
| | | * Check that the provided entry has a single value attribute which has the |
| | | * expected attribute value |
| | | */ |
| | | private static void checkEntryAttributeValue(Entry entry, String attributeName, |
| | | String attributeValue) |
| | | private static void checkEntryAttributeValue(Entry entry, String attributeName, String attributeValue) |
| | | { |
| | | List<Attribute> attrs = entry.getAttribute(attributeName.toLowerCase()); |
| | | assertNotNull(attrs, "Was expecting attribute " + attributeName + "=" + |
| | | attributeValue + " but got no attribute"); |
| | | assertEquals(attrs.size(), 1); |
| | | assertThat(attrs).as("Was expecting attribute " + attributeName + "=" + attributeValue).hasSize(1); |
| | | Attribute attr = attrs.get(0); |
| | | assertNotNull(attr); |
| | | Iterator<ByteString> attrValues = attr.iterator(); |
| | | assertNotNull(attrValues); |
| | | assertTrue(attrValues.hasNext()); |
| | | ByteString attrValue = attrValues.next(); |
| | | assertNotNull(attrValue); |
| | | assertFalse(attrValues.hasNext()); |
| | | assertEquals(attrValue.toString(), attributeValue, "Was expecting attribute " + |
| | | attributeName + "=" + attributeValue + " but got value: " + attrValue); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | replicationDomain.publish(modDnMsg); |
| | | |
| | | /* |
| | | * check that entry has been renamed and has only attribute left in the |
| | | * new RDN |
| | | */ |
| | | // check that entry has been renamed and has only attribute left in the new RDN |
| | | newEntry = getEntry(newEntryDn, TIMEOUT, true); |
| | | assertNotNull(newEntry); |
| | | assertEquals(newEntryDn, newEntry.getName()); |
| | | objectClass = DirectoryServer.getObjectClass("inetOrgPerson".toLowerCase()); |
| | | assertTrue(newEntry.hasObjectClass(objectClass)); |
| | | checkEntryAttributeValue(newEntry, "displayName", "ValueToBeKept"); |
| | | assertNull(newEntry.getAttribute("description")); |
| | | assertThat(newEntry.getAttribute("description")).isEmpty(); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | replicationDomain.publish(modDnMsg); |
| | | |
| | | /* |
| | | * check that entry has been renamed and has only attribute left in the |
| | | * new RDN |
| | | */ |
| | | // check that entry has been renamed and has only attribute left in the * new RDN |
| | | newEntry = getEntry(newEntryDn, TIMEOUT, true); |
| | | assertNotNull(newEntry); |
| | | assertEquals(newEntryDn, newEntry.getName()); |
| | | objectClass = DirectoryServer.getObjectClass("inetOrgPerson".toLowerCase()); |
| | | assertTrue(newEntry.hasObjectClass(objectClass)); |
| | | checkEntryAttributeValue(newEntry, "displayName", "ValueToBeKept"); |
| | | assertNull(newEntry.getAttribute("description")); |
| | | assertThat(newEntry.getAttribute("description")).isEmpty(); |
| | | } |
| | | finally |
| | | { |
| | |
| | | testModify(entry, hist, 1, true, newModification(DELETE, DISPLAYNAME, "aValue")); |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DISPLAYNAME); |
| | | assertNull(attrs); |
| | | assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DISPLAYNAME); |
| | | assertNull(attrs); |
| | | assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertEquals(hist.encodeAndPurge(), attrDel); |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DISPLAYNAME); |
| | | assertNull(attrs); |
| | | assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DESCRIPTION); |
| | | attr = Attributes.create(DESCRIPTION, "value2", "value3", "value4"); |
| | | assertEquals(attrs.get(0), attr); |
| | | assertEquals(attrs.get(0), Attributes.create(DESCRIPTION, "value2", "value3", "value4")); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DESCRIPTION); |
| | | attr = Attributes.create(DESCRIPTION, "value3", "value4"); |
| | | assertEquals(attrs.get(0), attr); |
| | | assertEquals(attrs.get(0), Attributes.create(DESCRIPTION, "value3", "value4")); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertEquals(hist.encodeAndPurge(), attrDel); |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DISPLAYNAME); |
| | | assertNull(attrs); |
| | | assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DISPLAYNAME); |
| | | assertNull(attrs); |
| | | assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DISPLAYNAME); |
| | | assertNull(attrs); |
| | | assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertEquals(hist.encodeAndPurge(), attrDel); |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DISPLAYNAME); |
| | | assertNull(attrs); |
| | | assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | assertEquals(hist.encodeAndPurge(), attrDel); |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DISPLAYNAME); |
| | | assertNull(attrs); |
| | | assertThat(entry.getAttribute(DISPLAYNAME)).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.testng.annotations.BeforeMethod; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | |
| | | assertEquals(getEntryUUID(resultEntry.getName()), |
| | | "c9cb8c3c-615a-4122-865d-50323aaaed48", |
| | | "The wrong entry has been renamed"); |
| | | assertNull(resultEntry.getAttribute(LDAPReplicationDomain.DS_SYNC_CONFLICT)); |
| | | assertThat(resultEntry.getAttribute(LDAPReplicationDomain.DS_SYNC_CONFLICT)).isEmpty(); |
| | | } |
| | | |
| | | private AddMsg addMsg(Entry entry, CSN csn, String parentUUID, String childUUID) |
| | |
| | | assertEquals(getEntryUUID(resultEntry.getName()), |
| | | "c9cb8c3c-615a-4122-865d-50323aaaed48", |
| | | "The wrong entry has been renamed"); |
| | | assertNull(resultEntry.getAttribute(LDAPReplicationDomain.DS_SYNC_CONFLICT)); |
| | | assertThat(resultEntry.getAttribute(LDAPReplicationDomain.DS_SYNC_CONFLICT)).isEmpty(); |
| | | } |
| | | |
| | | private Entry createAndAddEntry(String commonName) throws Exception |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.util.List; |
| | | import java.util.TreeSet; |
| | | import java.util.StringTokenizer; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.NameForm; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.LDIFReader; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of generic tests that may be used to examine the |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @BeforeClass |
| | | public void setUp() |
| | | throws Exception |
| | |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("attributetypes"); |
| | | assertNotNull(attrType); |
| | | List<Attribute> attrList = e.getAttribute(attrType); |
| | | if (attrList == null) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | // No attribute types in the schema file. This is OK. |
| | | continue; |
| | |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("objectclasses"); |
| | | assertNotNull(attrType); |
| | | List<Attribute> attrList = e.getAttribute(attrType); |
| | | if (attrList == null) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | // No attribute types in the schema file. This is OK. |
| | | continue; |
| | |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrNull("nameforms"); |
| | | assertNotNull(attrType); |
| | | List<Attribute> attrList = e.getAttribute(attrType); |
| | | if (attrList == null) |
| | | if (attrList.isEmpty()) |
| | | { |
| | | // No attribute types in the schema file. This is OK. |
| | | continue; |
| | |
| | | return LocalizableMessage.raw("Dummy"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeTask() |
| | | throws DirectoryException |
| | |
| | | Entry taskEntry = getTaskEntry(); |
| | | if (taskEntry != null) |
| | | { |
| | | List<Attribute> attrList = |
| | | taskEntry.getAttribute("ds-task-dummy-sleep-time"); |
| | | if (attrList != null) |
| | | for (Attribute a : taskEntry.getAttribute("ds-task-dummy-sleep-time")) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | sleepTime = Long.parseLong(v.toString()); |
| | | } |
| | | sleepTime = Long.parseLong(v.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | package org.opends.server.tools; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.PrintStream; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.AfterClass; |
| | | import static org.testng.Assert.assertNotNull; |
| | | import static org.testng.Assert.assertNull; |
| | | import static org.testng.Assert.assertEquals; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.util.LDIFReader; |
| | | import java.io.*; |
| | | |
| | | |
| | | /** |
| | | * LDIFSearch test cases. |
| | | */ |
| | | /** LDIFSearch test cases. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class LDIFSearchTestCase extends ToolsTestCase { |
| | | |
| | | |
| | |
| | | "*", "+" |
| | | }; |
| | | assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | | Entry e=reader.readEntry(); |
| | | reader.close(); |
| | | assertNotNull(e.getAttribute("objectclass")); |
| | | Entry e = readEntry(); |
| | | assertThat(e.getAttribute("objectclass")).isNotEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @throws Exception The objectclass attribute is returned. |
| | | */ |
| | | @Test |
| | | @Test |
| | | public void testLDIFSearchOpsOnly() throws Exception { |
| | | String[] args = |
| | | { |
| | |
| | | "+" |
| | | }; |
| | | assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | | Entry e=reader.readEntry(); |
| | | reader.close(); |
| | | assertNull(e.getAttribute("objectclass")); |
| | | Entry e = readEntry(); |
| | | assertThat(e.getAttribute("objectclass")).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | "+", "mail", "uid" |
| | | }; |
| | | assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | Entry e = readEntry(); |
| | | assertThat(e.getAttribute("objectclass")).isEmpty(); |
| | | assertThat(e.getAttribute("mail")).isNotEmpty(); |
| | | assertThat(e.getAttribute("uid")).isNotEmpty(); |
| | | } |
| | | |
| | | |
| | | private Entry readEntry() throws IOException, LDIFException |
| | | { |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | | Entry e=reader.readEntry(); |
| | | reader.close(); |
| | | assertNull(e.getAttribute("objectclass")); |
| | | assertNotNull(e.getAttribute("mail")); |
| | | assertNotNull(e.getAttribute("uid")); |
| | | try (LDIFReader reader = new LDIFReader(ldifConfig)) |
| | | { |
| | | return reader.readEntry(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws Exception The objectclass attribute is returned or one of the |
| | | * specified attributes is not returned. |
| | | */ |
| | | |
| | | @Test |
| | | @Test |
| | | public void testLDIFSearchAttrsOnly() throws Exception { |
| | | |
| | | String[] args = |
| | |
| | | "mail", "uid" |
| | | }; |
| | | assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0); |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | | Entry e=reader.readEntry(); |
| | | reader.close(); |
| | | assertNull(e.getAttribute("objectclass")); |
| | | assertNotNull(e.getAttribute("mail")); |
| | | assertNotNull(e.getAttribute("uid")); |
| | | Entry e = readEntry(); |
| | | assertThat(e.getAttribute("objectclass")).isEmpty(); |
| | | assertThat(e.getAttribute("mail")).isNotEmpty(); |
| | | assertThat(e.getAttribute("uid")).isNotEmpty(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | import org.opends.server.tasks.LdifFileWriter; |
| | | import org.opends.server.tools.ToolsTestCase; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | import static org.testng.Assert.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the MakeLDIF tool. |
| | | */ |
| | |
| | | |
| | | LdifFileWriter.makeLdif(outLdifFilePath, resourcePath, lines); |
| | | |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | | Entry top = reader.readEntry(); |
| | | Entry e = reader.readEntry(); |
| | | reader.close(); |
| | | |
| | | assertNotNull(top); |
| | | Entry e = readEntry(outLdifFilePath); |
| | | assertNotNull(e); |
| | | List<Attribute> attrs = e.getAttribute(attrName); |
| | | assertFalse(attrs.isEmpty()); |
| | |
| | | assertEquals(a, expectedRes); |
| | | } |
| | | |
| | | private Entry readEntry(String outLdifFilePath) throws IOException, LDIFException |
| | | { |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | try (LDIFReader reader = new LDIFReader(ldifConfig)) |
| | | { |
| | | assertNotNull(reader.readEntry()); |
| | | return reader.readEntry(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Test for escaped characters in templates, check LDIF output when |
| | | * the templates combines escaped characters and variables. |
| | |
| | | |
| | | LdifFileWriter.makeLdif(outLdifFilePath, resourcePath, lines); |
| | | |
| | | LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath); |
| | | ldifConfig.setValidateSchema(false); |
| | | LDIFReader reader = new LDIFReader(ldifConfig); |
| | | Entry top = reader.readEntry(); |
| | | Entry e = reader.readEntry(); |
| | | reader.close(); |
| | | |
| | | assertNotNull(top); |
| | | Entry e = readEntry(outLdifFilePath); |
| | | assertNotNull(e); |
| | | List<Attribute> attrs = e.getAttribute("cn"); |
| | | assertFalse(attrs.isEmpty()); |
| | |
| | | "cn value doesn't match the expected value"); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the {@link Entry} class. |
| | | * <p> |
| | | * At the moment this test suite only tests the parseAttribute method. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public final class TestEntry extends TypesTestCase { |
| | | |
| | | /** |
| | |
| | | AttributeType uidType = DirectoryServer.getAttributeTypeOrNull("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeTypeOrNull("modifiersname"); |
| | | |
| | | List<Attribute> attrs = e.getAttribute(ocType); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | assertThat(e.getAttribute(ocType)).hasSize(1); |
| | | assertThat(e.getAttribute(cnType)).hasSize(2); |
| | | assertThat(e.getAttribute(nameType)).hasSize(6); |
| | | |
| | | attrs = e.getAttribute(cnType); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getAttribute(nameType); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 6); |
| | | |
| | | attrs = e.getAttribute(nameType, false); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(uidType); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(mnType); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | |
| | | attrs = e.getAttribute("objectclass"); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | attrs = e.getAttribute("cn"); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getAttribute("uid"); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("modifiersname"); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | assertThat(e.getAttribute(nameType, false)).isEmpty(); |
| | | assertThat(e.getAttribute(uidType)).isEmpty(); |
| | | assertThat(e.getAttribute(mnType)).hasSize(1); |
| | | assertThat(e.getAttribute("objectclass")).hasSize(1); |
| | | assertThat(e.getAttribute("cn")).hasSize(2); |
| | | assertThat(e.getAttribute("uid")).isEmpty(); |
| | | assertThat(e.getAttribute("modifiersname")).hasSize(1); |
| | | |
| | | LinkedHashSet<String> options = null; |
| | | attrs = e.getAttribute(ocType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | assertThat(e.getAttribute(ocType, options)).hasSize(1); |
| | | assertThat(e.getAttribute(cnType, options)).hasSize(2); |
| | | assertThat(e.getAttribute(nameType, options)).hasSize(6); |
| | | |
| | | attrs = e.getAttribute(cnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getAttribute(nameType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 6); |
| | | |
| | | attrs = e.getAttribute(nameType, false, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(mnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | |
| | | attrs = e.getAttribute("objectclass", options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | attrs = e.getAttribute("cn", options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getAttribute("uid", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("modifiersname", options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | assertThat(e.getAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(mnType, options)).hasSize(1); |
| | | |
| | | options = new LinkedHashSet<>(); |
| | | attrs = e.getAttribute(ocType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | assertThat(e.getAttribute(ocType, options)).hasSize(1); |
| | | assertThat(e.getAttribute(cnType, options)).hasSize(2); |
| | | assertThat(e.getAttribute(nameType, options)).hasSize(6); |
| | | |
| | | attrs = e.getAttribute(cnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getAttribute(nameType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 6); |
| | | |
| | | attrs = e.getAttribute(nameType, false, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(mnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | |
| | | attrs = e.getAttribute("objectclass", options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | attrs = e.getAttribute("cn", options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getAttribute("uid", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("modifiersname", options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | assertThat(e.getAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(mnType, options)).hasSize(1); |
| | | |
| | | options.add("lang-en-US"); |
| | | attrs = e.getAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | assertThat(e.getAttribute(ocType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(cnType, options)).hasSize(1); |
| | | assertThat(e.getAttribute(nameType, options)).hasSize(3); |
| | | |
| | | attrs = e.getAttribute(cnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | attrs = e.getAttribute(nameType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 3); |
| | | |
| | | attrs = e.getAttribute(nameType, false, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | |
| | | attrs = e.getAttribute("objectclass", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("cn", options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | attrs = e.getAttribute("uid", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("modifiersname", options); |
| | | assertNull(attrs); |
| | | |
| | | assertThat(e.getAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(mnType, options)).isEmpty(); |
| | | |
| | | options.add("lang-en-GB"); |
| | | attrs = e.getAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | |
| | | attrs = e.getAttribute("objectclass", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("cn", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("uid", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("modifiersname", options); |
| | | assertNull(attrs); |
| | | |
| | | assertThat(e.getAttribute(ocType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(cnType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(nameType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(mnType, options)).isEmpty(); |
| | | |
| | | options.clear(); |
| | | options.add("lang-en-GB"); |
| | | attrs = e.getAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | |
| | | attrs = e.getAttribute("objectclass", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("cn", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("uid", options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getAttribute("modifiersname", options); |
| | | assertNull(attrs); |
| | | assertThat(e.getAttribute(ocType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(cnType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(nameType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getAttribute(mnType, options)).isEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | AttributeType uidType = DirectoryServer.getAttributeTypeOrNull("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeTypeOrNull("modifiersname"); |
| | | |
| | | List<Attribute> attrs = e.getUserAttribute(ocType); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(cnType); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getUserAttribute(nameType); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 6); |
| | | |
| | | attrs = e.getUserAttribute(uidType); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(mnType); |
| | | assertNull(attrs); |
| | | |
| | | |
| | | LinkedHashSet<String> options = null; |
| | | attrs = e.getUserAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(cnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getUserAttribute(nameType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 6); |
| | | |
| | | attrs = e.getUserAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | |
| | | options = new LinkedHashSet<>(); |
| | | attrs = e.getUserAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(cnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 2); |
| | | |
| | | attrs = e.getUserAttribute(nameType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 6); |
| | | |
| | | attrs = e.getUserAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | |
| | | options.add("lang-en-US"); |
| | | attrs = e.getUserAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(cnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | attrs = e.getUserAttribute(nameType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 3); |
| | | |
| | | attrs = e.getUserAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | |
| | | options.add("lang-en-GB"); |
| | | attrs = e.getUserAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | |
| | | options.clear(); |
| | | options.add("lang-en-GB"); |
| | | attrs = e.getUserAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getUserAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | assertThat(e.getUserAttribute(ocType)).isEmpty(); |
| | | assertThat(e.getUserAttribute(cnType)).hasSize(2); |
| | | assertThat(e.getUserAttribute(nameType)).hasSize(6); |
| | | assertThat(e.getUserAttribute(uidType)).isEmpty(); |
| | | assertThat(e.getUserAttribute(mnType)).isEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | AttributeType uidType = DirectoryServer.getAttributeTypeOrNull("uid"); |
| | | AttributeType mnType = DirectoryServer.getAttributeTypeOrNull("modifiersname"); |
| | | |
| | | List<Attribute> attrs = e.getOperationalAttribute(ocType); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(cnType); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(nameType); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(uidType); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(mnType); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | assertThat(e.getOperationalAttribute(ocType)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(cnType)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(nameType)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(uidType)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(mnType)).hasSize(1); |
| | | |
| | | LinkedHashSet<String> options = null; |
| | | attrs = e.getOperationalAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(mnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | assertThat(e.getOperationalAttribute(ocType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(cnType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(nameType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(mnType, options)).hasSize(1); |
| | | |
| | | options = new LinkedHashSet<>(); |
| | | attrs = e.getOperationalAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(mnType, options); |
| | | assertNotNull(attrs); |
| | | assertEquals(attrs.size(), 1); |
| | | |
| | | assertThat(e.getOperationalAttribute(ocType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(cnType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(nameType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(mnType, options)).hasSize(1); |
| | | |
| | | options.add("lang-en-US"); |
| | | attrs = e.getOperationalAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | assertThat(e.getOperationalAttribute(ocType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(cnType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(nameType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(mnType, options)).isEmpty(); |
| | | |
| | | options.add("lang-en-GB"); |
| | | attrs = e.getOperationalAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | |
| | | assertThat(e.getOperationalAttribute(ocType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(cnType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(nameType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(mnType, options)).isEmpty(); |
| | | |
| | | options.clear(); |
| | | options.add("lang-en-GB"); |
| | | attrs = e.getOperationalAttribute(ocType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(cnType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(nameType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(uidType, options); |
| | | assertNull(attrs); |
| | | |
| | | attrs = e.getOperationalAttribute(mnType, options); |
| | | assertNull(attrs); |
| | | assertThat(e.getOperationalAttribute(ocType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(cnType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(nameType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(uidType, options)).isEmpty(); |
| | | assertThat(e.getOperationalAttribute(mnType, options)).isEmpty(); |
| | | } |
| | | } |
| | | |