| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap.extensions; |
| | |
| | | |
| | | private String targetUser = ""; |
| | | |
| | | private final List<PasswordPolicyStateOperation> operations = |
| | | new ArrayList<PasswordPolicyStateOperation>(); |
| | | private final List<PasswordPolicyStateOperation> operations = new ArrayList<>(); |
| | | |
| | | static final String PASSWORD_POLICY_DN_NAME = "Password Policy DN"; |
| | | |
| | | static final String ACCOUNT_DISABLED_STATE_NAME = "Account Disabled State"; |
| | | |
| | | static final String ACCOUNT_EXPIRATION_TIME_NAME = "Account Expiration Time"; |
| | | |
| | | static final String SECONDS_UNTIL_ACCOUNT_EXPIRATION_NAME = "Seconds Until Account Expiration"; |
| | | |
| | | static final String PASSWORD_CHANGED_TIME_NAME = "Password Changed Time"; |
| | | |
| | | static final String PASSWORD_EXPIRATION_WARNED_TIME_NAME = "Password Expiration Warned Time"; |
| | | |
| | | static final String SECONDS_UNTIL_PASSWORD_EXPIRATION_NAME = |
| | | "Seconds Until Password Expiration"; |
| | | |
| | | static final String SECONDS_UNTIL_PASSWORD_EXPIRATION_WARNING_NAME = |
| | | "Seconds Until Password Expiration Warning"; |
| | | |
| | | static final String AUTHENTICATION_FAILURE_TIMES_NAME = "Authentication Failure Times"; |
| | | |
| | | static final String SECONDS_UNTIL_AUTHENTICATION_FAILURE_UNLOCK_NAME = |
| | | "Seconds Until Authentication Failure Unlock"; |
| | | |
| | | static final String REMAINING_AUTHENTICATION_FAILURE_COUNT_NAME = |
| | | "Remaining Authentication Failure Count"; |
| | | |
| | | static final String LAST_LOGIN_TIME_NAME = "Last Login Time"; |
| | | |
| | | static final String SECONDS_UNTIL_IDLE_LOCKOUT_NAME = "Seconds Until Idle Lockout"; |
| | | |
| | | static final String PASSWORD_RESET_STATE_NAME = "Password Reset State"; |
| | | |
| | | static final String SECONDS_UNTIL_PASSWORD_RESET_LOCKOUT_NAME = |
| | | "Seconds Until Password Reset Lockout"; |
| | | |
| | | static final String GRACE_LOGIN_USE_TIMES_NAME = "Grace Login Use Times"; |
| | | |
| | | static final String REMAINING_GRACE_LOGIN_COUNT_NAME = "Remaining Grace Login Count"; |
| | | |
| | | static final String PASSWORD_CHANGED_BY_REQUIRED_TIME_NAME = |
| | | "Password Changed By Required Time"; |
| | | |
| | | static final String SECONDS_UNTIL_REQUIRED_CHANGE_TIME_NAME = |
| | | "Seconds Until Required Change Time"; |
| | | |
| | | static final String PASSWORD_HISTORY_NAME = "Password History"; |
| | | |
| | | /** |
| | |
| | | // See if we have any values |
| | | if (reader.hasNextElement()) { |
| | | reader.readStartSequence(); |
| | | final ArrayList<ByteString> values = new ArrayList<ByteString>(); |
| | | final ArrayList<ByteString> values = new ArrayList<>(); |
| | | while (reader.hasNextElement()) { |
| | | values.add(reader.readOctetString()); |
| | | } |
| | |
| | | if (dates == null) { |
| | | operations.add(property); |
| | | } else { |
| | | final ArrayList<ByteString> times = new ArrayList<ByteString>(dates.length); |
| | | final ArrayList<ByteString> times = new ArrayList<>(dates.length); |
| | | for (final Date date : dates) { |
| | | times.add(toByteString(date)); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap.extensions; |
| | |
| | | AbstractExtendedResult<PasswordPolicyStateExtendedResult> implements |
| | | PasswordPolicyStateOperationContainer { |
| | | private String targetUser = ""; |
| | | private final List<PasswordPolicyStateOperation> operations = |
| | | new ArrayList<PasswordPolicyStateOperation>(); |
| | | private final List<PasswordPolicyStateOperation> operations = new ArrayList<>(); |
| | | |
| | | /** |
| | | * Creates a new password policy state extended result with the provided |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.util; |
| | | |
| | |
| | | @Override |
| | | public List<N> subList(final int fromIndex, final int toIndex) { |
| | | final List<M> subList = collection.subList(fromIndex, toIndex); |
| | | return new TransformedList<M, N>(subList, funcMtoN, funcNtoM); |
| | | return new TransformedList<>(subList, funcMtoN, funcNtoM); |
| | | } |
| | | |
| | | } |
| | |
| | | public static <M, N> Collection<N> transformedCollection(final Collection<M> collection, |
| | | final Function<? super M, ? extends N, NeverThrowsException> funcMtoN, |
| | | final Function<? super N, ? extends M, NeverThrowsException> funcNtoM) { |
| | | return new TransformedCollection<M, N, Collection<M>>(collection, funcMtoN, funcNtoM); |
| | | return new TransformedCollection<>(collection, funcMtoN, funcNtoM); |
| | | } |
| | | |
| | | /** |
| | |
| | | public static <M, N> List<N> transformedList(final List<M> list, |
| | | final Function<? super M, ? extends N, NeverThrowsException> funcMtoN, |
| | | final Function<? super N, ? extends M, NeverThrowsException> funcNtoM) { |
| | | return new TransformedList<M, N>(list, funcMtoN, funcNtoM); |
| | | return new TransformedList<>(list, funcMtoN, funcNtoM); |
| | | } |
| | | |
| | | /** Prevent instantiation. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2013-2014 ForgeRock AS. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.util; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private static final Iterable<Object> EMPTY_ITERABLE = new EmptyIterable<Object>(); |
| | | private static final Iterable<Object> EMPTY_ITERABLE = new EmptyIterable<>(); |
| | | |
| | | /** |
| | | * Returns an iterable containing the elements of {@code a}. The returned |
| | |
| | | * @return An iterable containing the elements of {@code a}. |
| | | */ |
| | | public static <M> Iterable<M> arrayIterable(final M[] a) { |
| | | return new ArrayIterable<M>(a); |
| | | return new ArrayIterable<>(a); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static <M, P> Iterable<M> filteredIterable(final Iterable<M> iterable, |
| | | final Predicate<? super M, P> predicate, final P p) { |
| | | return new FilteredIterable<M, P>(iterable, predicate, p); |
| | | return new FilteredIterable<>(iterable, predicate, p); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static <M> Iterable<M> filteredIterable(final Iterable<M> iterable, |
| | | final Predicate<? super M, Void> predicate) { |
| | | return new FilteredIterable<M, Void>(iterable, predicate, null); |
| | | return new FilteredIterable<>(iterable, predicate, null); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return An iterable containing the single element {@code value}. |
| | | */ |
| | | public static <M> Iterable<M> singletonIterable(final M value) { |
| | | return new SingletonIterable<M>(value); |
| | | return new SingletonIterable<>(value); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static <M, N> Iterable<N> transformedIterable(final Iterable<M> iterable, |
| | | final Function<? super M, ? extends N, NeverThrowsException> function) { |
| | | return new TransformedIterable<M, N>(iterable, function); |
| | | return new TransformedIterable<>(iterable, function); |
| | | } |
| | | |
| | | /** |
| | |
| | | * support element removal via the {@code remove()}. |
| | | */ |
| | | public static <M> Iterable<M> unmodifiableIterable(final Iterable<M> iterable) { |
| | | return new UnmodifiableIterable<M>(iterable); |
| | | return new UnmodifiableIterable<>(iterable); |
| | | } |
| | | |
| | | /** Prevent instantiation. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.util; |
| | |
| | | } |
| | | } |
| | | |
| | | private static final Iterator<Object> EMPTY_ITERATOR = new EmptyIterator<Object>(); |
| | | private static final Iterator<Object> EMPTY_ITERATOR = new EmptyIterator<>(); |
| | | |
| | | /** |
| | | * Returns an iterator over the elements contained in {@code a}. The |
| | |
| | | * @return An iterator over the elements contained in {@code a}. |
| | | */ |
| | | public static <M> Iterator<M> arrayIterator(final M[] a) { |
| | | return new ArrayIterator<M>(a); |
| | | return new ArrayIterator<>(a); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static <M, P> Iterator<M> filteredIterator(final Iterator<M> iterator, |
| | | final Predicate<? super M, P> predicate, final P p) { |
| | | return new FilteredIterator<M, P>(iterator, predicate, p); |
| | | return new FilteredIterator<>(iterator, predicate, p); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static <M> Iterator<M> filteredIterator(final Iterator<M> iterator, |
| | | final Predicate<? super M, Void> predicate) { |
| | | return new FilteredIterator<M, Void>(iterator, predicate, null); |
| | | return new FilteredIterator<>(iterator, predicate, null); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return An iterator containing the single element {@code value}. |
| | | */ |
| | | public static <M> Iterator<M> singletonIterator(final M value) { |
| | | return new SingletonIterator<M>(value); |
| | | return new SingletonIterator<>(value); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static <M, N> Iterator<N> transformedIterator(final Iterator<M> iterator, |
| | | final Function<? super M, ? extends N, NeverThrowsException> function) { |
| | | return new TransformedIterator<M, N>(iterator, function); |
| | | return new TransformedIterator<>(iterator, function); |
| | | } |
| | | |
| | | /** |
| | |
| | | * element removal via the {@code remove()}. |
| | | */ |
| | | public static <M> Iterator<M> unmodifiableIterator(final Iterator<M> iterator) { |
| | | return new UnmodifiableIterator<M>(iterator); |
| | | return new UnmodifiableIterator<>(iterator); |
| | | } |
| | | |
| | | /** Prevent instantiation. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.util; |
| | | |
| | |
| | | * complete list of such rules, refer to Section 4.2, RFC 4517. |
| | | */ |
| | | public final class StringPrepProfile { |
| | | /** |
| | | * A Table defining the mapped code-points as per RFC 3454. |
| | | */ |
| | | /** A Table defining the mapped code-points as per RFC 3454. */ |
| | | private static final class MappingTable { |
| | | /** Set of chars which are deleted from the incoming value. */ |
| | | private static final HashSet<Character> MAP_2_NULL = new HashSet<Character>(); |
| | | |
| | | private static final HashSet<Character> MAP_2_NULL = new HashSet<>(); |
| | | /** Set of chars which are replaced by a SPACE when found. */ |
| | | private static final HashSet<Character> MAP_2_SPACE = new HashSet<Character>(); |
| | | private static final HashSet<Character> MAP_2_SPACE = new HashSet<>(); |
| | | |
| | | /** |
| | | * Table for case-folding. Map of Character and String containing |
| | | * uppercase and lowercase value as the key-value pair. |
| | | */ |
| | | private static final HashMap<Character, String> CASE_MAP_TABLE = |
| | | new HashMap<Character, String>(); |
| | | private static final HashMap<Character, String> CASE_MAP_TABLE = new HashMap<>(); |
| | | |
| | | static { |
| | | // Appendix B.1 RFC 3454. |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.io; |
| | | |
| | |
| | | private int peekLength = -1; |
| | | private final int maxElementSize; |
| | | private ByteSequenceReader reader; |
| | | private final LinkedList<ByteSequenceReader> readerStack; |
| | | private final LinkedList<ByteSequenceReader> readerStack = new LinkedList<>(); |
| | | |
| | | /** |
| | | * Creates a new ASN1 reader whose source is the provided byte sequence |
| | |
| | | */ |
| | | ASN1ByteSequenceReader(final ByteSequenceReader reader, final int maxElementSize) { |
| | | this.reader = reader; |
| | | this.readerStack = new LinkedList<ByteSequenceReader>(); |
| | | this.maxElementSize = maxElementSize; |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.io; |
| | | |
| | |
| | | private int lengthBytesNeeded; |
| | | private final int maxElementSize; |
| | | private InputStream in; |
| | | private final LinkedList<InputStream> streamStack; |
| | | private byte[] buffer; |
| | | private final LinkedList<InputStream> streamStack = new LinkedList<>(); |
| | | private byte[] buffer = new byte[512]; |
| | | |
| | | /** |
| | | * Creates a new ASN1 reader whose source is the provided input stream and |
| | |
| | | */ |
| | | ASN1InputStreamReader(final InputStream stream, final int maxElementSize) { |
| | | this.in = stream; |
| | | this.streamStack = new LinkedList<InputStream>(); |
| | | this.buffer = new byte[512]; |
| | | this.maxElementSize = maxElementSize; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public void close() throws IOException { |
| | | // Calling close of SizeLimitInputStream should close the parent |
| | | // stream. |
| | | // Calling close of SizeLimitInputStream should close the parent stream. |
| | | in.close(); |
| | | streamStack.clear(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.io; |
| | | |
| | |
| | | |
| | | private final OutputStream rootStream; |
| | | private OutputStream out; |
| | | private final ArrayList<ByteStringBuilder> streamStack; |
| | | private final ArrayList<ByteStringBuilder> streamStack = new ArrayList<>(); |
| | | private int stackDepth; |
| | | private final int maxBufferSize; |
| | | |
| | |
| | | this.out = stream; |
| | | this.rootStream = stream; |
| | | this.maxBufferSize = Math.max(maxBufferSize, BUFFER_INIT_SIZE); |
| | | this.streamStack = new ArrayList<ByteStringBuilder>(); |
| | | this.stackDepth = -1; |
| | | } |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.io; |
| | |
| | | */ |
| | | public static <R extends ASN1Reader> LDAPReader<R> getReader(final R asn1Reader, |
| | | final DecodeOptions options) { |
| | | return new LDAPReader<R>(asn1Reader, options); |
| | | return new LDAPReader<>(asn1Reader, options); |
| | | } |
| | | |
| | | /** |
| | |
| | | * ASN.1 writer. |
| | | */ |
| | | public static <W extends ASN1Writer> LDAPWriter<W> getWriter(final W asn1Writer) { |
| | | return new LDAPWriter<W>(asn1Writer); |
| | | return new LDAPWriter<>(asn1Writer); |
| | | } |
| | | |
| | | /** |
| | |
| | | reader.readStartSequence(LDAP.TYPE_FILTER_AND); |
| | | try { |
| | | if (reader.hasNextElement()) { |
| | | final List<Filter> subFilters = new LinkedList<Filter>(); |
| | | final List<Filter> subFilters = new LinkedList<>(); |
| | | do { |
| | | subFilters.add(readFilter(reader)); |
| | | } while (reader.hasNextElement()); |
| | |
| | | reader.readStartSequence(LDAP.TYPE_FILTER_OR); |
| | | try { |
| | | if (reader.hasNextElement()) { |
| | | final List<Filter> subFilters = new LinkedList<Filter>(); |
| | | final List<Filter> subFilters = new LinkedList<>(); |
| | | do { |
| | | subFilters.add(readFilter(reader)); |
| | | } while (reader.hasNextElement()); |
| | |
| | | } |
| | | final List<ByteString> anySubstrings; |
| | | if (reader.hasNextElement() && (reader.peekType() == LDAP.TYPE_SUBANY)) { |
| | | anySubstrings = new LinkedList<ByteString>(); |
| | | anySubstrings = new LinkedList<>(); |
| | | do { |
| | | anySubstrings.add(reader.readOctetString(LDAP.TYPE_SUBANY)); |
| | | } while (reader.hasNextElement() && (reader.peekType() == LDAP.TYPE_SUBANY)); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | return false; |
| | | } |
| | | |
| | | final Map<ByteString, T> valuesToRetain = new HashMap<ByteString, T>(values.size()); |
| | | final Map<ByteString, T> valuesToRetain = new HashMap<>(values.size()); |
| | | for (final T value : values) { |
| | | valuesToRetain.put(normalizeValue(this, ByteString.valueOf(value)), value); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | final ScheduledExecutorService scheduler) { |
| | | Reject.ifNull(factories, unit); |
| | | |
| | | this.monitoredFactories = new ArrayList<MonitoredConnectionFactory>(factories.size()); |
| | | this.monitoredFactories = new ArrayList<>(factories.size()); |
| | | int i = 0; |
| | | for (final ConnectionFactory f : factories) { |
| | | this.monitoredFactories.add(new MonitoredConnectionFactory(f, i++)); |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected WeakHashMap<Schema, Map<String, AttributeDescription>> initialValue() { |
| | | return new WeakHashMap<Schema, Map<String, AttributeDescription>>(); |
| | | return new WeakHashMap<>(); |
| | | } |
| | | |
| | | }; |
| | | |
| | | /** Object class attribute description. */ |
| | |
| | | |
| | | // Multiple options need sorting and duplicates removed - we could |
| | | // optimize a bit further here for 2 option attribute descriptions. |
| | | final List<String> options = new LinkedList<String>(); |
| | | final List<String> options = new LinkedList<>(); |
| | | options.add(option); |
| | | |
| | | final SortedSet<String> normalizedOptions = new TreeSet<String>(); |
| | | final SortedSet<String> normalizedOptions = new TreeSet<>(); |
| | | normalizedOptions.add(normalizedOption); |
| | | |
| | | while (i < length) { |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | |
| | | private void allocatedRequestedAttributes() { |
| | | if (requestedAttributes.isEmpty()) { |
| | | requestedAttributes = new HashMap<AttributeDescription, AttributeDescription>(); |
| | | requestedAttributes = new HashMap<>(); |
| | | } |
| | | } |
| | | |
| | | private Attribute filterAttribute(final Attribute attribute) { |
| | | return typesOnly ? Attributes.emptyAttribute(attribute.getAttributeDescription()) |
| | | : attribute; |
| | | return typesOnly |
| | | ? Attributes.emptyAttribute(attribute.getAttributeDescription()) |
| | | : attribute; |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2012-2014 ForgeRock AS. |
| | | * Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | public <T> Set<T> asSetOf(final Function<ByteString, ? extends T, NeverThrowsException> f, |
| | | final Collection<? extends T> defaultValues) { |
| | | if (!isEmpty(attribute)) { |
| | | final LinkedHashSet<T> result = new LinkedHashSet<T>(attribute.size()); |
| | | final LinkedHashSet<T> result = new LinkedHashSet<>(attribute.size()); |
| | | for (final ByteString b : attribute) { |
| | | result.add(f.apply(b)); |
| | | } |
| | | return result; |
| | | } else if (defaultValues != null) { |
| | | return new LinkedHashSet<T>(defaultValues); |
| | | return new LinkedHashSet<>(defaultValues); |
| | | } else { |
| | | return new LinkedHashSet<T>(0); |
| | | return new LinkedHashSet<>(0); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | |
| | | @Override |
| | | public Promise<Connection, LdapException> getConnectionAsync() { |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | return parentFactory.getConnectionAsync() |
| | | .thenAsync( |
| | | new AsyncFunction<Connection, BindResult, LdapException>() { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * attempts succeed, which is unlikely (if one fails, then they are |
| | | * all likely to fail). |
| | | */ |
| | | final List<QueueElement> waitingPromises = new LinkedList<CachedConnectionPool.QueueElement>(); |
| | | final List<QueueElement> waitingPromises = new LinkedList<>(); |
| | | synchronized (queue) { |
| | | while (hasWaitingPromises()) { |
| | | waitingPromises.add(queue.removeFirst()); |
| | |
| | | * the listener may be immediately invoked so ensure |
| | | * that it is already in the list. |
| | | */ |
| | | listeners = new CopyOnWriteArrayList<ConnectionEventListener>(); |
| | | listeners = new CopyOnWriteArrayList<>(); |
| | | listeners.add(listener); |
| | | connection.addConnectionEventListener(this); |
| | | } else { |
| | |
| | | * Obtain a list of expired connections but don't close them yet |
| | | * since we don't want to hold the lock too long. |
| | | */ |
| | | idleConnections = new LinkedList<Connection>(); |
| | | idleConnections = new LinkedList<>(); |
| | | final long timeoutMillis = timeService.now() - idleTimeoutMillis; |
| | | int nonCoreConnectionCount = currentPoolSize() - corePoolSize; |
| | | for (QueueElement holder = queue.peek(); nonCoreConnectionCount > 0 |
| | |
| | | private final ScheduledFuture<?> idleTimeoutFuture; |
| | | private final long idleTimeoutMillis; |
| | | private final int maxPoolSize; |
| | | private final LinkedList<QueueElement> queue = new LinkedList<QueueElement>(); |
| | | private final LinkedList<QueueElement> queue = new LinkedList<>(); |
| | | private final ReferenceCountedObject<ScheduledExecutorService>.Reference scheduler; |
| | | |
| | | /** |
| | |
| | | * Remove any connections which are waiting in the queue as these |
| | | * can be closed immediately. |
| | | */ |
| | | idleConnections = new LinkedList<Connection>(); |
| | | idleConnections = new LinkedList<>(); |
| | | while (hasWaitingConnections()) { |
| | | final QueueElement holder = queue.removeFirst(); |
| | | idleConnections.add(holder.getWaitingConnection()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | public static ConnectionFactory newInternalConnectionFactory( |
| | | final RequestHandler<RequestContext> requestHandler) { |
| | | Reject.ifNull(requestHandler); |
| | | return new InternalConnectionFactory<Void>(Connections |
| | | .<Void> newServerConnectionFactory(requestHandler), null); |
| | | return new InternalConnectionFactory<>( |
| | | Connections.<Void> newServerConnectionFactory(requestHandler), null); |
| | | } |
| | | |
| | | /** |
| | |
| | | public static <C> ConnectionFactory newInternalConnectionFactory( |
| | | final RequestHandlerFactory<C, RequestContext> factory, final C clientContext) { |
| | | Reject.ifNull(factory); |
| | | return new InternalConnectionFactory<C>(newServerConnectionFactory(factory), clientContext); |
| | | return new InternalConnectionFactory<>(newServerConnectionFactory(factory), clientContext); |
| | | } |
| | | |
| | | /** |
| | |
| | | public static <C> ConnectionFactory newInternalConnectionFactory( |
| | | final ServerConnectionFactory<C, Integer> factory, final C clientContext) { |
| | | Reject.ifNull(factory); |
| | | return new InternalConnectionFactory<C>(factory, clientContext); |
| | | return new InternalConnectionFactory<>(factory, clientContext); |
| | | } |
| | | |
| | | /** |
| | |
| | | public static <C> ServerConnectionFactory<C, Integer> newServerConnectionFactory( |
| | | final RequestHandler<RequestContext> requestHandler) { |
| | | Reject.ifNull(requestHandler); |
| | | return new RequestHandlerFactoryAdapter<C>(new RequestHandlerFactory<C, RequestContext>() { |
| | | return new RequestHandlerFactoryAdapter<>(new RequestHandlerFactory<C, RequestContext>() { |
| | | @Override |
| | | public RequestHandler<RequestContext> handleAccept(final C clientContext) { |
| | | return requestHandler; |
| | |
| | | public static <C> ServerConnectionFactory<C, Integer> newServerConnectionFactory( |
| | | final RequestHandlerFactory<C, RequestContext> factory) { |
| | | Reject.ifNull(factory); |
| | | return new RequestHandlerFactoryAdapter<C>(factory); |
| | | return new RequestHandlerFactoryAdapter<>(factory); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2014 ForgeRock AS. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected WeakHashMap<Schema, Map<String, DN>> initialValue() { |
| | | return new WeakHashMap<Schema, Map<String, DN>>(); |
| | | return new WeakHashMap<>(); |
| | | } |
| | | |
| | | }; |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * attributes in order to avoid matching rule based |
| | | * comparisons. |
| | | */ |
| | | final Set<ByteString> oldValues = new LinkedHashSet<ByteString>(afrom); |
| | | final Set<ByteString> newValues = new LinkedHashSet<ByteString>(ato); |
| | | final Set<ByteString> oldValues = new LinkedHashSet<>(afrom); |
| | | final Set<ByteString> newValues = new LinkedHashSet<>(ato); |
| | | |
| | | final Set<ByteString> deletedValues = new LinkedHashSet<ByteString>(oldValues); |
| | | final Set<ByteString> deletedValues = new LinkedHashSet<>(oldValues); |
| | | deletedValues.removeAll(newValues); |
| | | diffDeleteValues(request, deletedValues.size() == afrom.size() ? afrom |
| | | : new LinkedAttribute(adfrom, deletedValues)); |
| | |
| | | if (objectClassAttribute == null) { |
| | | return Collections.emptySet(); |
| | | } else { |
| | | final Set<ObjectClass> objectClasses = |
| | | new HashSet<ObjectClass>(objectClassAttribute.size()); |
| | | final Set<ObjectClass> objectClasses = new HashSet<>(objectClassAttribute.size()); |
| | | for (final ByteString v : objectClassAttribute) { |
| | | final String objectClassName = v.toString(); |
| | | final ObjectClass objectClass; |
| | |
| | | * Use a hash set for membership checking rather than the attribute |
| | | * in order to avoid matching rule based comparisons. |
| | | */ |
| | | final Set<ByteString> oldValues = new LinkedHashSet<ByteString>(afrom); |
| | | final Set<ByteString> oldValues = new LinkedHashSet<>(afrom); |
| | | return !oldValues.containsAll(ato); |
| | | } else { |
| | | return !afrom.equals(ato); |
| | |
| | | Reject.ifNull(subFilter); |
| | | return new Filter(new AndImpl(Collections.singletonList(subFilter))); |
| | | } else { |
| | | final List<Filter> subFiltersList = new ArrayList<Filter>(subFilters.size()); |
| | | final List<Filter> subFiltersList = new ArrayList<>(subFilters.size()); |
| | | for (final Filter subFilter : subFilters) { |
| | | Reject.ifNull(subFilter); |
| | | subFiltersList.add(subFilter); |
| | |
| | | Reject.ifNull(subFilters[0]); |
| | | return new Filter(new AndImpl(Collections.singletonList(subFilters[0]))); |
| | | } else { |
| | | final List<Filter> subFiltersList = new ArrayList<Filter>(subFilters.length); |
| | | final List<Filter> subFiltersList = new ArrayList<>(subFilters.length); |
| | | for (final Filter subFilter : subFilters) { |
| | | Reject.ifNull(subFilter); |
| | | subFiltersList.add(subFilter); |
| | |
| | | Reject.ifNull(subFilter); |
| | | return new Filter(new OrImpl(Collections.singletonList(subFilter))); |
| | | } else { |
| | | final List<Filter> subFiltersList = new ArrayList<Filter>(subFilters.size()); |
| | | final List<Filter> subFiltersList = new ArrayList<>(subFilters.size()); |
| | | for (final Filter subFilter : subFilters) { |
| | | Reject.ifNull(subFilter); |
| | | subFiltersList.add(subFilter); |
| | |
| | | Reject.ifNull(subFilters[0]); |
| | | return new Filter(new OrImpl(Collections.singletonList(subFilters[0]))); |
| | | } else { |
| | | final List<Filter> subFiltersList = new ArrayList<Filter>(subFilters.length); |
| | | final List<Filter> subFiltersList = new ArrayList<>(subFilters.length); |
| | | for (final Filter subFilter : subFilters) { |
| | | Reject.ifNull(subFilter); |
| | | subFiltersList.add(subFilter); |
| | |
| | | Reject.ifNull(anySubstring); |
| | | anySubstringList = Collections.singletonList(ByteString.valueOf(anySubstring)); |
| | | } else { |
| | | anySubstringList = new ArrayList<ByteString>(anySubstrings.size()); |
| | | anySubstringList = new ArrayList<>(anySubstrings.size()); |
| | | for (final Object anySubstring : anySubstrings) { |
| | | Reject.ifNull(anySubstring); |
| | | |
| | |
| | | final byte[] valueBytes = getBytes(filterString.substring(equalPos, endPos)); |
| | | |
| | | // Find the locations of all the asterisks in the value. Also, check to |
| | | // see if there are any escaped values, since they will need special |
| | | // treatment. |
| | | // see if there are any escaped values, since they will need special treatment. |
| | | boolean hasEscape = false; |
| | | final LinkedList<Integer> asteriskPositions = new LinkedList<Integer>(); |
| | | final LinkedList<Integer> asteriskPositions = new LinkedList<>(); |
| | | for (int i = 0; i < valueBytes.length; i++) { |
| | | if (valueBytes[i] == ASTERISK) { |
| | | asteriskPositions.add(i); |
| | |
| | | subInitial = ByteString.wrap(valueBytes, 0, firstPos); |
| | | } |
| | | |
| | | // Next, process through the rest of the asterisks to get the subAny |
| | | // values. |
| | | final ArrayList<ByteString> subAny = new ArrayList<ByteString>(); |
| | | // Next, process through the rest of the asterisks to get the subAny values. |
| | | final ArrayList<ByteString> subAny = new ArrayList<>(); |
| | | for (final int asteriskPos : asteriskPositions) { |
| | | final int length = asteriskPos - firstPos - 1; |
| | | |
| | |
| | | if (subFilters != null) { |
| | | subFilters.add(subFilter); |
| | | } else if (firstFilter != null) { |
| | | subFilters = new LinkedList<Filter>(); |
| | | subFilters = new LinkedList<>(); |
| | | subFilters.add(firstFilter); |
| | | subFilters.add(subFilter); |
| | | firstFilter = null; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * the current heart beat completes. |
| | | */ |
| | | private final Queue<Runnable> pendingBindOrStartTLSRequests = |
| | | new ConcurrentLinkedQueue<Runnable>(); |
| | | new ConcurrentLinkedQueue<>(); |
| | | |
| | | /** |
| | | * List of pending responses for all active operations. These will be |
| | | * signalled if no heart beat is detected within the permitted timeout |
| | | * period. |
| | | * signaled if no heart beat is detected within the permitted timeout period. |
| | | */ |
| | | private final Queue<ResultHandler<?>> pendingResults = |
| | | new ConcurrentLinkedQueue<ResultHandler<?>>(); |
| | | private final Queue<ResultHandler<?>> pendingResults = new ConcurrentLinkedQueue<>(); |
| | | |
| | | /** Internal connection state. */ |
| | | private final ConnectionState state = new ConnectionState(); |
| | |
| | | } |
| | | |
| | | private <R extends Result> LdapPromise<R> timestampPromise(LdapPromise<R> wrappedPromise) { |
| | | final LdapPromiseImpl<R> outerPromise = new LdapPromiseImplWrapper<R>(wrappedPromise); |
| | | final LdapPromiseImpl<R> outerPromise = new LdapPromiseImplWrapper<>(wrappedPromise); |
| | | pendingResults.add(outerPromise); |
| | | wrappedPromise.onSuccess(new SuccessHandler<R>() { |
| | | @Override |
| | |
| | | */ |
| | | private final long timeoutMS; |
| | | |
| | | /** |
| | | * List of valid connections to which heartbeats will be sent. |
| | | */ |
| | | private final List<ConnectionImpl> validConnections = new LinkedList<ConnectionImpl>(); |
| | | /** List of valid connections to which heartbeats will be sent. */ |
| | | private final List<ConnectionImpl> validConnections = new LinkedList<>(); |
| | | |
| | | HeartBeatConnectionFactory(final ConnectionFactory factory, final long interval, |
| | | final long timeout, final TimeUnit unit, final SearchRequest heartBeat, |
| | |
| | | public Promise<Connection, LdapException> getConnectionAsync() { |
| | | acquireScheduler(); // Protect scheduler. |
| | | |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | final PromiseImpl<Connection, LdapException> promise = PromiseImpl.create(); |
| | | |
| | | // Request a connection and return the promise representing the heartbeat. |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2014 ForgeRock AS. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | */ |
| | | final class InternalConnection extends AbstractAsynchronousConnection { |
| | | private final ServerConnection<Integer> serverConnection; |
| | | private final List<ConnectionEventListener> listeners = new CopyOnWriteArrayList<ConnectionEventListener>(); |
| | | private final List<ConnectionEventListener> listeners = new CopyOnWriteArrayList<>(); |
| | | private final AtomicInteger messageID = new AtomicInteger(); |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | private boolean useStartTLS; |
| | | private long timeoutInMillis = DEFAULT_TIMEOUT; |
| | | private long connectTimeoutInMillis = DEFAULT_CONNECT_TIMEOUT; |
| | | private final List<String> enabledCipherSuites = new LinkedList<String>(); |
| | | private final List<String> enabledProtocols = new LinkedList<String>(); |
| | | private final List<String> enabledCipherSuites = new LinkedList<>(); |
| | | private final List<String> enabledProtocols = new LinkedList<>(); |
| | | |
| | | /** |
| | | * Creates a new set of connection options with default settings. SSL will |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | /** |
| | | * Set containing characters that do not need to be encoded. |
| | | */ |
| | | private static final Set<Character> VALID_CHARS = new HashSet<Character>(); |
| | | private static final Set<Character> VALID_CHARS = new HashSet<>(); |
| | | |
| | | static { |
| | | // Refer to RFC 3986 for more details. |
| | |
| | | |
| | | private List<String> parseAttributes(final String attrDesc) { |
| | | final StringTokenizer token = new StringTokenizer(attrDesc, String.valueOf(COMMA_CHAR)); |
| | | final List<String> parsedAttrs = new ArrayList<String>(token.countTokens()); |
| | | final List<String> parsedAttrs = new ArrayList<>(token.countTokens()); |
| | | while (token.hasMoreElements()) { |
| | | parsedAttrs.add(token.nextToken()); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | return true; |
| | | } |
| | | |
| | | final Map<ByteString, T> valuesToRetain = new HashMap<ByteString, T>(values.size()); |
| | | final Map<ByteString, T> valuesToRetain = new HashMap<>(values.size()); |
| | | for (final T value : values) { |
| | | valuesToRetain.put(normalizeValue(attribute, ByteString.valueOf(value)), value); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | attribute.multipleValues = new LinkedHashMap<ByteString, ByteString>(2); |
| | | attribute.multipleValues = new LinkedHashMap<>(2); |
| | | attribute.multipleValues.put(attribute.normalizedSingleValue, attribute.singleValue); |
| | | attribute.multipleValues.put(normalizedValue, value); |
| | | attribute.singleValue = null; |
| | |
| | | this.singleValue = other.singleValue; |
| | | this.normalizedSingleValue = other.normalizedSingleValue; |
| | | if (other.multipleValues != null) { |
| | | this.multipleValues = |
| | | new LinkedHashMap<ByteString, ByteString>(other.multipleValues); |
| | | this.multipleValues = new LinkedHashMap<>(other.multipleValues); |
| | | } |
| | | } else { |
| | | addAll(attribute); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | return TRUE; |
| | | } |
| | | |
| | | final List<MatcherImpl> subMatchers = new ArrayList<MatcherImpl>(subFilters.size()); |
| | | final List<MatcherImpl> subMatchers = new ArrayList<>(subFilters.size()); |
| | | for (final Filter f : subFilters) { |
| | | subMatchers.add(f.accept(this, schema)); |
| | | } |
| | |
| | | return FALSE; |
| | | } |
| | | |
| | | final List<MatcherImpl> subMatchers = new ArrayList<MatcherImpl>(subFilters.size()); |
| | | final List<MatcherImpl> subMatchers = new ArrayList<>(subFilters.size()); |
| | | for (final Filter f : subFilters) { |
| | | subMatchers.add(f.accept(this, schema)); |
| | | } |
| | |
| | | */ |
| | | public final class MemoryBackend implements RequestHandler<RequestContext> { |
| | | private final DecodeOptions decodeOptions; |
| | | private final ConcurrentSkipListMap<DN, Entry> entries = new ConcurrentSkipListMap<DN, Entry>(); |
| | | private final ConcurrentSkipListMap<DN, Entry> entries = new ConcurrentSkipListMap<>(); |
| | | private final Schema schema; |
| | | private final Object writeLock = new Object(); |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS |
| | | * Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * value. |
| | | */ |
| | | public static <T> Option<T> of(Class<T> type, T defaultValue) { |
| | | return new Option<T>(type, defaultValue); |
| | | return new Option<>(type, defaultValue); |
| | | } |
| | | |
| | | private Option(Class<T> type, T defaultValue) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2012 ForgeRock AS. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | |
| | | reader.mark(); |
| | | if (reader.remaining() > 0 && reader.read() == '+') { |
| | | final List<AVA> avas = new ArrayList<AVA>(); |
| | | final List<AVA> avas = new ArrayList<>(); |
| | | avas.add(firstAVA); |
| | | |
| | | do { |
| | |
| | | } |
| | | |
| | | private Iterator<AVA> getSortedAvas() { |
| | | TreeSet<AVA> sortedAvas = new TreeSet<AVA>(); |
| | | TreeSet<AVA> sortedAvas = new TreeSet<>(); |
| | | for (AVA ava : avas) { |
| | | sortedAvas.add(ava); |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2011-2014 ForgeRock AS |
| | | * Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | switch (state) { |
| | | case PENDING: |
| | | if (cancelRequestListeners == null) { |
| | | cancelRequestListeners = new LinkedList<CancelRequestListener>(); |
| | | cancelRequestListeners = new LinkedList<>(); |
| | | } |
| | | cancelRequestListeners.add(listener); |
| | | break; |
| | |
| | | /* Switch to CANCEL_REQUESTED state. */ |
| | | cancelRequestReason = reason; |
| | | if (cancelResultHandler != null) { |
| | | cancelResultHandlers = new LinkedList<ExtendedResultHandlerHolder<?>>(); |
| | | cancelResultHandlers = new LinkedList<>(); |
| | | cancelResultHandlers.add(new ExtendedResultHandlerHolder<R>(cancelRequest, |
| | | cancelResultHandler)); |
| | | } |
| | |
| | | */ |
| | | if (cancelResultHandler != null) { |
| | | if (cancelResultHandlers == null) { |
| | | cancelResultHandlers = new LinkedList<ExtendedResultHandlerHolder<?>>(); |
| | | cancelResultHandlers = new LinkedList<>(); |
| | | } |
| | | cancelResultHandlers.add(new ExtendedResultHandlerHolder<R>(cancelRequest, |
| | | cancelResultHandler)); |
| | |
| | | |
| | | private static final class ServerConnectionImpl implements ServerConnection<Integer> { |
| | | private final AtomicBoolean isClosed = new AtomicBoolean(); |
| | | private final ConcurrentHashMap<Integer, RequestContextImpl<?, ?>> pendingRequests = |
| | | new ConcurrentHashMap<Integer, RequestContextImpl<?, ?>>(); |
| | | private final ConcurrentHashMap<Integer, RequestContextImpl<?, ?>> pendingRequests = new ConcurrentHashMap<>(); |
| | | private final RequestHandler<RequestContext> requestHandler; |
| | | |
| | | private ServerConnectionImpl(final RequestHandler<RequestContext> requestHandler) { |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final ResultHandler<Result> resultHandler) { |
| | | final RequestContextImpl<Result, ResultHandler<Result>> requestContext = |
| | | new RequestContextImpl<Result, ResultHandler<Result>>(this, resultHandler, |
| | | messageID, true); |
| | | new RequestContextImpl<>(this, resultHandler, messageID, true); |
| | | if (addPendingRequest(requestContext)) { |
| | | requestHandler.handleAdd(requestContext, request, intermediateResponseHandler, |
| | | requestContext); |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final ResultHandler<BindResult> resultHandler) { |
| | | final RequestContextImpl<BindResult, ResultHandler<BindResult>> requestContext = |
| | | new RequestContextImpl<BindResult, ResultHandler<BindResult>>(this, |
| | | resultHandler, messageID, false); |
| | | new RequestContextImpl<>(this, resultHandler, messageID, false); |
| | | if (addPendingRequest(requestContext)) { |
| | | requestHandler.handleBind(requestContext, version, request, |
| | | intermediateResponseHandler, requestContext); |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final ResultHandler<CompareResult> resultHandler) { |
| | | final RequestContextImpl<CompareResult, ResultHandler<CompareResult>> requestContext = |
| | | new RequestContextImpl<CompareResult, ResultHandler<CompareResult>>(this, |
| | | resultHandler, messageID, true); |
| | | new RequestContextImpl<>(this, resultHandler, messageID, true); |
| | | if (addPendingRequest(requestContext)) { |
| | | requestHandler.handleCompare(requestContext, request, intermediateResponseHandler, |
| | | requestContext); |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final ResultHandler<Result> resultHandler) { |
| | | final RequestContextImpl<Result, ResultHandler<Result>> requestContext = |
| | | new RequestContextImpl<Result, ResultHandler<Result>>(this, resultHandler, |
| | | messageID, true); |
| | | new RequestContextImpl<>(this, resultHandler, messageID, true); |
| | | if (addPendingRequest(requestContext)) { |
| | | requestHandler.handleDelete(requestContext, request, intermediateResponseHandler, |
| | | requestContext); |
| | |
| | | * do this in order to monitor the number of pending operations. |
| | | */ |
| | | final RequestContextImpl<R, ResultHandler<R>> requestContext = |
| | | new RequestContextImpl<R, ResultHandler<R>>(this, resultHandler, messageID, |
| | | false); |
| | | new RequestContextImpl<>(this, resultHandler, messageID, false); |
| | | if (addPendingRequest(requestContext)) { |
| | | // Find and cancel the request. |
| | | final RequestContextImpl<?, ?> cancelledRequest = |
| | |
| | | // StartTLS requests cannot be cancelled. |
| | | boolean isCancelSupported = !request.getOID().equals(StartTLSExtendedRequest.OID); |
| | | final RequestContextImpl<R, ResultHandler<R>> requestContext = |
| | | new RequestContextImpl<R, ResultHandler<R>>(this, resultHandler, messageID, isCancelSupported); |
| | | new RequestContextImpl<>(this, resultHandler, messageID, isCancelSupported); |
| | | |
| | | if (addPendingRequest(requestContext)) { |
| | | requestHandler.handleExtendedRequest(requestContext, request, |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final ResultHandler<Result> resultHandler) { |
| | | final RequestContextImpl<Result, ResultHandler<Result>> requestContext = |
| | | new RequestContextImpl<Result, ResultHandler<Result>>(this, resultHandler, |
| | | messageID, true); |
| | | new RequestContextImpl<>(this, resultHandler, messageID, true); |
| | | if (addPendingRequest(requestContext)) { |
| | | requestHandler.handleModify(requestContext, request, intermediateResponseHandler, |
| | | requestContext); |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final ResultHandler<Result> resultHandler) { |
| | | final RequestContextImpl<Result, ResultHandler<Result>> requestContext = |
| | | new RequestContextImpl<Result, ResultHandler<Result>>(this, resultHandler, |
| | | messageID, true); |
| | | new RequestContextImpl<>(this, resultHandler, messageID, true); |
| | | if (addPendingRequest(requestContext)) { |
| | | requestHandler.handleModifyDN(requestContext, request, intermediateResponseHandler, |
| | | requestContext); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | //@Checkstyle:on |
| | | } |
| | | |
| | | private static final Map<Integer, ResultCode> ELEMENTS = new LinkedHashMap<Integer, ResultCode>(); |
| | | private static final Map<Integer, ResultCode> ELEMENTS = new LinkedHashMap<>(); |
| | | |
| | | private static final List<ResultCode> IMMUTABLE_ELEMENTS = Collections.unmodifiableList(new ArrayList<ResultCode>( |
| | | ELEMENTS.values())); |
| | |
| | | Reject.ifNull(schema, keys); |
| | | Reject.ifFalse(!keys.isEmpty(), "keys must not be empty"); |
| | | |
| | | final List<Comparator<Entry>> comparators = new ArrayList<Comparator<Entry>>(keys.size()); |
| | | final List<Comparator<Entry>> comparators = new ArrayList<>(keys.size()); |
| | | for (final SortKey key : keys) { |
| | | comparators.add(key.comparator(schema)); |
| | | } |
| | |
| | | public static Comparator<Entry> comparator(final String sortKeys) { |
| | | Reject.ifNull(sortKeys); |
| | | |
| | | final List<Comparator<Entry>> comparators = new LinkedList<Comparator<Entry>>(); |
| | | final List<Comparator<Entry>> comparators = new LinkedList<>(); |
| | | final StringTokenizer tokenizer = new StringTokenizer(sortKeys, ","); |
| | | while (tokenizer.hasMoreTokens()) { |
| | | final String token = tokenizer.nextToken().trim(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | // There is an sequence containing an attribute |
| | | // list, try to |
| | | // decode it. |
| | | // There is an sequence containing an attribute list, try to decode it. |
| | | if (reader.hasNextElement()) { |
| | | attributes = new LinkedList<AttributeType>(); |
| | | attributes = new LinkedList<>(); |
| | | reader.readStartSequence(); |
| | | while (reader.hasNextElement()) { |
| | | // Decode as an attribute type. |
| | |
| | | |
| | | List<AttributeType> copyOfAttributes; |
| | | if (attributes != null && attributes.length > 0) { |
| | | copyOfAttributes = new ArrayList<AttributeType>(attributes.length); |
| | | copyOfAttributes = new ArrayList<>(attributes.length); |
| | | for (final String attribute : attributes) { |
| | | copyOfAttributes.add(Schema.getDefaultSchema().getAttributeType(attribute)); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | final LinkedList<Filter> filters = new LinkedList<Filter>(); |
| | | final LinkedList<Filter> filters = new LinkedList<>(); |
| | | do { |
| | | final Filter filter = LDAP.readFilter(reader); |
| | | try { |
| | |
| | | if (filters.size() == 1) { |
| | | copyOfFilters = Collections.singletonList(validateFilter(filters.iterator().next())); |
| | | } else { |
| | | copyOfFilters = new ArrayList<Filter>(filters.size()); |
| | | copyOfFilters = new ArrayList<>(filters.size()); |
| | | for (final Filter filter : filters) { |
| | | copyOfFilters.add(validateFilter(filter)); |
| | | } |
| | |
| | | final String... filters) { |
| | | Reject.ifFalse(filters.length > 0, "filters is empty"); |
| | | |
| | | final List<Filter> parsedFilters = new ArrayList<Filter>(filters.length); |
| | | final List<Filter> parsedFilters = new ArrayList<>(filters.length); |
| | | for (final String filter : filters) { |
| | | parsedFilters.add(validateFilter(Filter.valueOf(filter))); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | if (reader.hasNextElement()) { |
| | | final String firstAttribute = reader.readOctetStringAsString(); |
| | | if (reader.hasNextElement()) { |
| | | attributes = new ArrayList<String>(); |
| | | attributes = new ArrayList<>(); |
| | | attributes.add(firstAttribute); |
| | | do { |
| | | attributes.add(reader.readOctetStringAsString()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | if (reader.hasNextElement()) { |
| | | final String firstAttribute = reader.readOctetStringAsString(); |
| | | if (reader.hasNextElement()) { |
| | | attributes = new ArrayList<String>(); |
| | | attributes = new ArrayList<>(); |
| | | attributes.add(firstAttribute); |
| | | do { |
| | | attributes.add(reader.readOctetStringAsString()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | throw DecodeException.error(message); |
| | | } |
| | | |
| | | final List<SortKey> keys = new LinkedList<SortKey>(); |
| | | final List<SortKey> keys = new LinkedList<>(); |
| | | while (reader.hasNextElement()) { |
| | | reader.readStartSequence(); |
| | | final String attrName = reader.readOctetStringAsString(); |
| | |
| | | final String sortKeys) { |
| | | Reject.ifNull(sortKeys); |
| | | |
| | | final List<SortKey> keys = new LinkedList<SortKey>(); |
| | | final List<SortKey> keys = new LinkedList<>(); |
| | | final StringTokenizer tokenizer = new StringTokenizer(sortKeys, ","); |
| | | while (tokenizer.hasMoreTokens()) { |
| | | final String token = tokenizer.nextToken().trim(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | return null; |
| | | } |
| | | |
| | | private final List<Control> controls = new LinkedList<Control>(); |
| | | private final List<Control> controls = new LinkedList<>(); |
| | | |
| | | AbstractRequestImpl() { |
| | | // No implementation required. |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | this.realm = initialBindRequest.getRealm(); |
| | | |
| | | // Create property map containing all the parameters. |
| | | final Map<String, String> props = new HashMap<String, String>(); |
| | | final Map<String, String> props = new HashMap<>(); |
| | | |
| | | final List<String> qopValues = initialBindRequest.getQOPs(); |
| | | if (!qopValues.isEmpty()) { |
| | |
| | | |
| | | } |
| | | |
| | | private final Map<String, String> additionalAuthParams = new LinkedHashMap<String, String>(); |
| | | private final Map<String, String> additionalAuthParams = new LinkedHashMap<>(); |
| | | private String authenticationID; |
| | | private String authorizationID; |
| | | |
| | |
| | | private Integer maxReceiveBufferSize; |
| | | private Integer maxSendBufferSize; |
| | | private byte[] password; |
| | | private final List<String> qopValues = new LinkedList<String>(); |
| | | private final List<String> qopValues = new LinkedList<>(); |
| | | private String realm; |
| | | /** |
| | | * Do not use primitives for these so that we can distinguish between default |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | "No password specified for GSSAPI SASL authentication")); |
| | | } |
| | | |
| | | final Map<String, Object> state = new HashMap<String, Object>(); |
| | | final Map<String, Object> state = new HashMap<>(); |
| | | state.put("javax.security.auth.login.name", authenticationID); |
| | | state.put("javax.security.auth.login.password", password.toString().toCharArray()); |
| | | state.put("javax.security.auth.useSubjectCredsOnly", "true"); |
| | | state.put("java.security.krb5.realm", realm); |
| | | state.put("java.security.krb5.kdc", kdc); |
| | | |
| | | final Map<String, Object> options = new HashMap<String, Object>(); |
| | | final Map<String, Object> options = new HashMap<>(); |
| | | options.put("tryFirstPass", "true"); |
| | | options.put("useTicketCache", "true"); |
| | | options.put("doNotPrompt", "true"); |
| | |
| | | Subject.doAs(subject, new PrivilegedExceptionAction<SaslClient>() { |
| | | @Override |
| | | public SaslClient run() throws LdapException { |
| | | /* |
| | | * Create property map containing all the |
| | | * parameters. |
| | | */ |
| | | final Map<String, String> props = new HashMap<String, String>(); |
| | | // Create property map containing all the parameters. |
| | | final Map<String, String> props = new HashMap<>(); |
| | | |
| | | final List<String> qopValues = initialBindRequest.getQOPs(); |
| | | if (!qopValues.isEmpty()) { |
| | |
| | | |
| | | } |
| | | |
| | | private final Map<String, String> additionalAuthParams = new LinkedHashMap<String, String>(); |
| | | private final Map<String, String> additionalAuthParams = new LinkedHashMap<>(); |
| | | |
| | | /** Ignored if subject is non-null. */ |
| | | private String authenticationID; |
| | |
| | | private Integer maxSendBufferSize; |
| | | |
| | | private byte[] password; |
| | | private final List<String> qopValues = new LinkedList<String>(); |
| | | private final List<String> qopValues = new LinkedList<>(); |
| | | private String realm; |
| | | /** |
| | | * Don't use primitives for these so that we can distinguish between default |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | * Modify request implementation. |
| | | */ |
| | | final class ModifyRequestImpl extends AbstractRequestImpl<ModifyRequest> implements ModifyRequest { |
| | | private final List<Modification> changes = new LinkedList<Modification>(); |
| | | private final List<Modification> changes = new LinkedList<>(); |
| | | private DN name; |
| | | |
| | | ModifyRequestImpl(final DN name) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | * Search request implementation. |
| | | */ |
| | | final class SearchRequestImpl extends AbstractRequestImpl<SearchRequest> implements SearchRequest { |
| | | private final List<String> attributes = new LinkedList<String>(); |
| | | private final List<String> attributes = new LinkedList<>(); |
| | | private DereferenceAliasesPolicy dereferenceAliasesPolicy = DereferenceAliasesPolicy.NEVER; |
| | | private Filter filter; |
| | | private DN name; |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | private static final ExtendedResultDecoder<ExtendedResult> RESULT_DECODER = new ResultDecoder(); |
| | | |
| | | /** The list of cipher suite. */ |
| | | private final List<String> enabledCipherSuites = new LinkedList<String>(); |
| | | private final List<String> enabledCipherSuites = new LinkedList<>(); |
| | | |
| | | /** The list of protocols. */ |
| | | private final List<String> enabledProtocols = new LinkedList<String>(); |
| | | private final List<String> enabledProtocols = new LinkedList<>(); |
| | | |
| | | private SSLContext sslContext; |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.responses; |
| | |
| | | return null; |
| | | } |
| | | |
| | | private final List<Control> controls = new LinkedList<Control>(); |
| | | private final List<Control> controls = new LinkedList<>(); |
| | | |
| | | AbstractResponseImpl() { |
| | | // No implementation required. |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.responses; |
| | |
| | | private Throwable cause; |
| | | private String diagnosticMessage = ""; |
| | | private String matchedDN = ""; |
| | | private final List<String> referralURIs = new LinkedList<String>(); |
| | | private final List<String> referralURIs = new LinkedList<>(); |
| | | private ResultCode resultCode; |
| | | |
| | | AbstractResultImpl(final Result result) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.responses; |
| | |
| | | final class SearchResultReferenceImpl extends AbstractResponseImpl<SearchResultReference> implements |
| | | SearchResultReference { |
| | | |
| | | private final List<String> uris = new LinkedList<String>(); |
| | | private final List<String> uris = new LinkedList<>(); |
| | | |
| | | SearchResultReferenceImpl(final SearchResultReference searchResultReference) { |
| | | super(searchResultReference); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | * Portions copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | return factory.createMatchAllQuery(); |
| | | } |
| | | |
| | | final Collection<T> subqueries = new LinkedList<T>(); |
| | | final Collection<T> subqueries = new LinkedList<>(); |
| | | if (normInitial != null) { |
| | | // relies on the fact that equality indexes are also ordered |
| | | subqueries.add(rangeMatch(factory, equalityIndexId, normInitial)); |
| | |
| | | // index substring length, and read those keys. |
| | | |
| | | // Eliminate duplicates by putting the keys into a set. |
| | | final TreeSet<ByteSequence> substringKeys = new TreeSet<ByteSequence>(); |
| | | final TreeSet<ByteSequence> substringKeys = new TreeSet<>(); |
| | | |
| | | // Example: The value is ABCDE and the substring length is 3. |
| | | // We produce the keys ABC BCD CDE. |
| | |
| | | .get(assertionValue, reader.pos())); |
| | | } |
| | | if (anyStrings == null) { |
| | | anyStrings = new LinkedList<ByteSequence>(); |
| | | anyStrings = new LinkedList<>(); |
| | | } |
| | | anyStrings.add(bytes); |
| | | } else { |
| | |
| | | /** A fluent API for incrementally constructing attribute type. */ |
| | | public static final class Builder extends SchemaElementBuilder<Builder> { |
| | | private String oid; |
| | | private final List<String> names = new LinkedList<String>(); |
| | | private final List<String> names = new LinkedList<>(); |
| | | private AttributeUsage attributeUsage; |
| | | private boolean isCollective; |
| | | private boolean isNoUserModification; |
| | |
| | | */ |
| | | private static void addCollationMatchingRules(final SchemaBuilder builder) { |
| | | // Build an intermediate map to ensure each locale name appears only once |
| | | final Map<String, Locale> localesCache = new TreeMap<String, Locale>(); |
| | | final Map<String, Locale> localesCache = new TreeMap<>(); |
| | | for (Locale locale : Locale.getAvailableLocales()) { |
| | | localesCache.put(localeName(locale), locale); |
| | | } |
| | | |
| | | // Build a intermediate map to list all available oids with their locale names |
| | | // An oid can be associated to multiple locale names |
| | | final Map<String, List<String>> oidsCache = new HashMap<String, List<String>>(); |
| | | final Map<String, List<String>> oidsCache = new HashMap<>(); |
| | | for (final String localeName: localesCache.keySet()) { |
| | | String oid = JVM_SUPPORTED_LOCALE_NAMES_TO_OIDS.get(localeName); |
| | | if (oid != null) { |
| | | List<String> names = oidsCache.get(oid); |
| | | if (names == null) { |
| | | names = new ArrayList<String>(5); |
| | | names = new ArrayList<>(5); |
| | | oidsCache.put(oid, names); |
| | | } |
| | | names.add(localeName); |
| | |
| | | */ |
| | | private static String[] collationMatchingRuleNames(final List<String> localeNames, final int numSuffix, |
| | | final String symbolicSuffix) { |
| | | final List<String> names = new ArrayList<String>(); |
| | | final List<String> names = new ArrayList<>(); |
| | | for (String localeName : localeNames) { |
| | | if (symbolicSuffix.isEmpty()) { |
| | | // the default rule |
| | |
| | | * To add support for a new locale to collation matching rules, add its name as key and the corresponding oid as |
| | | * value. |
| | | */ |
| | | private static final Map<String, String> LOCALE_NAMES_TO_OIDS = new HashMap<String, String>(); |
| | | private static final Map<String, String> LOCALE_NAMES_TO_OIDS = new HashMap<>(); |
| | | |
| | | /** |
| | | * Same as {@link CoreSchemaSupportedLocales#LOCALE_NAMES_TO_OIDS}, but it contains the old locale names |
| | |
| | | * but the JVM only works with the old locale names. |
| | | * @see CoreSchemaSupportedLocales#LOCALE_NAMES_TO_OIDS |
| | | */ |
| | | private static final Map<String, String> JVM_SUPPORTED_LOCALE_NAMES_TO_OIDS = new HashMap<String, String>(); |
| | | private static final Map<String, String> JVM_SUPPORTED_LOCALE_NAMES_TO_OIDS = new HashMap<>(); |
| | | |
| | | static { |
| | | LOCALE_NAMES_TO_OIDS.put("af", "1.3.6.1.4.1.42.2.27.9.4.1.1"); |
| | |
| | | /** A fluent API for incrementally constructing DIT structure rules. */ |
| | | public static final class Builder extends SchemaElementBuilder<Builder> { |
| | | private int ruleID; |
| | | private final List<String> names = new LinkedList<String>(); |
| | | private final List<String> names = new LinkedList<>(); |
| | | private boolean isObsolete; |
| | | private String nameFormOID; |
| | | private final Set<Integer> superiorRuleIDs = new LinkedHashSet<Integer>(); |
| | | private final Set<Integer> superiorRuleIDs = new LinkedHashSet<>(); |
| | | |
| | | Builder(final DITStructureRule structureRule, final SchemaBuilder builder) { |
| | | super(builder); |
| | |
| | | } |
| | | |
| | | if (!superiorRuleIDs.isEmpty()) { |
| | | superiorRules = new HashSet<DITStructureRule>(superiorRuleIDs.size()); |
| | | DITStructureRule rule; |
| | | superiorRules = new HashSet<>(superiorRuleIDs.size()); |
| | | for (final Integer id : superiorRuleIDs) { |
| | | try { |
| | | rule = schema.getDITStructureRule(id); |
| | | superiorRules.add(schema.getDITStructureRule(id)); |
| | | } catch (final UnknownSchemaElementException e) { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_DSR_UNKNOWN_RULE_ID.get(getNameOrRuleID(), id); |
| | | failValidation(invalidSchemaElements, warnings, message); |
| | | return false; |
| | | } |
| | | superiorRules.add(rule); |
| | | } |
| | | } |
| | | superiorRules = Collections.unmodifiableSet(superiorRules); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | /** |
| | | * The set of values that may be used as delivery methods. |
| | | */ |
| | | private static final HashSet<String> ALLOWED_VALUES = new HashSet<String>(); |
| | | private static final HashSet<String> ALLOWED_VALUES = new HashSet<>(); |
| | | { |
| | | ALLOWED_VALUES.add("any"); |
| | | ALLOWED_VALUES.add("mhs"); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | * Portions copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | EnumSyntaxImpl(final String oid, final List<String> entries) { |
| | | Reject.ifNull(oid, entries); |
| | | this.oid = oid; |
| | | final List<String> entryStrings = new ArrayList<String>(entries.size()); |
| | | final List<String> entryStrings = new ArrayList<>(entries.size()); |
| | | |
| | | for (final String entry : entries) { |
| | | final String normalized = normalize(ByteString.valueOf(entry)); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | * The set of allowed fax parameter values, formatted entirely in lowercase |
| | | * characters. |
| | | */ |
| | | public static final HashSet<String> ALLOWED_FAX_PARAMETERS = new HashSet<String>(7); |
| | | public static final HashSet<String> ALLOWED_FAX_PARAMETERS = new HashSet<>(7); |
| | | |
| | | static { |
| | | ALLOWED_FAX_PARAMETERS.add("twodimensional"); |
| | |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 Manuel Gaupp |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | * Tool for generating CoreSchema.java. |
| | | */ |
| | | final class GenerateCoreSchema { |
| | | private static final Set<String> ABBREVIATIONS = new HashSet<String>(Arrays.asList("SASL", |
| | | private static final Set<String> ABBREVIATIONS = new HashSet<>(Arrays.asList("SASL", |
| | | "LDAP", "DN", "DIT", "RDN", "JPEG", "OID", "UUID", "IA5", "UID", "UTC", "X500", "X121", |
| | | "C", "CN", "O", "OU", "L", "DC", "ISDN", "SN", "ST")); |
| | | |
| | |
| | | |
| | | final Schema schema = Schema.getCoreSchema(); |
| | | |
| | | final SortedMap<String, Syntax> syntaxes = new TreeMap<String, Syntax>(); |
| | | final SortedMap<String, Syntax> syntaxes = new TreeMap<>(); |
| | | for (final Syntax syntax : schema.getSyntaxes()) { |
| | | if (isOpenDSOID(syntax.getOID())) { |
| | | continue; |
| | |
| | | syntaxes.put(fieldName, syntax); |
| | | } |
| | | |
| | | final SortedMap<String, MatchingRule> matchingRules = new TreeMap<String, MatchingRule>(); |
| | | final SortedMap<String, MatchingRule> matchingRules = new TreeMap<>(); |
| | | for (final MatchingRule matchingRule : schema.getMatchingRules()) { |
| | | if (isOpenDSOID(matchingRule.getOID()) || isCollationMatchingRule(matchingRule.getOID())) { |
| | | continue; |
| | |
| | | matchingRules.put(fieldName, matchingRule); |
| | | } |
| | | |
| | | final SortedMap<String, AttributeType> attributeTypes = |
| | | new TreeMap<String, AttributeType>(); |
| | | final SortedMap<String, AttributeType> attributeTypes = new TreeMap<>(); |
| | | for (final AttributeType attributeType : schema.getAttributeTypes()) { |
| | | if (isOpenDSOID(attributeType.getOID())) { |
| | | continue; |
| | |
| | | attributeTypes.put(fieldName, attributeType); |
| | | } |
| | | |
| | | final SortedMap<String, ObjectClass> objectClasses = new TreeMap<String, ObjectClass>(); |
| | | final SortedMap<String, ObjectClass> objectClasses = new TreeMap<>(); |
| | | for (final ObjectClass objectClass : schema.getObjectClasses()) { |
| | | if (isOpenDSOID(objectClass.getOID())) { |
| | | continue; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2014 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | // single quotes separated by spaces followed by a close |
| | | // parenthesis. |
| | | if (extraProperties.isEmpty()) { |
| | | extraProperties = new HashMap<String, List<String>>(); |
| | | extraProperties = new HashMap<>(); |
| | | } |
| | | extraProperties.put(tokenName, SchemaUtils.readExtensions(reader)); |
| | | } else { |
| | |
| | | /** A fluent API for incrementally constructing matching rules. */ |
| | | public static final class Builder extends SchemaElementBuilder<Builder> { |
| | | private String oid; |
| | | private final List<String> names = new LinkedList<String>(); |
| | | private final List<String> names = new LinkedList<>(); |
| | | private boolean isObsolete; |
| | | private String syntaxOID; |
| | | private MatchingRuleImpl impl; |
| | |
| | | * @return The OID for this schema definition. |
| | | */ |
| | | public String getOID() { |
| | | |
| | | return oid; |
| | | } |
| | | |
| | |
| | | /** A fluent API for incrementally constructing matching rule uses. */ |
| | | public static final class Builder extends SchemaElementBuilder<Builder> { |
| | | private String oid; |
| | | private final List<String> names = new LinkedList<String>(); |
| | | private final List<String> names = new LinkedList<>(); |
| | | private boolean isObsolete; |
| | | private final Set<String> attributeOIDs = new LinkedHashSet<String>(); |
| | | private final Set<String> attributeOIDs = new LinkedHashSet<>(); |
| | | |
| | | Builder(MatchingRuleUse mru, SchemaBuilder builder) { |
| | | super(builder, mru); |
| | |
| | | throw new SchemaException(message, e); |
| | | } |
| | | |
| | | attributes = new HashSet<AttributeType>(attributeOIDs.size()); |
| | | AttributeType attributeType; |
| | | attributes = new HashSet<>(attributeOIDs.size()); |
| | | for (final String attribute : attributeOIDs) { |
| | | try { |
| | | attributeType = schema.getAttributeType(attribute); |
| | | attributes.add(schema.getAttributeType(attribute)); |
| | | } catch (final UnknownSchemaElementException e) { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR1.get(getNameOrOID(), attribute); |
| | | throw new SchemaException(message, e); |
| | | } |
| | | attributes.add(attributeType); |
| | | } |
| | | attributes = Collections.unmodifiableSet(attributes); |
| | | } |
| | |
| | | /** A fluent API for incrementally constructing object classes. */ |
| | | public static final class Builder extends SchemaElementBuilder<Builder> { |
| | | private boolean isObsolete; |
| | | private final List<String> names = new LinkedList<String>(); |
| | | private final List<String> names = new LinkedList<>(); |
| | | private String oid; |
| | | private final Set<String> optionalAttributes = new LinkedHashSet<String>(); |
| | | private final Set<String> requiredAttributes = new LinkedHashSet<String>(); |
| | | private final Set<String> superiorClasses = new LinkedHashSet<String>(); |
| | | private final Set<String> optionalAttributes = new LinkedHashSet<>(); |
| | | private final Set<String> requiredAttributes = new LinkedHashSet<>(); |
| | | private final Set<String> superiorClasses = new LinkedHashSet<>(); |
| | | private ObjectClassType type; |
| | | |
| | | Builder(final ObjectClass oc, final SchemaBuilder builder) { |
| | |
| | | boolean derivesTop = getObjectClassType() != ObjectClassType.STRUCTURAL; |
| | | |
| | | if (!superiorClassOIDs.isEmpty()) { |
| | | superiorClasses = new HashSet<ObjectClass>(superiorClassOIDs.size()); |
| | | superiorClasses = new HashSet<>(superiorClassOIDs.size()); |
| | | ObjectClass superiorClass; |
| | | for (final String superClassOid : superiorClassOIDs) { |
| | | try { |
| | |
| | | // Inherit all required attributes from superior class. |
| | | Iterator<AttributeType> i = superiorClass.getRequiredAttributes().iterator(); |
| | | if (i.hasNext() && requiredAttributes == Collections.EMPTY_SET) { |
| | | requiredAttributes = new HashSet<AttributeType>(); |
| | | requiredAttributes = new HashSet<>(); |
| | | } |
| | | while (i.hasNext()) { |
| | | requiredAttributes.add(i.next()); |
| | |
| | | // Inherit all optional attributes from superior class. |
| | | i = superiorClass.getRequiredAttributes().iterator(); |
| | | if (i.hasNext() && requiredAttributes == Collections.EMPTY_SET) { |
| | | requiredAttributes = new HashSet<AttributeType>(); |
| | | requiredAttributes = new HashSet<>(); |
| | | } |
| | | while (i.hasNext()) { |
| | | requiredAttributes.add(i.next()); |
| | |
| | | } |
| | | |
| | | if (oid.equals(EXTENSIBLE_OBJECT_OBJECTCLASS_OID)) { |
| | | declaredOptionalAttributes = new HashSet<AttributeType>(requiredAttributeOIDs.size()); |
| | | declaredOptionalAttributes = new HashSet<>(requiredAttributeOIDs.size()); |
| | | for (final AttributeType attributeType : schema.getAttributeTypes()) { |
| | | if (attributeType.getUsage() == AttributeUsage.USER_APPLICATIONS) { |
| | | declaredOptionalAttributes.add(attributeType); |
| | |
| | | optionalAttributes = declaredRequiredAttributes; |
| | | } else { |
| | | if (!requiredAttributeOIDs.isEmpty()) { |
| | | declaredRequiredAttributes = |
| | | new HashSet<AttributeType>(requiredAttributeOIDs.size()); |
| | | declaredRequiredAttributes = new HashSet<>(requiredAttributeOIDs.size()); |
| | | AttributeType attributeType; |
| | | for (final String requiredAttribute : requiredAttributeOIDs) { |
| | | try { |
| | |
| | | } |
| | | |
| | | if (!optionalAttributeOIDs.isEmpty()) { |
| | | declaredOptionalAttributes = |
| | | new HashSet<AttributeType>(optionalAttributeOIDs.size()); |
| | | declaredOptionalAttributes = new HashSet<>(optionalAttributeOIDs.size()); |
| | | AttributeType attributeType; |
| | | for (final String optionalAttribute : optionalAttributeOIDs) { |
| | | try { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2014 Manuel Gaupp |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | // one structural object class. |
| | | ObjectClass structuralObjectClass = null; |
| | | final Attribute objectClassAttribute = entry.getAttribute(objectClass()); |
| | | final List<ObjectClass> objectClasses = new LinkedList<ObjectClass>(); |
| | | final List<ObjectClass> objectClasses = new LinkedList<>(); |
| | | if (objectClassAttribute != null) { |
| | | for (final ByteString v : objectClassAttribute) { |
| | | final String objectClassName = v.toString(); |
| | |
| | | if (attrs == null) { |
| | | name2AttributeTypes.put(lowerName, Collections.singletonList(attribute)); |
| | | } else if (attrs.size() == 1) { |
| | | attrs = new ArrayList<AttributeType>(attrs); |
| | | attrs = new ArrayList<>(attrs); |
| | | attrs.add(attribute); |
| | | name2AttributeTypes.put(lowerName, attrs); |
| | | } else { |
| | |
| | | if (rules == null) { |
| | | name2ContentRules.put(lowerName, Collections.singletonList(rule)); |
| | | } else if (rules.size() == 1) { |
| | | rules = new ArrayList<DITContentRule>(rules); |
| | | rules = new ArrayList<>(rules); |
| | | rules.add(rule); |
| | | name2ContentRules.put(lowerName, rules); |
| | | } else { |
| | |
| | | if (rules == null) { |
| | | name2StructureRules.put(lowerName, Collections.singletonList(rule)); |
| | | } else if (rules.size() == 1) { |
| | | rules = new ArrayList<DITStructureRule>(rules); |
| | | rules = new ArrayList<>(rules); |
| | | rules.add(rule); |
| | | name2StructureRules.put(lowerName, rules); |
| | | } else { |
| | |
| | | if (uses == null) { |
| | | name2MatchingRuleUses.put(lowerName, Collections.singletonList(use)); |
| | | } else if (uses.size() == 1) { |
| | | uses = new ArrayList<MatchingRuleUse>(uses); |
| | | uses = new ArrayList<>(uses); |
| | | uses.add(use); |
| | | name2MatchingRuleUses.put(lowerName, uses); |
| | | } else { |
| | |
| | | if (rules == null) { |
| | | name2MatchingRules.put(lowerName, Collections.singletonList(rule)); |
| | | } else if (rules.size() == 1) { |
| | | rules = new ArrayList<MatchingRule>(rules); |
| | | rules = new ArrayList<>(rules); |
| | | rules.add(rule); |
| | | name2MatchingRules.put(lowerName, rules); |
| | | } else { |
| | |
| | | if (forms == null) { |
| | | name2NameForms.put(lowerName, Collections.singletonList(form)); |
| | | } else if (forms.size() == 1) { |
| | | forms = new ArrayList<NameForm>(forms); |
| | | forms = new ArrayList<>(forms); |
| | | forms.add(form); |
| | | name2NameForms.put(lowerName, forms); |
| | | } else { |
| | |
| | | if (classes == null) { |
| | | name2ObjectClasses.put(lowerName, Collections.singletonList(oc)); |
| | | } else if (classes.size() == 1) { |
| | | classes = new ArrayList<ObjectClass>(classes); |
| | | classes = new ArrayList<>(classes); |
| | | classes.add(oc); |
| | | name2ObjectClasses.put(lowerName, classes); |
| | | } else { |
| | |
| | | if (numericOID2Syntaxes == null) { |
| | | options = defaultSchemaOptions(); |
| | | |
| | | numericOID2Syntaxes = new LinkedHashMap<String, Syntax>(); |
| | | numericOID2MatchingRules = new LinkedHashMap<String, MatchingRule>(); |
| | | numericOID2MatchingRuleUses = new LinkedHashMap<String, MatchingRuleUse>(); |
| | | numericOID2AttributeTypes = new LinkedHashMap<String, AttributeType>(); |
| | | numericOID2ObjectClasses = new LinkedHashMap<String, ObjectClass>(); |
| | | numericOID2NameForms = new LinkedHashMap<String, NameForm>(); |
| | | numericOID2ContentRules = new LinkedHashMap<String, DITContentRule>(); |
| | | id2StructureRules = new LinkedHashMap<Integer, DITStructureRule>(); |
| | | numericOID2Syntaxes = new LinkedHashMap<>(); |
| | | numericOID2MatchingRules = new LinkedHashMap<>(); |
| | | numericOID2MatchingRuleUses = new LinkedHashMap<>(); |
| | | numericOID2AttributeTypes = new LinkedHashMap<>(); |
| | | numericOID2ObjectClasses = new LinkedHashMap<>(); |
| | | numericOID2NameForms = new LinkedHashMap<>(); |
| | | numericOID2ContentRules = new LinkedHashMap<>(); |
| | | id2StructureRules = new LinkedHashMap<>(); |
| | | |
| | | name2MatchingRules = new LinkedHashMap<String, List<MatchingRule>>(); |
| | | name2MatchingRuleUses = new LinkedHashMap<String, List<MatchingRuleUse>>(); |
| | | name2AttributeTypes = new LinkedHashMap<String, List<AttributeType>>(); |
| | | name2ObjectClasses = new LinkedHashMap<String, List<ObjectClass>>(); |
| | | name2NameForms = new LinkedHashMap<String, List<NameForm>>(); |
| | | name2ContentRules = new LinkedHashMap<String, List<DITContentRule>>(); |
| | | name2StructureRules = new LinkedHashMap<String, List<DITStructureRule>>(); |
| | | name2MatchingRules = new LinkedHashMap<>(); |
| | | name2MatchingRuleUses = new LinkedHashMap<>(); |
| | | name2AttributeTypes = new LinkedHashMap<>(); |
| | | name2ObjectClasses = new LinkedHashMap<>(); |
| | | name2NameForms = new LinkedHashMap<>(); |
| | | name2ContentRules = new LinkedHashMap<>(); |
| | | name2StructureRules = new LinkedHashMap<>(); |
| | | |
| | | objectClass2NameForms = new HashMap<String, List<NameForm>>(); |
| | | nameForm2StructureRules = new HashMap<String, List<DITStructureRule>>(); |
| | | warnings = new LinkedList<LocalizableMessage>(); |
| | | objectClass2NameForms = new HashMap<>(); |
| | | nameForm2StructureRules = new HashMap<>(); |
| | | warnings = new LinkedList<>(); |
| | | } |
| | | |
| | | if (copyOnWriteSchema != null) { |
| | |
| | | |
| | | // Attribute types need special processing because they have |
| | | // hierarchical dependencies. |
| | | final List<AttributeType> invalidAttributeTypes = new LinkedList<AttributeType>(); |
| | | final List<AttributeType> invalidAttributeTypes = new LinkedList<>(); |
| | | for (final AttributeType attributeType : numericOID2AttributeTypes.values()) { |
| | | attributeType.validate(schema, invalidAttributeTypes, warnings); |
| | | } |
| | |
| | | |
| | | // Object classes need special processing because they have hierarchical |
| | | // dependencies. |
| | | final List<ObjectClass> invalidObjectClasses = new LinkedList<ObjectClass>(); |
| | | final List<ObjectClass> invalidObjectClasses = new LinkedList<>(); |
| | | for (final ObjectClass objectClass : numericOID2ObjectClasses.values()) { |
| | | objectClass.validate(schema, invalidObjectClasses, warnings); |
| | | } |
| | |
| | | if (forms == null) { |
| | | objectClass2NameForms.put(ocOID, Collections.singletonList(form)); |
| | | } else if (forms.size() == 1) { |
| | | forms = new ArrayList<NameForm>(forms); |
| | | forms = new ArrayList<>(forms); |
| | | forms.add(form); |
| | | objectClass2NameForms.put(ocOID, forms); |
| | | } else { |
| | |
| | | |
| | | // DIT structure rules need special processing because they have |
| | | // hierarchical dependencies. |
| | | final List<DITStructureRule> invalidStructureRules = new LinkedList<DITStructureRule>(); |
| | | final List<DITStructureRule> invalidStructureRules = new LinkedList<>(); |
| | | for (final DITStructureRule rule : id2StructureRules.values()) { |
| | | rule.validate(schema, invalidStructureRules, warnings); |
| | | } |
| | |
| | | if (rules == null) { |
| | | nameForm2StructureRules.put(ocOID, Collections.singletonList(rule)); |
| | | } else if (rules.size() == 1) { |
| | | rules = new ArrayList<DITStructureRule>(rules); |
| | | rules = new ArrayList<>(rules); |
| | | rules.add(rule); |
| | | nameForm2StructureRules.put(ocOID, rules); |
| | | } else { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | SchemaElementBuilder(final SchemaBuilder schemaBuilder) { |
| | | this.schemaBuilder = schemaBuilder; |
| | | this.description = ""; |
| | | this.extraProperties = new LinkedHashMap<String, List<String>>(1); |
| | | this.extraProperties = new LinkedHashMap<>(1); |
| | | } |
| | | |
| | | SchemaElementBuilder(final SchemaBuilder schemaBuilder, final SchemaElement copy) { |
| | | this.schemaBuilder = schemaBuilder; |
| | | this.description = copy.description; |
| | | this.extraProperties = new LinkedHashMap<String, List<String>>(copy.extraProperties); |
| | | this.extraProperties = new LinkedHashMap<>(copy.extraProperties); |
| | | } |
| | | |
| | | /* |
| | |
| | | T extraProperties0(final String extensionName, final String... extensionValues) { |
| | | if (this.extraProperties.get(extensionName) != null) { |
| | | final List<String> tempExtraProperties = |
| | | new ArrayList<String>(this.extraProperties.get(extensionName)); |
| | | new ArrayList<>(this.extraProperties.get(extensionName)); |
| | | tempExtraProperties.addAll(Arrays.asList(extensionValues)); |
| | | this.extraProperties.put(extensionName, tempExtraProperties); |
| | | } else { |
| | |
| | | T removeExtraProperty0(final String extensionName, final String... extensionValues) { |
| | | if (this.extraProperties.get(extensionName) != null && extensionValues.length > 0) { |
| | | final List<String> tempExtraProperties = |
| | | new ArrayList<String>(this.extraProperties.get(extensionName)); |
| | | new ArrayList<>(this.extraProperties.get(extensionName)); |
| | | tempExtraProperties.removeAll(Arrays.asList(extensionValues)); |
| | | this.extraProperties.put(extensionName, tempExtraProperties); |
| | | } else if (this.extraProperties.get(extensionName) != null) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2014 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | if (c == ')') { |
| | | values = Collections.emptyList(); |
| | | } else { |
| | | values = new ArrayList<String>(); |
| | | values = new ArrayList<>(); |
| | | do { |
| | | reader.reset(); |
| | | values.add(readQuotedString(reader)); |
| | |
| | | if (c == ')') { |
| | | values = Collections.emptyList(); |
| | | } else { |
| | | values = new LinkedList<String>(); |
| | | values = new LinkedList<>(); |
| | | do { |
| | | reader.reset(); |
| | | values.add(readQuotedDescriptor(reader, allowCompatChars)); |
| | |
| | | try { |
| | | final char c = reader.read(); |
| | | if (c == '(') { |
| | | values = new LinkedHashSet<String>(); |
| | | values = new LinkedHashSet<>(); |
| | | do { |
| | | values.add(readOID(reader, allowCompatChars)); |
| | | |
| | |
| | | try { |
| | | final char c = reader.read(); |
| | | if (c == '(') { |
| | | values = new LinkedHashSet<Integer>(); |
| | | values = new LinkedHashSet<>(); |
| | | do { |
| | | values.add(readRuleID(reader)); |
| | | |
| | |
| | | final Map<String, List<String>> extraProperties) { |
| | | if (extraProperties == null || extraProperties.isEmpty()) { |
| | | return Collections.emptyMap(); |
| | | } else { |
| | | final Map<String, List<String>> tmp = |
| | | new LinkedHashMap<String, List<String>>(extraProperties.size()); |
| | | for (final Map.Entry<String, List<String>> e : extraProperties.entrySet()) { |
| | | tmp.put(e.getKey(), unmodifiableCopyOfList(e.getValue())); |
| | | } |
| | | return Collections.unmodifiableMap(tmp); |
| | | } |
| | | |
| | | final Map<String, List<String>> tmp = new LinkedHashMap<>(extraProperties.size()); |
| | | for (final Map.Entry<String, List<String>> e : extraProperties.entrySet()) { |
| | | tmp.put(e.getKey(), unmodifiableCopyOfList(e.getValue())); |
| | | } |
| | | return Collections.unmodifiableMap(tmp); |
| | | } |
| | | |
| | | static <E> List<E> unmodifiableCopyOfList(final List<E> l) { |
| | |
| | | } else if (l.size() == 1) { |
| | | return Collections.singletonList(l.get(0)); |
| | | } else { |
| | | final List<E> copy = new LinkedList<E>(l); |
| | | final List<E> copy = new LinkedList<>(l); |
| | | return Collections.unmodifiableList(copy); |
| | | } |
| | | } |
| | |
| | | } else if (s.size() == 1) { |
| | | return Collections.singleton(s.iterator().next()); |
| | | } else { |
| | | final Set<E> copy = new LinkedHashSet<E>(s); |
| | | final Set<E> copy = new LinkedHashSet<>(s); |
| | | return Collections.unmodifiableSet(copy); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | * The set of allowed fax parameter values, formatted entirely in lowercase |
| | | * characters. |
| | | */ |
| | | private static final HashSet<String> ALLOWED_TTX_PARAMETERS = new HashSet<String>(5); |
| | | private static final HashSet<String> ALLOWED_TTX_PARAMETERS = new HashSet<>(5); |
| | | |
| | | static { |
| | | ALLOWED_TTX_PARAMETERS.add("graphic"); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | int assertMonth = buffer.getInt(16); |
| | | int assertYear = buffer.getInt(20); |
| | | |
| | | List<T> queries = new ArrayList<T>(); |
| | | List<T> queries = new ArrayList<>(); |
| | | if (assertSecond >= 0) { |
| | | queries.add(createExactMatchQuery(factory, assertSecond, SECOND)); |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | |
| | | */ |
| | | private volatile LdapException connectionError; |
| | | |
| | | /** |
| | | * {@code true} if the connection has failed due to a disconnect |
| | | * notification. |
| | | */ |
| | | /** Whether the connection has failed due to a disconnect notification. */ |
| | | private boolean failedDueToDisconnect; |
| | | |
| | | /** |
| | | * Registered event listeners. |
| | | */ |
| | | private final List<ConnectionEventListener> listeners = |
| | | new LinkedList<ConnectionEventListener>(); |
| | | /** Registered event listeners. */ |
| | | private final List<ConnectionEventListener> listeners = new LinkedList<>(); |
| | | |
| | | /** |
| | | * Internal state implementation. |
| | | */ |
| | | /** Internal state implementation. */ |
| | | private volatile State state = State.VALID; |
| | | |
| | | /** |
| | | * Creates a new connection state which is initially valid. |
| | | */ |
| | | /** Creates a new connection state which is initially valid. */ |
| | | public ConnectionState() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | |
| | | * @return a new {@link LdapPromiseImpl} |
| | | */ |
| | | public static <S> LdapPromiseImpl<S> newLdapPromiseImpl(int requestID) { |
| | | return new LdapPromiseImpl<S>(PromiseImpl.<S, LdapException> create(), requestID); |
| | | return new LdapPromiseImpl<>(PromiseImpl.<S, LdapException> create(), requestID); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | |
| | | public static <S extends ExtendedResult> ExtendedResultLdapPromiseImpl<S> newExtendedLdapPromise( |
| | | final int requestID, final ExtendedRequest<S> request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final Connection connection) { |
| | | return new ExtendedResultLdapPromiseImpl<S>(requestID, request, intermediateResponseHandler, connection); |
| | | return new ExtendedResultLdapPromiseImpl<>(requestID, request, intermediateResponseHandler, connection); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | static <R> LdapPromise<R> wrap(Promise<R, LdapException> wrappedPromise, int requestID) { |
| | | return new LdapPromiseWrapper<R, Promise<R, LdapException>>(wrappedPromise, requestID); |
| | | return new LdapPromiseWrapper<>(wrappedPromise, requestID); |
| | | } |
| | | |
| | | private LdapPromises() { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | final LDIFRecord readLDIFRecord() throws IOException { |
| | | // Read the entry lines into a buffer. |
| | | final StringBuilder lastLineBuilder = new StringBuilder(); |
| | | final LinkedList<String> ldifLines = new LinkedList<String>(); |
| | | final LinkedList<String> ldifLines = new LinkedList<>(); |
| | | long recordLineNumber = 0; |
| | | final int stateStart = 0; |
| | | final int stateStartCommentLine = 1; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | * Common LDIF reader/writer functionality. |
| | | */ |
| | | abstract class AbstractLDIFStream { |
| | | final Set<AttributeDescription> excludeAttributes = new HashSet<AttributeDescription>(); |
| | | final Set<DN> excludeBranches = new HashSet<DN>(); |
| | | final List<Matcher> excludeFilters = new LinkedList<Matcher>(); |
| | | final Set<AttributeDescription> excludeAttributes = new HashSet<>(); |
| | | final Set<DN> excludeBranches = new HashSet<>(); |
| | | final List<Matcher> excludeFilters = new LinkedList<>(); |
| | | boolean excludeOperationalAttributes; |
| | | boolean excludeUserAttributes; |
| | | final Set<AttributeDescription> includeAttributes = new HashSet<AttributeDescription>(); |
| | | final Set<DN> includeBranches = new HashSet<DN>(); |
| | | final List<Matcher> includeFilters = new LinkedList<Matcher>(); |
| | | final Set<AttributeDescription> includeAttributes = new HashSet<>(); |
| | | final Set<DN> includeBranches = new HashSet<>(); |
| | | final List<Matcher> includeFilters = new LinkedList<>(); |
| | | |
| | | AbstractLDIFStream() { |
| | | // Nothing to do. |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | |
| | | private TemplateFile templateFile; |
| | | |
| | | /** Warnings issued by the parsing of the template file. */ |
| | | private final List<LocalizableMessage> warnings = new LinkedList<LocalizableMessage>(); |
| | | private final List<LocalizableMessage> warnings = new LinkedList<>(); |
| | | |
| | | /** Indicates if the generator is closed. */ |
| | | private boolean isClosed; |
| | |
| | | private boolean generateBranches = true; |
| | | |
| | | /** Dictionary of constants to use in the template file. */ |
| | | private Map<String, String> constants = new HashMap<String, String>(); |
| | | private Map<String, String> constants = new HashMap<>(); |
| | | |
| | | /** |
| | | * Creates a generator using default values. |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2011-2014 ForgeRock AS |
| | | * Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | * If {@code ldifLines} was {@code null}. |
| | | */ |
| | | public static List<Entry> makeEntries(String... ldifLines) { |
| | | List<Entry> entries = new ArrayList<Entry>(); |
| | | List<Entry> entries = new ArrayList<>(); |
| | | LDIFEntryReader reader = new LDIFEntryReader(ldifLines); |
| | | try { |
| | | while (reader.hasNext()) { |
| | |
| | | |
| | | // Move the renamed entries into a separate map |
| | | // in order to avoid cases where the renamed subtree overlaps. |
| | | final SortedMap<byte[], byte[]> renamedEntries = |
| | | new TreeMap<byte[], byte[]>(DN_ORDER); |
| | | final SortedMap<byte[], byte[]> renamedEntries = new TreeMap<>(DN_ORDER); |
| | | |
| | | // @formatter:off |
| | | final Iterator<Map.Entry<byte[], byte[]>> i = |
| | |
| | | } |
| | | |
| | | private static List<byte[][]> readEntriesAsList(final EntryReader reader) throws IOException { |
| | | final List<byte[][]> entries = new ArrayList<byte[][]>(); |
| | | final List<byte[][]> entries = new ArrayList<>(); |
| | | |
| | | while (reader.hasNext()) { |
| | | final Entry entry = reader.readEntry(); |
| | |
| | | |
| | | private static TreeMap<byte[], byte[]> readEntriesAsMap(final EntryReader reader) |
| | | throws IOException { |
| | | final TreeMap<byte[], byte[]> entries = new TreeMap<byte[], byte[]>(DN_ORDER); |
| | | final TreeMap<byte[], byte[]> entries = new TreeMap<>(DN_ORDER); |
| | | |
| | | while (reader.hasNext()) { |
| | | final Entry entry = reader.readEntry(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | } |
| | | |
| | | if (controls == null) { |
| | | controls = new LinkedList<Control>(); |
| | | controls = new LinkedList<>(); |
| | | } |
| | | |
| | | controls.add(parseControl(entryDN, record, ldifLine, pair.value)); |
| | |
| | | // Use an Entry for the AttributeSequence. |
| | | final Entry entry = new LinkedHashMapEntry(entryDN); |
| | | boolean schemaValidationFailure = false; |
| | | final List<LocalizableMessage> schemaErrors = new LinkedList<LocalizableMessage>(); |
| | | final List<LocalizableMessage> schemaErrors = new LinkedList<>(); |
| | | |
| | | if (lastLDIFLine != null |
| | | // This line was read when looking for the change type. |
| | |
| | | throws DecodeException { |
| | | final ModifyRequest modifyRequest = Requests.newModifyRequest(entryDN); |
| | | final KeyValuePair pair = new KeyValuePair(); |
| | | final List<ByteString> attributeValues = new ArrayList<ByteString>(); |
| | | final List<ByteString> attributeValues = new ArrayList<>(); |
| | | boolean schemaValidationFailure = false; |
| | | final List<LocalizableMessage> schemaErrors = new LinkedList<LocalizableMessage>(); |
| | | final List<LocalizableMessage> schemaErrors = new LinkedList<>(); |
| | | |
| | | while (record.iterator.hasNext()) { |
| | | String ldifLine = readLDIFRecordKeyValuePair(record, pair, false); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | // Use an Entry for the AttributeSequence. |
| | | final Entry entry = new LinkedHashMapEntry(entryDN); |
| | | boolean schemaValidationFailure = false; |
| | | final List<LocalizableMessage> schemaErrors = new LinkedList<LocalizableMessage>(); |
| | | final List<LocalizableMessage> schemaErrors = new LinkedList<>(); |
| | | while (record.iterator.hasNext()) { |
| | | final String ldifLine = record.iterator.next(); |
| | | if (!readLDIFRecordAttributeValue(record, ldifLine, entry, schemaErrors)) { |
| | |
| | | * A map of the contents of various text files used during the parsing |
| | | * process, mapped from absolute path to the array of lines in the file. |
| | | */ |
| | | private final Map<String, String[]> fileLines = new HashMap<String, String[]>(); |
| | | private final Map<String, String[]> fileLines = new HashMap<>(); |
| | | |
| | | /** The index of the next first name value that should be used. */ |
| | | private int firstNameIndex; |
| | |
| | | private int nameUniquenessCounter = 1; |
| | | |
| | | /** The set of branch definitions for this template file. */ |
| | | private final Map<DN, Branch> branches = new LinkedHashMap<DN, Branch>(); |
| | | private final Map<DN, Branch> branches = new LinkedHashMap<>(); |
| | | |
| | | /** The set of constant definitions for this template file. */ |
| | | private final Map<String, String> constants; |
| | | |
| | | /** The set of registered tags for this template file. */ |
| | | private final Map<String, TemplateTag> registeredTags = new LinkedHashMap<String, TemplateTag>(); |
| | | private final Map<String, TemplateTag> registeredTags = new LinkedHashMap<>(); |
| | | |
| | | /** The set of template definitions for this template file. */ |
| | | private final Map<String, Template> templates = new LinkedHashMap<String, Template>(); |
| | | private final Map<String, Template> templates = new LinkedHashMap<>(); |
| | | |
| | | /** The random number generator for this template file. */ |
| | | private final Random random; |
| | |
| | | * Structure to hold template data during parsing of the template. |
| | | */ |
| | | private static class TemplateData { |
| | | final Map<String, TemplateTag> tags = new LinkedHashMap<String, TemplateTag>(); |
| | | final Map<DN, Branch> branches = new LinkedHashMap<DN, Branch>(); |
| | | final Map<String, Template> templates = new LinkedHashMap<String, Template>(); |
| | | final Map<String, TemplateTag> tags = new LinkedHashMap<>(); |
| | | final Map<DN, Branch> branches = new LinkedHashMap<>(); |
| | | final Map<String, Template> templates = new LinkedHashMap<>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private String[] parseLinesUntilEndOfBlock(final int startLineNumber, final String startLine, |
| | | final String[] lines, final List<LocalizableMessage> warnings) { |
| | | final List<String> lineList = new ArrayList<String>(); |
| | | final List<String> lineList = new ArrayList<>(); |
| | | String line = startLine; |
| | | lineList.add(line); |
| | | |
| | |
| | | // that's not one of those. |
| | | int lineCount = 1; |
| | | Template parentTemplate = null; |
| | | final List<AttributeType> rdnAttributes = new ArrayList<AttributeType>(); |
| | | final List<String> subordinatesTemplateNames = new ArrayList<String>(); |
| | | final List<Integer> numberOfentriesPerTemplate = new ArrayList<Integer>(); |
| | | final List<AttributeType> rdnAttributes = new ArrayList<>(); |
| | | final List<String> subordinatesTemplateNames = new ArrayList<>(); |
| | | final List<Integer> numberOfentriesPerTemplate = new ArrayList<>(); |
| | | |
| | | for (; lineCount < templateLines.length; lineCount++) { |
| | | final int lineNumber = startLineNumber + lineCount; |
| | |
| | | int phase = PARSING_STATIC_TEXT; |
| | | int previousPhase = PARSING_STATIC_TEXT; |
| | | |
| | | final List<TemplateTag> tagList = new ArrayList<TemplateTag>(); |
| | | final List<TemplateTag> tagList = new ArrayList<>(); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | |
| | | for (; pos < length; pos++) { |
| | |
| | | } |
| | | } |
| | | |
| | | final List<String> args = new ArrayList<String>(); |
| | | final List<String> args = new ArrayList<>(); |
| | | while (tokenizer.hasMoreTokens()) { |
| | | args.add(tokenizer.nextToken().trim()); |
| | | } |
| | |
| | | // is the number of characters to use from the attribute value. The |
| | | // arguments will be delimited by colons. |
| | | final StringTokenizer tokenizer = new StringTokenizer(tagString, ":"); |
| | | final List<String> args = new ArrayList<String>(); |
| | | final List<String> args = new ArrayList<>(); |
| | | while (tokenizer.hasMoreTokens()) { |
| | | args.add(tokenizer.nextToken()); |
| | | } |
| | |
| | | * If a problem occurs while reading the lines. |
| | | */ |
| | | private List<String> readLines(final BufferedReader reader) throws IOException { |
| | | final List<String> lines = new ArrayList<String>(); |
| | | final List<String> lines = new ArrayList<>(); |
| | | while (true) { |
| | | final String line = reader.readLine(); |
| | | if (line == null) { |
| | |
| | | this.extraLines = extraLines; |
| | | |
| | | // The RDN template lines are based on the DN. |
| | | final List<LocalizableMessage> warnings = new ArrayList<LocalizableMessage>(); |
| | | rdnLines = new ArrayList<TemplateLine>(); |
| | | final List<LocalizableMessage> warnings = new ArrayList<>(); |
| | | rdnLines = new ArrayList<>(); |
| | | for (final AVA ava : branchDN.rdn()) { |
| | | final Attribute attribute = ava.toAttribute(); |
| | | for (final ByteString value : attribute.toArray()) { |
| | |
| | | final Schema schema, final List<LocalizableMessage> warnings) throws DecodeException { |
| | | final StaticTextTag tag = new StaticTextTag(); |
| | | tag.initializeForBranch(schema, templateFile, this, new String[] { value }, 0, warnings); |
| | | final List<TemplateTag> tags = new ArrayList<TemplateTag>(); |
| | | final List<TemplateTag> tags = new ArrayList<>(); |
| | | tags.add(tag); |
| | | return tags; |
| | | } |
| | |
| | | */ |
| | | private void completeBranchInitialization(final Map<String, Template> templates, |
| | | boolean generateBranches) throws DecodeException { |
| | | subordinateTemplates = new ArrayList<Template>(); |
| | | subordinateTemplates = new ArrayList<>(); |
| | | for (int i = 0; i < subordinateTemplateNames.size(); i++) { |
| | | subordinateTemplates.add(templates.get(subordinateTemplateNames.get(i).toLowerCase())); |
| | | if (subordinateTemplates.get(i) == null) { |
| | |
| | | */ |
| | | private TemplateEntry buildBranchEntry(boolean generateBranches) { |
| | | final TemplateEntry entry = new TemplateEntry(this); |
| | | final List<TemplateLine> lines = new ArrayList<TemplateLine>(rdnLines); |
| | | final List<TemplateLine> lines = new ArrayList<>(rdnLines); |
| | | lines.addAll(extraLines); |
| | | for (final TemplateLine line : lines) { |
| | | line.generateLine(entry); |
| | |
| | | * the template file. |
| | | */ |
| | | void completeTemplateInitialization(final Map<String, Template> templates) throws DecodeException { |
| | | subTemplates = new ArrayList<Template>(); |
| | | subTemplates = new ArrayList<>(); |
| | | for (final String subordinateName : subTemplateNames) { |
| | | final Template template = templates.get(subordinateName.toLowerCase()); |
| | | if (template == null) { |
| | |
| | | } |
| | | |
| | | private void ensureAllRDNAttributesAreDefined() throws DecodeException { |
| | | Set<AttributeType> rdnAttrs = new HashSet<AttributeType>(rdnAttributes); |
| | | List<AttributeType> templateAttrs = new ArrayList<AttributeType>(); |
| | | Set<AttributeType> rdnAttrs = new HashSet<>(rdnAttributes); |
| | | List<AttributeType> templateAttrs = new ArrayList<>(); |
| | | for (TemplateLine line : templateLines) { |
| | | templateAttrs.add(line.getAttributeType()); |
| | | } |
| | |
| | | * A list of template values is never empty in the map, it always has |
| | | * at least one element. |
| | | */ |
| | | private final LinkedHashMap<AttributeType, List<TemplateValue>> attributes; |
| | | private final LinkedHashMap<AttributeType, List<TemplateValue>> attributes = new LinkedHashMap<>(); |
| | | |
| | | /** |
| | | * The template used to generate this entry if it is associated with a |
| | |
| | | */ |
| | | TemplateEntry(final Branch branch) { |
| | | dn = branch.getBranchDN(); |
| | | attributes = new LinkedHashMap<AttributeType, List<TemplateValue>>(); |
| | | template = null; |
| | | parentDN = null; |
| | | } |
| | |
| | | TemplateEntry(final Template template, final DN parentDN) { |
| | | this.template = template; |
| | | this.parentDN = parentDN; |
| | | attributes = new LinkedHashMap<AttributeType, List<TemplateValue>>(); |
| | | } |
| | | |
| | | DN getParentDN() { |
| | |
| | | */ |
| | | DN getDN() { |
| | | if (dn == null) { |
| | | final Collection<AVA> avas = new ArrayList<AVA>(); |
| | | final Collection<AVA> avas = new ArrayList<>(); |
| | | for (final AttributeType attrType : template.getRDNAttributes()) { |
| | | final TemplateValue templateValue = getValue(attrType); |
| | | if (templateValue == null) { |
| | |
| | | void addValue(TemplateValue value) { |
| | | List<TemplateValue> values = attributes.get(value.getAttributeType()); |
| | | if (values == null) { |
| | | values = new ArrayList<TemplateValue>(); |
| | | values = new ArrayList<>(); |
| | | attributes.put(value.getAttributeType(), values); |
| | | } |
| | | values.add(value); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | public class AccountUsabilityRequestControlTestCase extends ControlsTestCase { |
| | | @Test |
| | | public void testControl() throws Exception { |
| | | // Send this control with a search request and see that you get |
| | | // a valid response. |
| | | // Send this control with a search request and see that you get a valid response. |
| | | final SearchRequest req = |
| | | Requests.newSearchRequest(DN.valueOf("uid=user.1,ou=people,o=test"), |
| | | SearchScope.BASE_OBJECT, Filter.objectClassPresent()); |
| | |
| | | AccountUsabilityRequestControl.newControl(false); |
| | | req.addControl(control); |
| | | final Connection con = TestCaseUtils.getInternalConnection(); |
| | | final List<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | final List<SearchResultEntry> entries = new ArrayList<>(); |
| | | con.search(req, entries); |
| | | assertTrue(entries.size() > 0); |
| | | final SearchResultEntry entry = entries.get(0); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap.controls; |
| | |
| | | Requests.newSearchRequest(DN.valueOf("uid=user.1,ou=people,o=test"), |
| | | SearchScope.BASE_OBJECT, Filter.objectClassPresent()); |
| | | final Connection con = TestCaseUtils.getInternalConnection(); |
| | | final List<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | final List<SearchResultEntry> entries = new ArrayList<>(); |
| | | con.search(req, entries); |
| | | assertTrue(entries.size() > 0); |
| | | final SearchResultEntry entry = entries.get(0); |
| | |
| | | |
| | | @Test |
| | | public void testValidResponseControl() throws Exception { |
| | | // Send this control with a search request and see that you get |
| | | // a valid response. |
| | | // Send this control with a search request and see that you get a valid response. |
| | | final SearchRequest req = |
| | | Requests.newSearchRequest(DN.valueOf("uid=user.1,ou=people,o=test"), |
| | | SearchScope.BASE_OBJECT, Filter.objectClassPresent()); |
| | |
| | | AccountUsabilityRequestControl.newControl(false); |
| | | req.addControl(control); |
| | | final Connection con = TestCaseUtils.getInternalConnection(); |
| | | final List<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | final List<SearchResultEntry> entries = new ArrayList<>(); |
| | | con.search(req, entries); |
| | | assertTrue(entries.size() > 0); |
| | | final SearchResultEntry entry = entries.get(0); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS, entry); |
| | | final SearchRequest searchRequest = |
| | | newSearchRequest("cn=test", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | List<SearchResultEntry> entries = new LinkedList<SearchResultEntry>(); |
| | | List<SearchResultEntry> entries = new LinkedList<>(); |
| | | assertThat(mockConnection.search(searchRequest, entries).getResultCode()).isEqualTo( |
| | | ResultCode.SUCCESS); |
| | | assertThat(entries.size()).isEqualTo(1); |
| | |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final SearchRequest searchRequest = |
| | | newSearchRequest("cn=test", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | List<SearchResultEntry> entries = new LinkedList<SearchResultEntry>(); |
| | | List<SearchResultEntry> entries = new LinkedList<>(); |
| | | try { |
| | | mockConnection.search(searchRequest, entries); |
| | | failWasExpected(LdapException.class); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2014 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | private boolean match(String[] rules, String[] addrs, String[] hostNames) |
| | | throws UnknownHostException { |
| | | int i = 0; |
| | | Collection<AddressMask> m = new ArrayList<AddressMask>(rules.length); |
| | | Collection<AddressMask> m = new ArrayList<>(rules.length); |
| | | for (i = 0; i < rules.length; i++) { |
| | | m.add(AddressMask.valueOf(rules[i])); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | public Iterator<Object[]> allPermutationsUpTo4Operands() { |
| | | final ConditionResult[] values = ConditionResult.values(); |
| | | |
| | | final List<Object[]> results = new ArrayList<Object[]>(); |
| | | final List<Object[]> results = new ArrayList<>(); |
| | | results.add(new Object[] { new ConditionResult[0] }); |
| | | for (int arrayLength = 1; arrayLength <= 4; arrayLength++) { |
| | | final ConditionResult[] template = new ConditionResult[arrayLength]; |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | */ |
| | | @Test |
| | | public void testConnectionEventListenerError() throws Exception { |
| | | final List<ConnectionEventListener> listeners = new LinkedList<ConnectionEventListener>(); |
| | | final List<ConnectionEventListener> listeners = new LinkedList<>(); |
| | | final Connection mockConnection = mockConnection(listeners); |
| | | final ConnectionFactory factory = mockConnectionFactory(mockConnection); |
| | | final ConnectionPool pool = newFixedConnectionPool(factory, 1); |
| | |
| | | */ |
| | | @Test |
| | | public void testConnectionEventListenerUnsolicitedNotification() throws Exception { |
| | | final List<ConnectionEventListener> listeners = new LinkedList<ConnectionEventListener>(); |
| | | final List<ConnectionEventListener> listeners = new LinkedList<>(); |
| | | final Connection mockConnection = mockConnection(listeners); |
| | | final ConnectionFactory factory = mockConnectionFactory(mockConnection); |
| | | final ConnectionPool pool = newFixedConnectionPool(factory, 1); |
| | |
| | | } |
| | | }).when(factory).getConnectionAsync(); |
| | | |
| | | List<Promise<? extends Connection, LdapException>> promises = |
| | | new ArrayList<Promise<? extends Connection, LdapException>>(); |
| | | List<Promise<? extends Connection, LdapException>> promises = new ArrayList<>(); |
| | | for (int i = 0; i < poolSize + 1; i++) { |
| | | promises.add(pool.getConnectionAsync()); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | @Test(dataProvider = "EntryFactory") |
| | | public void testAddAttributeAttributeCollection(final EntryFactory factory) throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> duplicateValues = new LinkedList<>(); |
| | | assertThat(entry.addAttribute(new LinkedAttribute("sn", "sn"), duplicateValues)).isTrue(); |
| | | assertThat(entry.getAttribute(AD_SN)).hasSize(1); |
| | | assertThat(duplicateValues).hasSize(0); |
| | |
| | | public void testAddAttributeAttributeCollectionValueMissing(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> duplicateValues = new LinkedList<>(); |
| | | assertThat(entry.addAttribute(new LinkedAttribute("cn", "newcn"), duplicateValues)) |
| | | .isTrue(); |
| | | assertThat(entry.getAttribute(AD_CN)).hasSize(2); |
| | |
| | | public void testAddAttributeAttributeCollectionValuePresent(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> duplicateValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> duplicateValues = new LinkedList<>(); |
| | | assertThat(entry.addAttribute(new LinkedAttribute("cn", "test"), duplicateValues)) |
| | | .isFalse(); |
| | | assertThat(entry.getAttribute(AD_CN)).hasSize(1); |
| | |
| | | public void testContainsAttributeAttributeCustomMissing(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(emptyAttribute(AD_CUSTOM2), missingValues)).isFalse(); |
| | | assertThat(missingValues).isEmpty(); |
| | | } |
| | |
| | | public void testContainsAttributeAttributeCustomPresent1(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(emptyAttribute(AD_CUSTOM1), missingValues)).isTrue(); |
| | | assertThat(missingValues).isEmpty(); |
| | | } |
| | |
| | | public void testContainsAttributeAttributeCustomPresent2(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(emptyAttribute("custom1"), missingValues)).isTrue(); |
| | | assertThat(missingValues).isEmpty(); |
| | | } |
| | |
| | | public void testContainsAttributeAttributeCustomValueMissing1(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat( |
| | | entry.containsAttribute(singletonAttribute(AD_CUSTOM2, "missing"), missingValues)) |
| | | .isFalse(); |
| | |
| | | @Test(dataProvider = "EntryFactory") |
| | | public void testContainsAttributeAttributeMissing(final EntryFactory factory) throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(emptyAttribute(AD_SN), missingValues)).isFalse(); |
| | | assertThat(missingValues).isEmpty(); |
| | | } |
| | |
| | | @Test(dataProvider = "EntryFactory") |
| | | public void testContainsAttributeAttributePresent1(final EntryFactory factory) throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(emptyAttribute(AD_CN), missingValues)).isTrue(); |
| | | assertThat(missingValues).isEmpty(); |
| | | } |
| | |
| | | @Test(dataProvider = "EntryFactory") |
| | | public void testContainsAttributeAttributePresent2(final EntryFactory factory) throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(emptyAttribute("cn"), missingValues)).isTrue(); |
| | | assertThat(missingValues).isEmpty(); |
| | | } |
| | |
| | | public void testContainsAttributeAttributeValueCustomMissing2(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat( |
| | | entry.containsAttribute(singletonAttribute(AD_CUSTOM1, "missing"), missingValues)) |
| | | .isFalse(); |
| | |
| | | public void testContainsAttributeAttributeValueCustomPresent(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat( |
| | | entry.containsAttribute(singletonAttribute(AD_CUSTOM1, "custom1"), missingValues)) |
| | | .isTrue(); |
| | |
| | | public void testContainsAttributeAttributeValueMissing1(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(singletonAttribute(AD_SN, "missing"), missingValues)) |
| | | .isFalse(); |
| | | assertThat(missingValues).hasSize(1); |
| | |
| | | public void testContainsAttributeAttributeValueMissing2(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(singletonAttribute(AD_CN, "missing"), missingValues)) |
| | | .isFalse(); |
| | | assertThat(missingValues).hasSize(1); |
| | |
| | | public void testContainsAttributeAttributeValuePresent(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.containsAttribute(singletonAttribute(AD_CN, "test"), missingValues)) |
| | | .isTrue(); |
| | | assertThat(missingValues).isEmpty(); |
| | |
| | | @Test(dataProvider = "EntryFactory") |
| | | public void testRemoveAttributeAttributeMissing(final EntryFactory factory) throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.removeAttribute(emptyAttribute(AD_SN), missingValues)).isFalse(); |
| | | assertThat(missingValues).isEmpty(); |
| | | } |
| | |
| | | @Test(dataProvider = "EntryFactory") |
| | | public void testRemoveAttributeAttributePresent(final EntryFactory factory) throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.removeAttribute(emptyAttribute(AD_CN), missingValues)).isTrue(); |
| | | assertThat(entry.getAttribute(AD_CN)).isNull(); |
| | | assertThat(missingValues).isEmpty(); |
| | |
| | | public void testRemoveAttributeAttributeValueMissing1(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.removeAttribute(singletonAttribute(AD_CN, "missing"), missingValues)) |
| | | .isFalse(); |
| | | assertThat(entry.getAttribute(AD_CN)).isNotNull(); |
| | |
| | | public void testRemoveAttributeAttributeValueMissing2(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.removeAttribute(singletonAttribute(AD_SN, "missing"), missingValues)) |
| | | .isFalse(); |
| | | assertThat(missingValues).hasSize(1); |
| | |
| | | public void testRemoveAttributeAttributeValuePresent(final EntryFactory factory) |
| | | throws Exception { |
| | | final Entry entry = createTestEntry(factory); |
| | | final List<ByteString> missingValues = new LinkedList<ByteString>(); |
| | | final List<ByteString> missingValues = new LinkedList<>(); |
| | | assertThat(entry.removeAttribute(singletonAttribute(AD_CN, "test"), missingValues)) |
| | | .isTrue(); |
| | | assertThat(entry.getAttribute(AD_CN)).isNull(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2012 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | Filter.lessOrEqual("dob", ByteString.valueOf("\\test*(Value)")); |
| | | final Filter presense = Filter.present("login"); |
| | | |
| | | final ArrayList<ByteString> any = new ArrayList<ByteString>(0); |
| | | final ArrayList<ByteString> multiAny = new ArrayList<ByteString>(1); |
| | | final ArrayList<ByteString> any = new ArrayList<>(0); |
| | | final ArrayList<ByteString> multiAny = new ArrayList<>(1); |
| | | multiAny.add(ByteString.valueOf("\\wid*(get)")); |
| | | multiAny.add(ByteString.valueOf("*")); |
| | | |
| | |
| | | Filter.extensible("2.4.6.8.19", null, ByteString |
| | | .valueOf("\\John* (Doe)"), false); |
| | | |
| | | final ArrayList<Filter> list1 = new ArrayList<Filter>(); |
| | | final ArrayList<Filter> list1 = new ArrayList<>(); |
| | | list1.add(equal); |
| | | list1.add(approx); |
| | | |
| | | final Filter and = Filter.and(list1); |
| | | |
| | | final ArrayList<Filter> list2 = new ArrayList<Filter>(); |
| | | final ArrayList<Filter> list2 = new ArrayList<>(); |
| | | list2.add(substring1); |
| | | list2.add(extensible1); |
| | | list2.add(and); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | } |
| | | |
| | | private void mockConnectionWithInitialHeartbeatResult(final ResultCode initialHeartBeatResult) { |
| | | listeners = new LinkedList<ConnectionEventListener>(); |
| | | listeners = new LinkedList<>(); |
| | | connection = mockConnection(listeners); |
| | | when(connection.isValid()).thenReturn(true); |
| | | mockHeartBeatResponse(connection, listeners, initialHeartBeatResult); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | |
| | | |
| | | if (saslServer == null |
| | | || !saslServer.getMechanismName().equalsIgnoreCase(saslMech)) { |
| | | final Map<String, String> props = new HashMap<String, String>(); |
| | | final Map<String, String> props = new HashMap<>(); |
| | | props.put(Sasl.QOP, "auth-conf,auth-int,auth"); |
| | | saslServer = |
| | | Sasl.createSaslServer(saslMech, "ldap", |
| | |
| | | } |
| | | |
| | | /** The mapping between entry DNs and the corresponding entries. */ |
| | | private final ConcurrentHashMap<DN, Entry> entryMap = new ConcurrentHashMap<DN, Entry>(); |
| | | private final ConcurrentHashMap<DN, Entry> entryMap = new ConcurrentHashMap<>(); |
| | | /** The LDAP listener. */ |
| | | private LDAPListener listener; |
| | | /** Whether the server is running. */ |
| | |
| | | * The mapping between the message id and the requests the server is |
| | | * currently handling. |
| | | */ |
| | | private final ConcurrentHashMap<Integer, AbandonableRequest> requestsInProgress = |
| | | new ConcurrentHashMap<Integer, AbandonableRequest>(); |
| | | private final ConcurrentHashMap<Integer, AbandonableRequest> requestsInProgress = new ConcurrentHashMap<>(); |
| | | |
| | | private SSLContext sslContext; |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | @Test |
| | | public void testSearchSubtreeReturnsAllEntries() throws Exception { |
| | | final Connection connection = getConnection(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<>(); |
| | | connection.search(Requests.newSearchRequest("dc=com", SearchScope.WHOLE_SUBTREE, "(objectclass=*)"), entries); |
| | | assertThat(entries).hasSize(numberOfEntriesInBackend); |
| | | } |
| | |
| | | @Test |
| | | public void testSearchSubordinatesReturnsAllEntries() throws Exception { |
| | | final Connection connection = getConnection(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<>(); |
| | | connection.search(Requests.newSearchRequest("dc=com", SearchScope.SUBORDINATES, "(objectclass=*)"), entries); |
| | | assertThat(entries).hasSize(numberOfEntriesInBackend - 1); |
| | | } |
| | |
| | | public void testSearchSubordinatesEntries() throws Exception { |
| | | int numberOfUsers = 5; |
| | | final Connection connection = getConnection(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<>(); |
| | | connection.search(Requests.newSearchRequest("ou=People,dc=example,dc=com", SearchScope.SUBORDINATES, |
| | | "(objectclass=*)"), entries); |
| | | assertThat(entries).hasSize(numberOfUsers); |
| | |
| | | @Test |
| | | public void testSearchSubtreeWithSizeLimit() throws Exception { |
| | | final Connection connection = getConnection(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<>(); |
| | | try { |
| | | connection.search( |
| | | Requests.newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=*)"). |
| | |
| | | @Test |
| | | public void testSearchPagedResults() throws Exception { |
| | | final Connection connection = getConnection(); |
| | | final List<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | final List<SearchResultEntry> entries = new ArrayList<>(); |
| | | final SearchRequest search = |
| | | Requests.newSearchRequest("ou=people,dc=example,dc=com", SearchScope.WHOLE_SUBTREE, |
| | | "(uid=*)"); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | } |
| | | |
| | | /** Saved scheduled tasks. */ |
| | | private final List<Callable<?>> tasks = new CopyOnWriteArrayList<Callable<?>>(); |
| | | private final List<Callable<?>> tasks = new CopyOnWriteArrayList<>(); |
| | | |
| | | MockScheduler() { |
| | | // Nothing to do. |
| | |
| | | } |
| | | |
| | | private <T> ScheduledCallableFuture<T> onceOnly(final Callable<T> callable) { |
| | | final ScheduledCallableFuture<T> wrapped = new ScheduledCallableFuture<T>(callable, true); |
| | | final ScheduledCallableFuture<T> wrapped = new ScheduledCallableFuture<>(callable, true); |
| | | tasks.add(wrapped); |
| | | return wrapped; |
| | | } |
| | | |
| | | private <T> ScheduledCallableFuture<T> repeated(final Callable<T> callable) { |
| | | final ScheduledCallableFuture<T> wrapped = new ScheduledCallableFuture<T>(callable, false); |
| | | final ScheduledCallableFuture<T> wrapped = new ScheduledCallableFuture<>(callable, false); |
| | | tasks.add(wrapped); |
| | | return wrapped; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | */ |
| | | @Test |
| | | public final void testGetExtraProperty() throws Exception { |
| | | final List<String> values = new ArrayList<String>(); |
| | | final List<String> values = new ArrayList<>(); |
| | | values.add("one"); |
| | | values.add("two"); |
| | | final Map<String, List<String>> props = Collections.singletonMap("test", values); |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2014 ForgeRock AS |
| | | * Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | Assertions.assertThat(indexer.getIndexID()).isEqualTo("substring"); |
| | | |
| | | final IndexingOptions options = newIndexingOptions(); |
| | | final TreeSet<ByteString> keys = new TreeSet<ByteString>(); |
| | | final TreeSet<ByteString> keys = new TreeSet<>(); |
| | | indexer.createKeys(Schema.getCoreSchema(), valueOf("ABCDE"), options, keys); |
| | | Assertions.assertThat(keys).containsOnly((Object[]) toByteStrings("ABC", "BCD", "CDE", "DE", "E")); |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | private void assertConformsToSchema(final Entry entry, final Schema schema, |
| | | final SchemaValidationPolicy policy) { |
| | | final List<LocalizableMessage> errorMessages = new LinkedList<LocalizableMessage>(); |
| | | final List<LocalizableMessage> errorMessages = new LinkedList<>(); |
| | | assertThat(schema.validateEntry(entry, policy, errorMessages)).as(errorMessages.toString()) |
| | | .isTrue(); |
| | | } |
| | |
| | | |
| | | private void assertDoesNotConformToSchema(final Entry entry, final Schema schema, |
| | | final SchemaValidationPolicy policy) { |
| | | final List<LocalizableMessage> errorMessages = new LinkedList<LocalizableMessage>(); |
| | | final List<LocalizableMessage> errorMessages = new LinkedList<>(); |
| | | assertThat(schema.validateEntry(entry, policy, errorMessages)).as(errorMessages.toString()) |
| | | .isFalse(); |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | */ |
| | | @Test |
| | | public final void testCreatesMatchingRulesUsingChainingMethods() { |
| | | final Map<String, List<String>> extraProperties = new TreeMap<String, List<String>>(); |
| | | final List<String> extra = new ArrayList<String>(); |
| | | final Map<String, List<String>> extraProperties = new TreeMap<>(); |
| | | final List<String> extra = new ArrayList<>(); |
| | | extra.add("Custom"); |
| | | extraProperties.put("X-ORIGIN", extra); |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | |
| | | */ |
| | | @Test |
| | | public final void testCreatesANewFormUsingChainingMethods() { |
| | | final Map<String, List<String>> extraProperties = new TreeMap<String, List<String>>(); |
| | | final List<String> extra = new ArrayList<String>(); |
| | | final Map<String, List<String>> extraProperties = new TreeMap<>(); |
| | | final List<String> extra = new ArrayList<>(); |
| | | extra.add("EntrySchemaCheckingTestCase"); |
| | | extraProperties.put("X-ORIGIN", extra); |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | // Get the instance of the rule to be tested. |
| | | final MatchingRule rule = getRule(); |
| | | |
| | | final List<ByteSequence> anyList = new ArrayList<ByteSequence>(anys.length); |
| | | final List<ByteSequence> anyList = new ArrayList<>(anys.length); |
| | | for (final String middleSub : anys) { |
| | | anyList.add(ByteString.valueOf(middleSub)); |
| | | } |
| | |
| | | final ByteString normalizedValue = rule.normalizeAttributeValue(ByteString.valueOf(value)); |
| | | |
| | | final StringBuilder printableMiddleSubs = new StringBuilder(); |
| | | final List<ByteSequence> middleList = new ArrayList<ByteSequence>(middleSubs.length); |
| | | final List<ByteSequence> middleList = new ArrayList<>(middleSubs.length); |
| | | printableMiddleSubs.append("*"); |
| | | for (final String middleSub : middleSubs) { |
| | | printableMiddleSubs.append(middleSub); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | |
| | | // Previous behaviour showed "missingVar" on line 5. |
| | | |
| | | TemplateFile templateFile = new TemplateFile(schema, null, resourcePath); |
| | | List<LocalizableMessage> warns = new ArrayList<LocalizableMessage>(); |
| | | List<LocalizableMessage> warns = new ArrayList<>(); |
| | | |
| | | try { |
| | | templateFile.parse(lines, warns); |
| | |
| | | @Test(dataProvider = "validTemplates") |
| | | public void testParsingEscapeCharInTemplate(String testName, String[] lines) throws Exception { |
| | | TemplateFile templateFile = new TemplateFile(schema, null, resourcePath); |
| | | List<LocalizableMessage> warns = new ArrayList<LocalizableMessage>(); |
| | | List<LocalizableMessage> warns = new ArrayList<>(); |
| | | templateFile.parse(lines, warns); |
| | | assertThat(warns).isEmpty(); |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2011 ForgeRock AS |
| | | * Copyright 2011-2015 ForgeRock AS |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | */ |
| | | |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesTrue() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesFalse() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesTrue() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesFalse() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetExcludeAttributeDoesntAllowNull() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | try { |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeBranchWrongDN() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final DN dn = DN.valueOf("dc=example.com"); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeBranchWithNoMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final DN dn = DN.valueOf("dc=example,dc=com"); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeBranchWithMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final DN dn = DN.valueOf("dc=example,dc=org"); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetExcludeBranchDoesntAllowNull() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | try { |
| | |
| | | @Test |
| | | public void testSetExcludeAttributeWithMatch() throws Exception { |
| | | final AttributeDescription attribute = AttributeDescription.valueOf("cn"); |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | @Test |
| | | public void testSetExcludeAttributeWithNoMatch() throws Exception { |
| | | final AttributeDescription attribute = AttributeDescription.valueOf("vip"); |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeAttributeWithMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeAttributeWithNoMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetIncludeAttributeDoesntAllowNull() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | try { |
| | | writer.setIncludeAttribute(null); |
| | |
| | | * If the test failed unexpectedly. |
| | | */ @Test |
| | | public void testSetIncludeBranchWithNoMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final DN dn = DN.valueOf("dc=example,dc=org"); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeBranchWithMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final DN dn = DN.valueOf("dc=example,dc=com"); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetIncludeBranchDoesntAllowNull() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | try { |
| | | writer.setIncludeBranch(null); |
| | |
| | | */ |
| | | @Test(enabled = false) |
| | | public void testSetAddUserFriendlyComments() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final CharSequence comment = "A simple comment"; |
| | |
| | | public void testWriteCommentUsingTheWrapFunction() throws Exception { |
| | | final CharSequence comment = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | int wrapColumn = 15; |
| | |
| | | public void testWriteCommentUsingTheWrapFunctionShortComment() throws Exception { |
| | | final CharSequence comment = "Lorem ipsum dolor"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | int wrapColumn = 30; |
| | |
| | | public void testWriteCommentUsingTheWrapFunctionNoEmptySpace() throws Exception { |
| | | final CharSequence comment = "Lorem ipsumdolorsitamet,consecteturadipisicingelit"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | int wrapColumn = 15; |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteChangeRecord() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteAddRequest() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final AddRequest changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteAddRequestNoBranchExcluded() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final DN dnAdd = DN.valueOf("uid=scarter,ou=People,dc=example,dc=com"); |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteAddRequestBranchExcluded() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | final DN dnAdd = DN.valueOf("uid=scarter,ou=People,dc=example,dc=com"); |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteAddRequestJpegAttributeOk() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | final File file = File.createTempFile("sdk", ".jpeg"); |
| | | final String url = file.toURI().toURL().toString(); |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteAddBinaryRequest() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteAddBinaryNonAsciiRequest() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteDeleteRequestBranchExcluded() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | // @formatter:off |
| | | final DeleteRequest changeRequest = (DeleteRequest) Requests.newChangeRecord( |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteDeleteRequestBranchNotExcluded() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | // @formatter:off |
| | | final DeleteRequest changeRequest = (DeleteRequest) Requests.newChangeRecord( |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteDeleteRequest() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteDeleteRequestContainingControl() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | final DN dn = DN.valueOf("uid=scarter,ou=People,dc=example,dc=com"); |
| | | |
| | |
| | | */ |
| | | @Test(expectedExceptions = LocalizedIllegalArgumentException.class) |
| | | public void testWriteDeleteRequestIllegalArguments() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModdnRequest() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModdnRequestNewSuperior() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | // @formatter:off |
| | | final ModifyDNRequest changeRequest = (ModifyDNRequest) Requests.newChangeRecord( |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModdnRequestDeleterdnFalse() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | // @formatter:off |
| | | final ModifyDNRequest changeRequest = (ModifyDNRequest) Requests.newChangeRecord( |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyRequest() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyRequestUsingControl() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyRequestNoModifications() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyRequestFilterAttributesExcluded() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyRequestBranchExcludedNoMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyRequestBranchExcludedMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyDNRequestBranchExcludedNoMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyDNRequestBranchExcludedMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteModifyDNRequest() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | // @formatter:off |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteMultipleChangeRecords() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | final ChangeRecord changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | | |
| | |
| | | "home-phone: 415/697-8899" |
| | | ); |
| | | // @formatter:on |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | writer.writeChangeRecord(changeRequest); |
| | | writer.close(); |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteComment() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | writer.writeComment("TLDIFChangeRecordWriter, this is a comment."); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetExcludeAttributeDoesntAllowNull() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | writer.setExcludeAttribute(null); |
| | |
| | | @Test |
| | | public void testSetExcludeAttributeWithMatch() throws Exception { |
| | | final AttributeDescription attribute = AttributeDescription.valueOf("cn"); |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | writer.setExcludeAttribute(attribute); |
| | |
| | | @Test |
| | | public void testSetExcludeAttributeWithNoMatch() throws Exception { |
| | | final AttributeDescription attribute = AttributeDescription.valueOf("vip"); |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | writer.setExcludeAttribute(attribute); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetExcludeBranchDoesntAllowNull() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | writer.setExcludeBranch(null); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeBranchWrongDN() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | DN dn = DN.valueOf("dc=example.com"); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeBranchWithNoMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | DN dn = DN.valueOf("dc=example,dc=com"); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeBranchWithMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | DN dn = DN.valueOf("dc=example,dc=org"); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testsetExcludeFilterDoesntAllowNull() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | writer.setExcludeFilter(null); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeFilterWithMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | final Filter filter = Filter.equality("objectclass", "vip"); |
| | | final Matcher excludeFilter = filter.matcher(); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeFilterWithNoMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | final Filter filter = Filter.equality("objectclass", "person"); |
| | | final Matcher excludeFilter = filter.matcher(); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetIncludeAttributeDoesntAllowNull() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | writer.setIncludeAttribute(null); |
| | | writer.close(); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeAttributeWithMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | writer.setIncludeAttribute(AttributeDescription.valueOf("cn")); |
| | | writer.setIncludeAttribute(AttributeDescription.valueOf("sn")); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeAttributeWithNoMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | writer.setIncludeAttribute(AttributeDescription.valueOf("manager")); |
| | | writer.writeEntry(getStandardEntry()); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeAttributeWithRepeatedAttributes() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | writer.setIncludeAttribute(AttributeDescription.valueOf("cn")); |
| | | writer.setIncludeAttribute(AttributeDescription.valueOf("sn")); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesFalse() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | int opAttributes = 0; |
| | | |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesTrue() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | writer.setExcludeAllOperationalAttributes(true); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesFalse() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | writer.setExcludeAllUserAttributes(false); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesTrue() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | writer.setExcludeAllUserAttributes(true); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetIncludeBranchDoesntAllowNull() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | writer.setIncludeBranch(null); |
| | | writer.close(); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeBranchWithMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | DN dn = DN.valueOf("dc=example,dc=com"); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeBranchWithNoMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | DN dn = DN.valueOf("dc=opendj,dc=org"); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeFilterWithNoMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | final Filter filter = Filter.equality("objectclass", "vip"); |
| | | final Matcher includeFilter = filter.matcher(); |
| | |
| | | */ |
| | | @Test |
| | | public void testSetIncludeFilterWithMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | final Filter filter = Filter.equality("objectclass", "person"); |
| | | final Matcher includeFilter = filter.matcher(); |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testSetIncludeFilterDoesntAllowNull() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | writer.setIncludeFilter(null); |
| | | writer.writeEntry(getStandardEntry()); |
| | |
| | | public void testWriteCommentUsingTheWrapFunction() throws Exception { |
| | | final CharSequence comment = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | int wrapColumn = 15; |
| | |
| | | public void testWriteCommentUsingTheWrapFunctionShortComment() throws Exception { |
| | | final CharSequence comment = "Lorem ipsum dolor"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | int wrapColumn = 30; |
| | |
| | | public void testWriteCommentUsingTheWrapFunctionNoEmptySpace() throws Exception { |
| | | final CharSequence comment = "Lorem ipsumdolorsitamet,consecteturadipisicingelit"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | int wrapColumn = 15; |
| | |
| | | final CharSequence comment1 = "This is a new comment"; |
| | | final CharSequence comment2 = "Another one"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | writer.writeComment(comment1); |
| | | writer.writeComment(comment2); |
| | |
| | | */ |
| | | @Test(enabled = false) |
| | | public void testSetAddUserFriendlyComments() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | final CharSequence comment = "A simple comment"; |
| | |
| | | */ |
| | | @Test |
| | | public void testWriteEntryUsingStandardEntry() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | final int wrapColumn = 15; |
| | | writer.setWrapColumn(wrapColumn); |
| | |
| | | entry.addAttribute("typeOnly"); |
| | | entry.addAttribute("localized;lang-fr", "\u00e7edilla"); |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | writer.writeEntry(entry); |
| | | writer.close(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | Entry e2 = new LinkedHashMapEntry("dn: uid=user.2,ou=People,dc=example,dc=com", "objectClass: person"); |
| | | // @formatter:on |
| | | |
| | | Collection<Entry> collection = new ArrayList<Entry>(); |
| | | Collection<Entry> collection = new ArrayList<>(); |
| | | collection.add(e); |
| | | collection.add(e1); |
| | | collection.add(e2); |
| | |
| | | ); |
| | | // @formatter:on |
| | | |
| | | final SortedMap<DN, Entry> sourceEntries = new TreeMap<DN, Entry>(); |
| | | final SortedMap<DN, Entry> sourceEntries = new TreeMap<>(); |
| | | sourceEntries.put(DN.valueOf("uid=user.0,ou=People,dc=example,dc=com"), e); |
| | | sourceEntries.put(DN.valueOf("uid=user.1,ou=People,dc=example,dc=com"), e1); |
| | | final Iterator<Entry> sourceIterator = sourceEntries.values().iterator(); |
| | |
| | | "changetype: delete" |
| | | ); |
| | | // @formatter:on |
| | | final java.util.List<String> actual = new ArrayList<String>(); |
| | | final java.util.List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | try { |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public final void testLdifCopyToChangeRecordDoesntAllowNullReader() throws Exception { |
| | | |
| | | final java.util.List<String> actual = new ArrayList<String>(); |
| | | final java.util.List<String> actual = new ArrayList<>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | | LDIF.copyTo(null, writer); |
| | |
| | | ); |
| | | // @formatter:on |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | try { |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public final void testLdifCopyToEntryWriterDoesntAllowNullReader() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final List<String> actual = new ArrayList<>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | |
| | | LDIF.copyTo(null, writer); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | |
| | | /** Helper method to build a template entry containing the provided values. */ |
| | | private TemplateEntry templateEntry(String... values) { |
| | | TemplateEntry templateEntry = mock(TemplateEntry.class); |
| | | List<TemplateValue> templateValues = new ArrayList<TemplateValue>(); |
| | | List<TemplateValue> templateValues = new ArrayList<>(); |
| | | for (String value : values) { |
| | | templateValues.add(templateValue(value)); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.grizzly; |
| | | |
| | |
| | | private final org.glassfish.grizzly.Connection<?> connection; |
| | | private final AtomicInteger nextMsgID = new AtomicInteger(1); |
| | | private final GrizzlyLDAPConnectionFactory factory; |
| | | private final ConcurrentHashMap<Integer, ResultLdapPromiseImpl<?, ?>> pendingRequests = |
| | | new ConcurrentHashMap<Integer, ResultLdapPromiseImpl<?, ?>>(); |
| | | private final ConcurrentHashMap<Integer, ResultLdapPromiseImpl<?, ?>> pendingRequests = new ConcurrentHashMap<>(); |
| | | private final Object stateLock = new Object(); |
| | | /** Guarded by stateLock. */ |
| | | private Result connectionInvalidReason; |
| | |
| | | notifyErrorOccurred = isFailed; |
| | | if (!isClosed) { |
| | | if (listeners == null) { |
| | | listeners = new CopyOnWriteArrayList<ConnectionEventListener>(); |
| | | listeners = new CopyOnWriteArrayList<>(); |
| | | } |
| | | listeners.add(listener); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.grizzly; |
| | |
| | | final ClientContextImpl clientContext = LDAP_CONNECTION_ATTR.get(connection); |
| | | if (clientContext != null) { |
| | | final ServerConnection<Integer> conn = clientContext.getServerConnection(); |
| | | final ExtendedHandler<R> handler = new ExtendedHandler<R>(clientContext, messageID); |
| | | final ExtendedHandler<R> handler = new ExtendedHandler<>(clientContext, messageID); |
| | | conn.handleExtendedRequest(messageID, request, handler, handler); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.grizzly; |
| | |
| | | @Test(dataProvider = "closeNotifyConfig") |
| | | public void testCloseNotify(final CloseNotify config) throws Exception { |
| | | final CountDownLatch connectLatch = new CountDownLatch(1); |
| | | final AtomicReference<LDAPClientContext> contextHolder = |
| | | new AtomicReference<LDAPClientContext>(); |
| | | final AtomicReference<LDAPClientContext> contextHolder = new AtomicReference<>(); |
| | | |
| | | final ServerConnectionFactory<LDAPClientContext, Integer> mockServer = |
| | | mock(ServerConnectionFactory.class); |
| | |
| | | @Test |
| | | public void testUnsolicitedNotifications() throws Exception { |
| | | final CountDownLatch connectLatch = new CountDownLatch(1); |
| | | final AtomicReference<LDAPClientContext> contextHolder = |
| | | new AtomicReference<LDAPClientContext>(); |
| | | final AtomicReference<LDAPClientContext> contextHolder = new AtomicReference<>(); |
| | | |
| | | final ServerConnectionFactory<LDAPClientContext, Integer> mockServer = |
| | | mock(ServerConnectionFactory.class); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.grizzly; |
| | | |
| | |
| | | private final Semaphore closeLatch = new Semaphore(0); |
| | | private final Semaphore connectLatch = new Semaphore(0); |
| | | private final Semaphore searchLatch = new Semaphore(0); |
| | | private final AtomicReference<LDAPClientContext> context = |
| | | new AtomicReference<LDAPClientContext>(); |
| | | private final AtomicReference<LDAPClientContext> context = new AtomicReference<>(); |
| | | private final LDAPListener server = createServer(); |
| | | private final InetSocketAddress socketAddress = server.getSocketAddress(); |
| | | private final ConnectionFactory factory = new LDAPConnectionFactory(socketAddress.getHostName(), |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.examples; |
| | |
| | | |
| | | // Create load balancer. |
| | | // --- JCite pools --- |
| | | final List<ConnectionFactory> factories = new LinkedList<ConnectionFactory>(); |
| | | final List<ConnectionFactory> bindFactories = new LinkedList<ConnectionFactory>(); |
| | | final List<ConnectionFactory> factories = new LinkedList<>(); |
| | | final List<ConnectionFactory> bindFactories = new LinkedList<>(); |
| | | for (int i = 4; i < args.length; i += 2) { |
| | | final String remoteAddress = args[i]; |
| | | final int remotePort = Integer.parseInt(args[i + 1]); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.examples; |
| | |
| | | @Override |
| | | public void handleAdd(final RequestContext requestContext, final AddRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final ResultHandler<Result> resultHandler) { |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | addProxiedAuthControl(request); |
| | | |
| | | factory.getConnectionAsync().thenAsync(new AsyncFunction<Connection, Result, LdapException>() { |
| | |
| | | } else { |
| | | // Authenticate using a separate bind connection pool, because |
| | | // we don't want to change the state of the pooled connection. |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | proxiedAuthControl = null; |
| | | bindFactory.getConnectionAsync() |
| | | .thenAsync(new AsyncFunction<Connection, BindResult, LdapException>() { |
| | |
| | | final ResultHandler<CompareResult> resultHandler) { |
| | | addProxiedAuthControl(request); |
| | | |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | factory.getConnectionAsync().thenAsync(new AsyncFunction<Connection, CompareResult, LdapException>() { |
| | | @Override |
| | | public Promise<CompareResult, LdapException> apply(Connection connection) throws LdapException { |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, final ResultHandler<Result> resultHandler) { |
| | | addProxiedAuthControl(request); |
| | | |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | factory.getConnectionAsync().thenAsync(new AsyncFunction<Connection, Result, LdapException>() { |
| | | @Override |
| | | public Promise<Result, LdapException> apply(Connection connection) throws LdapException { |
| | |
| | | // Forward all other extended operations. |
| | | addProxiedAuthControl(request); |
| | | |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | factory.getConnectionAsync().thenAsync(new AsyncFunction<Connection, R, LdapException>() { |
| | | @Override |
| | | public Promise<R, LdapException> apply(Connection connection) throws LdapException { |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, final ResultHandler<Result> resultHandler) { |
| | | addProxiedAuthControl(request); |
| | | |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | factory.getConnectionAsync().thenAsync(new AsyncFunction<Connection, Result, LdapException>() { |
| | | @Override |
| | | public Promise<Result, LdapException> apply(Connection connection) throws LdapException { |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, final ResultHandler<Result> resultHandler) { |
| | | addProxiedAuthControl(request); |
| | | |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | factory.getConnectionAsync().thenAsync(new AsyncFunction<Connection, Result, LdapException>() { |
| | | @Override |
| | | public Promise<Result, LdapException> apply(Connection connection) throws LdapException { |
| | |
| | | final ResultHandler<Result> resultHandler) { |
| | | addProxiedAuthControl(request); |
| | | |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | factory.getConnectionAsync().thenAsync(new AsyncFunction<Connection, Result, LdapException>() { |
| | | @Override |
| | | public Promise<Result, LdapException> apply(Connection connection) throws LdapException { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.examples; |
| | |
| | | |
| | | private SearchResultEntry rewrite(final SearchResultEntry entry) { |
| | | // Replace server attributes with client attributes. |
| | | final Set<Attribute> attrsToAdd = new HashSet<Attribute>(); |
| | | final Set<AttributeDescription> attrsToRemove = new HashSet<AttributeDescription>(); |
| | | final Set<Attribute> attrsToAdd = new HashSet<>(); |
| | | final Set<AttributeDescription> attrsToRemove = new HashSet<>(); |
| | | |
| | | for (final Attribute a : entry.getAllAttributes(serverAttributeDescription)) { |
| | | final AttributeDescription ad = a.getAttributeDescription(); |
| | |
| | | } |
| | | } |
| | | |
| | | private final ConcurrentSkipListMap<Long, String> dnEntriesAdded = new ConcurrentSkipListMap<Long, String>(); |
| | | private final ConcurrentSkipListMap<Long, String> dnEntriesAdded = new ConcurrentSkipListMap<>(); |
| | | private final ThreadLocal<Random> randomSeq = new ThreadLocal<Random>() { |
| | | @Override |
| | | protected Random initialValue() { |
| | |
| | | |
| | | /* addrate specifics arguments */ |
| | | deleteMode = |
| | | new MultiChoiceArgument<DeleteStrategy>("deletemode", 'C', "deleteMode", false, true, |
| | | new MultiChoiceArgument<>("deletemode", 'C', "deleteMode", false, true, |
| | | INFO_DELETEMODE_PLACEHOLDER.get(), Arrays.asList(DeleteStrategy.values()), false, |
| | | INFO_ADDRATE_DESCRIPTION_DELETEMODE.get()); |
| | | deleteMode.setDefaultValue(DeleteStrategy.FIFO.toString()); |
| | |
| | | argParser.addArgument(searchScope); |
| | | |
| | | dereferencePolicy = |
| | | new MultiChoiceArgument<DereferenceAliasesPolicy>("derefpolicy", 'a', |
| | | new MultiChoiceArgument<>("derefpolicy", 'a', |
| | | "dereferencePolicy", false, true, INFO_DEREFERENCE_POLICE_PLACEHOLDER |
| | | .get(), DereferenceAliasesPolicy.values(), false, |
| | | INFO_SEARCH_DESCRIPTION_DEREFERENCE_POLICY.get()); |
| | |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | | |
| | | final List<String> attributes = new LinkedList<String>(); |
| | | final List<String> attributes = new LinkedList<>(); |
| | | final ArrayList<String> filterAndAttributeStrings = argParser.getTrailingArguments(); |
| | | if (filterAndAttributeStrings.size() > 0) { |
| | | /*The list of trailing arguments should be structured as follow: |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | * Portions copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap.tools; |
| | |
| | | private int next; |
| | | |
| | | public IncrementLineFileDataSource(final String file) throws IOException { |
| | | lines = new ArrayList<String>(); |
| | | lines = new ArrayList<>(); |
| | | final BufferedReader in = new BufferedReader(new FileReader(file)); |
| | | try { |
| | | String line; |
| | |
| | | private final Random random; |
| | | |
| | | public RandomLineFileDataSource(final long seed, final String file) throws IOException { |
| | | lines = new ArrayList<String>(); |
| | | lines = new ArrayList<>(); |
| | | random = new Random(seed); |
| | | final BufferedReader in = new BufferedReader(new FileReader(file)); |
| | | try { |
| | |
| | | |
| | | private RandomStringDataSource(final int seed, final int length, final String charSet) { |
| | | this.length = length; |
| | | final Set<Character> chars = new HashSet<Character>(); |
| | | final Set<Character> chars = new HashSet<>(); |
| | | for (int i = 0; i < charSet.length(); i++) { |
| | | final char c = charSet.charAt(i); |
| | | if (c == '[') { |
| | |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | | |
| | | final ArrayList<String> dnStrings = new ArrayList<String>(); |
| | | final ArrayList<String> dnStrings = new ArrayList<>(); |
| | | final ArrayList<String> attrAndDNStrings = argParser.getTrailingArguments(); |
| | | |
| | | if (attrAndDNStrings.isEmpty()) { |
| | |
| | | // modifyOptions.setEncoding(encodingStr.getValue()); |
| | | // modifyOptions.setDefaultAdd(defaultAdd.isPresent()); |
| | | |
| | | controls = new LinkedList<Control>(); |
| | | controls = new LinkedList<>(); |
| | | if (controlStr.isPresent()) { |
| | | for (final String ctrlString : controlStr.getValues()) { |
| | | try { |
| | |
| | | if (preReadAttributes.isPresent()) { |
| | | final String valueStr = preReadAttributes.getValue(); |
| | | final StringTokenizer tokenizer = new StringTokenizer(valueStr, ", "); |
| | | final List<String> attributes = new LinkedList<String>(); |
| | | final List<String> attributes = new LinkedList<>(); |
| | | while (tokenizer.hasMoreTokens()) { |
| | | attributes.add(tokenizer.nextToken()); |
| | | } |
| | |
| | | if (postReadAttributes.isPresent()) { |
| | | final String valueStr = postReadAttributes.getValue(); |
| | | final StringTokenizer tokenizer = new StringTokenizer(valueStr, ", "); |
| | | final List<String> attributes = new LinkedList<String>(); |
| | | final List<String> attributes = new LinkedList<>(); |
| | | while (tokenizer.hasMoreTokens()) { |
| | | attributes.add(tokenizer.nextToken()); |
| | | } |
| | |
| | | argParser.addArgument(encodingStr); |
| | | |
| | | dereferencePolicy = |
| | | new MultiChoiceArgument<DereferenceAliasesPolicy>("derefpolicy", 'a', |
| | | new MultiChoiceArgument<>("derefpolicy", 'a', |
| | | "dereferencePolicy", false, true, INFO_DEREFERENCE_POLICE_PLACEHOLDER |
| | | .get(), DereferenceAliasesPolicy.values(), false, |
| | | INFO_SEARCH_DESCRIPTION_DEREFERENCE_POLICY.get()); |
| | |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | | |
| | | final List<Filter> filters = new LinkedList<Filter>(); |
| | | final List<String> attributes = new LinkedList<String>(); |
| | | final List<Filter> filters = new LinkedList<>(); |
| | | final List<String> attributes = new LinkedList<>(); |
| | | final ArrayList<String> filterAndAttributeStrings = argParser.getTrailingArguments(); |
| | | if (filterAndAttributeStrings.size() > 0) { |
| | | /* The list of trailing arguments should be structured as follow: |
| | |
| | | } |
| | | } |
| | | |
| | | final ArrayList<PersistentSearchChangeType> ct = |
| | | new ArrayList<PersistentSearchChangeType>(4); |
| | | final ArrayList<PersistentSearchChangeType> ct = new ArrayList<>(4); |
| | | if (tokenizer.hasMoreTokens()) { |
| | | final StringTokenizer st = new StringTokenizer(tokenizer.nextToken(), ", "); |
| | | if (!st.hasMoreTokens()) { |
| | |
| | | |
| | | if (matchedValuesFilter.isPresent()) { |
| | | final LinkedList<String> mvFilterStrings = matchedValuesFilter.getValues(); |
| | | final List<Filter> mvFilters = new ArrayList<Filter>(); |
| | | final List<Filter> mvFilters = new ArrayList<>(); |
| | | for (final String s : mvFilterStrings) { |
| | | try { |
| | | final Filter f = Filter.valueOf(s); |
| | |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | | |
| | | final List<Filter> filters = new LinkedList<Filter>(); |
| | | final List<String> attributes = new LinkedList<String>(); |
| | | final List<Filter> filters = new LinkedList<>(); |
| | | final List<String> attributes = new LinkedList<>(); |
| | | final List<String> trailingArguments = argParser.getTrailingArguments(); |
| | | if (trailingArguments.size() > 1) { |
| | | final List<String> filterAndAttributeStrings = |
| | |
| | | data = DataSource.generateData(dataSources, data); |
| | | } |
| | | mr = newModifyRequest(data); |
| | | ResultHandler<Result> modRes = new UpdateStatsResultHandler<Result>(startTime); |
| | | ResultHandler<Result> modRes = new UpdateStatsResultHandler<>(startTime); |
| | | |
| | | incrementIterationCount(); |
| | | return connection.modifyAsync(mr).onSuccess(modRes).onFailure(modRes); |
| | |
| | | * Keys (Long in microseconds) of this map must respect this pattern: n * 500 000 + 5 000 000, |
| | | * where n is a natural integer. |
| | | */ |
| | | private final ConcurrentSkipListMap<Long, AtomicLong> bigEtimes = new ConcurrentSkipListMap<Long, AtomicLong>(); |
| | | private final ConcurrentSkipListMap<Long, AtomicLong> bigEtimes = new ConcurrentSkipListMap<>(); |
| | | |
| | | /** |
| | | * Initialize both index2Frequency and index2Etime arrays. |
| | |
| | | * percentiles. |
| | | */ |
| | | List<Long> getPercentile(double[] percentiles, long nbData) { |
| | | List<Long> responseTimes = new ArrayList<Long>(); |
| | | Queue<Long> nbDataThresholds = new LinkedList<Long>(); |
| | | List<Long> responseTimes = new ArrayList<>(); |
| | | Queue<Long> nbDataThresholds = new LinkedList<>(); |
| | | long nbDataSum = nbData; |
| | | |
| | | for (int i = percentiles.length - 1; i >= 0; i--) { |
| | |
| | | protected final IntegerArgument maxIterationsArgument; |
| | | protected final IntegerArgument warmUpArgument; |
| | | |
| | | private final List<Thread> workerThreads = new ArrayList<Thread>(); |
| | | private final List<Thread> workerThreads = new ArrayList<>(); |
| | | |
| | | PerformanceRunner(final PerformanceRunnerOptions options) throws ArgumentException { |
| | | ArgumentParser argParser = options.getArgumentParser(); |
| | |
| | | } |
| | | |
| | | final int run(final ConnectionFactory connectionFactory) { |
| | | final List<Connection> connections = new ArrayList<Connection>(); |
| | | final List<Connection> connections = new ArrayList<>(); |
| | | |
| | | Connection connection = null; |
| | | try { |
| | |
| | | argParser.addArgument(searchScope); |
| | | |
| | | dereferencePolicy = |
| | | new MultiChoiceArgument<DereferenceAliasesPolicy>("derefpolicy", 'a', |
| | | new MultiChoiceArgument<>("derefpolicy", 'a', |
| | | "dereferencePolicy", false, true, INFO_DEREFERENCE_POLICE_PLACEHOLDER |
| | | .get(), DereferenceAliasesPolicy.values(), false, |
| | | INFO_SEARCH_DESCRIPTION_DEREFERENCE_POLICY.get()); |
| | |
| | | return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); |
| | | } |
| | | |
| | | final List<String> attributes = new LinkedList<String>(); |
| | | final List<String> attributes = new LinkedList<>(); |
| | | final ArrayList<String> filterAndAttributeStrings = argParser.getTrailingArguments(); |
| | | if (filterAndAttributeStrings.size() > 0) { |
| | | /* The list of trailing arguments should be structured as follow: |
| | |
| | | new File(outputFilePath).getParentFile().mkdirs(); |
| | | |
| | | // Get a sorted list of the files in the schema directory. |
| | | TreeSet<String> schemaFileNames = new TreeSet<String>(); |
| | | TreeSet<String> schemaFileNames = new TreeSet<>(); |
| | | for (File f : new File(schemaDirectory).listFiles()) { |
| | | if (f.isFile()) { |
| | | schemaFileNames.add(f.getName()); |
| | | } |
| | | } |
| | | |
| | | // Create a set of lists that will hold the schema elements read from the |
| | | // files. |
| | | LinkedList<String> attributeTypes = new LinkedList<String>(); |
| | | LinkedList<String> objectClasses = new LinkedList<String>(); |
| | | LinkedList<String> nameForms = new LinkedList<String>(); |
| | | LinkedList<String> ditContentRules = new LinkedList<String>(); |
| | | LinkedList<String> ditStructureRules = new LinkedList<String>(); |
| | | LinkedList<String> matchingRuleUses = new LinkedList<String>(); |
| | | LinkedList<String> ldapSyntaxes = new LinkedList<String>(); |
| | | // Create a set of lists that will hold the schema elements read from the files. |
| | | LinkedList<String> attributeTypes = new LinkedList<>(); |
| | | LinkedList<String> objectClasses = new LinkedList<>(); |
| | | LinkedList<String> nameForms = new LinkedList<>(); |
| | | LinkedList<String> ditContentRules = new LinkedList<>(); |
| | | LinkedList<String> ditStructureRules = new LinkedList<>(); |
| | | LinkedList<String> matchingRuleUses = new LinkedList<>(); |
| | | LinkedList<String> ldapSyntaxes = new LinkedList<>(); |
| | | int curLineNumber = 0; |
| | | |
| | | // Open each of the files in order and read the elements that they contain, |
| | |
| | | for (String name : schemaFileNames) { |
| | | // Read the contents of the file into a list with one schema element per |
| | | // list element. |
| | | LinkedList<StringBuilder> lines = new LinkedList<StringBuilder>(); |
| | | LinkedList<StringBuilder> lines = new LinkedList<>(); |
| | | try { |
| | | BufferedReader reader = new BufferedReader(new FileReader(new File(schemaDirectory, name))); |
| | | String line = reader.readLine(); |
| | |
| | | @Parameter(required = true, defaultValue = "true") |
| | | private Boolean isExtension; |
| | | |
| | | private final Map<String, StreamSourceFactory> componentDescriptors = |
| | | new LinkedHashMap<String, StreamSourceFactory>(); |
| | | private final Map<String, StreamSourceFactory> componentDescriptors = new LinkedHashMap<>(); |
| | | private TransformerFactory stylesheetFactory; |
| | | private Templates stylesheetMetaJava; |
| | | private Templates stylesheetServerJava; |
| | |
| | | private Templates stylesheetProfileCLI; |
| | | private Templates stylesheetMessages; |
| | | private Templates stylesheetManifest; |
| | | private final Queue<Future<?>> tasks = new LinkedList<Future<?>>(); |
| | | private final Queue<Future<?>> tasks = new LinkedList<>(); |
| | | |
| | | private final URIResolver resolver = new URIResolver() { |
| | | |
| | |
| | | } |
| | | |
| | | // Generate package-info.java files. |
| | | final Map<String, Templates> profileMap = new LinkedHashMap<String, Templates>(); |
| | | final Map<String, Templates> profileMap = new LinkedHashMap<>(); |
| | | profileMap.put("meta", stylesheetMetaPackageInfo); |
| | | profileMap.put("server", stylesheetServerPackageInfo); |
| | | profileMap.put("client", stylesheetClientPackageInfo); |
| | |
| | | } |
| | | |
| | | private List<String> getClasspathItems() throws DependencyResolutionRequiredException { |
| | | final List<String> classpathItems = new ArrayList<String>(); |
| | | final List<String> classpathItems = new ArrayList<>(); |
| | | |
| | | // add project dependencies |
| | | for (String artifactFile : project.getRuntimeClasspathElements()) { |
| | |
| | | * servlet if needed. However, make sure that it is closed on |
| | | * completion. |
| | | */ |
| | | final AtomicReference<Connection> savedConnection = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> savedConnection = new AtomicReference<>(); |
| | | final ServletSynchronizer sync = syncFactory.createServletSynchronizer(req, res); |
| | | |
| | | sync.addAsyncListener(new Runnable() { |
| | |
| | | switch (authenticationMethod) { |
| | | case SIMPLE: { |
| | | final Map<String, Object> authzid; |
| | | authzid = new LinkedHashMap<String, Object>(2); |
| | | authzid = new LinkedHashMap<>(2); |
| | | authzid.put(AUTHZID_DN, username); |
| | | authzid.put(AUTHZID_ID, username); |
| | | doBind(req, res, newSimpleBindRequest(username, password), chain, savedConnection, sync, username, |
| | |
| | | if (saslAuthzIdTemplate.startsWith("dn:")) { |
| | | final String bindDN = DN.format(saslAuthzIdTemplate.substring(3), schema, username).toString(); |
| | | bindId = "dn:" + bindDN; |
| | | authzid = new LinkedHashMap<String, Object>(2); |
| | | authzid = new LinkedHashMap<>(2); |
| | | authzid.put(AUTHZID_DN, bindDN); |
| | | authzid.put(AUTHZID_ID, username); |
| | | } else { |
| | |
| | | public void handleResult(final SearchResultEntry result) { |
| | | savedConnection.get().close(); |
| | | final String bindDN = result.getName().toString(); |
| | | final Map<String, Object> authzid = new LinkedHashMap<String, Object>(2); |
| | | final Map<String, Object> authzid = new LinkedHashMap<>(2); |
| | | authzid.put(AUTHZID_DN, bindDN); |
| | | authzid.put(AUTHZID_ID, username); |
| | | doBind(req, res, newSimpleBindRequest(bindDN, password), chain, savedConnection, sync, |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.util.promise.Function; |
| | | import org.forgerock.util.promise.NeverThrowsException; |
| | | |
| | | /** |
| | | * An abstract LDAP attribute mapper which provides a simple mapping from a JSON |
| | | * value to a single LDAP attribute. |
| | |
| | | * delete(x) followed by add(x) is idempotent when |
| | | * adding/removing the same value. |
| | | */ |
| | | modifications = new ArrayList<Modification>(2); |
| | | modifications = new ArrayList<>(2); |
| | | |
| | | final Attribute deletedValues = new LinkedAttribute(oldLDAPAttribute); |
| | | deletedValues.removeAll(newLDAPAttribute); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | | import static org.forgerock.opendj.rest2ldap.Utils.i18n; |
| | |
| | | |
| | | private final String dnFormatString; |
| | | private final String formatString; |
| | | private final List<String> keys = new ArrayList<String>(); |
| | | private final List<String> keys = new ArrayList<>(); |
| | | private final Impl pimpl; |
| | | private final String template; |
| | | |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | private final CountDownLatch cachedPromiseLatch = new CountDownLatch(1); |
| | | private final SearchRequest cachedRequest; |
| | | private volatile Result cachedResult; |
| | | private final ConcurrentLinkedQueue<SearchResultHandler> waitingResultHandlers = |
| | | new ConcurrentLinkedQueue<SearchResultHandler>(); |
| | | private final ConcurrentLinkedQueue<SearchResultHandler> waitingResultHandlers = new ConcurrentLinkedQueue<>(); |
| | | |
| | | CachedRead(final SearchRequest request, final SearchResultHandler resultHandler) { |
| | | this.cachedRequest = request; |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2012-2014 ForgeRock AS. |
| | | * Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | public void handleResult(final DN dn) { |
| | | // Convert the patch operations to LDAP modifications. |
| | | List<Promise<List<Modification>, ResourceException>> promises = |
| | | new ArrayList<Promise<List<Modification>, ResourceException>>( |
| | | request.getPatchOperations().size()); |
| | | new ArrayList<>(request.getPatchOperations().size()); |
| | | for (final PatchOperation operation : request.getPatchOperations()) { |
| | | final ResultHandlerFromPromise<List<Modification>> handler = |
| | | new ResultHandlerFromPromise<List<Modification>>(); |
| | | final ResultHandlerFromPromise<List<Modification>> handler = new ResultHandlerFromPromise<>(); |
| | | attributeMapper.patch(c, new JsonPointer(), operation, handler); |
| | | promises.add(handler.promise); |
| | | } |
| | |
| | | final Set<String> requestedLDAPAttributes; |
| | | if (requestedAttributes.isEmpty()) { |
| | | // Full read. |
| | | requestedLDAPAttributes = new LinkedHashSet<String>(); |
| | | requestedLDAPAttributes = new LinkedHashSet<>(); |
| | | attributeMapper.getLDAPAttributes(c, new JsonPointer(), new JsonPointer(), |
| | | requestedLDAPAttributes); |
| | | } else { |
| | | // Partial read. |
| | | requestedLDAPAttributes = new LinkedHashSet<String>(requestedAttributes.size()); |
| | | requestedLDAPAttributes = new LinkedHashSet<>(requestedAttributes.size()); |
| | | for (final JsonPointer requestedAttribute : requestedAttributes) { |
| | | attributeMapper.getLDAPAttributes(c, new JsonPointer(), requestedAttribute, |
| | | requestedLDAPAttributes); |
| | |
| | | new QueryFilterVisitor<Void, ResultHandler<Filter>>() { |
| | | @Override |
| | | public Void visitAndFilter(final ResultHandler<Filter> p, final List<QueryFilter> subFilters) { |
| | | List<Promise<Filter, ResourceException>> promises = |
| | | new ArrayList<Promise<Filter, ResourceException>>(subFilters.size()); |
| | | List<Promise<Filter, ResourceException>> promises = new ArrayList<>(subFilters.size()); |
| | | for (final QueryFilter subFilter : subFilters) { |
| | | final ResultHandlerFromPromise<Filter> handler = new ResultHandlerFromPromise<Filter>(); |
| | | final ResultHandlerFromPromise<Filter> handler = new ResultHandlerFromPromise<>(); |
| | | subFilter.accept(this, handler); |
| | | promises.add(handler.promise); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public Void visitOrFilter(final ResultHandler<Filter> p, final List<QueryFilter> subFilters) { |
| | | List<Promise<Filter, ResourceException>> promises = |
| | | new ArrayList<Promise<Filter, ResourceException>>(subFilters.size()); |
| | | List<Promise<Filter, ResourceException>> promises = new ArrayList<>(subFilters.size()); |
| | | for (final QueryFilter subFilter : subFilters) { |
| | | final ResultHandlerFromPromise<Filter> handler = new ResultHandlerFromPromise<Filter>(); |
| | | final ResultHandlerFromPromise<Filter> handler = new ResultHandlerFromPromise<>(); |
| | | subFilter.accept(this, handler); |
| | | promises.add(handler.promise); |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2012-2014 ForgeRock AS. |
| | | * Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private final Map<String, Mapping> mappings = new LinkedHashMap<String, Mapping>(); |
| | | private final Map<String, Mapping> mappings = new LinkedHashMap<>(); |
| | | |
| | | ObjectAttributeMapper() { |
| | | // Nothing to do. |
| | |
| | | */ |
| | | return null; |
| | | } else { |
| | | /* |
| | | * Combine the sub-attributes into a single |
| | | * JSON object. |
| | | */ |
| | | final Map<String, Object> result = |
| | | new LinkedHashMap<String, Object>(value.size()); |
| | | // Combine the sub-attributes into a single JSON object. |
| | | final Map<String, Object> result = new LinkedHashMap<>(value.size()); |
| | | for (final Map.Entry<String, JsonValue> e : value) { |
| | | result.put(e.getKey(), e.getValue().getObject()); |
| | | } |
| | |
| | | case 1: |
| | | return value.get(0); |
| | | default: |
| | | final List<T> attributes = new ArrayList<T>(value.size()); |
| | | final List<T> attributes = new ArrayList<>(value.size()); |
| | | for (final List<T> a : value) { |
| | | attributes.addAll(a); |
| | | } |
| | |
| | | */ |
| | | private Map<String, Mapping> checkMapping(final JsonPointer path, final JsonValue v) |
| | | throws ResourceException { |
| | | final Map<String, Mapping> missingMappings = new LinkedHashMap<String, Mapping>(mappings); |
| | | final Map<String, Mapping> missingMappings = new LinkedHashMap<>(mappings); |
| | | if (v != null && !v.isNull()) { |
| | | if (v.isMap()) { |
| | | for (final String attribute : v.asMap().keySet()) { |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2012-2014 ForgeRock AS. |
| | | * Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | public void handleResult(final Filter result) { |
| | | // Search for all referenced entries and construct a filter. |
| | | final SearchRequest request = createSearchRequest(result); |
| | | final List<Filter> subFilters = new LinkedList<Filter>(); |
| | | final List<Filter> subFilters = new LinkedList<>(); |
| | | |
| | | final FailureHandler<LdapException> failureHandler = new FailureHandler<LdapException>() { |
| | | @Override |
| | |
| | | final ResultHandler<Attribute> h) { |
| | | /* |
| | | * For each value use the subordinate mapper to obtain the LDAP primary |
| | | * key, the perform a search for each one to find the corresponding |
| | | * entries. |
| | | * key, the perform a search for each one to find the corresponding entries. |
| | | */ |
| | | final Attribute newLDAPAttribute = new LinkedAttribute(ldapAttributeName); |
| | | final AtomicInteger pendingSearches = new AtomicInteger(newValues.size()); |
| | | final AtomicReference<ResourceException> exception = new AtomicReference<ResourceException>(); |
| | | final AtomicReference<ResourceException> exception = new AtomicReference<>(); |
| | | |
| | | for (final Object value : newValues) { |
| | | mapper.create(c, path, new JsonValue(value), new ResultHandler<List<Attribute>>() { |
| | |
| | | return null; |
| | | } else { |
| | | // Combine values into a single JSON array. |
| | | final List<Object> result = new ArrayList<Object>(value.size()); |
| | | final List<Object> result = new ArrayList<>(value.size()); |
| | | for (final JsonValue e : value) { |
| | | result.add(e.getObject()); |
| | | } |
| | |
| | | |
| | | private void readEntry(final Context c, final JsonPointer path, final DN dn, |
| | | final ResultHandler<JsonValue> handler) { |
| | | final Set<String> requestedLDAPAttributes = new LinkedHashSet<String>(); |
| | | final Set<String> requestedLDAPAttributes = new LinkedHashSet<>(); |
| | | mapper.getLDAPAttributes(c, path, new JsonPointer(), requestedLDAPAttributes); |
| | | c.getConnection().readEntryAsync(dn, requestedLDAPAttributes) |
| | | .onSuccess(new SuccessHandler<SearchResultEntry>() { |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | | import static org.forgerock.opendj.ldap.requests.Requests.newSearchRequest; |
| | |
| | | * A builder for incrementally constructing LDAP resource collections. |
| | | */ |
| | | public static final class Builder { |
| | | private final List<Attribute> additionalLDAPAttributes = new LinkedList<Attribute>(); |
| | | private final List<Attribute> additionalLDAPAttributes = new LinkedList<>(); |
| | | private AuthorizationPolicy authzPolicy = AuthorizationPolicy.NONE; |
| | | private DN baseDN; // TODO: support template variables. |
| | | private AttributeDescription etagAttribute; |
| | |
| | | final JsonValue parent = |
| | | normalizeConnectionFactory(configuration, |
| | | current.get("inheritFrom").asString(), depth + 1); |
| | | final Map<String, Object> normalized = |
| | | new LinkedHashMap<String, Object>(parent.asMap()); |
| | | final Map<String, Object> normalized = new LinkedHashMap<>(parent.asMap()); |
| | | normalized.putAll(current.asMap()); |
| | | normalized.remove("inheritFrom"); |
| | | return new JsonValue(normalized); |
| | |
| | | final BindRequest bindRequest, final int connectionPoolSize, |
| | | final int heartBeatIntervalSeconds, final int heartBeatTimeoutMilliSeconds, |
| | | final LDAPOptions options) { |
| | | final List<ConnectionFactory> servers = new ArrayList<ConnectionFactory>(config.size()); |
| | | final List<ConnectionFactory> servers = new ArrayList<>(config.size()); |
| | | for (final JsonValue server : config) { |
| | | final String host = server.get("hostname").required().asString(); |
| | | final int port = server.get("port").required().asInteger(); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2012-2014 ForgeRock AS. |
| | | * Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | throw new IllegalStateException(); |
| | | } |
| | | this.latch = new AtomicInteger(size); |
| | | this.results = new ArrayList<V>(size); |
| | | this.results = new ArrayList<>(size); |
| | | this.handler = handler; |
| | | if (size == 0) { |
| | | // Invoke immediately. |
| | |
| | | * {@code size} asynchronous operations. |
| | | */ |
| | | static <V> ResultHandler<V> accumulate(final int size, final ResultHandler<List<V>> handler) { |
| | | return new AccumulatingResultHandler<V>(size, handler); |
| | | return new AccumulatingResultHandler<>(size, handler); |
| | | } |
| | | |
| | | static Object attributeToJson(final Attribute a) { |
| | |
| | | private static <T> List<T> asList(final Collection<T> c) { |
| | | if (c instanceof List) { |
| | | return (List<T>) c; |
| | | } else { |
| | | return new ArrayList<T>(c); |
| | | } |
| | | return new ArrayList<>(c); |
| | | } |
| | | |
| | | /** Prevent instantiation. */ |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | } |
| | | |
| | | private Map<String, Object> map(String... keyValues) { |
| | | Map<String, Object> map = new LinkedHashMap<String, Object>(); |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | for (int i = 0; i < keyValues.length; i += 2) { |
| | | map.put(keyValues[i], keyValues[i + 1]); |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | @Test |
| | | public void testQueryAll() throws Exception { |
| | | final Connection connection = newConnection(); |
| | | final List<Resource> resources = new LinkedList<Resource>(); |
| | | final List<Resource> resources = new LinkedList<>(); |
| | | final QueryResult result = |
| | | connection.query(ctx(), Requests.newQueryRequest("").setQueryFilter( |
| | | QueryFilter.alwaysTrue()), resources); |
| | |
| | | @Test |
| | | public void testQueryNone() throws Exception { |
| | | final Connection connection = newConnection(); |
| | | final List<Resource> resources = new LinkedList<Resource>(); |
| | | final List<Resource> resources = new LinkedList<>(); |
| | | final QueryResult result = |
| | | connection.query(ctx(), Requests.newQueryRequest("").setQueryFilter( |
| | | QueryFilter.alwaysFalse()), resources); |
| | |
| | | @Test |
| | | public void testQueryPageResultsCookie() throws Exception { |
| | | final Connection connection = newConnection(); |
| | | final List<Resource> resources = new ArrayList<Resource>(); |
| | | final List<Resource> resources = new ArrayList<>(); |
| | | |
| | | // Read first page. |
| | | QueryResult result = |
| | |
| | | @Test |
| | | public void testQueryPageResultsIndexed() throws Exception { |
| | | final Connection connection = newConnection(); |
| | | final List<Resource> resources = new ArrayList<Resource>(); |
| | | final List<Resource> resources = new ArrayList<>(); |
| | | QueryResult result = |
| | | connection.query(ctx(), newQueryRequest("") |
| | | .setQueryFilter(QueryFilter.alwaysTrue()).setPageSize(2) |
| | |
| | | |
| | | @Test |
| | | public void testPatchEmpty() throws Exception { |
| | | final List<Request> requests = new LinkedList<Request>(); |
| | | final List<Request> requests = new LinkedList<>(); |
| | | final Connection connection = newConnection(requests); |
| | | final Resource resource1 = connection.patch(ctx(), newPatchRequest("/test1")); |
| | | checkResourcesAreEqual(resource1, getTestUser1(12345)); |
| | |
| | | |
| | | @Test |
| | | public void testUpdateNoChange() throws Exception { |
| | | final List<Request> requests = new LinkedList<Request>(); |
| | | final List<Request> requests = new LinkedList<>(); |
| | | final Connection connection = newConnection(requests); |
| | | final Resource resource1 = |
| | | connection.update(ctx(), newUpdateRequest("/test1", getTestUser1(12345))); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013 ForgeRock Inc. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | * @return The list of parsed JSON pointers. |
| | | */ |
| | | public static List<JsonPointer> filter(final String... fields) { |
| | | final List<JsonPointer> result = new ArrayList<JsonPointer>(fields.length); |
| | | final List<JsonPointer> result = new ArrayList<>(fields.length); |
| | | for (final String field : fields) { |
| | | result.add(new JsonPointer(field)); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.server.core; |
| | | |
| | |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(AbstractDataProvider.class); |
| | | |
| | | /** The list of event listeners associated with this data provider. */ |
| | | private final List<DataProviderEventListener> eventListeners = |
| | | new CopyOnWriteArrayList<DataProviderEventListener>(); |
| | | private final List<DataProviderEventListener> eventListeners = new CopyOnWriteArrayList<>(); |
| | | |
| | | /** |
| | | * Creates a new abstract data provider. |
| | | */ |
| | | /** Creates a new abstract data provider. */ |
| | | protected AbstractDataProvider() { |
| | | // No implementation required. |
| | | } |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.server.setup.cli; |
| | | |
| | |
| | | |
| | | // Verifying provided informations. |
| | | try { |
| | | final LinkedHashSet<LocalizableMessage> errorMessages = new LinkedHashSet<LocalizableMessage>(); |
| | | final LinkedHashSet<LocalizableMessage> errorMessages = new LinkedHashSet<>(); |
| | | checkServerPassword(errorMessages); |
| | | checkProvidedPorts(errorMessages); |
| | | checkImportDataArguments(errorMessages); |
| | |
| | | showUsage = addGlobal(CommonArguments.getShowUsage()); |
| | | |
| | | //Sub-commands && their arguments |
| | | final ArrayList<SubCommand> subCommandList = new ArrayList<SubCommand>(2); |
| | | final ArrayList<SubCommand> subCommandList = new ArrayList<>(2); |
| | | createDirectoryServer = new SubCommand(argParser, "create-directory-server", |
| | | INFO_SETUP_SUBCOMMAND_CREATE_DIRECTORY_SERVER.get()); |
| | | // TODO to complete. |
| | |
| | | * execution of the checking. |
| | | */ |
| | | private void checkProvidedPorts(final Collection<LocalizableMessage> errorMessages) { |
| | | /* |
| | | * Check that the provided ports do not match. |
| | | */ |
| | | // Check that the provided ports do not match. |
| | | try { |
| | | final Set<Integer> ports = new HashSet<Integer>(); |
| | | final Set<Integer> ports = new HashSet<>(); |
| | | ports.add(ldapPort.getIntValue()); |
| | | |
| | | checkPortArgument(adminConnectorPort, ports, errorMessages); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.server.setup.model; |
| | |
| | | static final String OBFUSCATED_VALUE = "******"; |
| | | |
| | | ArrayList<String> getSetupEquivalentCommandLine(final Model configuration) { |
| | | final ArrayList<String> cmdLines = new ArrayList<String>(); |
| | | final ArrayList<String> cmdLines = new ArrayList<>(); |
| | | final ListenerSettings settings = configuration.getListenerSettings(); |
| | | |
| | | // Starts the server ? |
| | |
| | | /** The overall SVN Client Manager. */ |
| | | private final SVNClientManager svnClientManager = SVNClientManager.newInstance(); |
| | | |
| | | private final List<String> errorFilePaths = new LinkedList<String>(); |
| | | private final List<String> errorFilePaths = new LinkedList<>(); |
| | | |
| | | /** {@inheritDoc} **/ |
| | | public void execute() throws MojoExecutionException, MojoFailureException { |