Code cleanup
*.java:
Used CollectionUtils.newArrayList() as much as possible.
Made use of LDAPAttribute constructors which accepts Strings. This avoids String to ByteString conversion in client code since the constructors handle it.
AttributeBuilder.java:
Added toAttributeList() to avoid the need for client code to create a List itself.
Attributes.java:
Added several createAsList() to avoid the need for client code to create a List itself.
| | |
| | | package org.forgerock.opendj.adapter.server3x; |
| | | |
| | | import static org.forgerock.opendj.ldap.LdapException.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | |
| | | */ |
| | | public static org.opends.server.types.RawAttribute to( |
| | | final org.forgerock.opendj.ldap.Attribute attribute) { |
| | | ArrayList<ByteString> listAttributeValues = new ArrayList<>(attribute.size()); |
| | | Collections.addAll(listAttributeValues, attribute.toArray()); |
| | | ArrayList<ByteString> listAttributeValues = newArrayList(attribute.toArray()); |
| | | return new LDAPAttribute(attribute.getAttributeDescriptionAsString(), listAttributeValues); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import static org.opends.server.util.StaticUtils.toLowerCase; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | import javax.naming.directory.Attributes; |
| | | import javax.naming.directory.SearchResult; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | } |
| | | builder.add(bs); |
| | | } |
| | | List<org.opends.server.types.Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | |
| | | List<org.opends.server.types.Attribute> attrList = builder.toAttributeList(); |
| | | if (attrType.isOperational()) |
| | | { |
| | | operationalAttributes.put(attrType, attrList); |
| | |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.toLowerCase; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | import java.util.Random; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.JButton; |
| | | import javax.swing.JLabel; |
| | |
| | | import javax.swing.event.ListSelectionEvent; |
| | | import javax.swing.event.ListSelectionListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.ObjectClass; |
| | |
| | | }; |
| | | for (int j=0; j < attrNames.length; j++) |
| | | { |
| | | List<Object> attrValues = new ArrayList<>(1); |
| | | attrValues.add(values[j] + r.nextInt()); |
| | | csr.set(attrNames[j], attrValues); |
| | | Object o = values[j] + r.nextInt(); |
| | | csr.set(attrNames[j], newArrayList(o)); |
| | | } |
| | | try |
| | | { |
| | |
| | | }; |
| | | for (int j=0; j < attrNames.length; j++) |
| | | { |
| | | List<Object> attrValues = new ArrayList<>(1); |
| | | attrValues.add(values[j]); |
| | | csr.set(attrNames[j], attrValues); |
| | | Object o = values[j]; |
| | | csr.set(attrNames[j], newArrayList(o)); |
| | | } |
| | | try |
| | | { |
| | |
| | | } |
| | | builder.add(bs); |
| | | } |
| | | List<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | |
| | | List<Attribute> attrList = builder.toAttributeList(); |
| | | if (attrType.isOperational()) |
| | | { |
| | | operationalAttributes.put(attrType, attrList); |
| | |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | | import static org.opends.server.util.StaticUtils.isDigit; |
| | | import static org.opends.server.util.StaticUtils.isHexDigit; |
| | | import static org.opends.server.util.StaticUtils.hexStringToByteArray; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | /** |
| | | * This class is used to encapsulate DN pattern matching using wildcards. |
| | | * The following wildcard uses are supported. |
| | |
| | | { |
| | | if (element[0].matchesRDN(dn.getRDN(pos))) |
| | | { |
| | | boolean subMatch = true; |
| | | for (int i=1; i < anyLength; i++) |
| | | if (subMatch(dn, pos, element, anyLength)) |
| | | { |
| | | if (!element[i].matchesRDN(dn.getRDN(pos+i))) |
| | | { |
| | | subMatch = false; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (subMatch) |
| | | { |
| | | match = subMatch; |
| | | match = true; |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean subMatch(DN dn, int pos, PatternRDN[] element, int length) |
| | | { |
| | | for (int i = 1; i < length; i++) |
| | | { |
| | | if (!element[i].matchesRDN(dn.getRDN(pos + i))) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Create a new DN pattern matcher to match a suffix. |
| | |
| | | if (pos == length) |
| | | { |
| | | // This means that the DN was completely comprised of spaces |
| | | // and therefore should be considered the same as a null or |
| | | // empty DN. |
| | | // and therefore should be considered the same as a null or empty DN. |
| | | return new PatternDN(new PatternRDN[0]); |
| | | } |
| | | else |
| | |
| | | } |
| | | |
| | | // We know that it's not an empty DN, so we can do the real |
| | | // processing. Create a loop and iterate through all the RDN |
| | | // components. |
| | | // processing. Create a loop and iterate through all the RDN components. |
| | | rdnLoop: |
| | | while (true) |
| | | { |
| | |
| | | // RDN component and return the DN. |
| | | if (pos >= length) |
| | | { |
| | | ArrayList<ByteString> arrayList = new ArrayList<>(1); |
| | | arrayList.add(ByteString.empty()); |
| | | ArrayList<ByteString> arrayList = newArrayList(ByteString.empty()); |
| | | rdnComponents.add(new PatternRDN(name, arrayList, dnString)); |
| | | break; |
| | | } |
| | |
| | | |
| | | |
| | | // Most likely, we will be at either the end of the RDN |
| | | // component or the end of the DN. If so, then handle that |
| | | // appropriately. |
| | | // component or the end of the DN. If so, then handle that appropriately. |
| | | if (pos >= length) |
| | | { |
| | | // We're at the end of the DN string and should have a valid |
| | | // DN so return it. |
| | | // We're at the end of the DN string and should have a valid DN so return it. |
| | | rdnComponents.add(rdn); |
| | | break; |
| | | } |
| | | else if ((c == ',') || (c == ';')) |
| | | { |
| | | // We're at the end of the RDN component, so add it to the |
| | | // list, skip over the comma/semicolon, and start on the next |
| | | // component. |
| | | // We're at the end of the RDN component, so add it to the list, |
| | | // skip over the comma/semicolon, and start on the next component. |
| | | rdnComponents.add(rdn); |
| | | pos++; |
| | | continue; |
| | |
| | | // This should not happen. At any rate, it's an illegal |
| | | // character, so throw an exception. |
| | | LocalizableMessage message = ERR_ATTR_SYNTAX_DN_INVALID_CHAR.get(dnString, c, pos); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | | message); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | |
| | | // the RDN component and return the DN. |
| | | if (pos >= length) |
| | | { |
| | | ArrayList<ByteString> arrayList = new ArrayList<>(1); |
| | | arrayList.add(ByteString.empty()); |
| | | ArrayList<ByteString> arrayList = newArrayList(ByteString.empty()); |
| | | rdn.addValue(name, arrayList, dnString); |
| | | rdnComponents.add(rdn); |
| | | break; |
| | |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import java.util.List; |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.TreeMap; |
| | | import java.util.Set; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | | |
| | | /** |
| | | * This class is used to match RDN patterns containing wildcards in either |
| | | * the attribute types or the attribute values. |
| | |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * Indicate whether the RDN contains a wildcard in any of its attribute |
| | | * types. |
| | | */ |
| | | /** Indicate whether the RDN contains a wildcard in any of its attribute types. */ |
| | | private boolean hasTypeWildcard; |
| | | |
| | | |
| | | /** |
| | | * The set of attribute type patterns. |
| | | */ |
| | | /** The set of attribute type patterns. */ |
| | | private String[] typePatterns; |
| | | |
| | | |
| | | /** |
| | | * The set of attribute value patterns. |
| | | * The value pattern is split into a list according to the positions of any |
| | |
| | | * of three elements "", A and "". |
| | | */ |
| | | private ArrayList<ArrayList<ByteString>> valuePatterns; |
| | | |
| | | |
| | | /** |
| | | * The number of attribute-value pairs in this RDN pattern. |
| | | */ |
| | | /** The number of attribute-value pairs in this RDN pattern. */ |
| | | private int numValues; |
| | | |
| | | |
| | |
| | | * @param dnString The DN pattern containing the attribute-value pair. |
| | | * @throws DirectoryException If the attribute-value pair is not valid. |
| | | */ |
| | | public PatternRDN(String type, ArrayList<ByteString> valuePattern, |
| | | String dnString) |
| | | public PatternRDN(String type, ArrayList<ByteString> valuePattern, String dnString) |
| | | throws DirectoryException |
| | | { |
| | | // Only Whole-Type wildcards permitted. |
| | |
| | | |
| | | numValues = 1; |
| | | typePatterns = new String[] { type }; |
| | | valuePatterns = new ArrayList<>(1); |
| | | valuePatterns.add(valuePattern); |
| | | valuePatterns = newArrayList(valuePattern); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | WARN_PATTERN_DN_TYPE_WILDCARD_IN_MULTIVALUED_RDN.get(dnString); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, |
| | | message); |
| | | throw new DirectoryException(ResultCode.INVALID_DN_SYNTAX, message); |
| | | } |
| | | |
| | | numValues++; |
| | |
| | | for (int i=0; i < numAVAs; i++) |
| | | { |
| | | AttributeType attrType = rdn.getAttributeType(i); |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(Attributes.create(attrType, rdn.getAttributeValue(i))); |
| | | userAttrs.put(attrType, attrList); |
| | | userAttrs.put(attrType, Attributes.createAsList(attrType, rdn.getAttributeValue(i))); |
| | | } |
| | | |
| | | backupBaseEntry = new Entry(backupBaseDN, objectClasses, userAttrs, opAttrs); |
| | |
| | | for (String s : dependencies) { |
| | | builder.add(s); |
| | | } |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | userAttrs.put(t, attrList); |
| | | userAttrs.put(t, builder.toAttributeList()); |
| | | } |
| | | |
| | | byte[] signedHash = backupInfo.getSignedHash(); |
| | |
| | | |
| | | private void putByteString(LinkedHashMap<AttributeType, List<Attribute>> userAttrs, String attrName, byte[] value) |
| | | { |
| | | AttributeType t; |
| | | t = DirectoryServer.getAttributeType(attrName, true); |
| | | AttributeType t = DirectoryServer.getAttributeType(attrName, true); |
| | | userAttrs.put(t, asList(t, ByteString.wrap(value))); |
| | | } |
| | | |
| | |
| | | attrsMap.put(t, asList(t, createBooleanValue(value))); |
| | | } |
| | | |
| | | private ArrayList<Attribute> asList(AttributeType attrType, ByteString value) |
| | | private List<Attribute> asList(AttributeType attrType, ByteString value) |
| | | { |
| | | final ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(Attributes.create(attrType, value)); |
| | | return attrList; |
| | | return Attributes.createAsList(attrType, value); |
| | | } |
| | | |
| | | private DirectoryException newConstraintViolation(LocalizableMessage message) |
| | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | |
| | | private void put(final HashMap<AttributeType, List<Attribute>> attrsMap, final Attribute attr) |
| | | { |
| | | attrsMap.put(attr.getAttributeType(), toList(attr)); |
| | | } |
| | | |
| | | private ArrayList<Attribute> toList(final Attribute attr) |
| | | { |
| | | final ArrayList<Attribute> results = new ArrayList<>(1); |
| | | results.add(attr); |
| | | return results; |
| | | attrsMap.put(attr.getAttributeType(), newArrayList(attr)); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | final AttributeType attributeType = rdn.getAttributeType(i); |
| | | final ByteString value = rdn.getAttributeValue(attributeType); |
| | | final Attribute attr = Attributes.create(attributeType, value); |
| | | monitorUserAttrs.put(attributeType, toList(attr)); |
| | | monitorUserAttrs.put(attributeType, Attributes.createAsList(attributeType, value)); |
| | | } |
| | | } |
| | | |
| | |
| | | final AttributeType rdnType = entryRDN.getAttributeType(0); |
| | | final ByteString rdnValue = entryRDN.getAttributeValue(0); |
| | | |
| | | attrMap.put(rdnType, toList(Attributes.create(rdnType, rdnValue))); |
| | | attrMap.put(rdnType, Attributes.createAsList(rdnType, rdnValue)); |
| | | |
| | | // Take the rest of the information from the monitor data. |
| | | for (final Attribute a : monitorAttrs) |
| | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | Attribute supportedAuthPWSchemesAttr = |
| | | createAttribute(ATTR_SUPPORTED_AUTH_PW_SCHEMES, |
| | | ATTR_SUPPORTED_AUTH_PW_SCHEMES_LC, authPWSchemes); |
| | | ArrayList<Attribute> supportedAuthPWSchemesAttrs = new ArrayList<>(1); |
| | | supportedAuthPWSchemesAttrs.add(supportedAuthPWSchemesAttr); |
| | | ArrayList<Attribute> supportedAuthPWSchemesAttrs = newArrayList(supportedAuthPWSchemesAttr); |
| | | if (showAllAttributes |
| | | || !supportedSASLMechAttr.getAttributeType().isOperational()) |
| | | { |
| | |
| | | { |
| | | if (!publicNamingContextAttr.isEmpty()) |
| | | { |
| | | List<Attribute> privateNamingContextAttrs = new ArrayList<>(1); |
| | | privateNamingContextAttrs.add(publicNamingContextAttr); |
| | | List<Attribute> privateNamingContextAttrs = newArrayList(publicNamingContextAttr); |
| | | final AttributeType attrType = publicNamingContextAttr.getAttributeType(); |
| | | if (showAllAttributes || !attrType.isOperational()) |
| | | { |
| | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private ArrayList<Attribute> newArrayList(Attribute a) |
| | | { |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(a); |
| | | return attrList; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean entryExists(DN entryDN) |
| | |
| | | import java.security.KeyStore; |
| | | import java.security.KeyStoreException; |
| | | import java.security.cert.Certificate; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | |
| | | throw new InitializationException( |
| | | ERR_TRUSTSTORE_PIN_FILE_EMPTY.get(pinFilePath, configEntryDN)); |
| | | } |
| | | else |
| | | { |
| | | trustStorePIN = pinStr.toCharArray(); |
| | | } |
| | | trustStorePIN = pinStr.toCharArray(); |
| | | } |
| | | } |
| | | } |
| | |
| | | throw new InitializationException( |
| | | ERR_TRUSTSTORE_PIN_ENVAR_NOT_SET.get(pinProperty, configEntryDN)); |
| | | } |
| | | else |
| | | { |
| | | trustStorePIN = pinStr.toCharArray(); |
| | | } |
| | | trustStorePIN = pinStr.toCharArray(); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | throw new InitializationException(ERR_TRUSTSTORE_PIN_PROPERTY_NOT_SET.get(pinProperty, configEntryDN)); |
| | | } |
| | | else |
| | | { |
| | | trustStorePIN = pinStr.toCharArray(); |
| | | } |
| | | trustStorePIN = pinStr.toCharArray(); |
| | | } |
| | | |
| | | // Create a certificate manager. |
| | |
| | | for (int i=0; i < numAVAs; i++) |
| | | { |
| | | AttributeType attrType = rdn.getAttributeType(i); |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(Attributes.create(attrType, rdn.getAttributeValue(i))); |
| | | userAttrs.put(attrType, attrList); |
| | | userAttrs.put(attrType, Attributes.createAsList(attrType, rdn.getAttributeValue(i))); |
| | | } |
| | | |
| | | baseEntry = new Entry(baseDN, objectClasses, userAttrs, opAttrs); |
| | |
| | | LinkedHashMap<AttributeType,List<Attribute>> opAttrs = new LinkedHashMap<>(0); |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(3); |
| | | |
| | | userAttrs.put(t, asList(Attributes.create(t, v))); |
| | | userAttrs.put(t, Attributes.createAsList(t, v)); |
| | | |
| | | |
| | | t = DirectoryServer.getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE, true); |
| | | AttributeBuilder builder = new AttributeBuilder(t); |
| | | builder.setOption("binary"); |
| | | builder.add(certValue); |
| | | userAttrs.put(t, asList(builder.toAttribute())); |
| | | userAttrs.put(t, builder.toAttributeList()); |
| | | |
| | | |
| | | Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs); |
| | |
| | | return e; |
| | | } |
| | | |
| | | private ArrayList<Attribute> asList(Attribute create) |
| | | { |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(create); |
| | | return attrList; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addEntry(Entry entry, AddOperation addOperation) |
| | |
| | | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | { |
| | | this.taskState = taskState; |
| | | Attribute attr = Attributes.create(ATTR_TASK_STATE, taskState.toString()); |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(attr); |
| | | taskEntry.putAttribute(attr.getAttributeType(), attrList); |
| | | taskEntry.putAttribute(attr.getAttributeType(), newArrayList(attr)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | this.actualStartTime = actualStartTime; |
| | | Date d = new Date(actualStartTime); |
| | | String startTimeStr = StaticUtils.formatDateTimeString(d); |
| | | Attribute attr = Attributes.create(ATTR_TASK_ACTUAL_START_TIME, |
| | | startTimeStr); |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(attr); |
| | | taskEntry.putAttribute(attr.getAttributeType(), attrList); |
| | | Attribute attr = Attributes.create(ATTR_TASK_ACTUAL_START_TIME, startTimeStr); |
| | | taskEntry.putAttribute(attr.getAttributeType(), newArrayList(attr)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME); |
| | | dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
| | | Date d = new Date(completionTime); |
| | | Attribute attr = Attributes.create(ATTR_TASK_COMPLETION_TIME, |
| | | dateFormat.format(d)); |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(attr); |
| | | taskEntry.putAttribute(attr.getAttributeType(), attrList); |
| | | Attribute attr = Attributes.create(ATTR_TASK_COMPLETION_TIME, dateFormat.format(d)); |
| | | taskEntry.putAttribute(attr.getAttributeType(), newArrayList(attr)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.core.ServerContext; |
| | | 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 org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | |
| | | } |
| | | |
| | | Attribute attr = Attributes.create(ATTR_TASK_STATE, TaskState.RECURRING.toString()); |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(attr); |
| | | Entry recurringTaskEntry = recurringTask.getRecurringTaskEntry(); |
| | | recurringTaskEntry.putAttribute(attr.getAttributeType(), attrList); |
| | | recurringTaskEntry.putAttribute(attr.getAttributeType(), newArrayList(attr)); |
| | | |
| | | if (scheduleIteration) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public List<String> activeValuesToStrings() |
| | | { |
| | | return asList(String.valueOf(activeValue)); |
| | | return newArrayList(String.valueOf(activeValue)); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | if (hasPendingValues()) |
| | | { |
| | | return asList(String.valueOf(pendingValue)); |
| | | return newArrayList(String.valueOf(pendingValue)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private List<String> asList(String s) |
| | | { |
| | | ArrayList<String> result = new ArrayList<>(1); |
| | | result.add(s); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a new configuration attribute of this type that will contain the |
| | | * values from the provided attribute. |
| | |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.util.ArrayList; |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DN; |
| | | |
| | | /** |
| | | * This class defines a DN configuration attribute, which can hold zero or more |
| | |
| | | } |
| | | else |
| | | { |
| | | activeValues = new ArrayList<>(1); |
| | | activeValues.add(value); |
| | | activeValues = newArrayList(value); |
| | | } |
| | | |
| | | pendingValues = activeValues; |
| | |
| | | |
| | | if (requiresAdminAction()) |
| | | { |
| | | pendingValues = new ArrayList<>(1); |
| | | pendingValues.add(value); |
| | | pendingValues = newArrayList(value); |
| | | setPendingValues(getValueSet(value)); |
| | | } |
| | | else |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, |
| | | boolean allowFailures) |
| | | public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | | { |
| | | if ((valueStrings == null) || valueStrings.isEmpty()) |
| | |
| | | } |
| | | return valueStrings; |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | activeValues, pendingValues); |
| | | } |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.config; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanParameterInfo; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import org.opends.server.types.Attribute; |
| | | |
| | | /** |
| | | * This class defines a configuration attribute that stores both an integer |
| | | * value and an associated unit. The unit will contain both a string and a |
| | |
| | | * |
| | | * @return The name of the data type for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public String getDataType() |
| | | { |
| | | return "IntegerWithUnit"; |
| | |
| | | * |
| | | * @return The attribute syntax for this configuration attribute. |
| | | */ |
| | | @Override |
| | | public Syntax getSyntax() |
| | | { |
| | | return DirectoryServer.getDefaultStringSyntax(); |
| | |
| | | * configuration attribute. This will not take any action if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public void applyPendingValues() |
| | | { |
| | | if (! hasPendingValues()) |
| | |
| | | * @return <CODE>true</CODE> if the provided value is acceptable for use in |
| | | * this attribute, or <CODE>false</CODE> if not. |
| | | */ |
| | | @Override |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder rejectReason) |
| | | { |
| | |
| | | * @throws ConfigException If an unrecoverable problem occurs while |
| | | * performing the conversion. |
| | | */ |
| | | @Override |
| | | public LinkedHashSet<ByteString> |
| | | stringsToValues(List<String> valueStrings, boolean allowFailures) |
| | | throws ConfigException |
| | |
| | | * @return The string representations of the set of active values for this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public List<String> activeValuesToStrings() |
| | | { |
| | | ArrayList<String> valueStrings = new ArrayList<>(1); |
| | | valueStrings.add(activeIntValue + " " + activeUnit); |
| | | |
| | | return valueStrings; |
| | | return newArrayList(activeIntValue + " " + activeUnit); |
| | | } |
| | | |
| | | |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if there are no |
| | | * pending values. |
| | | */ |
| | | @Override |
| | | public List<String> pendingValuesToStrings() |
| | | { |
| | | if (hasPendingValues()) |
| | | { |
| | | ArrayList<String> valueStrings = new ArrayList<>(1); |
| | | valueStrings.add(pendingIntValue + " " + pendingUnit); |
| | | return valueStrings; |
| | | return newArrayList(pendingIntValue + " " + pendingUnit); |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | * single-valued and the provided attribute has |
| | | * multiple values). |
| | | */ |
| | | @Override |
| | | public ConfigAttribute getConfigAttribute(List<Attribute> attributeList) |
| | | throws ConfigException |
| | | { |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if it does not have |
| | | * any active values. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttribute() |
| | | { |
| | | return new javax.management.Attribute(getName(), |
| | |
| | | * configuration attribute, or <CODE>null</CODE> if it does not have |
| | | * any active values. |
| | | */ |
| | | @Override |
| | | public javax.management.Attribute toJMXAttributePending() |
| | | { |
| | | return new javax.management.Attribute(getName() + ";" |
| | |
| | | * The attribute list to which the JMX attribute(s) should |
| | | * be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttribute(AttributeList attributeList) |
| | | { |
| | | String activeValue = activeIntValue + " " + activeUnit; |
| | |
| | | * @param attributeInfoList The list to which the attribute information |
| | | * should be added. |
| | | */ |
| | | @Override |
| | | public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList) |
| | | { |
| | | attributeInfoList.add(new MBeanAttributeInfo(getName(), |
| | |
| | | * @return A JMX <CODE>MBeanParameterInfo</CODE> object that describes this |
| | | * configuration attribute. |
| | | */ |
| | | @Override |
| | | public MBeanParameterInfo toJMXParameterInfo() |
| | | { |
| | | return new MBeanParameterInfo(getName(), String.class.getName(), |
| | |
| | | * acceptable value for this configuration |
| | | * attribute. |
| | | */ |
| | | @Override |
| | | public void setValue(javax.management.Attribute jmxAttribute) |
| | | throws ConfigException |
| | | { |
| | |
| | | * |
| | | * @return A duplicate of this configuration attribute. |
| | | */ |
| | | @Override |
| | | public ConfigAttribute duplicate() |
| | | { |
| | | return new IntegerWithUnitConfigAttribute(getName(), getDescription(), |
| | |
| | | pendingIntValue, pendingUnit); |
| | | } |
| | | } |
| | | |
| | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement.*; |
| | | |
| | |
| | | |
| | | rawEntryDN = ByteString.valueOf(entryDN.toString()); |
| | | |
| | | ArrayList<String> values = new ArrayList<>(objectClasses.values()); |
| | | rawAttributes = new ArrayList<>(); |
| | | |
| | | ArrayList<ByteString> ocValues = new ArrayList<>(); |
| | | for (String s : objectClasses.values()) |
| | | { |
| | | ocValues.add(ByteString.valueOf(s)); |
| | | } |
| | | |
| | | LDAPAttribute ocAttr = new LDAPAttribute(ATTR_OBJECTCLASS, ocValues); |
| | | rawAttributes.add(ocAttr); |
| | | |
| | | for (List<Attribute> attrList : userAttributes.values()) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | rawAttributes.add(new LDAPAttribute(a)); |
| | | } |
| | | } |
| | | |
| | | for (List<Attribute> attrList : operationalAttributes.values()) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | rawAttributes.add(new LDAPAttribute(a)); |
| | | } |
| | | } |
| | | rawAttributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, values)); |
| | | addAll(rawAttributes, userAttributes); |
| | | addAll(rawAttributes, operationalAttributes); |
| | | |
| | | responseControls = new ArrayList<>(); |
| | | proxiedAuthorizationDN = null; |
| | | cancelRequest = null; |
| | | } |
| | | |
| | | private void addAll(List<RawAttribute> rawAttributes, Map<AttributeType, List<Attribute>> attributesToAdd) |
| | | { |
| | | for (List<Attribute> attrList : attributesToAdd.values()) |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | rawAttributes.add(new LDAPAttribute(a)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final ByteString getRawEntryDN() |
| | |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<>(1); |
| | | attrs.add(attr); |
| | | operationalAttributes.put(attrType, attrs); |
| | | } |
| | | else |
| | | { |
| | | attrs.add(attr); |
| | | } |
| | | attrs.add(attr); |
| | | } |
| | | else |
| | | { |
| | | List<Attribute> attrs = userAttributes.get(attrType); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<>(1); |
| | | attrs.add(attr); |
| | | attrs = newArrayList(attr); |
| | | userAttributes.put(attrType, attrs); |
| | | } |
| | | else |
| | |
| | | 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.protocols.ldap.ExtendedRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | // Write the value to the entry. |
| | | InternalClientConnection internalConnection = |
| | | InternalClientConnection.getRootConnection(); |
| | | List<Modification> modifications = new ArrayList<>(1); |
| | | Attribute attribute = Attributes.create( |
| | | ConfigConstants.ATTR_CRYPTO_SYMMETRIC_KEY, symmetricKey); |
| | | modifications.add( |
| | | List<Modification> modifications = newArrayList( |
| | | new Modification(ModificationType.ADD, attribute, false)); |
| | | ModifyOperation internalModify = |
| | | internalConnection.processModify(entry.getName(), |
| | | modifications); |
| | | ModifyOperation internalModify = internalConnection.processModify(entry.getName(), modifications); |
| | | if (internalModify.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | throw new CryptoManagerException( |
| | |
| | | isCompromised); |
| | | |
| | | // Write the value to the entry. |
| | | List<Modification> modifications = new ArrayList<>(1); |
| | | Attribute attribute = Attributes.create(ATTR_CRYPTO_SYMMETRIC_KEY, symmetricKey); |
| | | modifications.add(new Modification(ModificationType.ADD, attribute, false)); |
| | | List<Modification> modifications = newArrayList( |
| | | new Modification(ModificationType.ADD, attribute, false)); |
| | | ModifyOperation internalModify = |
| | | getRootConnection().processModify(entry.getName(), modifications); |
| | | if (internalModify.getResultCode() != ResultCode.SUCCESS) |
| | |
| | | } |
| | | |
| | | private static void putSingleValueAttribute( |
| | | Map<AttributeType, List<Attribute>> attrs, AttributeType type, |
| | | String value) |
| | | Map<AttributeType, List<Attribute>> attrs, AttributeType type, String value) |
| | | { |
| | | attrs.put(type, asList(Attributes.create(type, value))); |
| | | } |
| | | |
| | | private static <T> List<T> asList(T element) |
| | | { |
| | | ArrayList<T> attrList = new ArrayList<>(1); |
| | | attrList.add(element); |
| | | return attrList; |
| | | attrs.put(type, Attributes.createAsList(type, value)); |
| | | } |
| | | |
| | | /** |
| | |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(); |
| | | |
| | | // Add the key ID attribute. |
| | | userAttrs.put(attrKeyID, asList(Attributes.create(attrKeyID, distinguishedValue))); |
| | | userAttrs.put(attrKeyID, Attributes.createAsList(attrKeyID, distinguishedValue)); |
| | | |
| | | // Add the transformation name attribute. |
| | | putSingleValueAttribute(userAttrs, attrTransformation, keyEntry.getType()); |
| | |
| | | |
| | | builder.add(symmetricKey); |
| | | } |
| | | userAttrs.put(attrSymmetricKey, asList(builder.toAttribute())); |
| | | userAttrs.put(attrSymmetricKey, builder.toAttributeList()); |
| | | |
| | | // Create the entry. |
| | | Entry entry = new Entry(entryDN, ocMap, userAttrs, opAttrs); |
| | |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(); |
| | | |
| | | // Add the key ID attribute. |
| | | userAttrs.put(attrKeyID, asList(Attributes.create(attrKeyID, distinguishedValue))); |
| | | userAttrs.put(attrKeyID, Attributes.createAsList(attrKeyID, distinguishedValue)); |
| | | |
| | | // Add the mac algorithm name attribute. |
| | | putSingleValueAttribute(userAttrs, attrMacAlgorithm, keyEntry.getType()); |
| | |
| | | builder.add(symmetricKey); |
| | | } |
| | | |
| | | userAttrs.put(attrSymmetricKey, asList(builder.toAttribute())); |
| | | userAttrs.put(attrSymmetricKey, builder.toAttributeList()); |
| | | |
| | | // Create the entry. |
| | | Entry entry = new Entry(entryDN, ocMap, userAttrs, opAttrs); |
| | |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.AccountStatusNotificationType.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | List<ByteString> encodedPasswords; |
| | | if (isPreEncoded) |
| | | { |
| | | encodedPasswords = new ArrayList<>(1); |
| | | encodedPasswords.add(newPassword); |
| | | encodedPasswords = newArrayList(newPassword); |
| | | } |
| | | else |
| | | { |
| | |
| | | List<ByteString> currentPasswords = null; |
| | | if (oldPassword != null) |
| | | { |
| | | currentPasswords = new ArrayList<>(1); |
| | | currentPasswords.add(oldPassword); |
| | | currentPasswords = newArrayList(oldPassword); |
| | | } |
| | | List<ByteString> newPasswords = new ArrayList<>(1); |
| | | newPasswords.add(newPassword); |
| | | List<ByteString> newPasswords = newArrayList(newPassword); |
| | | |
| | | Map<AccountStatusNotificationProperty, List<String>> notifProperties = |
| | | AccountStatusNotification.createProperties(pwPolicyState, false, -1, currentPasswords, newPasswords); |
| | |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | case OP_SET_AUTHENTICATION_FAILURE_TIMES: |
| | | if (opValues == null) |
| | | { |
| | | ArrayList<Long> valueList = new ArrayList<>(1); |
| | | valueList.add(pwpState.getCurrentTime()); |
| | | pwpState.setAuthFailureTimes(valueList); |
| | | pwpState.setAuthFailureTimes(newArrayList(pwpState.getCurrentTime())); |
| | | } |
| | | else |
| | | { |
| | |
| | | case OP_SET_GRACE_LOGIN_USE_TIMES: |
| | | if (opValues == null) |
| | | { |
| | | ArrayList<Long> valueList = new ArrayList<>(1); |
| | | valueList.add(pwpState.getCurrentTime()); |
| | | pwpState.setGraceLoginTimes(valueList); |
| | | pwpState.setGraceLoginTimes(newArrayList(pwpState.getCurrentTime())); |
| | | } |
| | | else |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.ClientConnectionMonitorProviderCfg; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ConnectionHandler; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a Directory Server monitor provider that can be |
| | | * used to obtain information about the client connections established |
| | |
| | | * is requested. |
| | | */ |
| | | @Override |
| | | public ArrayList<Attribute> getMonitorData() |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | // Re-order the connections by connection ID. |
| | | TreeMap<Long, ClientConnection> connMap = new TreeMap<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getDefaultAttributeType("connection"); |
| | | AttributeType attrType = DirectoryServer.getDefaultAttributeType("connection"); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | for (ClientConnection conn : connMap.values()) |
| | | { |
| | | builder.add(conn.getMonitorSummary()); |
| | | } |
| | | |
| | | ArrayList<Attribute> attrs = new ArrayList<>(1); |
| | | attrs.add(builder.toAttribute()); |
| | | return attrs; |
| | | return builder.toAttributeList(); |
| | | } |
| | | } |
| | |
| | | |
| | | import static org.opends.messages.PluginMessages.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | byte[] dnBytes = entry.getName().toNormalizedByteString().toByteArray(); |
| | | UUID uuid = UUID.nameUUIDFromBytes(dnBytes); |
| | | |
| | | Attribute uuidAttr = Attributes.create(entryUUIDType, uuid.toString()); |
| | | uuidList = new ArrayList<>(1); |
| | | uuidList.add(uuidAttr); |
| | | uuidList = Attributes.createAsList(entryUUIDType, uuid.toString()); |
| | | entry.putAttribute(entryUUIDType, uuidList); |
| | | |
| | | |
| | | // We shouldn't ever need to return a non-success result. |
| | | return PluginResult.ImportLDIF.continueEntryProcessing(); |
| | | } |
| | |
| | | |
| | | // Construct a new random UUID. |
| | | UUID uuid = UUID.randomUUID(); |
| | | Attribute uuidAttr = Attributes.create(entryUUIDType, uuid.toString()); |
| | | uuidList = new ArrayList<>(1); |
| | | uuidList.add(uuidAttr); |
| | | |
| | | uuidList = Attributes.createAsList(entryUUIDType, uuid.toString()); |
| | | |
| | | // Add the attribute to the entry and return. |
| | | addOperation.setAttribute(entryUUIDType, uuidList); |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | import java.util.ArrayList; |
| | | 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.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyDNOperation; |
| | |
| | | |
| | | /** The attribute type for the "createTimestamp" attribute. */ |
| | | private final AttributeType createTimestampType; |
| | | |
| | | /** The attribute type for the "creatorsName" attribute. */ |
| | | private final AttributeType creatorsNameType; |
| | | |
| | | /** The attribute type for the "modifiersName" attribute. */ |
| | | private final AttributeType modifiersNameType; |
| | | |
| | | /** The attribute type for the "modifyTimestamp" attribute. */ |
| | | private final AttributeType modifyTimestampType; |
| | | |
| | | /** The current configuration for this plugin. */ |
| | | private LastModPluginCfg currentConfig; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this Directory Server plugin. Every plugin must |
| | | * implement a default constructor (it is the only one that will be used to |
| | |
| | | { |
| | | builder.add(creatorDN.toString()); |
| | | } |
| | | Attribute nameAttr = builder.toAttribute(); |
| | | ArrayList<Attribute> nameList = new ArrayList<>(1); |
| | | nameList.add(nameAttr); |
| | | addOperation.setAttribute(creatorsNameType, nameList); |
| | | addOperation.setAttribute(creatorsNameType, builder.toAttributeList()); |
| | | |
| | | |
| | | // Create the attribute list for the createTimestamp attribute. |
| | | Attribute timeAttr = Attributes.create(createTimestampType, |
| | | OP_ATTR_CREATE_TIMESTAMP, getGMTTime()); |
| | | ArrayList<Attribute> timeList = new ArrayList<>(1); |
| | | timeList.add(timeAttr); |
| | | List<Attribute> timeList = Attributes.createAsList( |
| | | createTimestampType, OP_ATTR_CREATE_TIMESTAMP, getGMTTime()); |
| | | addOperation.setAttribute(createTimestampType, timeList); |
| | | |
| | | |
| | | // We shouldn't ever need to return a non-success result. |
| | | return PluginResult.PreOperation.continueOperationProcessing(); |
| | | } |
| | |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RawAttribute; |
| | | |
| | | /** |
| | | * This class defines the data structures and methods to use when interacting |
| | |
| | | { |
| | | this.attributeType = attributeType; |
| | | |
| | | values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf(value)); |
| | | values = newArrayList(ByteString.valueOf(value)); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | this.attributeType = attributeType; |
| | | |
| | | values = new ArrayList<>(1); |
| | | values.add(value); |
| | | values = newArrayList(value); |
| | | } |
| | | |
| | | |
| | |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<>(1); |
| | | attrs.add(attr); |
| | | operationalAttributes.put(attrType, attrs); |
| | | } |
| | | else |
| | | { |
| | | attrs.add(attr); |
| | | } |
| | | attrs.add(attr); |
| | | } |
| | | else |
| | | { |
| | | List<Attribute> attrs = userAttributes.get(attrType); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<>(1); |
| | | attrs.add(attr); |
| | | attrs = newArrayList(attr); |
| | | userAttributes.put(attrType, attrs); |
| | | } |
| | | else |
| | |
| | | import static org.opends.server.replication.plugin.EntryHistorical.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.service.ReplicationMonitor.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | import org.opends.server.admin.std.server.ReplicationDomainCfg; |
| | | import org.opends.server.api.AlertGenerator; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.Backend.BackendOperation; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.api.SynchronizationProvider; |
| | | import org.opends.server.api.Backend.BackendOperation; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | // find the attribute/value pair matching the pair in the RDN |
| | | { |
| | | // Construct and store new attribute list |
| | | newRdnAttrLists.add( |
| | | newList(Attributes.create(attributeType, sameAttrValue))); |
| | | newRdnAttrLists.add(Attributes.createAsList(attributeType, sameAttrValue)); |
| | | /* |
| | | Store matching attribute type |
| | | The mapping will be done using object from rdnAttrTypes as key |
| | |
| | | return hasSomeAttributesToFilter; |
| | | } |
| | | |
| | | private static <T> ArrayList<T> newList(T elem) |
| | | { |
| | | final ArrayList<T> list = new ArrayList<>(1); |
| | | list.add(elem); |
| | | return list; |
| | | } |
| | | |
| | | private static <T> Set<T> newSet(T elem) |
| | | { |
| | | final Set<T> list = new LinkedHashSet<>(1); |
| | | list.add(elem); |
| | | return list; |
| | | } |
| | | |
| | | private static boolean isMandatoryAttribute(Set<ObjectClass> entryClasses, |
| | | AttributeType attributeType) |
| | | private static boolean isMandatoryAttribute(Set<ObjectClass> entryClasses, AttributeType attributeType) |
| | | { |
| | | for (ObjectClass objectClass : entryClasses) |
| | | { |
| | |
| | | private void markConflictEntry(Operation op, DN currentDN, DN conflictDN) |
| | | { |
| | | // create new internal modify operation and run it. |
| | | AttributeType attrType = DirectoryServer.getAttributeType(DS_SYNC_CONFLICT, |
| | | true); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(DS_SYNC_CONFLICT, true); |
| | | Attribute attr = Attributes.create(attrType, conflictDN.toString()); |
| | | List<Modification> mods = |
| | | newList(new Modification(ModificationType.REPLACE, attr)); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | |
| | | ModifyOperation newOp = new ModifyOperationBasis( |
| | | conn, nextOperationID(), nextMessageID(), new ArrayList<Control>(0), |
| | |
| | | { |
| | | // The generationId is stored in the root entry of the domain. |
| | | final ByteString asn1BaseDn = ByteString.valueOf(entryDN.toString()); |
| | | final ArrayList<ByteString> values = |
| | | newList(ByteString.valueOf(Long.toString(generationId))); |
| | | |
| | | LDAPAttribute attr = new LDAPAttribute(REPLICATION_GENERATION_ID, values); |
| | | LDAPAttribute attr = new LDAPAttribute(REPLICATION_GENERATION_ID, Long.toString(generationId)); |
| | | List<RawModification> mods = new ArrayList<>(1); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | |
| | |
| | | |
| | | // baseDN branch is the only one included in the export |
| | | LDIFExportConfig exportConfig = new LDIFExportConfig(os); |
| | | exportConfig.setIncludeBranches(newList(getBaseDN())); |
| | | exportConfig.setIncludeBranches(newArrayList(getBaseDN())); |
| | | |
| | | // For the checksum computing mode, only consider the 'stable' attributes |
| | | if (checksumOutput) |
| | |
| | | } |
| | | |
| | | importConfig = new LDIFImportConfig(input); |
| | | importConfig.setIncludeBranches(newSet(getBaseDN())); |
| | | importConfig.setIncludeBranches(newLinkedHashSet(getBaseDN())); |
| | | importConfig.setAppendToExistingData(false); |
| | | importConfig.setSkipDNValidation(true); |
| | | // We should not validate schema for replication |
| | |
| | | entryHist.setPurgeDelay(getHistoricalPurgeDelay()); |
| | | Attribute attr = entryHist.encodeAndPurge(); |
| | | count += entryHist.getLastPurgedValuesCount(); |
| | | List<Modification> mods = |
| | | newList(new Modification(ModificationType.REPLACE, attr)); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | |
| | | ModifyOperation newOp = new ModifyOperationBasis( |
| | | conn, nextOperationID(), nextMessageID(), new ArrayList<Control>(0), |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.common.ServerState; |
| | | 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.DirectoryException; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | |
| | | */ |
| | | class PersistentServerState |
| | | { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private final DN baseDN; |
| | |
| | | */ |
| | | private ResultCode runUpdateStateEntry(DN serverStateEntryDN) |
| | | { |
| | | ArrayList<ByteString> values = state.toASN1ArrayList(); |
| | | |
| | | LDAPAttribute attr = new LDAPAttribute(REPLICATION_STATE, values); |
| | | LDAPAttribute attr = new LDAPAttribute(REPLICATION_STATE, state.toASN1ArrayList()); |
| | | RawModification mod = new LDAPModification(ModificationType.REPLACE, attr); |
| | | |
| | | ModifyOperationBasis op = new ModifyOperationBasis(getRootConnection(), |
| | |
| | | import org.opends.server.config.StringConfigAttribute; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | |
| | | e.getMessageObject(), e); |
| | | } |
| | | |
| | | ArrayList<ByteString> valueList = new ArrayList<>(1); |
| | | valueList.add(ServerConstants.TRUE_VALUE); |
| | | LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList); |
| | | |
| | | LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, ServerConstants.TRUE_VALUE); |
| | | LDAPModification m = new LDAPModification(ModificationType.REPLACE, a); |
| | | |
| | | ArrayList<RawModification> modList = new ArrayList<>(1); |
| | | modList.add(m); |
| | | ArrayList<RawModification> modList = CollectionUtils.<RawModification> newArrayList(m); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | String backendDNString = configEntryDN.toString(); |
| | | ByteString rawEntryDN = |
| | | ByteString.valueOf(backendDNString); |
| | | ModifyOperation internalModify = conn.processModify(rawEntryDN, modList); |
| | | ByteString rawEntryDN = ByteString.valueOf(backendDNString); |
| | | ModifyOperation internalModify = getRootConnection().processModify(rawEntryDN, modList); |
| | | |
| | | ResultCode resultCode = internalModify.getResultCode(); |
| | | if (resultCode != ResultCode.SUCCESS) |
| | |
| | | e.getMessageObject(), e); |
| | | } |
| | | |
| | | ArrayList<ByteString> valueList = new ArrayList<>(1); |
| | | valueList.add(ServerConstants.FALSE_VALUE); |
| | | LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList); |
| | | |
| | | LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, ServerConstants.FALSE_VALUE); |
| | | LDAPModification m = new LDAPModification(ModificationType.REPLACE, a); |
| | | |
| | | ArrayList<RawModification> modList = new ArrayList<>(1); |
| | | modList.add(m); |
| | | ArrayList<RawModification> modList = CollectionUtils.<RawModification> newArrayList(m); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | String backendDNString = configEntryDN.toString(); |
| | | ByteString rawEntryDN = |
| | | ByteString.valueOf(backendDNString); |
| | | ModifyOperation internalModify = conn.processModify(rawEntryDN, modList); |
| | | ByteString rawEntryDN = ByteString.valueOf(backendDNString); |
| | | ModifyOperation internalModify = getRootConnection().processModify(rawEntryDN, modList); |
| | | |
| | | ResultCode resultCode = internalModify.getResultCode(); |
| | | if (resultCode != ResultCode.SUCCESS) |
| | |
| | | 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.util.Utils; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.api.Backend; |
| | |
| | | |
| | | List<String> backendIDs = backendID.getValues(); |
| | | if (backendIDs != null && !backendIDs.isEmpty()) { |
| | | ArrayList<ByteString> values = new ArrayList<>(backendIDs.size()); |
| | | for (String s : backendIDs) { |
| | | values.add(ByteString.valueOf(s)); |
| | | } |
| | | attributes.add( |
| | | new LDAPAttribute(ATTR_TASK_BACKUP_BACKEND_ID, values)); |
| | | new LDAPAttribute(ATTR_TASK_BACKUP_BACKEND_ID, backendIDs)); |
| | | } |
| | | |
| | | addIfHasValue(attributes, ATTR_BACKUP_ID, backupIDString); |
| | |
| | | private void addIfHasValue(List<RawAttribute> attributes, String attrName, Argument arg) |
| | | { |
| | | if (hasValueDifferentThanDefaultValue(arg)) { |
| | | attributes.add(new LDAPAttribute(attrName, asList(arg.getValue()))); |
| | | attributes.add(new LDAPAttribute(attrName, arg.getValue())); |
| | | } |
| | | } |
| | | |
| | |
| | | && !arg.getValue().equals(arg.getDefaultValue()); |
| | | } |
| | | |
| | | private ArrayList<ByteString> asList(String value) |
| | | { |
| | | ArrayList<ByteString> values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf(value)); |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getTaskObjectclass() { |
| | |
| | | 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.std.server.BackendCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.Backend.BackendOperation; |
| | |
| | | public void addTaskAttributes(List<RawAttribute> attributes) |
| | | { |
| | | // Required attributes |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_LDIF_FILE, toByteStrings(ldifFile.getValue()))); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_BACKEND_ID, toByteStrings(backendID.getValue()))); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_LDIF_FILE, ldifFile.getValue())); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_BACKEND_ID, backendID.getValue())); |
| | | |
| | | // Optional attributes |
| | | addAttribute(attributes, ATTR_TASK_EXPORT_APPEND_TO_LDIF, appendToLDIF); |
| | |
| | | if (excludeOperationalAttrs.isPresent()) |
| | | { |
| | | attributes.add( |
| | | new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES, |
| | | toByteStrings("false"))); |
| | | new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES, "false")); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (arg.getValue() != null && !arg.getValue().equals(arg.getDefaultValue())) |
| | | { |
| | | attributes.add(new LDAPAttribute(attrName, toByteStrings(arg.getValue()))); |
| | | attributes.add(new LDAPAttribute(attrName, arg.getValue())); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (attrValues != null && !attrValues.isEmpty()) |
| | | { |
| | | attributes.add(new LDAPAttribute(attrName, toByteStrings(attrValues))); |
| | | attributes.add(new LDAPAttribute(attrName, attrValues)); |
| | | } |
| | | } |
| | | |
| | | private ArrayList<ByteString> toByteStrings(String value) |
| | | { |
| | | final ArrayList<ByteString> values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf(value)); |
| | | return values; |
| | | } |
| | | |
| | | private ArrayList<ByteString> toByteStrings(List<String> includeAttributes) |
| | | { |
| | | final ArrayList<ByteString> values = new ArrayList<>(includeAttributes.size()); |
| | | for (String includeAttribute : includeAttributes) |
| | | { |
| | | values.add(ByteString.valueOf(includeAttribute)); |
| | | } |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getTaskObjectclass() { |
| | |
| | | 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.BackendCfg; |
| | | import org.opends.server.api.Backend; |
| | |
| | | { |
| | | if (value != null) |
| | | { |
| | | attributes.add(new LDAPAttribute(attrName, toByteStrings(value))); |
| | | attributes.add(new LDAPAttribute(attrName, value)); |
| | | } |
| | | } |
| | | |
| | |
| | | final String value = arg.getValue(); |
| | | if (value != null && !value.equals(arg.getDefaultValue())) |
| | | { |
| | | attributes.add(new LDAPAttribute(attrName, toByteStrings(value))); |
| | | attributes.add(new LDAPAttribute(attrName, value)); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (attrValues != null && !attrValues.isEmpty()) |
| | | { |
| | | attributes.add(new LDAPAttribute(attrName, toByteStrings(attrValues))); |
| | | attributes.add(new LDAPAttribute(attrName, attrValues)); |
| | | } |
| | | } |
| | | |
| | | private ArrayList<ByteString> toByteStrings(String value) |
| | | { |
| | | final ArrayList<ByteString> values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf(value)); |
| | | return values; |
| | | } |
| | | |
| | | private ArrayList<ByteString> toByteStrings(List<String> attrValues) |
| | | { |
| | | final ArrayList<ByteString> values = new ArrayList<>(attrValues.size()); |
| | | for (String includeBranche : attrValues) |
| | | { |
| | | values.add(ByteString.valueOf(includeBranche)); |
| | | } |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getTaskObjectclass() { |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.Backend.BackendOperation; |
| | |
| | | // Required attributes |
| | | addLdapAttribute(attributes, ATTR_REBUILD_BASE_DN, baseDNString.getValue()); |
| | | |
| | | final List<String> indexes = indexList.getValues(); |
| | | final ArrayList<ByteString> values = new ArrayList<>(indexes.size()); |
| | | for (final String s : indexes) |
| | | { |
| | | values.add(ByteString.valueOf(s)); |
| | | } |
| | | attributes.add(new LDAPAttribute(ATTR_REBUILD_INDEX, values)); |
| | | attributes.add(new LDAPAttribute(ATTR_REBUILD_INDEX, indexList.getValues())); |
| | | |
| | | if (hasNonDefaultValue(tmpDirectory)) |
| | | { |
| | |
| | | |
| | | private void addLdapAttribute(List<RawAttribute> attributes, String attrType, String attrValue) |
| | | { |
| | | attributes.add(new LDAPAttribute(attrType, toByteStrings(attrValue))); |
| | | attributes.add(new LDAPAttribute(attrType, attrValue)); |
| | | } |
| | | |
| | | private boolean hasNonDefaultValue(BooleanArgument arg) |
| | |
| | | && !arg.getValue().equals(arg.getDefaultValue()); |
| | | } |
| | | |
| | | private ArrayList<ByteString> toByteStrings(String value) |
| | | { |
| | | final ArrayList<ByteString> values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf(value)); |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getTaskObjectclass() |
| | |
| | | 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.std.server.BackendCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.Backend.BackendOperation; |
| | |
| | | { |
| | | if (arg.getValue() != null && !arg.getValue().equals(arg.getDefaultValue())) |
| | | { |
| | | attributes.add(new LDAPAttribute(attrName, toByteStrings(arg.getValue()))); |
| | | attributes.add(new LDAPAttribute(attrName, arg.getValue())); |
| | | } |
| | | } |
| | | |
| | | private ArrayList<ByteString> toByteStrings(String value) |
| | | { |
| | | final ArrayList<ByteString> values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf(value)); |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getTaskObjectclass() { |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | SCHEDULED_TASK_BASE_RDN + "," + DN_TASK_ROOT); |
| | | |
| | | ArrayList<RawAttribute> attributes = new ArrayList<>(); |
| | | |
| | | ArrayList<ByteString> ocValues = new ArrayList<>(3); |
| | | ocValues.add(ByteString.valueOf("top")); |
| | | ocValues.add(ByteString.valueOf("ds-task")); |
| | | ocValues.add(ByteString.valueOf("ds-task-shutdown")); |
| | | attributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, ocValues)); |
| | | |
| | | ArrayList<ByteString> taskIDValues = new ArrayList<>(1); |
| | | taskIDValues.add(ByteString.valueOf(taskID)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_ID, taskIDValues)); |
| | | |
| | | ArrayList<ByteString> classValues = new ArrayList<>(1); |
| | | classValues.add(ByteString.valueOf(ShutdownTask.class.getName())); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, classValues)); |
| | | |
| | | attributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, newArrayList("top", "ds-task", "ds-task-shutdown"))); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_ID, taskID)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, ShutdownTask.class.getName())); |
| | | if (restart.isPresent()) |
| | | { |
| | | ArrayList<ByteString> restartValues = new ArrayList<>(1); |
| | | restartValues.add(ByteString.valueOf("true")); |
| | | attributes.add(new LDAPAttribute(ATTR_RESTART_SERVER, restartValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_RESTART_SERVER, "true")); |
| | | } |
| | | |
| | | if (stopReason.isPresent()) |
| | | { |
| | | ArrayList<ByteString> stopReasonValues = new ArrayList<>(1); |
| | | stopReasonValues.add(ByteString.valueOf(stopReason.getValue())); |
| | | attributes.add(new LDAPAttribute(ATTR_SHUTDOWN_MESSAGE, stopReasonValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_SHUTDOWN_MESSAGE, stopReason.getValue())); |
| | | } |
| | | |
| | | if (stopTime != null) |
| | | { |
| | | ArrayList<ByteString> stopTimeValues = new ArrayList<>(1); |
| | | |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME); |
| | | dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
| | | stopTimeValues.add(ByteString.valueOf(dateFormat.format(stopTime))); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME, |
| | | stopTimeValues)); |
| | | String stopTimeValues = dateFormat.format(stopTime); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME, stopTimeValues)); |
| | | } |
| | | |
| | | ArrayList<Control> controls = new ArrayList<>(); |
| | | if (proxyAuthzID.isPresent()) |
| | | { |
| | | Control c = new ProxiedAuthV2Control( |
| | | ByteString.valueOf(proxyAuthzID.getValue())); |
| | | controls.add(c); |
| | | controls.add(new ProxiedAuthV2Control( |
| | | ByteString.valueOf(proxyAuthzID.getValue()))); |
| | | } |
| | | |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN, |
| | | attributes); |
| | | AddRequestProtocolOp addRequest = new AddRequestProtocolOp(entryDN, attributes); |
| | | LDAPMessage requestMessage = |
| | | new LDAPMessage(nextMessageID.getAndIncrement(), addRequest, controls); |
| | | |
| | |
| | | */ |
| | | package org.opends.server.tools.dsreplication; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.tools.tasks.TaskScheduleInformation; |
| | | import org.opends.server.tools.tasks.TaskScheduleUserData; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.RawAttribute; |
| | | |
| | | /** |
| | | * This is a simple adaptor to create a task schedule information object |
| | | * using the data provided by the user. It is used to be able to share some |
| | | * code with the {@link TaskTool} class. |
| | | * |
| | | */ |
| | | public class PurgeHistoricalScheduleInformation |
| | | implements TaskScheduleInformation |
| | |
| | | /** {@inheritDoc} */ |
| | | public void addTaskAttributes(List<RawAttribute> attributes) |
| | | { |
| | | ArrayList<ByteString> baseDNs = new ArrayList<>(); |
| | | for (String baseDN : uData.getBaseDNs()) |
| | | { |
| | | baseDNs.add(ByteString.valueOf(baseDN)); |
| | | } |
| | | attributes.add(new LDAPAttribute( |
| | | ConfigConstants.ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN, baseDNs)); |
| | | ConfigConstants.ATTR_TASK_CONFLICTS_HIST_PURGE_DOMAIN_DN, uData.getBaseDNs())); |
| | | attributes.add(new LDAPAttribute( |
| | | ConfigConstants.ATTR_TASK_CONFLICTS_HIST_PURGE_MAX_DURATION, |
| | | Long.toString(uData.getMaximumDuration()))); |
| | | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | builder.add(v.getValue().toString()); |
| | | } |
| | | |
| | | operationalAttributes.put(t, asList(builder)); |
| | | operationalAttributes.put(t, builder.toAttributeList()); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | userAttributes.put(t, asList(builder)); |
| | | userAttributes.put(t, builder.toAttributeList()); |
| | | if (urlBuilder != null) |
| | | { |
| | | urlAttributes.put(t, asList(urlBuilder)); |
| | | urlAttributes.put(t, urlBuilder.toAttributeList()); |
| | | } |
| | | if (base64Builder != null) |
| | | { |
| | | base64Attributes.put(t, asList(base64Builder)); |
| | | base64Attributes.put(t, base64Builder.toAttributeList()); |
| | | } |
| | | } |
| | | } |
| | |
| | | return attrName; |
| | | } |
| | | |
| | | private ArrayList<Attribute> asList(AttributeBuilder builder) |
| | | { |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | return attrList; |
| | | } |
| | | |
| | | private boolean contains(List<Attribute> urlAttrList, ByteString v) |
| | | { |
| | | if (urlAttrList != null) |
| | |
| | | */ |
| | | package org.opends.server.tools.tasks; |
| | | |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.backends.task.FailedDependencyAction; |
| | | import org.opends.server.backends.task.TaskState; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.protocols.ldap.AddRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.AddResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.DeleteRequestProtocolOp; |
| | |
| | | import org.opends.server.tools.LDAPConnection; |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | /** |
| | |
| | | |
| | | ArrayList<RawAttribute> attributes = new ArrayList<>(); |
| | | |
| | | ArrayList<ByteString> ocValues = new ArrayList<>(3); |
| | | ocValues.add(ByteString.valueOf("top")); |
| | | ocValues.add(ByteString.valueOf(ConfigConstants.OC_TASK)); |
| | | |
| | | ArrayList<String> ocValues = new ArrayList<>(4); |
| | | ocValues.add("top"); |
| | | ocValues.add(ConfigConstants.OC_TASK); |
| | | if (scheduleRecurring) { |
| | | ocValues.add(ByteString.valueOf(ConfigConstants.OC_RECURRING_TASK)); |
| | | ocValues.add((ConfigConstants.OC_RECURRING_TASK)); |
| | | } |
| | | |
| | | ocValues.add(ByteString.valueOf(information.getTaskObjectclass())); |
| | | ocValues.add(information.getTaskObjectclass()); |
| | | attributes.add(new LDAPAttribute(ATTR_OBJECTCLASS, ocValues)); |
| | | |
| | | ArrayList<ByteString> taskIDValues = new ArrayList<>(1); |
| | | taskIDValues.add(ByteString.valueOf(taskID)); |
| | | |
| | | if (scheduleRecurring) { |
| | | attributes.add(new LDAPAttribute(ATTR_RECURRING_TASK_ID, taskIDValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_RECURRING_TASK_ID, taskID)); |
| | | } |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_ID, taskIDValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_ID, taskID)); |
| | | |
| | | ArrayList<ByteString> classValues = new ArrayList<>(1); |
| | | classValues.add(ByteString.valueOf(information.getTaskClass().getName())); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, classValues)); |
| | | String classValue = information.getTaskClass().getName(); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_CLASS, classValue)); |
| | | |
| | | // add the start time if necessary |
| | | Date startDate = information.getStartDateTime(); |
| | | if (startDate != null) { |
| | | String startTimeString = StaticUtils.formatDateTimeString(startDate); |
| | | ArrayList<ByteString> startDateValues = new ArrayList<>(1); |
| | | startDateValues.add(ByteString.valueOf(startTimeString)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME, startDateValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME, startTimeString)); |
| | | } |
| | | |
| | | if (scheduleRecurring) { |
| | | ArrayList<ByteString> recurringPatternValues = new ArrayList<>(1); |
| | | recurringPatternValues.add(ByteString.valueOf( |
| | | information.getRecurringDateTime())); |
| | | String recurringPatternValues = information.getRecurringDateTime(); |
| | | attributes.add(new LDAPAttribute(ATTR_RECURRING_TASK_SCHEDULE, recurringPatternValues)); |
| | | } |
| | | |
| | | // add dependency IDs |
| | | List<String> dependencyIds = information.getDependencyIds(); |
| | | if (dependencyIds != null && !dependencyIds.isEmpty()) { |
| | | ArrayList<ByteString> dependencyIdValues = new ArrayList<>(dependencyIds.size()); |
| | | for (String dependencyId : dependencyIds) { |
| | | dependencyIdValues.add(ByteString.valueOf(dependencyId)); |
| | | } |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_DEPENDENCY_IDS, dependencyIdValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_DEPENDENCY_IDS, dependencyIds)); |
| | | |
| | | // add the dependency action |
| | | FailedDependencyAction fda = information.getFailedDependencyAction(); |
| | | if (fda == null) { |
| | | fda = FailedDependencyAction.defaultValue(); |
| | | } |
| | | ArrayList<ByteString> fdaValues = new ArrayList<>(1); |
| | | fdaValues.add(ByteString.valueOf(fda.name())); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_FAILED_DEPENDENCY_ACTION, fdaValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_FAILED_DEPENDENCY_ACTION, fda.name())); |
| | | } |
| | | |
| | | // add completion notification email addresses |
| | | List<String> compNotifEmailAddresss = |
| | | information.getNotifyUponCompletionEmailAddresses(); |
| | | List<String> compNotifEmailAddresss = information.getNotifyUponCompletionEmailAddresses(); |
| | | if (compNotifEmailAddresss != null && !compNotifEmailAddresss.isEmpty()) { |
| | | ArrayList<ByteString> compNotifEmailAddrValues = new ArrayList<>(compNotifEmailAddresss.size()); |
| | | for (String emailAddr : compNotifEmailAddresss) { |
| | | compNotifEmailAddrValues.add(ByteString.valueOf(emailAddr)); |
| | | } |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_COMPLETION, compNotifEmailAddrValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_COMPLETION, compNotifEmailAddresss)); |
| | | } |
| | | |
| | | // add error notification email addresses |
| | | List<String> errNotifEmailAddresss = |
| | | information.getNotifyUponErrorEmailAddresses(); |
| | | List<String> errNotifEmailAddresss = information.getNotifyUponErrorEmailAddresses(); |
| | | if (errNotifEmailAddresss != null && !errNotifEmailAddresss.isEmpty()) { |
| | | ArrayList<ByteString> errNotifEmailAddrValues = new ArrayList<>(errNotifEmailAddresss.size()); |
| | | for (String emailAddr : errNotifEmailAddresss) { |
| | | errNotifEmailAddrValues.add(ByteString.valueOf(emailAddr)); |
| | | } |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_ERROR, errNotifEmailAddrValues)); |
| | | attributes.add(new LDAPAttribute(ATTR_TASK_NOTIFY_ON_ERROR, errNotifEmailAddresss)); |
| | | } |
| | | |
| | | information.addTaskAttributes(attributes); |
| | |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | String newState; |
| | | if (TaskState.isPending(state)) { |
| | | newState = TaskState.CANCELED_BEFORE_STARTING.name(); |
| | | } else { |
| | | newState = TaskState.STOPPED_BY_ADMINISTRATOR.name(); |
| | | } |
| | | values.add(ByteString.valueOf(newState)); |
| | | LDAPAttribute attr = new LDAPAttribute(ATTR_TASK_STATE, values); |
| | | LDAPAttribute attr = new LDAPAttribute(ATTR_TASK_STATE, newState); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | |
| | | ModifyRequestProtocolOp modRequest = |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import static org.opends.server.types.AccountStatusNotificationProperty.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | import org.opends.server.core.PasswordPolicy; |
| | | import org.opends.server.core.PasswordPolicyState; |
| | | |
| | | import static org.opends.server.types. |
| | | AccountStatusNotificationProperty.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines a data type for storing information associated |
| | | * with an account status notification. |
| | |
| | | HashMap<AccountStatusNotificationProperty,List<String>> props = new HashMap<>(4); |
| | | |
| | | PasswordPolicy policy = pwPolicyState.getAuthenticationPolicy(); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(1); |
| | | propList.add(policy.getDN().toString()); |
| | | props.put(PASSWORD_POLICY_DN, propList); |
| | | props.put(PASSWORD_POLICY_DN, newArrayList(policy.getDN().toString())); |
| | | |
| | | if (tempLocked) |
| | | { |
| | | long secondsUntilUnlock = policy.getLockoutDuration(); |
| | | if (secondsUntilUnlock > 0L) |
| | | { |
| | | propList = new ArrayList<>(1); |
| | | propList.add(String.valueOf(secondsUntilUnlock)); |
| | | props.put(SECONDS_UNTIL_UNLOCK, propList); |
| | | props.put(SECONDS_UNTIL_UNLOCK, newArrayList(String.valueOf(secondsUntilUnlock))); |
| | | |
| | | propList = new ArrayList<>(1); |
| | | propList.add(secondsToTimeString(secondsUntilUnlock).toString()); |
| | | props.put(TIME_UNTIL_UNLOCK, propList); |
| | | String string = secondsToTimeString(secondsUntilUnlock).toString(); |
| | | props.put(TIME_UNTIL_UNLOCK, newArrayList(string)); |
| | | |
| | | long unlockTime = System.currentTimeMillis() + |
| | | (1000*secondsUntilUnlock); |
| | | propList = new ArrayList<>(1); |
| | | propList.add(new Date(unlockTime).toString()); |
| | | props.put(ACCOUNT_UNLOCK_TIME, propList); |
| | | long unlockTime = System.currentTimeMillis() + (1000 * secondsUntilUnlock); |
| | | props.put(ACCOUNT_UNLOCK_TIME, newArrayList(new Date(unlockTime).toString())); |
| | | } |
| | | } |
| | | |
| | | if (timeToExpiration >= 0) |
| | | { |
| | | propList = new ArrayList<>(1); |
| | | propList.add(String.valueOf(timeToExpiration)); |
| | | props.put(SECONDS_UNTIL_EXPIRATION, propList); |
| | | props.put(SECONDS_UNTIL_EXPIRATION, newArrayList(String.valueOf(timeToExpiration))); |
| | | |
| | | propList = new ArrayList<>(1); |
| | | propList.add(secondsToTimeString(timeToExpiration).toString()); |
| | | props.put(TIME_UNTIL_EXPIRATION, propList); |
| | | String string = secondsToTimeString(timeToExpiration).toString(); |
| | | props.put(TIME_UNTIL_EXPIRATION, newArrayList(string)); |
| | | |
| | | long expTime = System.currentTimeMillis() + (1000*timeToExpiration); |
| | | propList = new ArrayList<>(1); |
| | | propList.add(new Date(expTime).toString()); |
| | | props.put(PASSWORD_EXPIRATION_TIME, propList); |
| | | long expTime = System.currentTimeMillis() + (1000 * timeToExpiration); |
| | | props.put(PASSWORD_EXPIRATION_TIME, newArrayList(new Date(expTime).toString())); |
| | | } |
| | | |
| | | if ((oldPasswords != null) && (! oldPasswords.isEmpty())) |
| | |
| | | * @return A string representation of this account status |
| | | * notification. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return "AccountStatusNotification(type=" + |
| | |
| | | ",message=" + message + ")"; |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.util.Reject; |
| | | import org.forgerock.util.Utils; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | private static final class RealAttributeNoOptions extends RealAttribute |
| | | { |
| | | |
| | | /** |
| | | * Creates a new real attribute that has no options. |
| | | * |
| | |
| | | { |
| | | return (options == null || options.isEmpty()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | private static final class RealAttributeSingleOption |
| | | extends RealAttribute |
| | | { |
| | | |
| | | /** The normalized single option. */ |
| | | private final String normalizedOption; |
| | | |
| | |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private static final class AttributeValue |
| | | { |
| | | |
| | | private final AttributeType attributeType; |
| | | |
| | | /** User-provided value. */ |
| | |
| | | { |
| | | return value != null ? value.toString() : "null"; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** The attribute type for this attribute. */ |
| | | private AttributeType attributeType; |
| | | |
| | | /** The name of this attribute as provided by the end user. */ |
| | | private String name; |
| | | |
| | | /** The normalized set of options if there are more than one. */ |
| | | private SortedSet<String> normalizedOptions; |
| | | |
| | | /** The set of options. */ |
| | | private final SmallSet<String> options = new SmallSet<>(); |
| | | |
| | | /** The set of attribute values, which are lazily normalized. */ |
| | | private Set<AttributeValue> values = new SmallSet<>(); |
| | | |
| | |
| | | * supports attribute value removals via its <code>remove</code> |
| | | * method. |
| | | * |
| | | * @return An iterator over the attribute values in this attribute |
| | | * builder. |
| | | * @return An iterator over the attribute values in this attribute builder. |
| | | */ |
| | | @Override |
| | | public Iterator<ByteString> iterator() |
| | |
| | | */ |
| | | boolean isNormalized() |
| | | { |
| | | Iterator<AttributeValue> iterator = values.iterator(); |
| | | while (iterator.hasNext()) |
| | | for (AttributeValue attrValue : values) |
| | | { |
| | | if (iterator.next().isNormalized()) |
| | | if (attrValue.isNormalized()) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns an attribute representing the content of this attribute |
| | | * builder. |
| | | * Returns an attribute representing the content of this attribute builder. |
| | | * <p> |
| | | * For efficiency purposes this method resets the content of this |
| | | * attribute builder so that it no longer contains any options or |
| | | * values and its attribute type is <code>null</code>. |
| | | * |
| | | * @return An attribute representing the content of this attribute |
| | | * builder. |
| | | * @return An attribute representing the content of this attribute builder. |
| | | * @throws IllegalStateException |
| | | * If this attribute builder has an undefined attribute |
| | | * type or name. |
| | | * If this attribute builder has an undefined attribute type or name. |
| | | */ |
| | | public Attribute toAttribute() throws IllegalStateException |
| | | { |
| | | if (attributeType == null) |
| | | { |
| | | throw new IllegalStateException( |
| | | "Undefined attribute type or name"); |
| | | throw new IllegalStateException("Undefined attribute type or name"); |
| | | } |
| | | |
| | | // Now create the appropriate attribute based on the options. |
| | | Attribute attribute; |
| | | switch (options.size()) |
| | | { |
| | | case 0: |
| | | attribute = new RealAttributeNoOptions(attributeType, name, values); |
| | | break; |
| | | case 1: |
| | | attribute = |
| | | new RealAttributeSingleOption(attributeType, name, values, options.firstElement); |
| | | break; |
| | | default: |
| | | attribute = |
| | | new RealAttributeManyOptions(attributeType, name, values, |
| | | Collections.unmodifiableSet(options.elements), Collections.unmodifiableSortedSet(normalizedOptions)); |
| | | break; |
| | | } |
| | | Attribute attribute = toAttribute0(); |
| | | |
| | | // Reset the state of this builder. |
| | | attributeType = null; |
| | |
| | | return attribute; |
| | | } |
| | | |
| | | private Attribute toAttribute0() |
| | | { |
| | | switch (options.size()) |
| | | { |
| | | case 0: |
| | | return new RealAttributeNoOptions(attributeType, name, values); |
| | | case 1: |
| | | return new RealAttributeSingleOption(attributeType, name, values, options.firstElement); |
| | | default: |
| | | return new RealAttributeManyOptions(attributeType, name, values, |
| | | Collections.unmodifiableSet(options.elements), Collections.unmodifiableSortedSet(normalizedOptions)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns a List with a single attribute representing the content of this attribute builder. |
| | | * <p> |
| | | * For efficiency purposes this method resets the content of this |
| | | * attribute builder so that it no longer contains any options or |
| | | * values and its attribute type is <code>null</code>. |
| | | * |
| | | * @return A List with a single attribute representing the content of this attribute builder. |
| | | * @throws IllegalStateException |
| | | * If this attribute builder has an undefined attribute type or name. |
| | | */ |
| | | public List<Attribute> toAttributeList() throws IllegalStateException |
| | | { |
| | | return CollectionUtils.newArrayList(toAttribute()); |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | |
| | | { |
| | | |
| | | /** |
| | | * Creates a new single-valued attribute with the specified |
| | | * attribute type and value. |
| | | * Creates a new single-valued attribute with the specified attribute type and value. |
| | | * |
| | | * @param attributeType |
| | | * The attribute type to use. |
| | |
| | | return create(attributeType, attributeType.getNameOrOID(), value); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Creates a new List with a single-valued attribute with the specified attribute type and value. |
| | | * |
| | | * @param attributeType |
| | | * The attribute type to use. |
| | | * @param value |
| | | * The attribute value. |
| | | * @return A new List with a single-valued attribute with the attribute type and value. |
| | | */ |
| | | public static List<Attribute> createAsList(AttributeType attributeType, ByteString value) |
| | | { |
| | | return newArrayList(create(attributeType, value)); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new single-valued attribute with the specified name and |
| | | * value. |
| | | * Creates a new single-valued attribute with the specified name and value. |
| | | * |
| | | * @param attributeType |
| | | * The attribute type to use. |
| | |
| | | * The String representation of the attribute value. |
| | | * @return A new attribute with the specified name and value. |
| | | */ |
| | | public static Attribute create(AttributeType attributeType, |
| | | String valueString) |
| | | public static Attribute create(AttributeType attributeType, String valueString) |
| | | { |
| | | return create(attributeType, attributeType.getNameOrOID(), |
| | | valueString); |
| | | return create(attributeType, attributeType.getNameOrOID(), valueString); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Creates a new List with a single-valued attribute with the specified name and value. |
| | | * |
| | | * @param attributeType |
| | | * The attribute type to use. |
| | | * @param valueString |
| | | * The String representation of the attribute value. |
| | | * @return A new List with a attribute with the specified name and value. |
| | | */ |
| | | public static List<Attribute> createAsList(AttributeType attributeType, String valueString) |
| | | { |
| | | return newArrayList(create(attributeType, valueString)); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new single-valued attribute with the specified |
| | |
| | | * The attribute value. |
| | | * @return A new attribute with the attribute type and value. |
| | | */ |
| | | public static Attribute create(AttributeType attributeType, |
| | | String name, ByteString value) |
| | | public static Attribute create(AttributeType attributeType, String name, ByteString value) |
| | | { |
| | | return AttributeBuilder.create(attributeType, name, Collections |
| | | .singleton(value)); |
| | | return AttributeBuilder.create(attributeType, name, Collections.singleton(value)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new single-valued attribute with the attribute type and |
| | | * value. |
| | | * Creates a new single-valued attribute with the attribute type and value. |
| | | * |
| | | * @param attributeType |
| | | * The attribute type to use. |
| | |
| | | * The String representation of the attribute value. |
| | | * @return A new attribute with the attribute type and value. |
| | | */ |
| | | public static Attribute create(AttributeType attributeType, |
| | | String name, String valueString) |
| | | public static Attribute create(AttributeType attributeType, String name, String valueString) |
| | | { |
| | | ByteString value = ByteString.valueOf(valueString); |
| | | return create(attributeType, name, value); |
| | | return create(attributeType, name, ByteString.valueOf(valueString)); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new List with a single-valued attribute with the attribute type and value. |
| | | * |
| | | * @param attributeType |
| | | * The attribute type to use. |
| | | * @param name |
| | | * The user-provided name for this attribute. |
| | | * @param valueString |
| | | * The String representation of the attribute value. |
| | | * @return A new List with a single-valued attribute with the attribute type and value. |
| | | */ |
| | | |
| | | public static List<Attribute> createAsList(AttributeType attributeType, String name, String valueString) |
| | | { |
| | | return newArrayList(create(attributeType, name, valueString)); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new single-valued attribute with the specified |
| | |
| | | import java.io.BufferedWriter; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.server.api.CompressedSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.api.ProtocolElement; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.UtilityMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.LDIFWriter.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | } |
| | | if (attributeType.isObjectClass() && !objectClasses.isEmpty()) |
| | | { |
| | | return newList(getObjectClassAttribute()); |
| | | return newArrayList(getObjectClassAttribute()); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | |
| | | // We are adding the first attribute with this attribute type. |
| | | putAttributes(attributeType, newList(attribute)); |
| | | putAttributes(attributeType, newArrayList(attribute)); |
| | | return; |
| | | } |
| | | |
| | |
| | | objectClassesCopy = new LinkedHashMap<>(0); |
| | | |
| | | // Add empty object class attribute. |
| | | userAttrsCopy.put(ocType, newList(Attributes.empty(ocType))); |
| | | userAttrsCopy.put(ocType, newArrayList(Attributes.empty(ocType))); |
| | | } |
| | | else |
| | | { |
| | |
| | | Attribute ocAttr = getObjectClassAttribute(); |
| | | if (ocAttr != null) |
| | | { |
| | | userAttrsCopy.put(ocType, newList(ocAttr)); |
| | | userAttrsCopy.put(ocType, newArrayList(ocAttr)); |
| | | } |
| | | } |
| | | |
| | |
| | | if (omitValues) |
| | | { |
| | | // Add empty object class attribute. |
| | | userAttrsCopy.put(ocType, newList(Attributes.empty(ocType))); |
| | | userAttrsCopy.put(ocType, newArrayList(Attributes.empty(ocType))); |
| | | } |
| | | else |
| | | { |
| | |
| | | Attribute ocAttr = getObjectClassAttribute(); |
| | | if (ocAttr != null) |
| | | { |
| | | userAttrsCopy.put(ocType, newList(ocAttr)); |
| | | userAttrsCopy.put(ocType, newArrayList(ocAttr)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (omitValues) |
| | | { |
| | | userAttrsCopy.put(ocType, newList(Attributes.empty(ocType, |
| | | attrName))); |
| | | userAttrsCopy.put(ocType, newArrayList(Attributes.empty(ocType, attrName))); |
| | | } |
| | | else |
| | | { |
| | |
| | | ocAttr = builder.toAttribute(); |
| | | } |
| | | |
| | | userAttrsCopy.put(ocType, newList(ocAttr)); |
| | | userAttrsCopy.put(ocType, newArrayList(ocAttr)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns a new List containing only the supplied element. |
| | | * |
| | | * @param elem |
| | | * the element to add to the list |
| | | * @return a new List containing only the supplied element. |
| | | */ |
| | | private List<Attribute> newList(Attribute elem) |
| | | { |
| | | List<Attribute> l = new ArrayList<>(1); |
| | | l.add(elem); |
| | | return l; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Copies the provided list of attributes into the destination |
| | | * attribute map according to the provided criteria. |
| | | * |
| | |
| | | for (String value : objectClasses.values()) { |
| | | builder.add(value); |
| | | } |
| | | Map<AttributeType, List<Attribute>> attributes = |
| | | toAttributesMap(attrBuilders); |
| | | Map<AttributeType, List<Attribute>> attributes = toAttributesMap(attrBuilders); |
| | | if (attributes.get(ocType) == null) |
| | | { |
| | | List<Attribute> ocAttrList = new ArrayList<>(1); |
| | | ocAttrList.add(builder.toAttribute()); |
| | | attributes.put(ocType, ocAttrList); |
| | | attributes.put(ocType, builder.toAttributeList()); |
| | | } |
| | | |
| | | return new AddChangeRecordEntry(entryDN, attributes); |
| | |
| | | AttributeType attrType, String attrName, ByteString attrValue) |
| | | { |
| | | List<Attribute> attrList = attrs.get(attrType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrName); |
| | | builder.add(attrValue); |
| | | attrList = new ArrayList<>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | attrs.put(attrType, attrList); |
| | | } |
| | | else |
| | | if (attrList != null && !attrList.isEmpty()) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attrList.get(0)); |
| | | builder.add(attrValue); |
| | | attrList.set(0, builder.toAttribute()); |
| | | } |
| | | else |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attrType, attrName); |
| | | builder.add(attrValue); |
| | | attrs.put(attrType, builder.toAttributeList()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | |
| | | |
| | | // Set the password changed time attribute. |
| | | ArrayList<Attribute> changedTimeList = new ArrayList<>(1); |
| | | Attribute changedTime = Attributes.create( |
| | | OP_ATTR_PWPOLICY_CHANGED_TIME, TimeThread.getGeneralizedTime()); |
| | | changedTimeList.add(changedTime); |
| | | entry.putAttribute(changedTime.getAttributeType(), changedTimeList); |
| | | entry.putAttribute(changedTime.getAttributeType(), newArrayList(changedTime)); |
| | | |
| | | |
| | | // If we should force change on add, then set the appropriate flag. |
| | |
| | | { |
| | | addPWPolicyControl(PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | |
| | | ArrayList<Attribute> resetList = new ArrayList<>(1); |
| | | Attribute reset = Attributes.create( |
| | | OP_ATTR_PWPOLICY_RESET_REQUIRED, "TRUE"); |
| | | resetList.add(reset); |
| | | entry.putAttribute(reset.getAttributeType(), resetList); |
| | | Attribute reset = Attributes.create(OP_ATTR_PWPOLICY_RESET_REQUIRED, "TRUE"); |
| | | entry.putAttribute(reset.getAttributeType(), newArrayList(reset)); |
| | | } |
| | | } |
| | | |
| | |
| | | BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp(); |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", "newPassword"); |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("newPassword")); |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", values); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("newPassword")); |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", values); |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", "newPassword"); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | |
| | | TestPasswordValidator.setNextReturnValue(false); |
| | |
| | | BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp(); |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", "password"); |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("password")); |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", values); |
| | | mods.add(new LDAPModification(ModificationType.DELETE, attr)); |
| | | |
| | | values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("newPassword")); |
| | | attr = new LDAPAttribute("userPassword", values); |
| | | attr = new LDAPAttribute("userPassword", "newPassword"); |
| | | mods.add(new LDAPModification(ModificationType.ADD, attr)); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | |
| | | BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp(); |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", "newPassword"); |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("newPassword")); |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", values); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | |
| | | BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp(); |
| | | assertEquals(bindResponse.getResultCode(), 0); |
| | | |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", "password"); |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("password")); |
| | | LDAPAttribute attr = new LDAPAttribute("userPassword", values); |
| | | mods.add(new LDAPModification(ModificationType.DELETE, attr)); |
| | | |
| | | values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("newPassword")); |
| | | attr = new LDAPAttribute("userPassword", values); |
| | | attr = new LDAPAttribute("userPassword", "newPassword"); |
| | | mods.add(new LDAPModification(ModificationType.ADD, attr)); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPPasswordModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.testng.Assert; |
| | | import org.testng.Reporter; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | |
| | | { |
| | | Reporter.log("Restoring global ACI attribute: " + globalACIAttribute); |
| | | |
| | | List<Modification> modifications = new ArrayList<>(1); |
| | | modifications.add(new Modification(ModificationType.REPLACE, |
| | | globalACIAttribute)); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ResultCode rc = |
| | | conn.processModify(DN.valueOf(ACCESS_HANDLER_DN), |
| | | modifications).getResultCode(); |
| | | Assert.assertEquals(rc, ResultCode.SUCCESS, |
| | | "Unable to restore global ACI"); |
| | | Modification mod = new Modification(ModificationType.REPLACE,globalACIAttribute); |
| | | ModifyOperation op = getRootConnection().processModify(DN.valueOf(ACCESS_HANDLER_DN), newArrayList(mod)); |
| | | Assert.assertEquals(op.getResultCode(), ResultCode.SUCCESS, "Unable to restore global ACI"); |
| | | } |
| | | } |
| | | |
| | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.controls.PersistentSearchChangeType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | //Modify the configuration to allow only 1 concurrent persistent search. |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("1")); |
| | | LDAPAttribute attr = new LDAPAttribute("ds-cfg-max-psearches", values); |
| | | LDAPAttribute attr = new LDAPAttribute("ds-cfg-max-psearches", "1"); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, attr)); |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | // the delay request control so it won't complete before we can send the |
| | | // abandon request. |
| | | ArrayList<RawAttribute> attributes = new ArrayList<>(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<>(2); |
| | | values.add(ByteString.valueOf("top")); |
| | | values.add(ByteString.valueOf("organizationalUnit")); |
| | | attributes.add(new LDAPAttribute("objectClass", values)); |
| | | |
| | | values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf("People")); |
| | | attributes.add(new LDAPAttribute("ou", values)); |
| | | attributes.add(new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit"))); |
| | | attributes.add(new LDAPAttribute("ou", "People")); |
| | | |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), |
| | | attributes); |
| | | new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), attributes); |
| | | message = new LDAPMessage(2, addRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | // Create a modify request and send it to the server. Make sure to include |
| | | // the delay request control so it won't complete before we can send the |
| | | // abandon request. |
| | | ArrayList<ByteString> values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf("foo")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(1); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | | new LDAPAttribute("description", values))); |
| | | new LDAPAttribute("description", "foo"))); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods); |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.WritabilityMode; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.AfterMethod; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | ArrayList<Control> noControls = new ArrayList<>(); |
| | | |
| | | ArrayList<RawAttribute> ldapAttrList = newRawAttributes( |
| | | new LDAPAttribute("objectclass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectclass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: ou=People,o=test", |
| | |
| | | public void testGetEntryDNInitiallyNull() |
| | | { |
| | | ArrayList<RawAttribute> ldapAttrList = newRawAttributes( |
| | | new LDAPAttribute("objectclass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectclass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | AddOperationBasis addOperation = |
| | | new AddOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | |
| | | assertFalse(rawAttrs.isEmpty()); |
| | | |
| | | ArrayList<RawAttribute> copiedAttrs = new ArrayList<>(rawAttrs); |
| | | copiedAttrs.add(new LDAPAttribute("description", byteStrings("foo"))); |
| | | copiedAttrs.add(new LDAPAttribute("description", "foo")); |
| | | addOperation.setRawAttributes(copiedAttrs); |
| | | |
| | | assertTrue(find(addOperation, "description")); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd("ou=People,o=test", attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd("invalid", attrs); |
| | | assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organization")), |
| | | new LDAPAttribute("o", byteStrings("test"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organization")), |
| | | new LDAPAttribute("o", "test")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd("o=test", attrs); |
| | | assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organization")), |
| | | new LDAPAttribute("o", byteStrings("undefined"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organization")), |
| | | new LDAPAttribute("o", "undefined")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd("o=undefined", attrs); |
| | | assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd("ou=People,o=undefined", attrs); |
| | | assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd("ou=People,o=missing,o=test", attrs); |
| | | assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | bind(r, w); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People")), |
| | | new LDAPAttribute("creatorsName", byteStrings("cn=Directory Manager")), |
| | | new LDAPAttribute("createTimestamp", byteStrings("20060101000000Z"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People"), |
| | | new LDAPAttribute("creatorsName", "cn=Directory Manager"), |
| | | new LDAPAttribute("createTimestamp", "20060101000000Z")); |
| | | |
| | | long addRequests = ldapStatistics.getAddRequests(); |
| | | long addResponses = ldapStatistics.getAddResponses(); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "undefined")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "undefined")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | assertNotEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("description", byteStrings("foo")), |
| | | new LDAPAttribute("ou", byteStrings("People")), |
| | | new LDAPAttribute("description", byteStrings("bar"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("description", "foo"), |
| | | new LDAPAttribute("ou", "People"), |
| | | new LDAPAttribute("description", "bar")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("description", byteStrings("foo")), |
| | | new LDAPAttribute("ou", byteStrings("People")), |
| | | new LDAPAttribute("description;lang-en-us", byteStrings("foo"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("description", "foo"), |
| | | new LDAPAttribute("ou", "People"), |
| | | new LDAPAttribute("description;lang-en-us", "foo")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People")), |
| | | new LDAPAttribute("description;lang-en-us", byteStrings("foo"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People"), |
| | | new LDAPAttribute("description;lang-en-us", "foo")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(ByteString.valueOf("ou=People,o=test"), attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "ds-root-dse", "extensibleObject")), |
| | | new LDAPAttribute("cn", byteStrings("Root DSE"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "ds-root-dse", "extensibleObject")), |
| | | new LDAPAttribute("cn", "Root DSE")); |
| | | |
| | | AddOperation addOperation = |
| | | getRootConnection().processAdd(ByteString.empty(), attrs); |
| | |
| | | bind(r, w); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | DirectoryServer.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | | |
| | |
| | | bind(r, w); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | b.setWritabilityMode(WritabilityMode.INTERNAL_ONLY); |
| | |
| | | bind(r, w); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | addDisconnect(r, w, attrs, "PreParse"); |
| | | |
| | |
| | | bind(r, w); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | addDisconnect(r, w, attrs, "PreOperation"); |
| | | |
| | |
| | | bind(r, w); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | addDisconnect(r, w, attrs, "PostOperation"); |
| | | |
| | |
| | | bind(r, w); |
| | | |
| | | ArrayList<RawAttribute> attrs = newRawAttributes( |
| | | new LDAPAttribute("objectClass", byteStrings("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", byteStrings("People"))); |
| | | new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit")), |
| | | new LDAPAttribute("ou", "People")); |
| | | |
| | | writeAddRequest(w, attrs, "PostResponse"); |
| | | |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.WritabilityMode; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods)); |
| | | |
| | | ArrayList<ByteString> values2 = newArrayList(ByteString.valueOf("bar")); |
| | | LDAPAttribute ldapAttr2 = new LDAPAttribute("description", values2); |
| | | String value2 = "bar"; |
| | | LDAPAttribute ldapAttr2 = new LDAPAttribute("description", value2); |
| | | ldapMods = newRawModifications(delete(ldapAttr), add(ldapAttr2)); |
| | | |
| | | opList.add(newModifyOperation(null, ByteString.empty(), ldapMods)); |
| | |
| | | opList.add(newModifyOperation(null, ByteString.valueOf("o=test"), ldapMods)); |
| | | opList.add(newModifyOperation(noControls, ByteString.valueOf("o=test"), ldapMods)); |
| | | |
| | | ldapAttr2 = new LDAPAttribute("cn", values2); |
| | | ldapAttr2 = new LDAPAttribute("cn", value2); |
| | | ldapMods = newRawModifications(replace(ldapAttr), replace(ldapAttr2)); |
| | | |
| | | opList.add(newModifyOperation(null, ByteString.empty(), ldapMods)); |
| | |
| | | assertNotNull(modifyOperation.getEntryDN()); |
| | | } |
| | | |
| | | |
| | | private LDAPAttribute newLDAPAttribute(String attributeType, String... valueStrings) |
| | | { |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | for (String valueStr : valueStrings) |
| | | { |
| | | values.add(ByteString.valueOf(valueStr)); |
| | | } |
| | | return new LDAPAttribute(attributeType, values); |
| | | return new LDAPAttribute(attributeType, newArrayList(valueStrings)); |
| | | } |
| | | |
| | | /** |
| | |
| | | "axuJ8LFNbZtsp1ldW3i84+F5+SYT+xI67ZcoAtwx/VFVI9s5I/Gkmu9f9nxjPpK7" + |
| | | "1AIUXiE3Qcck"; |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.wrap(Base64.decode(certificateValue))); |
| | | LDAPAttribute attr = new LDAPAttribute("usercertificate", values); |
| | | ByteString value = ByteString.wrap(Base64.decode(certificateValue)); |
| | | LDAPAttribute attr = new LDAPAttribute("usercertificate", value); |
| | | ModifyOperation modifyOperation = processModify("uid=test.user," + baseDN, add(attr)); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | // the delay request control so it won't complete before we can send the |
| | | // cancel request. |
| | | ArrayList<RawAttribute> attributes = new ArrayList<>(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<>(2); |
| | | values.add(ByteString.valueOf("top")); |
| | | values.add(ByteString.valueOf("organizationalUnit")); |
| | | attributes.add(new LDAPAttribute("objectClass", values)); |
| | | |
| | | values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf("People")); |
| | | attributes.add(new LDAPAttribute("ou", values)); |
| | | attributes.add(new LDAPAttribute("objectClass", newArrayList("top", "organizationalUnit"))); |
| | | attributes.add(new LDAPAttribute("ou", "People")); |
| | | |
| | | AddRequestProtocolOp addRequest = |
| | | new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), |
| | | attributes); |
| | | new AddRequestProtocolOp(ByteString.valueOf("ou=People,o=test"), attributes); |
| | | message = new LDAPMessage(2, addRequest, |
| | | DelayPreOpPlugin.createDelayControlList(5000)); |
| | | w.writeMessage(message); |
| | |
| | | // Create a modify request and send it to the server. Make sure to include |
| | | // the delay request control so it won't complete before we can send the |
| | | // cancel request. |
| | | ArrayList<ByteString> values = new ArrayList<>(1); |
| | | values.add(ByteString.valueOf("foo")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(1); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | | new LDAPAttribute("description", values))); |
| | | new LDAPAttribute("description", "foo"))); |
| | | |
| | | ModifyRequestProtocolOp modifyRequest = |
| | | new ModifyRequestProtocolOp(ByteString.valueOf("o=test"), mods); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.ErrorLogAccountStatusNotificationHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server.ErrorLogAccountStatusNotificationHandlerCfg; |
| | | import org.opends.server.api.AccountStatusNotificationHandler; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta. |
| | | ErrorLogAccountStatusNotificationHandlerCfgDefn; |
| | | import org.opends.server.admin.std.server. |
| | | ErrorLogAccountStatusNotificationHandlerCfg; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.PasswordPolicy; |
| | | import org.opends.server.types.AccountStatusNotification; |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import static org.opends.server.types.AccountStatusNotificationType.*; |
| | | import static org.opends.server.types.AccountStatusNotificationProperty.*; |
| | | |
| | | |
| | | import static org.opends.server.types.AccountStatusNotificationType.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the error log account status notification handler. |
| | |
| | | DirectoryServer.getAccountStatusNotificationHandler(handlerDN); |
| | | assertNotNull(handler); |
| | | |
| | | Entry userEntry = |
| | | DirectoryServer.getEntry(DN.valueOf("uid=test.user,o=test")); |
| | | |
| | | PasswordPolicy policy = (PasswordPolicy) AuthenticationPolicy.forUser( |
| | | userEntry, false); |
| | | |
| | | Entry userEntry = DirectoryServer.getEntry(DN.valueOf("uid=test.user,o=test")); |
| | | HashMap<AccountStatusNotificationProperty, List<String>> notificationProperties = new HashMap<>(); |
| | | |
| | | ArrayList<String> propList = new ArrayList<>(1); |
| | | propList.add(policy.getDN().toString()); |
| | | notificationProperties.put(PASSWORD_POLICY_DN, propList); |
| | | |
| | | PasswordPolicy policy = (PasswordPolicy) AuthenticationPolicy.forUser(userEntry, false); |
| | | notificationProperties.put(PASSWORD_POLICY_DN, newArrayList(policy.getDN().toString())); |
| | | |
| | | if (notificationType == ACCOUNT_TEMPORARILY_LOCKED) |
| | | { |
| | | propList = new ArrayList<>(1); |
| | | propList.add("300"); |
| | | notificationProperties.put(SECONDS_UNTIL_UNLOCK, propList); |
| | | notificationProperties.put(SECONDS_UNTIL_UNLOCK, newArrayList("300")); |
| | | notificationProperties.put(TIME_UNTIL_UNLOCK, newArrayList("5 minutes")); |
| | | |
| | | propList = new ArrayList<>(1); |
| | | propList.add("5 minutes"); |
| | | notificationProperties.put(TIME_UNTIL_UNLOCK, propList); |
| | | |
| | | propList = new ArrayList<>(1); |
| | | propList.add(new Date(System.currentTimeMillis() + 300000L).toString()); |
| | | notificationProperties.put(ACCOUNT_UNLOCK_TIME, propList); |
| | | Date date = new Date(System.currentTimeMillis() + 300000L); |
| | | notificationProperties.put(ACCOUNT_UNLOCK_TIME, newArrayList(date.toString())); |
| | | } |
| | | else if (notificationType == PASSWORD_EXPIRING) |
| | | { |
| | | propList = new ArrayList<>(1); |
| | | propList.add("86400"); |
| | | notificationProperties.put(SECONDS_UNTIL_EXPIRATION, propList); |
| | | notificationProperties.put(SECONDS_UNTIL_EXPIRATION, newArrayList("86400")); |
| | | notificationProperties.put(TIME_UNTIL_EXPIRATION, newArrayList("1 day")); |
| | | |
| | | propList = new ArrayList<>(1); |
| | | propList.add("1 day"); |
| | | notificationProperties.put(TIME_UNTIL_EXPIRATION, propList); |
| | | |
| | | propList = new ArrayList<>(1); |
| | | propList.add(new Date(System.currentTimeMillis() + 86400000L).toString()); |
| | | notificationProperties.put(PASSWORD_EXPIRATION_TIME, propList); |
| | | Date date = new Date(System.currentTimeMillis() + 86400000L); |
| | | notificationProperties.put(PASSWORD_EXPIRATION_TIME, newArrayList(date.toString())); |
| | | } |
| | | else if ((notificationType == PASSWORD_CHANGED) || |
| | | (notificationType == PASSWORD_RESET)) |
| | | { |
| | | propList = new ArrayList<>(1); |
| | | propList.add("oldpassword"); |
| | | notificationProperties.put(OLD_PASSWORD, propList); |
| | | |
| | | propList = new ArrayList<>(1); |
| | | propList.add("newpassword"); |
| | | notificationProperties.put(NEW_PASSWORD, propList); |
| | | notificationProperties.put(OLD_PASSWORD, newArrayList("oldpassword")); |
| | | notificationProperties.put(NEW_PASSWORD, newArrayList("newpassword")); |
| | | } |
| | | |
| | | |
| | |
| | | handler.handleStatusNotification(notification); |
| | | } |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | // Create a modification to remove the match attribute. |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("undefinedAttribute")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | | new LDAPAttribute("ds-cfg-match-attribute", |
| | | values))); |
| | | new LDAPAttribute("ds-cfg-match-attribute", "undefinedAttribute"))); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config"; |
| | |
| | | throws Exception |
| | | { |
| | | // Create a modification to remove the match attribute. |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("invalidDN")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | | new LDAPAttribute("ds-cfg-match-base-dn", |
| | | values))); |
| | | new LDAPAttribute("ds-cfg-match-base-dn", "invalidDN"))); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | String mapperDNString = "cn=Exact Match,cn=Identity Mappers,cn=config"; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | nextMessageID); |
| | | |
| | | HashMap<String,List<String>> saslProperties = new HashMap<>(2); |
| | | |
| | | ArrayList<String> authIDList = new ArrayList<>(1); |
| | | authIDList.add("dn:uid=proxy.user,o=test"); |
| | | saslProperties.put("authID", authIDList); |
| | | |
| | | ArrayList<String> authzIDList = new ArrayList<>(1); |
| | | authzIDList.add("dn:uid=test.user,o=test"); |
| | | saslProperties.put("authzID", authzIDList); |
| | | saslProperties.put("authID", newArrayList("dn:uid=proxy.user,o=test")); |
| | | saslProperties.put("authzID", newArrayList("dn:uid=test.user,o=test")); |
| | | |
| | | authHandler.doSASLPlain(ByteString.empty(), |
| | | ByteString.valueOf("password"), saslProperties, |
| | |
| | | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.admin.std.server.PluginCfg; |
| | | 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.ConfigException; |
| | | import org.opends.server.controls.ControlDecoder; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.operation.*; |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | /** |
| | | * This class defines a very simple pre-operation plugin that sleeps for up to |
| | |
| | | */ |
| | | public static List<Control> createDelayControlList(long delay) |
| | | { |
| | | ArrayList<Control> controlList = new ArrayList<>(1); |
| | | |
| | | controlList.add(new DelayRequestControl(false, delay)); |
| | | |
| | | return controlList; |
| | | Control c = new DelayRequestControl(false, delay); |
| | | return CollectionUtils.newArrayList(c); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | 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.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.admin.std.server.PluginCfg; |
| | | 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.ConfigException; |
| | | import org.opends.server.controls.ControlDecoder; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.operation.*; |
| | | |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | /** |
| | | * This class defines a very simple plugin that terminates the client connection |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.error(LocalizableMessage.raw("Unable to decode the disconnect client control: " + |
| | | e)); |
| | | logger.error(LocalizableMessage.raw("Unable to decode the disconnect client control: " + e)); |
| | | } |
| | | |
| | | |
| | | // If we've gotten here, then we shouldn't disconnect the client. |
| | | return false; |
| | | } |
| | |
| | | */ |
| | | public static List<Control> createDisconnectControlList(String section) |
| | | { |
| | | ArrayList<Control> controlList = new ArrayList<>(1); |
| | | |
| | | controlList.add(new DisconnectClientControl(false, section)); |
| | | |
| | | return controlList; |
| | | Control c = new DisconnectClientControl(false, section); |
| | | return CollectionUtils.newArrayList(c); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | private void deleteSubtree(String... dns) throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | SubtreeDeleteControl control = new SubtreeDeleteControl(true); |
| | | List<Control> controls = new ArrayList<>(1); |
| | | controls.add(control); |
| | | Control control = new SubtreeDeleteControl(true); |
| | | List<Control> controls = newArrayList(control); |
| | | |
| | | for (String dn : dns) |
| | | { |
| | | DeleteOperation op = conn.processDelete(DN.valueOf(dn), controls); |
| | | DeleteOperation op = getRootConnection().processDelete(DN.valueOf(dn), controls); |
| | | assertEquals(op.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | |
| | | 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.ConfigException; |
| | | import org.opends.server.controls.ControlDecoder; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | * |
| | | * @return A list containing the appropriate short circuit request control. |
| | | */ |
| | | public static List<Control> createShortCircuitControlList(int resultCode, |
| | | String section) |
| | | public static List<Control> createShortCircuitControlList(int resultCode, String section) |
| | | { |
| | | ArrayList<Control> controlList = new ArrayList<>(1); |
| | | controlList.add(createShortCircuitControl(resultCode, section)); |
| | | return controlList; |
| | | return newArrayList(createShortCircuitControl(resultCode, section)); |
| | | } |
| | | |
| | | /** Registered short circuits for operations regardless of controls. */ |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.PluginCfg; |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyOperation; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | /** |
| | | * This class defines a pre-operation plugin that can be used in add and modify |
| | |
| | | |
| | | for (Attribute a : setAttributes) |
| | | { |
| | | ArrayList<Attribute> attrList = new ArrayList<>(1); |
| | | attrList.add(a); |
| | | addOperation.setAttribute(a.getAttributeType(), attrList); |
| | | addOperation.setAttribute(a.getAttributeType(), newArrayList(a)); |
| | | } |
| | | |
| | | for (ObjectClass oc : removeObjectClasses) |
| | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | ByteString dn = ByteString.valueOf("cn=test,o=test"); |
| | | |
| | | ArrayList<RawAttribute> attrs = new ArrayList<>(); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("top")); |
| | | values.add(ByteString.valueOf("device")); |
| | | attrs.add(new LDAPAttribute("objectClass", values)); |
| | | |
| | | values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("test")); |
| | | attrs.add(new LDAPAttribute("cn", values)); |
| | | attrs.add(new LDAPAttribute("objectClass", newArrayList("top", "device"))); |
| | | attrs.add(new LDAPAttribute("cn", "test")); |
| | | |
| | | AddOperation addOperation = getRootConnection().processAdd(dn, attrs); |
| | | assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | "objectClass: device", |
| | | "cn: test"); |
| | | |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("This is a test")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | | new LDAPAttribute("description", values))); |
| | | new LDAPAttribute("description", "This is a test"))); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | // Try to modify the entry to add a description. |
| | | ArrayList<Modification> mods = new ArrayList<>(1); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("description", "foo"))); |
| | | ArrayList<Modification> mods = |
| | | newArrayList(new Modification(ModificationType.REPLACE, Attributes.create("description", "foo"))); |
| | | |
| | | ModifyOperationBasis modifyOperation = new ModifyOperationBasis(conn, |
| | | conn.nextOperationID(), conn.nextMessageID(), controls, e.getName(), |
| | |
| | | |
| | | |
| | | // Try to modify the entry to add a description. |
| | | ArrayList<Modification> mods = new ArrayList<>(1); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("description", "foo"))); |
| | | ArrayList<Modification> mods = |
| | | newArrayList(new Modification(ModificationType.REPLACE, Attributes.create("description", "foo"))); |
| | | |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, |
| | |
| | | */ |
| | | public class TestAddRequestProtocolOp extends LdapTestCase |
| | | { |
| | | /** |
| | | * The protocol op type for add requests. |
| | | */ |
| | | /** The protocol op type for add requests. */ |
| | | private static final byte OP_TYPE_ADD_REQUEST = 0x68; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The protocol op type for add responses. |
| | | */ |
| | | /** The protocol op type for add responses. */ |
| | | private static final byte OP_TYPE_ADD_RESPONSE = 0x69; |
| | | |
| | | /** |
| | | * The DN for add requests in this test case. |
| | | */ |
| | | private static final ByteString dn = |
| | | ByteString.valueOf("dc=example,dc=com"); |
| | | |
| | | /** |
| | | * The alternative DN for add requests in this test case. |
| | | */ |
| | | private static final ByteString dnAlt = |
| | | ByteString.valueOf("dc=sun,dc=com"); |
| | | /** The DN for add requests in this test case. */ |
| | | private static final ByteString dn = ByteString.valueOf("dc=example,dc=com"); |
| | | |
| | | /** |
| | | * Generate attributes for use in test cases. Attributes will have names |
| | |
| | | |
| | | for (int i = 0; i < numAttributes; i++) |
| | | { |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | ArrayList<String> values = new ArrayList<>(); |
| | | for (int j = 0; j < numValues; j++) |
| | | { |
| | | values.add(ByteString.valueOf(prefix + "Value" + i + "." + j)); |
| | | values.add(prefix + "Value" + i + "." + j); |
| | | } |
| | | attributes.add(new LDAPAttribute("testAttribute" + i, values)); |
| | | } |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.BeforeTest; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RawFilter; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.testng.annotations.BeforeTest; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | public class TestLDAPFilter extends LdapTestCase |
| | |
| | | LDAPFilter presense = LDAPFilter.createPresenceFilter("login"); |
| | | |
| | | ArrayList<ByteString> any = new ArrayList<>(0); |
| | | ArrayList<ByteString> multiAny = new ArrayList<>(1); |
| | | multiAny.add(ByteString.valueOf("\\wid*(get)")); |
| | | multiAny.add(ByteString.valueOf("*")); |
| | | ArrayList<ByteString> multiAny = newArrayList(ByteString.valueOf("\\wid*(get)"), ByteString.valueOf("*")); |
| | | |
| | | LDAPFilter substring1 = LDAPFilter.createSubstringFilter("givenName", |
| | | ByteString.valueOf("\\Jo*()"), |
| | |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | // Replay a replace of a value B at time t2 on a second server. |
| | | Attribute attr = Attributes.create(attrType, "B"); |
| | | Modification mod = new Modification(ModificationType.REPLACE, attr); |
| | | List<Modification> mods = new ArrayList<>(1); |
| | | mods.add(mod); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | ModifyMsg modMsg = new ModifyMsg(t2, dn1, mods, entryuuid); |
| | | broker.publish(modMsg); |
| | | |
| | |
| | | |
| | | // Replay an add of a value A at time t1 on a first server. |
| | | attr = Attributes.create(attrType, "A"); |
| | | mod = new Modification(ModificationType.ADD, attr); |
| | | mods = new ArrayList<>(1); |
| | | mods.add(mod); |
| | | mods = newArrayList(new Modification(ModificationType.ADD, attr)); |
| | | modMsg = new ModifyMsg(t1, dn1, mods, entryuuid); |
| | | broker.publish(modMsg); |
| | | |
| | |
| | | |
| | | // Replay an delete of attribute displayname at time t2 on a second server. |
| | | attr = Attributes.empty(attrType); |
| | | mod = new Modification(ModificationType.DELETE, attr); |
| | | mods = new ArrayList<>(1); |
| | | mods.add(mod); |
| | | mods = newArrayList(new Modification(ModificationType.DELETE, attr)); |
| | | modMsg = new ModifyMsg(t2, dn1, mods, entryuuid); |
| | | broker.publish(modMsg); |
| | | |
| | |
| | | |
| | | // Replay a replace of a value A at time t1 on a first server. |
| | | attr = Attributes.create(attrType, "A"); |
| | | mod = new Modification(ModificationType.REPLACE, attr); |
| | | mods = new ArrayList<>(1); |
| | | mods.add(mod); |
| | | mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | modMsg = new ModifyMsg(t1, dn1, mods, entryuuid); |
| | | broker.publish(modMsg); |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | DN dn, String entryuuid, AttributeType attrType, String newValue) |
| | | { |
| | | Attribute attr = Attributes.create(attrType.getNormalizedPrimaryName(), newValue); |
| | | Modification mod = new Modification(ModificationType.ADD, attr); |
| | | List<Modification> mods = new ArrayList<>(1); |
| | | mods.add(mod); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.ADD, attr)); |
| | | broker.publish(new ModifyMsg(changeNum, dn, mods, entryuuid)); |
| | | } |
| | | |
| | |
| | | UUID uuid = UUID.randomUUID(); |
| | | |
| | | // Create the att values list |
| | | ArrayList<Attribute> uuidList = new ArrayList<>(1); |
| | | Attribute uuidAttr = Attributes.create(entryuuidAttrType, uuid.toString()); |
| | | uuidList.add(uuidAttr); |
| | | List<Attribute> uuidList = Attributes.createAsList(entryuuidAttrType, uuid.toString()); |
| | | |
| | | // Add the uuid in the entry |
| | | Map<AttributeType, List<Attribute>> operationalAttributes = entry.getOperationalAttributes(); |
| | |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | | import java.util.ArrayList; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | // start the server. |
| | | TestCaseUtils.startServer(); |
| | | |
| | | attributes = new HashMap<>(); |
| | | attribute = Attributes.create("cn", "hello world"); |
| | | ArrayList<Attribute> alist = new ArrayList<>(1); |
| | | alist.add(attribute); |
| | | attributes.put(attribute.getAttributeType(), alist); |
| | | attributes = new HashMap<>(); |
| | | attributes.put(attribute.getAttributeType(), newArrayList(attribute)); |
| | | } |
| | | |
| | | /** |