Used CollectionUtils methods.
| | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import javax.swing.Box; |
| | |
| | | import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*; |
| | | import static org.opends.guitools.controlpanel.util.Utilities.*; |
| | |
| | | public class EntryCachesMonitoringPanel extends GeneralMonitoringPanel |
| | | { |
| | | private static final long serialVersionUID = 9031734563700069830L; |
| | | private static List<MonitoringAttributes> ngOperations = new ArrayList<MonitoringAttributes>(Arrays.asList( |
| | | private static List<MonitoringAttributes> ngOperations = CollectionUtils.<MonitoringAttributes> newArrayList( |
| | | ENTRY_CACHE_TRIES, ENTRY_CACHE_HITS, ENTRY_CACHE_HIT_RATIO, CURRENT_ENTRY_CACHE_SIZE, MAX_ENTRY_CACHE_SIZE, |
| | | CURRENT_ENTRY_CACHE_COUNT, MAX_ENTRY_CACHE_COUNT)); |
| | | CURRENT_ENTRY_CACHE_COUNT, MAX_ENTRY_CACHE_COUNT); |
| | | |
| | | private ArrayList<JLabel> monitoringLabels = new ArrayList<>(); |
| | | { |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import static com.forgerock.opendj.util.OperatingSystem.isWindows; |
| | | |
| | | import java.awt.Component; |
| | |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Comparator; |
| | | import java.util.HashSet; |
| | |
| | | /** |
| | | * The panel where the user can specify the java arguments and java home to be |
| | | * used in the command-lines. |
| | | * |
| | | */ |
| | | public class JavaPropertiesPanel extends StatusGenericPanel |
| | | { |
| | |
| | | |
| | | private Set<JavaArgumentsDescriptor> readJavaArguments = new HashSet<>(); |
| | | private Set<JavaArgumentsDescriptor> currentJavaArguments = new HashSet<>(); |
| | | private Set<String> allScriptNames = new HashSet<>(Arrays.asList( |
| | | private Set<String> allScriptNames = newHashSet( |
| | | "start-ds", "import-ldif.offline", "backup.online", "base64", |
| | | "create-rc-script", "dsconfig", "dsreplication", |
| | | "export-ldif.online", "import-ldif.online", "ldapcompare", |
| | |
| | | "ldif-diff", "ldifmodify", "ldifsearch", "make-ldif", |
| | | "rebuild-index", "restore.offline", "upgrade", |
| | | "verify-index", "dbtest" |
| | | )); |
| | | |
| | | private Set<String> relevantScriptNames = new HashSet<>(Arrays.asList( |
| | | ); |
| | | private Set<String> relevantScriptNames = newHashSet( |
| | | "start-ds", "import-ldif.offline", "backup.offline", |
| | | "export-ldif.offline", |
| | | "ldif-diff", "make-ldif", "rebuild-index", "restore.offline", |
| | | "verify-index", "dbtest" |
| | | )); |
| | | ); |
| | | |
| | | private String readJavaHome; |
| | | private boolean readUseOpenDSJavaHome; |
| | |
| | | import java.io.File; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | import java.util.concurrent.Callable; |
| | | import java.util.concurrent.ExecutionException; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.SetupUtils; |
| | | |
| | | /** |
| | |
| | | String[] children = rootDirectory.list(); |
| | | if (children != null) |
| | | { |
| | | Set<String> childrenSet = new HashSet<>(Arrays.asList(children)); |
| | | Set<String> childrenSet = CollectionUtils.newHashSet(children); |
| | | for (String dir : REQUIRED_DIRECTORIES) |
| | | { |
| | | if (!childrenSet.contains(dir)) |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | |
| | | import org.opends.server.types.LDIFImportResult; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.RestoreConfig; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.opends.server.util.LDIFWriter; |
| | |
| | | private HashSet<DN> baseDNSet; |
| | | |
| | | /** The set of supported controls for this backend. */ |
| | | private final Set<String> supportedControls = new HashSet<>(Arrays.asList( |
| | | private final Set<String> supportedControls = CollectionUtils.newHashSet( |
| | | OID_SUBTREE_DELETE_CONTROL, |
| | | OID_PAGED_RESULTS_CONTROL, |
| | | OID_MANAGE_DSAIT_CONTROL, |
| | | OID_SERVER_SIDE_SORT_REQUEST_CONTROL, |
| | | OID_VLV_REQUEST_CONTROL)); |
| | | OID_VLV_REQUEST_CONTROL); |
| | | |
| | | /** The map of null entry object classes. */ |
| | | private Map<ObjectClass,String> objectClasses; |
| | |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.ListIterator; |
| | |
| | | import org.opends.server.types.Privilege; |
| | | import org.opends.server.types.RestoreConfig; |
| | | import org.opends.server.util.BackupManager; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.RuntimeInformation; |
| | | |
| | | import com.sleepycat.je.DatabaseException; |
| | |
| | | private DiskSpaceMonitor diskMonitor; |
| | | private StorageStatus storageStatus = StorageStatus.working(); |
| | | |
| | | /** |
| | | * The controls supported by this backend. |
| | | */ |
| | | private static final Set<String> supportedControls = new HashSet<>(Arrays.asList( |
| | | /** The controls supported by this backend. */ |
| | | private static final Set<String> supportedControls = CollectionUtils.newHashSet( |
| | | OID_SUBTREE_DELETE_CONTROL, |
| | | OID_PAGED_RESULTS_CONTROL, |
| | | OID_MANAGE_DSAIT_CONTROL, |
| | | OID_SERVER_SIDE_SORT_REQUEST_CONTROL, |
| | | OID_VLV_REQUEST_CONTROL)); |
| | | OID_VLV_REQUEST_CONTROL); |
| | | |
| | | /** Begin a Backend API method that reads the database. */ |
| | | private void readerBegin() |
| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.RestoreConfig; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.RuntimeInformation; |
| | | |
| | |
| | | private Storage storage; |
| | | |
| | | /** The controls supported by this backend. */ |
| | | private static final Set<String> supportedControls = new HashSet<>(Arrays.asList( |
| | | private static final Set<String> supportedControls = CollectionUtils.newHashSet( |
| | | OID_SUBTREE_DELETE_CONTROL, |
| | | OID_PAGED_RESULTS_CONTROL, |
| | | OID_MANAGE_DSAIT_CONTROL, |
| | | OID_SERVER_SIDE_SORT_REQUEST_CONTROL, |
| | | OID_VLV_REQUEST_CONTROL)); |
| | | OID_VLV_REQUEST_CONTROL); |
| | | |
| | | /** |
| | | * Begin a Backend API method that accesses the {@link EntryContainer} for <code>entryDN</code> |
| | |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | |
| | | Backend<?> backend = registeredBackends.get(backendDN); |
| | | if (backend != null) |
| | | { |
| | | LinkedHashSet<DN> removedDNs = new LinkedHashSet<>(Arrays.asList(backend.getBaseDNs())); |
| | | LinkedHashSet<DN> removedDNs = newLinkedHashSet(backend.getBaseDNs()); |
| | | LinkedHashSet<DN> addedDNs = new LinkedHashSet<>(baseDNs); |
| | | Iterator<DN> iterator = removedDNs.iterator(); |
| | | while (iterator.hasNext()) |
| | |
| | | import java.lang.management.ManagementFactory; |
| | | import java.net.InetAddress; |
| | | import java.text.DecimalFormat; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashMap; |
| | |
| | | private TreeMap<String, Backend<?>> backends; |
| | | |
| | | /** The set of supported controls registered with the Directory Server. */ |
| | | private final TreeSet<String> supportedControls = new TreeSet<>(Arrays.asList( |
| | | private final TreeSet<String> supportedControls = newTreeSet( |
| | | OID_LDAP_ASSERTION, |
| | | OID_LDAP_READENTRY_PREREAD, |
| | | OID_LDAP_READENTRY_POSTREAD, |
| | |
| | | OID_VIRTUAL_ATTRS_ONLY, |
| | | OID_ACCOUNT_USABLE_CONTROL, |
| | | OID_NS_PASSWORD_EXPIRED, |
| | | OID_NS_PASSWORD_EXPIRING)); |
| | | OID_NS_PASSWORD_EXPIRING); |
| | | |
| | | /** The set of supported feature OIDs registered with the Directory Server. */ |
| | | private final TreeSet<String> supportedFeatures = new TreeSet<>(Arrays.asList( |
| | | private final TreeSet<String> supportedFeatures = newTreeSet( |
| | | OID_ALL_OPERATIONAL_ATTRS_FEATURE, |
| | | OID_MODIFY_INCREMENT_FEATURE, |
| | | OID_TRUE_FALSE_FILTERS_FEATURE)); |
| | | OID_TRUE_FALSE_FILTERS_FEATURE); |
| | | |
| | | /** |
| | | * The trust manager provider configuration manager for the Directory Server. |
| | | */ |
| | | /** The trust manager provider configuration manager for the Directory Server. */ |
| | | private TrustManagerProviderConfigManager trustManagerProviderConfigManager; |
| | | |
| | | /** |
| | | * The virtual attribute provider configuration manager for the Directory |
| | | * Server. |
| | | */ |
| | | /** The virtual attribute provider configuration manager for the Directory Server. */ |
| | | private final VirtualAttributeConfigManager virtualAttributeConfigManager; |
| | | |
| | | /** The work queue that will be used to service client requests. */ |
| | |
| | | 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.*; |
| | | |
| | | /** |
| | |
| | | dn2SubEntry = new HashMap<>(); |
| | | dn2CollectiveSubEntry = new HashMap<>(); |
| | | dit2SubEntry = new DITCacheMap<>(); |
| | | |
| | | changeListeners = new CopyOnWriteArrayList<>(); |
| | | |
| | | requestAttrs = new LinkedHashSet<>(); |
| | | requestAttrs.add("*"); |
| | | requestAttrs.add("+"); |
| | | requestAttrs = newLinkedHashSet("*", "+"); |
| | | |
| | | DirectoryServer.registerInternalPlugin(this); |
| | | DirectoryServer.registerBackendInitializationListener(this); |
| | |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | /** |
| | | * This class provides an implementation of a Directory Server identity mapper |
| | |
| | | |
| | | // Create the attribute list to include in search requests. We want to |
| | | // include all user and operational attributes. |
| | | requestedAttributes = new LinkedHashSet<>(2); |
| | | requestedAttributes.add("*"); |
| | | requestedAttributes.add("+"); |
| | | requestedAttributes = newLinkedHashSet("*", "+"); |
| | | } |
| | | |
| | | |
| | |
| | | import java.security.MessageDigest; |
| | | import java.security.cert.Certificate; |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.*; |
| | | import java.util.Collection; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import javax.security.auth.x500.X500Principal; |
| | | |
| | |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | |
| | | |
| | | // Create the attribute list to include in search requests. We want to |
| | | // include all user and operational attributes. |
| | | requestedAttributes = new LinkedHashSet<>(2); |
| | | requestedAttributes.add("*"); |
| | | requestedAttributes.add("+"); |
| | | requestedAttributes = newLinkedHashSet("*", "+"); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public PasswordModifyExtendedOperation() |
| | | { |
| | | super(new HashSet<String>(Arrays.asList(OID_LDAP_NOOP_OPENLDAP_ASSIGNED, OID_PASSWORD_POLICY_CONTROL))); |
| | | super(newHashSet(OID_LDAP_NOOP_OPENLDAP_ASSIGNED, OID_PASSWORD_POLICY_CONTROL)); |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | 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.*; |
| | |
| | | throws ConfigException, InitializationException |
| | | { |
| | | userFilter = SearchFilter.objectClassPresent(); |
| | | |
| | | // Construct the set of request attributes. |
| | | requestAttributes = new LinkedHashSet<>(2); |
| | | requestAttributes.add("*"); |
| | | requestAttributes.add("+"); |
| | | |
| | | requestAttributes = newLinkedHashSet("*", "+"); |
| | | |
| | | DirectoryServer.registerSupportedExtension(OID_PASSWORD_POLICY_STATE_EXTOP, this); |
| | | // FIXME registerControlAndFeatures? |
| | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | |
| | | |
| | | // Create the attribute list to include in search requests. We want to |
| | | // include all user and operational attributes. |
| | | requestedAttributes = new LinkedHashSet<>(2); |
| | | requestedAttributes.add("*"); |
| | | requestedAttributes.add("+"); |
| | | requestedAttributes = newLinkedHashSet("*", "+"); |
| | | } |
| | | |
| | | |
| | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | 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.StaticUtils.*; |
| | | |
| | | import java.security.cert.Certificate; |
| | |
| | | |
| | | // Create the attribute list to include in search requests. We want to |
| | | // include all user and operational attributes. |
| | | requestedAttributes = new LinkedHashSet<>(2); |
| | | requestedAttributes.add("*"); |
| | | requestedAttributes.add("+"); |
| | | requestedAttributes = newLinkedHashSet("*", "+"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | 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.types.*; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | /** |
| | | * This class implements a very simple Directory Server certificate mapper that |
| | |
| | | |
| | | // Create the attribute list to include in search requests. We want to |
| | | // include all user and operational attributes. |
| | | requestedAttributes = new LinkedHashSet<>(2); |
| | | requestedAttributes.add("*"); |
| | | requestedAttributes.add("+"); |
| | | requestedAttributes = newLinkedHashSet("*", "+"); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | 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.WhoAmIExtendedOperationHandlerCfg; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ExtendedOperationHandler; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.controls.ProxiedAuthV1Control; |
| | | import org.opends.server.controls.ProxiedAuthV2Control; |
| | | import org.opends.server.core.AccessControlConfigManager; |
| | | import org.opends.server.core.ExtendedOperation; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.messages.ProtocolMessages.ERR_PROXYAUTH_AUTHZ_NOT_PERMITTED; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | /** |
| | | * This class implements the "Who Am I?" extended operation defined in RFC 4532. |
| | |
| | | */ |
| | | public WhoAmIExtendedOperation() |
| | | { |
| | | super(new HashSet<String>(Arrays.asList( |
| | | OID_PROXIED_AUTH_V1, OID_PROXIED_AUTH_V2))); |
| | | super(newHashSet(OID_PROXIED_AUTH_V1, OID_PROXIED_AUTH_V2)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | * replication related operational attributes when used in a search operation. |
| | | */ |
| | | private static final Set<String> USER_AND_REPL_OPERATIONAL_ATTRS = |
| | | new HashSet<>(Arrays.asList(HISTORICAL_ATTRIBUTE_NAME, ENTRYUUID_ATTRIBUTE_NAME, "*")); |
| | | newHashSet(HISTORICAL_ATTRIBUTE_NAME, ENTRYUUID_ATTRIBUTE_NAME, "*"); |
| | | |
| | | /** |
| | | * This class is used in the session establishment phase |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | |
| | | |
| | | 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.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | |
| | | import org.opends.server.admin.std.server.CollationMatchingRuleCfg; |
| | | import org.opends.server.api.MatchingRuleFactory; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** Stores the list of available locales on this JVM. */ |
| | | private static final Set<Locale> supportedLocales = new HashSet<>(Arrays.asList(Locale.getAvailableLocales())); |
| | | private static final Set<Locale> supportedLocales = CollectionUtils.newHashSet(Locale.getAvailableLocales()); |
| | | |
| | | /** Current Configuration. */ |
| | | private CollationMatchingRuleCfg currentConfig; |
| | |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | public Object[][] invalidAcis() throws Exception { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | List<String> invalid = new ArrayList<>(Arrays.asList(INVALID_ACIS)); |
| | | List<String> invalid = newArrayList(INVALID_ACIS); |
| | | for (String[] aciAndMask: INVALID_ACIS_IF_ANY_CHAR_REMOVED) { |
| | | invalid.addAll(getAciMissingCharCombos(aciAndMask[0], aciAndMask[1])); |
| | | } |
| | |
| | | } |
| | | |
| | | private static String getNotThisDayOfWeek() { |
| | | Set<String> otherDays = new HashSet<>(Arrays.asList(DAYS_OF_WEEK)); |
| | | Set<String> otherDays = newHashSet(DAYS_OF_WEEK); |
| | | otherDays.remove(getThisDayOfWeek()); |
| | | String dayList = ""; |
| | | for (String otherDay: otherDays) { |
| | |
| | | import java.io.IOException; |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | private ArrayList<RawAttribute> newRawAttributes(RawAttribute... attributes) |
| | | { |
| | | return new ArrayList<>(Arrays.asList(attributes)); |
| | | return newArrayList(attributes); |
| | | } |
| | | |
| | | private ArrayList<ByteString> byteStrings(final String... v) |
| | |
| | | @Test |
| | | public void testSearchExternalAllUserAttributes() throws Exception |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<>(); |
| | | attributes.add("*"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("*"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | |
| | | @Test |
| | | public void testSearchExternalAllUserAttributesOmitValues() throws Exception |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<>(); |
| | | attributes.add("*"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("*"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | |
| | | @Test |
| | | public void testSearchExternalObjectClassAttribute() throws Exception |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<>(); |
| | | attributes.add("objectclass"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("objectclass"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | |
| | | public void testSearchExternalObjectClassAttributeOmitValues() |
| | | throws Exception |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<>(); |
| | | attributes.add("objectclass"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("objectclass"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | |
| | | @Test |
| | | public void testSearchExternalSelectedAttributes() throws Exception |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<>(); |
| | | attributes.add("uid"); |
| | | attributes.add("createtimestamp"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("uid", "createtimestamp"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | |
| | | @Test |
| | | public void testSearchExternalAttributeWithSubtypes() throws Exception |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<>(); |
| | | attributes.add("title"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("title"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | |
| | | public void testSearchExternalAttributeWithSubtypesOmitValues() |
| | | throws Exception |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<>(); |
| | | attributes.add("title"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("title"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | |
| | | @Test |
| | | public void testSearchExternalAttributeWithOptions() throws Exception |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<>(); |
| | | attributes.add("title;lang-ja;phonetic"); |
| | | LinkedHashSet<String> attributes = newLinkedHashSet("title;lang-ja;phonetic"); |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | | ByteString.valueOf(BASE), |
| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.mockito.Mockito.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | |
| | | import static org.assertj.core.api.Assertions.assertThat; |
| | | import static org.mockito.Mockito.mock; |
| | | import static org.mockito.Mockito.when; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.opendj.ldap.AddressMask; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class AbstractTextAccessLogPublisherTest extends DirectoryServerTestCase |
| | | { |
| | |
| | | public void testCriteriaFilterRequestTargetDNEqualTo() throws Exception |
| | | { |
| | | final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); |
| | | when(cfg.getRequestTargetDNEqualTo()).thenReturn(setOf("dc=com")); |
| | | when(cfg.getRequestTargetDNEqualTo()).thenReturn(newTreeSet("dc=com")); |
| | | final CriteriaFilter filter = new CriteriaFilter(cfg); |
| | | final SearchOperation operation = mockAnonymousSearchOperation(); |
| | | when(operation.getBaseDN()).thenReturn(dn("dc=com"), dn("dc=org")); |
| | |
| | | public void testCriteriaFilterRequestTargetDNNotEqualTo() throws Exception |
| | | { |
| | | final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); |
| | | when(cfg.getRequestTargetDNNotEqualTo()).thenReturn(setOf("dc=com")); |
| | | when(cfg.getRequestTargetDNNotEqualTo()).thenReturn(newTreeSet("dc=com")); |
| | | final CriteriaFilter filter = new CriteriaFilter(cfg); |
| | | final SearchOperation operation = mockAnonymousSearchOperation(); |
| | | when(operation.getBaseDN()).thenReturn(dn("dc=com"), dn("dc=org")); |
| | |
| | | public void testCriteriaFilterResponseResultCodeEqualTo() throws Exception |
| | | { |
| | | final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); |
| | | when(cfg.getResponseResultCodeEqualTo()).thenReturn(setOf(32)); |
| | | when(cfg.getResponseResultCodeEqualTo()).thenReturn(newTreeSet(32)); |
| | | final CriteriaFilter filter = new CriteriaFilter(cfg); |
| | | final SearchOperation operation = mockAnonymousSearchOperation(); |
| | | when(operation.getResultCode()).thenReturn(ResultCode.NO_SUCH_OBJECT, |
| | |
| | | public void testCriteriaFilterResponseResultCodeNotEqualTo() throws Exception |
| | | { |
| | | final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); |
| | | when(cfg.getResponseResultCodeNotEqualTo()).thenReturn(setOf(32)); |
| | | when(cfg.getResponseResultCodeNotEqualTo()).thenReturn(newTreeSet(32)); |
| | | final CriteriaFilter filter = new CriteriaFilter(cfg); |
| | | final SearchOperation operation = mockAnonymousSearchOperation(); |
| | | when(operation.getResultCode()).thenReturn(ResultCode.NO_SUCH_OBJECT, |
| | |
| | | { |
| | | final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); |
| | | when(cfg.getUserDNEqualTo()) |
| | | .thenReturn(setOf(dnOfUserInGroup().toString())); |
| | | .thenReturn(newTreeSet(dnOfUserInGroup().toString())); |
| | | final CriteriaFilter filter = new CriteriaFilter(cfg); |
| | | final SearchOperation operation1 = mockAuthenticatedSearchOperation(dnOfUserInGroup()); |
| | | assertThat(filter.isRequestLoggable(operation1)).isTrue(); |
| | |
| | | { |
| | | final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); |
| | | when(cfg.getUserDNNotEqualTo()).thenReturn( |
| | | setOf(dnOfUserInGroup().toString())); |
| | | newTreeSet(dnOfUserInGroup().toString())); |
| | | final CriteriaFilter filter = new CriteriaFilter(cfg); |
| | | final SearchOperation operation1 = mockAuthenticatedSearchOperation(dnOfUserInGroup()); |
| | | assertThat(filter.isRequestLoggable(operation1)).isFalse(); |
| | |
| | | public void testCriteriaFilterUserIsMemberOf() throws Exception |
| | | { |
| | | final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); |
| | | when(cfg.getUserIsMemberOf()).thenReturn(setOf(dnOfGroup())); |
| | | when(cfg.getUserIsMemberOf()).thenReturn(newTreeSet(dnOfGroup())); |
| | | final CriteriaFilter filter = new CriteriaFilter(cfg); |
| | | final SearchOperation operation1 = mockAuthenticatedSearchOperation(dnOfUserInGroup()); |
| | | assertThat(filter.isRequestLoggable(operation1)).isTrue(); |
| | |
| | | public void testCriteriaFilterUserIsNotMemberOf() throws Exception |
| | | { |
| | | final AccessLogFilteringCriteriaCfg cfg = mockCriteriaFilterCfg(); |
| | | when(cfg.getUserIsNotMemberOf()).thenReturn(setOf(dnOfGroup())); |
| | | when(cfg.getUserIsNotMemberOf()).thenReturn(newTreeSet(dnOfGroup())); |
| | | final CriteriaFilter filter = new CriteriaFilter(cfg); |
| | | final SearchOperation operation1 = mockAuthenticatedSearchOperation(dnOfUserInGroup()); |
| | | assertThat(filter.isRequestLoggable(operation1)).isFalse(); |
| | |
| | | return cfg; |
| | | } |
| | | |
| | | |
| | | |
| | | private SearchOperation mockSearchOperation(final AuthenticationInfo authInfo) |
| | | throws Exception |
| | | { |
| | |
| | | when(connection.getAuthenticationInfo()).thenReturn(authInfo); |
| | | return operation; |
| | | } |
| | | |
| | | |
| | | |
| | | private <T> SortedSet<T> setOf(final T... values) |
| | | { |
| | | return new TreeSet<>(Arrays.asList(values)); |
| | | } |
| | | } |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | |
| | | import org.assertj.core.api.SoftAssertions; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy.*; |
| | | import static org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | replicaDB = newReplicaDB(replicationServer); |
| | | |
| | | final CSN[] csns = generateCSNs(1, System.currentTimeMillis(), 5); |
| | | final ArrayList<CSN> csns2 = new ArrayList<>(Arrays.asList(csns)); |
| | | final ArrayList<CSN> csns2 = newArrayList(csns); |
| | | csns2.remove(csns[3]); |
| | | |
| | | for (CSN csn : csns2) |
| | |
| | | */ |
| | | package org.opends.server.replication.server.changelog.file; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.replication.server.changelog.api.DBCursor; |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | class SequentialDBCursor implements DBCursor<UpdateMsg> |
| | |
| | | */ |
| | | public SequentialDBCursor(UpdateMsg... msgs) |
| | | { |
| | | this.msgs = new ArrayList<>(Arrays.asList(msgs)); |
| | | this.msgs = CollectionUtils.newArrayList(msgs); |
| | | } |
| | | |
| | | public void add(UpdateMsg msg) |
| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.assertj.core.api.SoftAssertions; |
| | |
| | | import org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy; |
| | | import org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | // but use only 4 of them for update msg |
| | | // beforeCsn, middleCsn and afterCsn are not used |
| | | // in order to test cursor generation from a key not present in the log (before, in the middle, after) |
| | | final List<CSN> usedCsns = new ArrayList<>(Arrays.asList(sevenCsns)); |
| | | final List<CSN> usedCsns = CollectionUtils.newArrayList(sevenCsns); |
| | | usedCsns.remove(beforeCsn); |
| | | usedCsns.remove(middleCsn); |
| | | usedCsns.remove(afterCsn); |
| | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.replication.service.ReplicationBroker.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | entry(12, NOTE_RS_HAS_DIFFERENT_GROUP_ID_THAN_DS.ordinal())); |
| | | } |
| | | |
| | | private void containsOnly(final Map<Integer, LocalizableMessage> evaluations, |
| | | MapEntry... entries) |
| | | private void containsOnly(final Map<Integer, LocalizableMessage> evaluations, MapEntry... entries) |
| | | { |
| | | final List<MapEntry> notFound = new ArrayList<>(Arrays.asList(entries)); |
| | | final List<MapEntry> notFound = newArrayList(entries); |
| | | for (Iterator<MapEntry> iter = notFound.iterator(); iter.hasNext();) |
| | | { |
| | | final MapEntry entry = iter.next(); |
| | |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Map; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | import java.util.concurrent.BlockingQueue; |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | int replicationPort, String dirName, int windowSize, |
| | | String... replServers) throws Exception |
| | | { |
| | | return createReplicationServer(serverId, replicationPort, dirName, |
| | | windowSize, new TreeSet<String>(Arrays.asList(replServers))); |
| | | return createReplicationServer(serverId, replicationPort, dirName, windowSize, newTreeSet(replServers)); |
| | | } |
| | | |
| | | private ReplicationServer createReplicationServer(int serverId, |
| | |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.api.TestTaskListener.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | private String[] backupTask(String... additionalLdif) |
| | | { |
| | | final ArrayList<String> l = new ArrayList<>(Arrays.asList( |
| | | final ArrayList<String> l = newArrayList( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-backup", |
| | | "ds-task-class-name: org.opends.server.tasks.BackupTask", |
| | | "ds-backup-directory-path: bak")); |
| | | "ds-backup-directory-path: bak"); |
| | | l.addAll(Arrays.asList(additionalLdif)); |
| | | return l.toArray(new String[0]); |
| | | } |
| | | |
| | | private String[] restoreTask(String... additionalLdif) |
| | | { |
| | | final ArrayList<String> l = new ArrayList<>(Arrays.asList( |
| | | final ArrayList<String> l = newArrayList( |
| | | "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks", |
| | | "objectclass: top", |
| | | "objectclass: ds-task", |
| | | "objectclass: ds-task-restore", |
| | | "ds-task-class-name: org.opends.server.tasks.RestoreTask")); |
| | | "ds-task-class-name: org.opends.server.tasks.RestoreTask"); |
| | | l.addAll(Arrays.asList(additionalLdif)); |
| | | return l.toArray(new String[0]); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.testng.Assert; |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class AttributeBuilderTest extends TypesTestCase |
| | | { |
| | | |
| | | /** CN attribute type used in all tests. */ |
| | | private AttributeType cnType; |
| | | |
| | |
| | | options.length))); |
| | | } |
| | | |
| | | List<String> tmp = new ArrayList<>(Arrays.asList(options)); |
| | | List<String> tmp = newArrayList(options); |
| | | tmp.add("xxxx"); |
| | | Assert.assertFalse(a.hasAllOptions(tmp)); |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | // Check optionsEquals. |
| | | Assert.assertTrue(a |
| | | .optionsEqual(new HashSet<String>(Arrays.asList(options)))); |
| | | Assert.assertTrue(a.optionsEqual(newHashSet(options))); |
| | | |
| | | if (options.length > 1) |
| | | { |
| | | Assert.assertFalse(a.optionsEqual(Collections.singleton(options[0]))); |
| | | } |
| | | |
| | | Set<String> stmp = new HashSet<>(Arrays.asList(options)); |
| | | Set<String> stmp = newHashSet(options); |
| | | stmp.add("xxxx"); |
| | | Assert.assertFalse(a.optionsEqual(stmp)); |
| | | |
| | |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | { Arrays.asList(0, 1), Arrays.asList(0, 1, 1), false }, |
| | | |
| | | // Check multi-element sequential behaviour. |
| | | { new LinkedList<Integer>(Arrays.asList(0, 1)), |
| | | new LinkedList<Integer>(Arrays.asList(0, 1)), true }, |
| | | { new LinkedList<Integer>(Arrays.asList(0, 1)), |
| | | new LinkedList<Integer>(Arrays.asList(1, 0)), false }, |
| | | { newLinkedList(0, 1), newLinkedList(0, 1), true }, |
| | | { newLinkedList(0, 1), newLinkedList(1, 0), false }, |
| | | |
| | | // ...With duplicates. |
| | | { new LinkedList<Integer>(Arrays.asList(0, 1)), |
| | | new LinkedList<Integer>(Arrays.asList(0, 1, 1)), false } }; |
| | | { newLinkedList(0, 1), newLinkedList(0, 1, 1), false } }; |
| | | } |
| | | |
| | | /** |