Remove all {@inheritDoc} javadoc tags (superseded by @Override annotations)
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | this.priority = priority; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final ArgumentGroup o) { |
| | | // Groups with higher priority numbers appear before |
| | |
| | | * @return boolean where true means this group contains members |
| | | */ |
| | | boolean containsArguments() { |
| | | return this.args.size() > 0; |
| | | return !args.isEmpty(); |
| | | } |
| | | |
| | | /** |
| | |
| | | this.description = description; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return getClass().getSimpleName() + "(description=" + description + ")"; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | * a single space. |
| | | */ |
| | | public final class TabSeparatedTablePrinter extends TablePrinter { |
| | | |
| | | /** |
| | | * Table serializer implementation. |
| | | */ |
| | | /** Table serializer implementation. */ |
| | | private final class Serializer extends TableSerializer { |
| | | /** |
| | | * Counts the number of separators that should be output the next time a non-empty cell is displayed. The tab |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addCell(String s) { |
| | | // Avoid printing tab separators for trailing empty cells. |
| | |
| | | writer.print(s.replaceAll("[\\t\\n\\r]", " ")); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addHeading(String s) { |
| | | if (displayHeadings) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void endHeader() { |
| | | if (displayHeadings) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void endRow() { |
| | | writer.println(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void endTable() { |
| | | writer.flush(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void startHeader() { |
| | | requiredSeparators = 0; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void startRow() { |
| | | requiredSeparators = 0; |
| | |
| | | this.displayHeadings = displayHeadings; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected TableSerializer getSerializer() { |
| | | return new Serializer(); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | * Tables have configurable column widths, padding, and column separators. |
| | | */ |
| | | public final class TextTablePrinter extends TablePrinter { |
| | | |
| | | /** |
| | | * Table serializer implementation. |
| | | */ |
| | | /** Table serializer implementation. */ |
| | | private final class Serializer extends TableSerializer { |
| | | |
| | | /**The real column widths taking into account size constraints but |
| | | not including padding or separators.*/ |
| | | private final List<Integer> columnWidths = new ArrayList<>(); |
| | |
| | | this.indentPadding = builder.toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addCell(String s) { |
| | | currentRow.add(s); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addColumn(int width) { |
| | | columnWidths.add(width); |
| | | totalColumns++; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addHeading(String s) { |
| | | if (displayHeadings) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void endHeader() { |
| | | if (displayHeadings) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void endRow() { |
| | | boolean isRemainingText; |
| | |
| | | endIndex = width; |
| | | head = contents.substring(0, endIndex); |
| | | tail = contents.substring(endIndex); |
| | | |
| | | } else { |
| | | head = contents.substring(0, endIndex); |
| | | tail = contents.substring(endIndex + 1); |
| | |
| | | |
| | | // Output the line. |
| | | writer.println(builder.toString()); |
| | | |
| | | } while (isRemainingText); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void endTable() { |
| | | writer.flush(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void startHeader() { |
| | | determineColumnWidths(); |
| | | currentRow.clear(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void startRow() { |
| | | currentRow.clear(); |
| | |
| | | /** The number of characters the table should be indented. */ |
| | | private int indentWidth; |
| | | |
| | | /** |
| | | * The character which should be used to separate the table |
| | | * heading row from the rows beneath. |
| | | */ |
| | | /** The character which should be used to separate the table heading row from the rows beneath. */ |
| | | private char headingSeparator = DEFAULT_HEADING_SEPARATOR; |
| | | |
| | | /** The column where the heading separator should begin. */ |
| | |
| | | */ |
| | | private int padding = DEFAULT_PADDING; |
| | | |
| | | /** |
| | | * Total permitted width for the table which expandable columns |
| | | * can use up. |
| | | */ |
| | | /** Total permitted width for the table which expandable columns can use up. */ |
| | | private int totalWidth = MAX_LINE_WIDTH; |
| | | |
| | | /** The output destination. */ |
| | |
| | | this.totalWidth = totalWidth; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected TableSerializer getSerializer() { |
| | | return new Serializer(); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | import static org.testng.Assert.assertFalse; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | /** |
| | | * Unit tests for the console application class. |
| | | */ |
| | | /** Unit tests for the console application class. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class ConsoleApplicationTestCase extends CliTestCase { |
| | | |
| | | final LocalizableMessage msg = LocalizableMessage.raw("Language is the source of misunderstandings."); |
| | | final LocalizableMessage msg2 = LocalizableMessage |
| | | .raw("If somebody wants a sheep, that is a proof that one exists."); |
| | | |
| | | /** |
| | | * For test purposes only. |
| | | */ |
| | | /** For test purposes only. */ |
| | | private static class MockConsoleApplication extends ConsoleApplication { |
| | | private static ByteArrayOutputStream out; |
| | | private static ByteArrayOutputStream err; |
| | |
| | | return err.toString("UTF-8"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isVerbose() { |
| | | return verbose; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isInteractive() { |
| | | return interactive; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isQuiet() { |
| | | return quiet; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap.extensions; |
| | | |
| | | import java.io.IOException; |
| | |
| | | return connectionID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return GetConnectionIDExtendedRequest.OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(6); |
| | |
| | | return buffer.toByteString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return true; |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | import org.forgerock.opendj.ldap.responses.ExtendedResultDecoder; |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | |
| | | /** |
| | | * Get symmetric key extended request. |
| | | */ |
| | | /** Get symmetric key extended request. */ |
| | | public final class GetSymmetricKeyExtendedRequest extends |
| | | AbstractExtendedRequest<GetSymmetricKeyExtendedRequest, ExtendedResult> { |
| | | private static final class RequestDecoder implements |
| | | ExtendedRequestDecoder<GetSymmetricKeyExtendedRequest, ExtendedResult> { |
| | | |
| | | @Override |
| | | public GetSymmetricKeyExtendedRequest decodeExtendedRequest( |
| | | final ExtendedRequest<?> request, final DecodeOptions options) |
| | |
| | | } |
| | | |
| | | private static final class ResultDecoder extends AbstractExtendedResultDecoder<ExtendedResult> { |
| | | |
| | | @Override |
| | | public ExtendedResult newExtendedErrorResult(final ResultCode resultCode, |
| | | final String matchedDN, final String diagnosticMessage) { |
| | |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The request OID for the get symmetric key extended operation. |
| | | */ |
| | | /** The request OID for the get symmetric key extended operation. */ |
| | | public static final String OID = "1.3.6.1.4.1.26027.1.6.3"; |
| | | |
| | | /** |
| | | * The BER type value for the symmetric key element of the operation value. |
| | | */ |
| | | /** The BER type value for the symmetric key element of the operation value. */ |
| | | private static final byte TYPE_SYMMETRIC_KEY_ELEMENT = (byte) 0x80; |
| | | |
| | | /** |
| | | * The BER type value for the instance key ID element of the operation |
| | | * value. |
| | | */ |
| | | /** The BER type value for the instance key ID element of the operation value. */ |
| | | private static final byte TYPE_INSTANCE_KEY_ID_ELEMENT = (byte) 0x81; |
| | | |
| | | /** |
| | | * A decoder which can be used to decode get symmetric key extended |
| | | * operation requests. |
| | | */ |
| | | /** A decoder which can be used to decode get symmetric key extended operation requests. */ |
| | | public static final RequestDecoder REQUEST_DECODER = new RequestDecoder(); |
| | | |
| | | /** No need to expose this. */ |
| | | private static final ResultDecoder RESULT_DECODER = new ResultDecoder(); |
| | | |
| | |
| | | return instanceKeyID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return OID; |
| | |
| | | return requestSymmetricKey; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ExtendedResultDecoder<ExtendedResult> getResultDecoder() { |
| | | return RESULT_DECODER; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | |
| | | return buffer.toByteString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return true; |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap.extensions; |
| | | |
| | | import java.io.IOException; |
| | |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return property + ": " + values; |
| | |
| | | private static final class RequestDecoder |
| | | implements |
| | | ExtendedRequestDecoder<PasswordPolicyStateExtendedRequest, PasswordPolicyStateExtendedResult> { |
| | | |
| | | @Override |
| | | public PasswordPolicyStateExtendedRequest decodeExtendedRequest( |
| | | final ExtendedRequest<?> request, final DecodeOptions options) |
| | |
| | | |
| | | private static final class ResultDecoder extends |
| | | AbstractExtendedResultDecoder<PasswordPolicyStateExtendedResult> { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PasswordPolicyStateExtendedResult newExtendedErrorResult( |
| | | final ResultCode resultCode, final String matchedDN, final String diagnosticMessage) { |
| | |
| | | "Seconds Until Required Change Time"; |
| | | static final String PASSWORD_HISTORY_NAME = "Password History"; |
| | | |
| | | /** |
| | | * A decoder which can be used to decode password policy state extended |
| | | * operation requests. |
| | | */ |
| | | /** A decoder which can be used to decode password policy state extended operation requests. */ |
| | | public static final RequestDecoder REQUEST_DECODER = new RequestDecoder(); |
| | | |
| | | /** No need to expose this. */ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Creates a new password policy state extended request. |
| | | */ |
| | | /** Creates a new password policy state extended request. */ |
| | | public PasswordPolicyStateExtendedRequest() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | setDateProperty(ADD_GRACE_LOGIN_USE_TIME, date); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addOperation(final PasswordPolicyStateOperation operation) { |
| | | operations.add(operation); |
| | | } |
| | | |
| | | /** |
| | | * Clears the account disabled state. |
| | | */ |
| | | /** Clears the account disabled state. */ |
| | | public void clearAccountDisabledState() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_ACCOUNT_DISABLED_STATE); |
| | | } |
| | | |
| | | /** |
| | | * Clears the account expiration time. |
| | | */ |
| | | /** Clears the account expiration time. */ |
| | | public void clearAccountExpirationTime() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_ACCOUNT_EXPIRATION_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Clears the authentication failure times. |
| | | */ |
| | | /** Clears the authentication failure times. */ |
| | | public void clearAuthenticationFailureTimes() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_AUTHENTICATION_FAILURE_TIMES); |
| | | } |
| | | |
| | | /** |
| | | * Clears the grace login use times. |
| | | */ |
| | | /** Clears the grace login use times. */ |
| | | public void clearGraceLoginUseTimes() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_GRACE_LOGIN_USE_TIMES); |
| | | } |
| | | |
| | | /** |
| | | * Clears the last login time. |
| | | */ |
| | | /** Clears the last login time. */ |
| | | public void clearLastLoginTime() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_LAST_LOGIN_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Clears the password changed by required time. |
| | | */ |
| | | /** Clears the password changed by required time. */ |
| | | public void clearPasswordChangedByRequiredTime() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_CHANGED_BY_REQUIRED_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Clears the password changed time. |
| | | */ |
| | | /** Clears the password changed time. */ |
| | | public void clearPasswordChangedTime() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_CHANGED_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Clears the password expiration warned time. |
| | | */ |
| | | /** Clears the password expiration warned time. */ |
| | | public void clearPasswordExpirationWarnedTime() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_EXPIRATION_WARNED_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Clears the password history. |
| | | */ |
| | | /** Clears the password history. */ |
| | | public void clearPasswordHistory() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_HISTORY); |
| | | } |
| | | |
| | | /** |
| | | * Clears the password reset state. |
| | | */ |
| | | /** Clears the password reset state. */ |
| | | public void clearPasswordResetState() { |
| | | operations.add(PasswordPolicyStateOperationType.CLEAR_PASSWORD_RESET_STATE); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Iterable<PasswordPolicyStateOperation> getOperations() { |
| | | return operations; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ExtendedResultDecoder<PasswordPolicyStateExtendedResult> getResultDecoder() { |
| | | return RESULT_DECODER; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getTargetUser() { |
| | | return targetUser; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | return encode(targetUser, operations); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * Returns the account disabled state. |
| | | */ |
| | | /** Returns the account disabled state. */ |
| | | public void requestAccountDisabledState() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_ACCOUNT_DISABLED_STATE); |
| | | } |
| | | |
| | | /** |
| | | * Returns the account expiration time. |
| | | */ |
| | | /** Returns the account expiration time. */ |
| | | public void requestAccountExpirationTime() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_ACCOUNT_EXPIRATION_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Returns the authentication failure times. |
| | | */ |
| | | /** Returns the authentication failure times. */ |
| | | public void requestAuthenticationFailureTimes() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_AUTHENTICATION_FAILURE_TIMES); |
| | | } |
| | | |
| | | /** |
| | | * Returns the grace login use times. |
| | | */ |
| | | /** Returns the grace login use times. */ |
| | | public void requestGraceLoginUseTimes() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_GRACE_LOGIN_USE_TIMES); |
| | | } |
| | | |
| | | /** |
| | | * Returns the last login time. |
| | | */ |
| | | /** Returns the last login time. */ |
| | | public void requestLastLoginTime() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_LAST_LOGIN_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Returns the password changed by required time. |
| | | */ |
| | | /** Returns the password changed by required time. */ |
| | | public void requestPasswordChangedByRequiredTime() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_CHANGED_BY_REQUIRED_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Returns the password changed time. |
| | | */ |
| | | /** Returns the password changed time. */ |
| | | public void requestPasswordChangedTime() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_CHANGED_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Returns the password expiration warned time. |
| | | */ |
| | | /** Returns the password expiration warned time. */ |
| | | public void requestPasswordExpirationWarnedTime() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_EXPIRATION_WARNED_TIME); |
| | | } |
| | | |
| | | /** |
| | | * Returns the password history. |
| | | */ |
| | | /** Returns the password history. */ |
| | | public void requestPasswordHistory() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_HISTORY); |
| | | } |
| | | |
| | | /** |
| | | * Returns the password policy DN. |
| | | */ |
| | | /** Returns the password policy DN. */ |
| | | public void requestPasswordPolicyDN() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_POLICY_DN); |
| | | } |
| | | |
| | | /** |
| | | * Returns the password reset state. |
| | | */ |
| | | /** Returns the password reset state. */ |
| | | public void requestPasswordResetState() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_PASSWORD_RESET_STATE); |
| | | } |
| | | |
| | | /** |
| | | * Returns the remaining authentication failure count. |
| | | */ |
| | | /** Returns the remaining authentication failure count. */ |
| | | public void requestRemainingAuthenticationFailureCount() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_REMAINING_AUTHENTICATION_FAILURE_COUNT); |
| | | } |
| | | |
| | | /** |
| | | * Returns the remaining grace login count. |
| | | */ |
| | | /** Returns the remaining grace login count. */ |
| | | public void requestRemainingGraceLoginCount() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_REMAINING_GRACE_LOGIN_COUNT); |
| | | } |
| | | |
| | | /** |
| | | * Returns the seconds until account expiration. |
| | | */ |
| | | /** Returns the seconds until account expiration. */ |
| | | public void requestSecondsUntilAccountExpiration() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_ACCOUNT_EXPIRATION); |
| | | } |
| | | |
| | | /** |
| | | * Returns the seconds until authentication failure unlock. |
| | | */ |
| | | /** Returns the seconds until authentication failure unlock. */ |
| | | public void requestSecondsUntilAuthenticationFailureUnlock() { |
| | | operations |
| | | .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_AUTHENTICATION_FAILURE_UNLOCK); |
| | | } |
| | | |
| | | /** |
| | | * Returns the seconds until idle lockout. |
| | | */ |
| | | /** Returns the seconds until idle lockout. */ |
| | | public void requestSecondsUntilIdleLockout() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_IDLE_LOCKOUT); |
| | | } |
| | | |
| | | /** |
| | | * Returns the seconds until password expiration. |
| | | */ |
| | | /** Returns the seconds until password expiration. */ |
| | | public void requestSecondsUntilPasswordExpiration() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_PASSWORD_EXPIRATION); |
| | | } |
| | | |
| | | /** |
| | | * Returns the seconds until password expiration warning. |
| | | */ |
| | | /** Returns the seconds until password expiration warning. */ |
| | | public void requestSecondsUntilPasswordExpirationWarning() { |
| | | operations |
| | | .add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_PASSWORD_EXPIRATION_WARNING); |
| | | } |
| | | |
| | | /** |
| | | * Returns the seconds until password reset lockout. |
| | | */ |
| | | /** Returns the seconds until password reset lockout. */ |
| | | public void requestSecondsUntilPasswordResetLockout() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_PASSWORD_RESET_LOCKOUT); |
| | | } |
| | | |
| | | /** |
| | | * Returns the seconds until required change time. |
| | | */ |
| | | /** Returns the seconds until required change time. */ |
| | | public void requestSecondsUntilRequiredChangeTime() { |
| | | operations.add(PasswordPolicyStateOperationType.GET_SECONDS_UNTIL_REQUIRED_CHANGE_TIME); |
| | | } |
| | |
| | | return ByteString.valueOfUtf8(formatAsGeneralizedTime(date)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setTargetUser(String targetUser) { |
| | | this.targetUser = targetUser != null ? targetUser : ""; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.util; |
| | | |
| | |
| | | import org.forgerock.util.Function; |
| | | import org.forgerock.util.promise.NeverThrowsException; |
| | | |
| | | /** |
| | | * Additional {@code Collection} based utility methods. |
| | | */ |
| | | /** Additional {@code Collection} based utility methods. */ |
| | | public final class Collections2 { |
| | | private static class TransformedCollection<M, N, C extends Collection<M>> extends |
| | | AbstractCollection<N> implements Collection<N> { |
| | | |
| | | protected final C collection; |
| | | |
| | | protected final Function<? super M, ? extends N, NeverThrowsException> funcMtoN; |
| | |
| | | this.funcNtoM = funcNtoM; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean add(final N e) { |
| | | return collection.add(funcNtoM.apply(e)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void clear() { |
| | | collection.clear(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @SuppressWarnings("unchecked") |
| | | public boolean contains(final Object o) { |
| | | return collection.contains(funcNtoM.apply((N) o)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isEmpty() { |
| | | return collection.isEmpty(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Iterator<N> iterator() { |
| | | return Iterators.transformedIterator(collection.iterator(), funcMtoN); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @SuppressWarnings("unchecked") |
| | | public boolean remove(final Object o) { |
| | | return collection.remove(funcNtoM.apply((N) o)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int size() { |
| | | return collection.size(); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static final class TransformedList<M, N> extends |
| | | TransformedCollection<M, N, List<M>> implements List<N> { |
| | | |
| | | private TransformedList(final List<M> list, |
| | | final Function<? super M, ? extends N, NeverThrowsException> funcMtoN, |
| | | final Function<? super N, ? extends M, NeverThrowsException> funcNtoM) { |
| | | super(list, funcMtoN, funcNtoM); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void add(final int index, final N element) { |
| | | collection.add(index, funcNtoM.apply(element)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean addAll(final int index, final Collection<? extends N> c) { |
| | | // We cannot transform c here due to type-safety. |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public N get(final int index) { |
| | | return funcMtoN.apply(collection.get(index)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @SuppressWarnings("unchecked") |
| | | public int indexOf(final Object o) { |
| | | return collection.indexOf(funcNtoM.apply((N) o)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @SuppressWarnings("unchecked") |
| | | public int lastIndexOf(final Object o) { |
| | | return collection.lastIndexOf(funcNtoM.apply((N) o)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ListIterator<N> listIterator() { |
| | | return listIterator(0); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ListIterator<N> listIterator(final int index) { |
| | | final ListIterator<M> iterator = collection.listIterator(index); |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public N remove(final int index) { |
| | | return funcMtoN.apply(collection.remove(index)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public N set(final int index, final N element) { |
| | | final M result = collection.set(index, funcNtoM.apply(element)); |
| | | return funcMtoN.apply(result); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public List<N> subList(final int fromIndex, final int toIndex) { |
| | | final List<M> subList = collection.subList(fromIndex, toIndex); |
| | | return new TransformedList<>(subList, funcMtoN, funcNtoM); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | private Collections2() { |
| | | // Do nothing. |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.util; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | |
| | | /** |
| | | * An implementation of input stream that enforces an read size limit. |
| | | */ |
| | | /** An implementation of input stream that enforces an read size limit. */ |
| | | public class SizeLimitInputStream extends InputStream { |
| | | private int bytesRead; |
| | | private int markBytesRead; |
| | |
| | | this.readLimit = readLimit; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int available() throws IOException { |
| | | final int streamAvail = parentStream.available(); |
| | |
| | | return limitedAvail < streamAvail ? limitedAvail : streamAvail; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | parentStream.close(); |
| | |
| | | return readLimit; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public synchronized void mark(final int readlimit) { |
| | | parentStream.mark(readlimit); |
| | | markBytesRead = bytesRead; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean markSupported() { |
| | | return parentStream.markSupported(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int read() throws IOException { |
| | | if (bytesRead >= readLimit) { |
| | |
| | | return b; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int read(final byte[] b, final int off, int len) throws IOException { |
| | | if (off < 0 || len < 0 || off + len > b.length) { |
| | |
| | | return readLen; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public synchronized void reset() throws IOException { |
| | | parentStream.reset(); |
| | | bytesRead = markBytesRead; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long skip(long n) throws IOException { |
| | | if (bytesRead + n > readLimit) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.io; |
| | | |
| | |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * An ASN1Writer implementation that outputs to an outputstream. |
| | | */ |
| | | /** An ASN1Writer implementation that outputs to an outputstream. */ |
| | | final class ASN1OutputStreamWriter extends AbstractASN1Writer { |
| | | /** Initial size of internal buffers. */ |
| | | private static final int BUFFER_INIT_SIZE = 32; |
| | |
| | | this.stackDepth = -1; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | while (stackDepth >= 0) { |
| | |
| | | rootStream.close(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void flush() throws IOException { |
| | | rootStream.flush(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeBoolean(final byte type, final boolean booleanValue) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeEndSequence() throws IOException { |
| | | if (stackDepth < 0) { |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeEndSet() throws IOException { |
| | | return writeEndSequence(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeEnumerated(final byte type, final int intValue) throws IOException { |
| | | return writeInteger(type, intValue); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeInteger(final byte type, final int intValue) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeInteger(final byte type, final long longValue) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeNull(final byte type) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeOctetString(final byte type, final byte[] value, final int offset, |
| | | final int length) throws IOException { |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeOctetString(final byte type, final ByteSequence value) |
| | | throws IOException { |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeOctetString(final byte type, final String value) throws IOException { |
| | | out.write(type); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeStartSequence(final byte type) throws IOException { |
| | | // Write the type in current stream switch to next sub-stream |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ASN1Writer writeStartSet(final byte type) throws IOException { |
| | | // From an implementation point of view, a set is equivalent to a |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import org.forgerock.opendj.ldap.requests.AddRequest; |
| | |
| | | * asynchronous methods. |
| | | */ |
| | | public abstract class AbstractAsynchronousConnection extends AbstractConnection { |
| | | |
| | | /** |
| | | * Creates a new abstract asynchronous connection. |
| | | */ |
| | | /** Creates a new abstract asynchronous connection. */ |
| | | protected AbstractAsynchronousConnection() { |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Result add(final AddRequest request) throws LdapException { |
| | | return blockingGetOrThrow(addAsync(request)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public BindResult bind(final BindRequest request) throws LdapException { |
| | | return blockingGetOrThrow(bindAsync(request)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public CompareResult compare(final CompareRequest request) throws LdapException { |
| | | return blockingGetOrThrow(compareAsync(request)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Result delete(final DeleteRequest request) throws LdapException { |
| | | return blockingGetOrThrow(deleteAsync(request)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R extends ExtendedResult> R extendedRequest(final ExtendedRequest<R> request, |
| | | final IntermediateResponseHandler handler) throws LdapException { |
| | | return blockingGetOrThrow(extendedRequestAsync(request, handler)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Result modify(final ModifyRequest request) throws LdapException { |
| | | return blockingGetOrThrow(modifyAsync(request)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Result modifyDN(final ModifyDNRequest request) throws LdapException { |
| | | return blockingGetOrThrow(modifyDNAsync(request)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Result search(final SearchRequest request, final SearchResultHandler handler) throws LdapException { |
| | | return blockingGetOrThrow(searchAsync(request, handler)); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import java.util.Collection; |
| | |
| | | * interface, to minimize the effort required to implement this interface. |
| | | */ |
| | | public abstract class AbstractConnection implements Connection { |
| | | |
| | | private static final class SingleEntryHandler implements SearchResultHandler { |
| | | private volatile SearchResultEntry firstEntry; |
| | | private volatile SearchResultReference firstReference; |
| | |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * Creates a new abstract connection. |
| | | */ |
| | | /** Creates a new abstract connection. */ |
| | | protected AbstractConnection() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public abstract String toString(); |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import java.util.Collection; |
| | |
| | | * The type of wrapped connection. |
| | | */ |
| | | public abstract class AbstractConnectionWrapper<C extends Connection> implements Connection { |
| | | /** |
| | | * The wrapped connection. |
| | | */ |
| | | /** The wrapped connection. */ |
| | | protected final C connection; |
| | | |
| | | /** |
| | |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import java.util.List; |
| | |
| | | * additional parameter. |
| | | */ |
| | | public abstract class AbstractFilterVisitor<R, P> implements FilterVisitor<R, P> { |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | /** Default constructor. */ |
| | | protected AbstractFilterVisitor() { |
| | | // Nothing to do. |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * Abstract implementation for {@code Map} based entries. |
| | | */ |
| | | /** Abstract implementation for {@code Map} based entries. */ |
| | | abstract class AbstractMapEntry extends AbstractEntry { |
| | | private final Map<AttributeDescription, Attribute> attributes; |
| | | private DN name; |
| | |
| | | this.attributes = attributes; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final boolean addAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Entry clearAttributes() { |
| | | attributes.clear(); |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Iterable<Attribute> getAllAttributes() { |
| | | return attributes.values(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Attribute getAttribute(final AttributeDescription attributeDescription) { |
| | | final Attribute attribute = attributes.get(attributeDescription); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int getAttributeCount() { |
| | | return attributes.size(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final DN getName() { |
| | | return name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final boolean removeAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> missingValues) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Entry setName(final DN dn) { |
| | | Reject.ifNull(dn); |
| | | this.name = dn; |
| | | return this; |
| | | } |
| | | |
| | | } |
| | |
| | | * 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-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import org.forgerock.opendj.ldap.requests.AbandonRequest; |
| | |
| | | * the equivalent synchronous methods. |
| | | */ |
| | | public abstract class AbstractSynchronousConnection extends AbstractConnection { |
| | | |
| | | /** |
| | | * Creates a new abstract synchronous connection. |
| | | */ |
| | | /** Creates a new abstract synchronous connection. */ |
| | | protected AbstractSynchronousConnection() { |
| | | // No implementation required. |
| | | } |
| | |
| | | private <R extends Result> LdapPromise<R> thenOnResult(final R result) { |
| | | return newSuccessfulLdapPromise(result); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * An immutable sequence of bytes backed by a byte array. |
| | | */ |
| | | /** An immutable sequence of bytes backed by a byte array. */ |
| | | public final class ByteString implements ByteSequence { |
| | | |
| | | /** Singleton empty byte string. */ |
| | | private static final ByteString EMPTY = wrap(new byte[0]); |
| | | |
| | |
| | | return new ByteSequenceReader(this); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public byte byteAt(final int index) { |
| | | if (index >= length || index < 0) { |
| | |
| | | return buffer[offset + index]; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final byte[] bytes, final int offset, final int length) { |
| | | checkArrayBounds(bytes, offset, length); |
| | | return compareTo(this.buffer, this.offset, this.length, bytes, offset, length); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final ByteSequence o) { |
| | | if (this == o) { |
| | |
| | | return -o.compareTo(buffer, offset, length); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public byte[] copyTo(final byte[] bytes) { |
| | | copyTo(bytes, 0); |
| | | return bytes; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public byte[] copyTo(final byte[] bytes, final int offset) { |
| | | if (offset < 0) { |
| | |
| | | return builder; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean copyTo(CharBuffer charBuffer, CharsetDecoder decoder) { |
| | | return copyTo(ByteBuffer.wrap(buffer, offset, length), charBuffer, decoder); |
| | |
| | | return !result.isError() && !result.isOverflow(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public OutputStream copyTo(final OutputStream stream) throws IOException { |
| | | stream.write(buffer, offset, length); |
| | | return stream; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final byte[] bytes, final int offset, final int length) { |
| | | checkArrayBounds(bytes, offset, length); |
| | |
| | | return length == 0; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int length() { |
| | | return length; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString subSequence(final int start, final int end) { |
| | | if (start < 0 || start > end || end > length) { |
| | |
| | | return new ByteString(buffer, offset + start, end - start); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean startsWith(ByteSequence prefix) { |
| | | if (prefix == null || prefix.length() > length) { |
| | | return false; |
| | | } |
| | | return prefix.equals(buffer, 0, prefix.length()); |
| | | return prefix != null && prefix.length() <= length && prefix.equals(buffer, 0, prefix.length()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toBase64String() { |
| | | return Base64.encode(this); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public byte[] toByteArray() { |
| | | return copyTo(new byte[length]); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString toByteString() { |
| | | return this; |
| | |
| | | return v; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return toString(buffer, offset, length); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import java.util.Arrays; |
| | |
| | | */ |
| | | public static final DereferenceAliasesPolicy FINDING_BASE = register(2, "find"); |
| | | |
| | | /** |
| | | * Dereference aliases both in searching and in locating the base object of |
| | | * a Search operation. |
| | | */ |
| | | /** Dereference aliases both in searching and in locating the base object of a Search operation. */ |
| | | public static final DereferenceAliasesPolicy ALWAYS = register(3, "always"); |
| | | |
| | | /** |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return intValue; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * @see Entries#diffEntries(Entry, Entry, DiffOptions) |
| | | */ |
| | | public static final class DiffOptions { |
| | | /** |
| | | * Selects which attributes will be compared. By default all user |
| | | * attributes will be compared. |
| | | */ |
| | | /** Selects which attributes will be compared. By default all user attributes will be compared. */ |
| | | private AttributeFilter attributeFilter = USER_ATTRIBUTES_ONLY_FILTER; |
| | | |
| | | /** |
| | |
| | | private Entry filter(final Entry entry) { |
| | | return attributeFilter.filteredViewOf(entry); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static final class UnmodifiableEntry implements Entry { |
| | |
| | | this.entry = entry; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean addAttribute(final Attribute attribute) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean addAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry addAttribute(final String attributeDescription, final Object... values) { |
| | | throw new UnsupportedOperationException(); |
| | |
| | | return entry.containsAttribute(attributeDescription, values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object object) { |
| | | return object == this || entry.equals(object); |
| | |
| | | .getAllAttributes(attributeDescription), UNMODIFIABLE_ATTRIBUTE_FUNCTION)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Iterable<Attribute> getAllAttributes(final String attributeDescription) { |
| | | return Iterables.unmodifiableIterable(Iterables.transformedIterable(entry |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Attribute getAttribute(final String attributeDescription) { |
| | | final Attribute attribute = entry.getAttribute(attributeDescription); |
| | |
| | | return entry.getAttributeCount(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN getName() { |
| | | return entry.getName(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return entry.hashCode(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeParser parseAttribute(final AttributeDescription attributeDescription) { |
| | | return entry.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeParser parseAttribute(final String attributeDescription) { |
| | | return entry.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean removeAttribute(final Attribute attribute, |
| | | final Collection<? super ByteString> missingValues) { |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry removeAttribute(final String attributeDescription, final Object... values) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean replaceAttribute(final Attribute attribute) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry replaceAttribute(final String attributeDescription, final Object... values) { |
| | | throw new UnsupportedOperationException(); |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Entry setName(final String dn) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return entry.toString(); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static final Comparator<Entry> COMPARATOR = new Comparator<Entry>() { |
| | |
| | | |
| | | final int cmp = adfrom.compareTo(adto); |
| | | if (cmp == 0) { |
| | | /* |
| | | * Attribute is in both entries so compute the differences |
| | | * between the old and new. |
| | | */ |
| | | /* Attribute is in both entries so compute the differences between the old and new. */ |
| | | if (options.useReplaceMaxValues > ato.size()) { |
| | | // This attribute is a candidate for replacing. |
| | | if (diffAttributeNeedsReplacing(afrom, ato, options)) { |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2012-2015 ForgeRock AS. |
| | | * Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * Rules </a> |
| | | */ |
| | | public final class GeneralizedTime implements Comparable<GeneralizedTime> { |
| | | |
| | | /** UTC TimeZone is assumed to never change over JVM lifetime. */ |
| | | private static final TimeZone TIME_ZONE_UTC_OBJ = TimeZone.getTimeZone("UTC"); |
| | | |
| | |
| | | this.stringValue = stringValue; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final GeneralizedTime o) { |
| | | final Long timeMS1 = getTimeInMillis(); |
| | |
| | | return timeMS1.compareTo(timeMS2); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | return tmpTimeMS; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return ((Long) getTimeInMillis()).hashCode(); |
| | |
| | | return (Date) tmpDate.clone(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | String tmpString = stringValue; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | */ |
| | | private final boolean isSecured; |
| | | |
| | | /** |
| | | * The host name corresponding to an LDAP URL. |
| | | */ |
| | | /** The host name corresponding to an LDAP URL. */ |
| | | private final String host; |
| | | |
| | | /** |
| | | * The port number corresponding to an LDAP URL. |
| | | */ |
| | | /** The port number corresponding to an LDAP URL. */ |
| | | private final int port; |
| | | |
| | | /** |
| | | * The distinguished name corresponding to an LDAP URL. |
| | | */ |
| | | /** The distinguished name corresponding to an LDAP URL. */ |
| | | private final DN name; |
| | | |
| | | /** |
| | | * The search scope corresponding to an LDAP URL. |
| | | */ |
| | | /** The search scope corresponding to an LDAP URL. */ |
| | | private final SearchScope scope; |
| | | |
| | | /** |
| | | * The search filter corresponding to an LDAP URL. |
| | | */ |
| | | /** The search filter corresponding to an LDAP URL. */ |
| | | private final Filter filter; |
| | | |
| | | /** |
| | | * The attributes that need to be searched. |
| | | */ |
| | | /** The attributes that need to be searched. */ |
| | | private final List<String> attributes; |
| | | |
| | | /** |
| | | * The String value of LDAP URL. |
| | | */ |
| | | /** The String value of LDAP URL. */ |
| | | private final String urlString; |
| | | |
| | | /** |
| | | * Normalized ldap URL. |
| | | */ |
| | | /** Normalized ldap URL. */ |
| | | private String normalizedURL; |
| | | |
| | | /** |
| | | * The default scheme to be used with LDAP URL. |
| | | */ |
| | | /** The default scheme to be used with LDAP URL. */ |
| | | private static final String DEFAULT_URL_SCHEME = "ldap"; |
| | | |
| | | /** |
| | | * The SSL-based scheme allowed to be used with LDAP URL. |
| | | */ |
| | | /** The SSL-based scheme allowed to be used with LDAP URL. */ |
| | | private static final String SSL_URL_SCHEME = "ldaps"; |
| | | |
| | | /** |
| | | * The default host. |
| | | */ |
| | | /** The default host. */ |
| | | private static final String DEFAULT_HOST = "localhost"; |
| | | |
| | | /** |
| | | * The default non-SSL port. |
| | | */ |
| | | /** The default non-SSL port. */ |
| | | private static final int DEFAULT_PORT = 389; |
| | | |
| | | /** |
| | | * The default SSL port. |
| | | */ |
| | | /** The default SSL port. */ |
| | | private static final int DEFAULT_SSL_PORT = 636; |
| | | |
| | | /** |
| | | * The default filter. |
| | | */ |
| | | /** The default filter. */ |
| | | private static final Filter DEFAULT_FILTER = Filter.objectClassPresent(); |
| | | |
| | | /** |
| | | * The default search scope. |
| | | */ |
| | | /** The default search scope. */ |
| | | private static final SearchScope DEFAULT_SCOPE = SearchScope.BASE_OBJECT; |
| | | |
| | | /** |
| | | * The default distinguished name. |
| | | */ |
| | | /** The default distinguished name. */ |
| | | private static final DN DEFAULT_DN = DN.rootDN(); |
| | | |
| | | /** |
| | | * The % encoding character. |
| | | */ |
| | | /** The % encoding character. */ |
| | | private static final char PERCENT_ENCODING_CHAR = '%'; |
| | | |
| | | /** |
| | | * The ? character. |
| | | */ |
| | | /** The ? character. */ |
| | | private static final char QUESTION_CHAR = '?'; |
| | | |
| | | /** |
| | | * The slash (/) character. |
| | | */ |
| | | /** The slash (/) character. */ |
| | | private static final char SLASH_CHAR = '/'; |
| | | |
| | | /** |
| | | * The comma (,) character. |
| | | */ |
| | | /** The comma (,) character. */ |
| | | private static final char COMMA_CHAR = ','; |
| | | |
| | | /** |
| | | * The colon (:) character. |
| | | */ |
| | | /** The colon (:) character. */ |
| | | private static final char COLON_CHAR = ':'; |
| | | |
| | | /** |
| | | * Set containing characters that do not need to be encoded. |
| | | */ |
| | | /** Set containing characters that do not need to be encoded. */ |
| | | private static final Set<Character> VALID_CHARS = new HashSet<>(); |
| | | |
| | | static { |
| | |
| | | return request; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | |
| | | return scope; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | final String s = toNormalizedString(); |
| | |
| | | return isSecured; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return urlString; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import java.util.Collection; |
| | |
| | | public final class LinkedAttribute extends AbstractAttribute { |
| | | |
| | | private static abstract class Impl { |
| | | |
| | | abstract boolean add(LinkedAttribute attribute, ByteString value); |
| | | |
| | | abstract void clear(LinkedAttribute attribute); |
| | |
| | | } |
| | | |
| | | private static final class MultiValueImpl extends Impl { |
| | | |
| | | @Override |
| | | boolean add(final LinkedAttribute attribute, final ByteString value) { |
| | | final ByteString normalizedValue = normalizeValue(attribute, value); |
| | |
| | | } |
| | | |
| | | private static final class SingleValueImpl extends Impl { |
| | | |
| | | @Override |
| | | boolean add(final LinkedAttribute attribute, final ByteString value) { |
| | | final ByteString normalizedValue = normalizeValue(attribute, value); |
| | |
| | | } |
| | | |
| | | private static final class ZeroValueImpl extends Impl { |
| | | |
| | | @Override |
| | | boolean add(final LinkedAttribute attribute, final ByteString value) { |
| | | attribute.singleValue = value; |
| | |
| | | int size(final LinkedAttribute attribute) { |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * An attribute factory which can be used to create new linked attributes. |
| | | */ |
| | | /** An attribute factory which can be used to create new linked attributes. */ |
| | | public static final AttributeFactory FACTORY = new AttributeFactory() { |
| | | @Override |
| | | public Attribute newAttribute(final AttributeDescription attributeDescription) { |
| | |
| | | add(values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean add(final ByteString value) { |
| | | Reject.ifNull(value); |
| | | return pimpl.add(this, value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void clear() { |
| | | pimpl.clear(this); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean contains(final Object value) { |
| | | Reject.ifNull(value); |
| | | return pimpl.contains(this, ByteString.valueOfObject(value)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean containsAll(final Collection<?> values) { |
| | | Reject.ifNull(values); |
| | | return pimpl.containsAll(this, values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString firstValue() { |
| | | return pimpl.firstValue(this); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeDescription getAttributeDescription() { |
| | | return attributeDescription; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Iterator<ByteString> iterator() { |
| | | return pimpl.iterator(this); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean remove(final Object value) { |
| | | Reject.ifNull(value); |
| | | return pimpl.remove(this, ByteString.valueOfObject(value)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> boolean retainAll(final Collection<T> values, |
| | | final Collection<? super T> missingValues) { |
| | |
| | | return pimpl.retainAll(this, values, missingValues); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int size() { |
| | | return pimpl.size(this); |
| | |
| | | } |
| | | return normalizedSingleValue; |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * A modification to be performed on an entry during a Modify operation. |
| | | */ |
| | | /** A modification to be performed on an entry during a Modify operation. */ |
| | | public final class Modification { |
| | | private final ModificationType modificationType; |
| | | private final Attribute attribute; |
| | |
| | | return modificationType; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | builder.append("})"); |
| | | return builder.toString(); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * Directory Access Protocol (LDAP) Modify-Increment Extension </a> |
| | | */ |
| | | public final class ModificationType { |
| | | |
| | | /** |
| | | * Contains equivalent values for the ModificationType values. |
| | | * This allows easily using ModificationType values with switch statements. |
| | |
| | | this.modificationTypeEnum = modificationTypeEnum; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return intValue; |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2011-2015 ForgeRock AS. |
| | | * Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import static com.forgerock.opendj.ldap.CoreMessages.INFO_CANCELED_BY_ABANDON_REQUEST; |
| | |
| | | * The type of client context. |
| | | */ |
| | | final class RequestHandlerFactoryAdapter<C> implements ServerConnectionFactory<C, Integer> { |
| | | /** |
| | | * Request context implementation. |
| | | */ |
| | | /** Request context implementation. */ |
| | | private static class RequestContextImpl<S extends Result, H extends LdapResultHandler<S>> |
| | | implements RequestContext, LdapResultHandler<S> { |
| | | |
| | | /** |
| | | * Adapter class which invokes cancel result handlers with correct |
| | | * result type. |
| | | */ |
| | | /** Adapter class which invokes cancel result handlers with correct result type. */ |
| | | private static final class ExtendedResultHandlerHolder<R extends ExtendedResult> { |
| | | private final ExtendedRequest<R> request; |
| | | private final LdapResultHandler<R> resultHandler; |
| | |
| | | this.isCancelSupported = isCancelSupported; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addCancelRequestListener(final CancelRequestListener listener) { |
| | | Reject.ifNull(listener); |
| | |
| | | case TOO_LATE: |
| | | case RESULT_SENT: |
| | | case CANCELLED: |
| | | /* |
| | | * No point in registering the callback since the request |
| | | * can never be cancelled now. |
| | | */ |
| | | /* No point in registering the callback since the request can never be cancelled now. */ |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void checkIfCancelled(final boolean signalTooLate) throws CancelledResultException { |
| | | synchronized (stateLock) { |
| | |
| | | } |
| | | break; |
| | | case CANCEL_REQUESTED: |
| | | /* |
| | | * Don't change state: let the handler ack the cancellation |
| | | * request. |
| | | */ |
| | | /* Don't change state: let the handler ack the cancellation request. */ |
| | | throw (CancelledResultException) newLdapException(ResultCode.CANCELLED, |
| | | cancelRequestReason.toString()); |
| | | case TOO_LATE: |
| | |
| | | break; |
| | | case RESULT_SENT: |
| | | case CANCELLED: |
| | | /* |
| | | * This should not happen - could throw an illegal state |
| | | * exception? |
| | | */ |
| | | /* This should not happen - could throw an illegal state exception? */ |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int getMessageID() { |
| | | return messageID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleException(final LdapException error) { |
| | | if (clientConnection.removePendingRequest(this)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleResult(final S result) { |
| | | if (clientConnection.removePendingRequest(this)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeCancelRequestListener(final CancelRequestListener listener) { |
| | | Reject.ifNull(listener); |
| | |
| | | this.sendResult &= sendResult; |
| | | break; |
| | | case CANCEL_REQUESTED: |
| | | /* |
| | | * Cancel already request so listeners already invoked. |
| | | */ |
| | | /* Cancel already request so listeners already invoked. */ |
| | | if (cancelResultHandler != null) { |
| | | if (cancelResultHandlers == null) { |
| | | cancelResultHandlers = new LinkedList<>(); |
| | |
| | | break; |
| | | case TOO_LATE: |
| | | case RESULT_SENT: |
| | | /* |
| | | * Cannot cancel, so invoke result handler immediately |
| | | * outside of lock. |
| | | */ |
| | | /* Cannot cancel, so invoke result handler immediately outside of lock. */ |
| | | if (cancelResultHandler != null) { |
| | | invokeResultHandler = true; |
| | | resultHandlerIsSuccess = false; |
| | |
| | | } |
| | | break; |
| | | case CANCEL_REQUESTED: |
| | | /* |
| | | * Switch to appropriate final state and invoke any cancel |
| | | * request handlers. |
| | | */ |
| | | /* Switch to appropriate final state and invoke any cancel request handlers. */ |
| | | if (!result.getResultCode().equals(ResultCode.CANCELLED)) { |
| | | state = RequestState.RESULT_SENT; |
| | | } else { |
| | |
| | | break; |
| | | case RESULT_SENT: |
| | | case CANCELLED: |
| | | /* |
| | | * This should not happen - could throw an illegal state |
| | | * exception? |
| | | */ |
| | | /* This should not happen - could throw an illegal state exception? */ |
| | | maySendResult = false; // Prevent sending multiple results. |
| | | break; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Search request context implementation. |
| | | */ |
| | | /** Search request context implementation. */ |
| | | private static final class SearchRequestContextImpl extends RequestContextImpl<Result, LdapResultHandler<Result>> |
| | | implements SearchResultHandler { |
| | | |
| | |
| | | this.entryHandler = entryHandler; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean handleEntry(final SearchResultEntry entry) { |
| | | return entryHandler.handleEntry(entry); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean handleReference(final SearchResultReference reference) { |
| | | return entryHandler.handleReference(reference); |
| | |
| | | this.requestHandler = requestHandler; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAbandon(final Integer messageID, final AbandonRequest request) { |
| | | final RequestContextImpl<?, ?> abandonedRequest = |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAdd(final Integer messageID, final AddRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final Integer messageID, final int version, |
| | | final BindRequest request, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleCompare(final Integer messageID, final CompareRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionClosed(final Integer messageID, final UnbindRequest request) { |
| | | final LocalizableMessage cancelReason = INFO_CANCELED_BY_CLIENT_DISCONNECT.get(); |
| | | doClose(cancelReason); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionDisconnected(final ResultCode resultCode, final String message) { |
| | | final LocalizableMessage cancelReason = INFO_CANCELED_BY_SERVER_DISCONNECT.get(); |
| | | doClose(cancelReason); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionError(final Throwable error) { |
| | | final LocalizableMessage cancelReason = INFO_CANCELED_BY_CLIENT_ERROR.get(); |
| | | doClose(cancelReason); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleDelete(final Integer messageID, final DeleteRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R extends ExtendedResult> void handleExtendedRequest(final Integer messageID, |
| | | final ExtendedRequest<R> request, |
| | |
| | | INFO_CANCELED_BY_CANCEL_REQUEST.get(messageID); |
| | | cancelledRequest.cancel(cancelReason, request, requestContext, true); |
| | | } else { |
| | | /* |
| | | * Couldn't find the request. Invoke on context in order |
| | | * to remove pending request. |
| | | */ |
| | | /* Couldn't find the request. Invoke on context in order to remove pending request. */ |
| | | requestContext.handleException(newLdapException(ResultCode.NO_SUCH_OPERATION)); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModify(final Integer messageID, final ModifyRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModifyDN(final Integer messageID, final ModifyDNRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleSearch(final Integer messageID, final SearchRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler, |
| | |
| | | private boolean removePendingRequest(final RequestContextImpl<?, ?> requestContext) { |
| | | return pendingRequests.remove(requestContext.getMessageID()) != null; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | this.factory = factory; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ServerConnection<Integer> handleAccept(final C clientContext) throws LdapException { |
| | | return adaptRequestHandler(factory.handleAccept(clientContext)); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | * Portions copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * Lightweight Directory Access Protocol (LDAP): The Protocol </a> |
| | | */ |
| | | public final class ResultCode { |
| | | |
| | | /** |
| | | * Contains equivalent values for the ResultCode values. |
| | | * This allows easily using ResultCode values with switch statements. |
| | |
| | | this.resultCodeEnum = resultCodeEnum; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | return name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return intValue; |
| | |
| | | public String toString() { |
| | | return name.toString(); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | * Scope for LDAP </a> |
| | | */ |
| | | public final class SearchScope { |
| | | |
| | | /** |
| | | * Contains equivalent values for the SearchScope values. |
| | | * This allows easily using SearchScope values with switch statements. |
| | |
| | | private static final List<SearchScope> IMMUTABLE_ELEMENTS = Collections.unmodifiableList(Arrays |
| | | .asList(ELEMENTS)); |
| | | |
| | | /** |
| | | * The scope is constrained to the search base entry. |
| | | */ |
| | | /** The scope is constrained to the search base entry. */ |
| | | public static final SearchScope BASE_OBJECT = register(0, "base", Enum.BASE_OBJECT); |
| | | |
| | | /** |
| | | * The scope is constrained to the immediate subordinates of the search base |
| | | * entry. |
| | | */ |
| | | /** The scope is constrained to the immediate subordinates of the search base entry. */ |
| | | public static final SearchScope SINGLE_LEVEL = register(1, "one", Enum.SINGLE_LEVEL); |
| | | |
| | | /** |
| | | * The scope is constrained to the search base entry and to all its |
| | | * subordinates. |
| | | */ |
| | | /** The scope is constrained to the search base entry and to all its subordinates. */ |
| | | public static final SearchScope WHOLE_SUBTREE = register(2, "sub", Enum.WHOLE_SUBTREE); |
| | | |
| | | /** |
| | |
| | | this.searchScopeEnum = searchScopeEnum; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return intValue; |
| | |
| | | * 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-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | return new ADNotificationRequestControl(isCritical); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | * - Persistent Search: A Simple LDAP Change Notification Mechanism </a> |
| | | */ |
| | | public final class EntryChangeNotificationResponseControl implements Control { |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | /** |
| | | * The OID for the entry change notification response control. |
| | | */ |
| | | /** The OID for the entry change notification response control. */ |
| | | public static final String OID = "2.16.840.1.113730.3.4.7"; |
| | | |
| | | /** |
| | | * A decoder which can be used for decoding the entry change notification |
| | | * response control. |
| | | */ |
| | | /** A decoder which can be used for decoding the entry change notification response control. */ |
| | | public static final ControlDecoder<EntryChangeNotificationResponseControl> DECODER = |
| | | new ControlDecoder<EntryChangeNotificationResponseControl>() { |
| | | |
| | |
| | | return changeType; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOID() { |
| | | return OID; |
| | |
| | | return previousName; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString getValue() { |
| | | final ByteStringBuilder buffer = new ByteStringBuilder(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasValue() { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isCritical() { |
| | | return isCritical; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | builder.append(")"); |
| | | return builder.toString(); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | * </a> |
| | | */ |
| | | public enum PasswordPolicyErrorType { |
| | | |
| | | /** |
| | | * Indicates that the password has expired and must be reset. |
| | | */ |
| | | /** Indicates that the password has expired and must be reset. */ |
| | | PASSWORD_EXPIRED(0, "passwordExpired"), |
| | | |
| | | /** |
| | | * Indicates that the user's account has been locked. |
| | | */ |
| | | /** Indicates that the user's account has been locked. */ |
| | | ACCOUNT_LOCKED(1, "accountLocked"), |
| | | |
| | | /** |
| | |
| | | */ |
| | | CHANGE_AFTER_RESET(2, "changeAfterReset"), |
| | | |
| | | /** |
| | | * Indicates that a user is restricted from changing her password. |
| | | */ |
| | | /** Indicates that a user is restricted from changing her password. */ |
| | | PASSWORD_MOD_NOT_ALLOWED(3, "passwordModNotAllowed"), |
| | | |
| | | /** |
| | | * Indicates that the old password must be supplied in order to modify the |
| | | * password. |
| | | */ |
| | | /** Indicates that the old password must be supplied in order to modify the password. */ |
| | | MUST_SUPPLY_OLD_PASSWORD(4, "mustSupplyOldPassword"), |
| | | |
| | | /** |
| | | * Indicates that a password doesn't pass quality checking. |
| | | */ |
| | | /** Indicates that a password doesn't pass quality checking. */ |
| | | INSUFFICIENT_PASSWORD_QUALITY(5, "insufficientPasswordQuality"), |
| | | |
| | | /** |
| | | * Indicates that a password is not long enough. |
| | | */ |
| | | /** Indicates that a password is not long enough. */ |
| | | PASSWORD_TOO_SHORT(6, "passwordTooShort"), |
| | | |
| | | /** |
| | | * Indicates that the age of the password to be modified is not yet old |
| | | * enough. |
| | | */ |
| | | /** Indicates that the age of the password to be modified is not yet old enough. */ |
| | | PASSWORD_TOO_YOUNG(7, "passwordTooYoung"), |
| | | |
| | | /** |
| | | * Indicates that a password has already been used and the user must choose |
| | | * a different one. |
| | | */ |
| | | /** Indicates that a password has already been used and the user must choose a different one. */ |
| | | PASSWORD_IN_HISTORY(8, "passwordInHistory"); |
| | | |
| | | private final int intValue; |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | int intValue() { |
| | | return intValue; |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | * </a> |
| | | */ |
| | | public enum PasswordPolicyWarningType { |
| | | /** |
| | | * Indicates the number of seconds before a password will expire. |
| | | */ |
| | | /** Indicates the number of seconds before a password will expire. */ |
| | | TIME_BEFORE_EXPIRATION(0, "timeBeforeExpiration"), |
| | | |
| | | /** |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | * Portions copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.controls; |
| | | |
| | |
| | | * - Persistent Search: A Simple LDAP Change Notification Mechanism </a> |
| | | */ |
| | | public enum PersistentSearchChangeType { |
| | | /** |
| | | * Indicates that an Add operation triggered the entry change notification. |
| | | */ |
| | | /** Indicates that an Add operation triggered the entry change notification. */ |
| | | ADD(1, "add"), |
| | | |
| | | /** |
| | | * Indicates that an Delete operation triggered the entry change |
| | | * notification. |
| | | */ |
| | | /** Indicates that an Delete operation triggered the entry change notification. */ |
| | | DELETE(2, "delete"), |
| | | |
| | | /** |
| | | * Indicates that an Modify operation triggered the entry change |
| | | * notification. |
| | | */ |
| | | /** Indicates that an Modify operation triggered the entry change notification. */ |
| | | MODIFY(4, "modify"), |
| | | |
| | | /** |
| | | * Indicates that an Modify DN operation triggered the entry change |
| | | * notification. |
| | | */ |
| | | /** Indicates that an Modify DN operation triggered the entry change notification. */ |
| | | MODIFY_DN(8, "modifyDN"); |
| | | |
| | | private final String name; |
| | |
| | | this.intValue = intValue; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | * values in byte order. |
| | | */ |
| | | abstract class AbstractApproximateMatchingRuleImpl extends AbstractMatchingRuleImpl { |
| | | |
| | | private final Indexer indexer; |
| | | |
| | | AbstractApproximateMatchingRuleImpl(String indexID) { |
| | |
| | | return named(indexer.getIndexID(), normalizeAttributeValue(schema, assertionValue)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Collection<? extends Indexer> createIndexers(IndexingOptions options) { |
| | | return Collections.singleton(indexer); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | return defaultAssertion(normalizeAttributeValue(schema, assertionValue)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<? extends Indexer> createIndexers(IndexingOptions options) { |
| | | return Collections.singleton(indexer); |
| | |
| | | Assertion defaultAssertion(final ByteSequence normalizedAssertionValue) { |
| | | return named(indexer.getIndexID(), normalizedAssertionValue); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | this.indexer = new DefaultIndexer(indexId); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Assertion getAssertion(final Schema schema, final ByteSequence value) |
| | | throws DecodeException { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Assertion getGreaterOrEqualAssertion(final Schema schema, final ByteSequence value) |
| | | throws DecodeException { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Assertion getLessOrEqualAssertion(final Schema schema, final ByteSequence value) |
| | | throws DecodeException { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Collection<? extends Indexer> createIndexers(IndexingOptions options) { |
| | | return Collections.singleton(indexer); |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 Manuel Gaupp |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | | import java.io.IOException; |
| | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements the certificate attribute syntax. It is restricted to |
| | | * accept only X.509 certificates. |
| | | */ |
| | | final class CertificateSyntaxImpl extends AbstractSyntaxImpl { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getEqualityMatchingRule() { |
| | | return EMR_CERTIFICATE_EXACT_OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() { |
| | | return SYNTAX_CERTIFICATE_NAME; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getOrderingMatchingRule() { |
| | | return OMR_OCTET_STRING_OID; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isBEREncodingRequired() { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isHumanReadable() { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean valueIsAcceptable(final Schema schema, final ByteSequence value, |
| | | final LocalizableMessageBuilder invalidReason) { |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | * ordering rules) and a substring one (for substring rule). |
| | | */ |
| | | final class CollationMatchingRulesImpl { |
| | | |
| | | private static final String INDEX_ID_SHARED = "shared"; |
| | | private static final String INDEX_ID_SUBSTRING = "substring"; |
| | | |
| | |
| | | return new CollationGreaterThanOrEqualToMatchingRuleImpl(locale); |
| | | } |
| | | |
| | | /** |
| | | * Defines the base for collation matching rules. |
| | | */ |
| | | /** Defines the base for collation matching rules. */ |
| | | private static abstract class AbstractCollationMatchingRuleImpl extends AbstractMatchingRuleImpl { |
| | | private final Locale locale; |
| | | final Collator collator; |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<? extends Indexer> createIndexers(IndexingOptions options) { |
| | | return Collections.singletonList(indexer); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) |
| | | throws DecodeException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Defines the collation equality matching rule. |
| | | */ |
| | | /** Defines the collation equality matching rule. */ |
| | | private static final class CollationEqualityMatchingRuleImpl extends AbstractCollationMatchingRuleImpl { |
| | | |
| | | /** |
| | | * Creates the matching rule with the provided locale. |
| | | * |
| | |
| | | throws DecodeException { |
| | | return named(indexName, normalizeAttributeValue(schema, assertionValue)); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Defines the collation substring matching rule. |
| | | */ |
| | | /** Defines the collation substring matching rule. */ |
| | | private static final class CollationSubstringMatchingRuleImpl extends AbstractCollationMatchingRuleImpl { |
| | | |
| | | private final AbstractSubstringMatchingRuleImpl substringMatchingRule; |
| | | |
| | | /** |
| | |
| | | return substringMatchingRule.getAssertion(schema, assertionValue); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Assertion getSubstringAssertion(Schema schema, ByteSequence subInitial, |
| | | List<? extends ByteSequence> subAnyElements, ByteSequence subFinal) throws DecodeException { |
| | | return substringMatchingRule.getSubstringAssertion(schema, subInitial, subAnyElements, subFinal); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final Collection<? extends Indexer> createIndexers(IndexingOptions options) { |
| | | final Collection<Indexer> indexers = new ArrayList<>(substringMatchingRule.createIndexers(options)); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Defines the collation ordering matching rule. |
| | | */ |
| | | /** Defines the collation ordering matching rule. */ |
| | | private static abstract class CollationOrderingMatchingRuleImpl extends AbstractCollationMatchingRuleImpl { |
| | | |
| | | final AbstractOrderingMatchingRuleImpl orderingMatchingRule; |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Defines the collation less than matching rule. |
| | | */ |
| | | /** Defines the collation less than matching rule. */ |
| | | private static final class CollationLessThanMatchingRuleImpl extends CollationOrderingMatchingRuleImpl { |
| | | |
| | | CollationLessThanMatchingRuleImpl(Locale locale) { |
| | | super(locale); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Assertion getAssertion(Schema schema, ByteSequence assertionValue) throws DecodeException { |
| | | return orderingMatchingRule.getAssertion(schema, assertionValue); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Defines the collation less than or equal matching rule. |
| | | */ |
| | | /** Defines the collation less than or equal matching rule. */ |
| | | private static final class CollationLessThanOrEqualToMatchingRuleImpl extends CollationOrderingMatchingRuleImpl { |
| | | |
| | | CollationLessThanOrEqualToMatchingRuleImpl(Locale locale) { |
| | | super(locale); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Assertion getAssertion(Schema schema, ByteSequence assertionValue) throws DecodeException { |
| | | return orderingMatchingRule.getLessOrEqualAssertion(schema, assertionValue); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Defines the collation greater than matching rule. |
| | | */ |
| | | /** Defines the collation greater than matching rule. */ |
| | | private static final class CollationGreaterThanMatchingRuleImpl extends CollationOrderingMatchingRuleImpl { |
| | | |
| | | CollationGreaterThanMatchingRuleImpl(Locale locale) { |
| | | super(locale); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Assertion getAssertion(Schema schema, ByteSequence assertionValue) |
| | | throws DecodeException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Defines the collation greater than or equal matching rule. |
| | | */ |
| | | /** Defines the collation greater than or equal matching rule. */ |
| | | private static final class CollationGreaterThanOrEqualToMatchingRuleImpl |
| | | extends CollationOrderingMatchingRuleImpl { |
| | | |
| | | CollationGreaterThanOrEqualToMatchingRuleImpl(Locale locale) { |
| | | super(locale); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Assertion getAssertion(Schema schema, ByteSequence assertionValue) throws DecodeException { |
| | | return orderingMatchingRule.getGreaterOrEqualAssertion(schema, assertionValue); |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<? extends Indexer> createIndexers(IndexingOptions options) { |
| | | return Collections.emptySet(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | * Portions copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | | import static org.forgerock.opendj.ldap.schema.SchemaUtils.unmodifiableCopyOfExtraProperties; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Lazily created string representation. |
| | | */ |
| | | /** Lazily created string representation. */ |
| | | private String definition; |
| | | |
| | | /** The description for this definition. */ |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract boolean equals(Object obj); |
| | | |
| | |
| | | return extraProperties; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract int hashCode(); |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | * Portions copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | | import org.forgerock.opendj.ldap.IntermediateResponseHandler; |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultReference; |
| | | import org.forgerock.util.promise.PromiseImpl; |
| | | |
| | | /** |
| | | * Search result promise implementation. |
| | | */ |
| | | /** Search result promise implementation. */ |
| | | public final class SearchResultLdapPromiseImpl extends ResultLdapPromiseImpl<SearchRequest, Result> implements |
| | | SearchResultHandler { |
| | | private SearchResultHandler searchResultHandler; |
| | |
| | | || request.containsControl(ADNotificationRequestControl.OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean handleEntry(final SearchResultEntry entry) { |
| | | // FIXME: there's a potential race condition here - the promise could |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean handleReference(final SearchResultReference reference) { |
| | | // FIXME: there's a potential race condition here - the promise could |
| | |
| | | // Persistent searches should not time out. |
| | | return !isPersistentSearch; |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | | import java.util.NoSuchElementException; |
| | |
| | | * interface which is not mockable. |
| | | */ |
| | | public class ConnectionEntryReader implements EntryReader { |
| | | /* |
| | | * See OPENDJ-1124 for more discussion about why this class is non-final. |
| | | */ |
| | | /* See OPENDJ-1124 for more discussion about why this class is non-final. */ |
| | | |
| | | /** |
| | | * Result handler that places all responses in a queue. |
| | | */ |
| | | /** Result handler that places all responses in a queue. */ |
| | | private static final class BufferHandler implements SearchResultHandler, LdapResultHandler<Result> { |
| | | private final BlockingQueue<Response> responses; |
| | | private volatile boolean isInterrupted; |
| | |
| | | promise = connection.searchAsync(searchRequest, buffer).thenOnResult(buffer).thenOnException(buffer); |
| | | } |
| | | |
| | | /** |
| | | * Closes this connection entry reader, canceling the search request if it |
| | | * is still active. |
| | | */ |
| | | /** Closes this connection entry reader, canceling the search request if it is still active. */ |
| | | @Override |
| | | public void close() { |
| | | // Cancel the search if it is still running. |
| | | promise.cancel(true); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasNext() throws LdapException { |
| | | // Poll for the next response if needed. |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | * Portions copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | |
| | | super(Arrays.asList(ldifLines)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | close0(); |
| | |
| | | } |
| | | |
| | | try { |
| | | /* |
| | | * Read the DN of the entry and see if it is one that should be |
| | | * included in the import. |
| | | */ |
| | | /* Read the DN of the entry and see if it is one that should be included in the import. */ |
| | | final DN entryDN = readLDIFRecordDN(record); |
| | | if (entryDN == null) { |
| | | // Skip version record. |
| | |
| | | schemaErrors.add(message); |
| | | continue; |
| | | default: // Ignore |
| | | /* |
| | | * This should not happen: we should be using a non-strict |
| | | * schema for this policy. |
| | | */ |
| | | /* This should not happen: we should be using a non-strict schema for this policy. */ |
| | | throw new IllegalStateException("Schema is not consistent with policy", e); |
| | | } |
| | | } catch (final LocalizedIllegalArgumentException e) { |
| | |
| | | attributeDescription = attributeDescription.withOption("binary"); |
| | | } |
| | | |
| | | /* |
| | | * Now go through the rest of the attributes until the "-" line is |
| | | * reached. |
| | | */ |
| | | /* Now go through the rest of the attributes until the "-" line is reached. */ |
| | | attributeValues.clear(); |
| | | while (record.iterator.hasNext()) { |
| | | ldifLine = record.iterator.next(); |
| | |
| | | |
| | | return modifyDNRequest; |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | | import java.io.IOException; |
| | |
| | | * Interchange Format (LDIF) - Technical Specification </a> |
| | | */ |
| | | public final class LDIFChangeRecordWriter extends AbstractLDIFWriter implements ChangeRecordWriter { |
| | | |
| | | /** |
| | | * Returns the LDIF string representation of the provided change record. |
| | | * |
| | |
| | | super(writer); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | close0(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void flush() throws IOException { |
| | | flush0(); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final AddRequest change) throws IOException { |
| | | Reject.ifNull(change); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ChangeRecord change) throws IOException { |
| | | Reject.ifNull(change); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final DeleteRequest change) throws IOException { |
| | | Reject.ifNull(change); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ModifyDNRequest change) |
| | | throws IOException { |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeChangeRecord(final ModifyRequest change) throws IOException { |
| | | Reject.ifNull(change); |
| | |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LDIFChangeRecordWriter writeComment(final CharSequence comment) throws IOException { |
| | | writeComment0(comment); |
| | | return this; |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | * Portions copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | |
| | | super(Arrays.asList(ldifLines)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() throws IOException { |
| | | close0(); |
| | |
| | | } |
| | | |
| | | try { |
| | | /* |
| | | * Read the DN of the entry and see if it is one that should be |
| | | * included in the import. |
| | | */ |
| | | /* Read the DN of the entry and see if it is one that should be included in the import. */ |
| | | final DN entryDN = readLDIFRecordDN(record); |
| | | if (entryDN == null) { |
| | | // Skip version record. |
| | |
| | | |
| | | return nextEntry; |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | | import java.util.LinkedList; |
| | |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class AbstractAsynchronousConnectionTestCase extends SdkTestCase { |
| | | |
| | | public final class MockConnection extends AbstractAsynchronousConnection { |
| | | private final ResultCode resultCode; |
| | | private final SearchResultEntry[] entries; |
| | |
| | | this.entries = entries; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Void> abandonAsync(AbandonRequest request) { |
| | | if (!resultCode.isExceptional()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> addAsync(AddRequest request, |
| | | IntermediateResponseHandler intermediateResponseHandler) { |
| | | return getPromiseFromResultCode(newResult(resultCode)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addConnectionEventListener(ConnectionEventListener listener) { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<BindResult> bindAsync(BindRequest request, |
| | | IntermediateResponseHandler intermediateResponseHandler) { |
| | | return getPromiseFromResultCode(newBindResult(resultCode)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close(UnbindRequest request, String reason) { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<CompareResult> compareAsync(CompareRequest request, |
| | | IntermediateResponseHandler intermediateResponseHandler) { |
| | | return getPromiseFromResultCode(newCompareResult(resultCode)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> deleteAsync(DeleteRequest request, |
| | | IntermediateResponseHandler intermediateResponseHandler) { |
| | | return getPromiseFromResultCode(newResult(resultCode)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R extends ExtendedResult> LdapPromise<R> extendedRequestAsync(ExtendedRequest<R> request, |
| | | IntermediateResponseHandler intermediateResponseHandler) { |
| | | return getPromiseFromResultCode(request.getResultDecoder().newExtendedErrorResult(resultCode, "", "")); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isClosed() { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isValid() { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> modifyAsync(ModifyRequest request, |
| | | IntermediateResponseHandler intermediateResponseHandler) { |
| | | return getPromiseFromResultCode(newResult(resultCode)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> modifyDNAsync(ModifyDNRequest request, |
| | | IntermediateResponseHandler intermediateResponseHandler) { |
| | | return getPromiseFromResultCode(newResult(resultCode)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeConnectionEventListener(ConnectionEventListener listener) { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LdapPromise<Result> searchAsync(SearchRequest request, |
| | | IntermediateResponseHandler intermediateResponseHandler, SearchResultHandler entryHandler) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return "MockConnection"; |
| | | } |
| | | |
| | | } |
| | | |
| | | @Test |
| | |
| | | verify(exceptionHandler).handleException(any(LdapException.class)); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | * 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-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.responses.ExtendedResult; |
| | | |
| | | /** |
| | | * A connection event listener which records events and signals when it has been |
| | | * notified. |
| | | */ |
| | | /** A connection event listener which records events and signals when it has been notified. */ |
| | | @SuppressWarnings("javadoc") |
| | | public final class MockConnectionEventListener implements ConnectionEventListener { |
| | | private final CountDownLatch closedLatch = new CountDownLatch(1); |
| | |
| | | private ExtendedResult notification; |
| | | private final AtomicInteger invocationCount = new AtomicInteger(); |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionClosed() { |
| | | invocationCount.incrementAndGet(); |
| | | closedLatch.countDown(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionError(boolean isDisconnectNotification, LdapException error) { |
| | | this.isDisconnectNotification = isDisconnectNotification; |
| | |
| | | errorLatch.countDown(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleUnsolicitedNotification(ExtendedResult notification) { |
| | | this.notification = notification; |
| | |
| | | import static org.mockito.Mockito.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Tests all generic code of AbstractSubstringMatchingRuleImpl. |
| | | */ |
| | | /** Tests all generic code of AbstractSubstringMatchingRuleImpl. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class AbstractSubstringMatchingRuleImplTest extends AbstractSchemaTestCase { |
| | | |
| | | private int subStringLength = 3; |
| | | |
| | | private static class FakeSubstringMatchingRuleImpl extends AbstractSubstringMatchingRuleImpl { |
| | | |
| | | FakeSubstringMatchingRuleImpl() { |
| | | super(SMR_CASE_EXACT_OID, EMR_CASE_EXACT_OID); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString normalizeAttributeValue(Schema schema, ByteSequence value) throws DecodeException { |
| | | return value.toByteString(); |
| | | } |
| | | |
| | | } |
| | | |
| | | static class FakeIndexQueryFactory implements IndexQueryFactory<String> { |
| | | |
| | | private final IndexingOptions options; |
| | | private final boolean normalizedValuesAreReadable; |
| | | |
| | |
| | | public IndexingOptions getIndexingOptions() { |
| | | return options; |
| | | } |
| | | |
| | | } |
| | | |
| | | private MatchingRuleImpl getRule() { |
| | |
| | | }; |
| | | } |
| | | |
| | | @Test(dataProvider = "invalidAssertions", expectedExceptions = { DecodeException.class }) |
| | | @Test(dataProvider = "invalidAssertions", expectedExceptions = DecodeException.class) |
| | | public void testInvalidAssertion(String assertionValue) throws Exception { |
| | | getRule().getAssertion(null, valueOfUtf8(assertionValue)); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Attribute type syntax tests. |
| | | */ |
| | | /** Attribute type syntax tests. */ |
| | | @Test |
| | | public class AttributeTypeSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | + " NO-USER-MODIFICATION USAGE userApplications", false }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the BitStringEqualityMatchingRule. |
| | | */ |
| | | /** Test the BitStringEqualityMatchingRule. */ |
| | | public class BitStringEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | { "\'1010\'A" }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "\'0\'B", "\'1\'B", ConditionResult.FALSE }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_BIT_STRING_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | /** Bit string syntax tests. */ |
| | | @Test |
| | | public class BitStringSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_BIT_STRING_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the BooleanEqualityMatchingRule. |
| | | */ |
| | | /** Test the BooleanEqualityMatchingRule. */ |
| | | public class BooleanEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { { "garbage" }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "TRUE", "false", ConditionResult.FALSE }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_BOOLEAN_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the CaseExactEqualityMatchingRule. |
| | | */ |
| | | /** Test the CaseExactEqualityMatchingRule. */ |
| | | public class CaseExactEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "ABC45678", "abc45678", ConditionResult.FALSE }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_CASE_EXACT_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the CaseExactIA5EqualityMatchingRule. |
| | | */ |
| | | /** Test the CaseExactIA5EqualityMatchingRule. */ |
| | | public class CaseExactIA5EqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_CASE_EXACT_IA5_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the CaseExactOrderingMatchingRule. |
| | | */ |
| | | /** Test the CaseExactOrderingMatchingRule. */ |
| | | public class CaseExactOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | |
| | | { "abcdef", "abcdef", 0 }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(OMR_CASE_EXACT_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the CaseIgnoreEqualityMatchingRule. |
| | | */ |
| | | /** Test the CaseIgnoreEqualityMatchingRule. */ |
| | | public class CaseIgnoreEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "foo\u0149bar", "foo\u02BC\u006Ebar", ConditionResult.TRUE }, |
| | | { "foo\u017Bbar", "foo\u017Cbar", ConditionResult.TRUE }, |
| | | { "foo\u017BBAR", "foo\u017Cbar", ConditionResult.TRUE }, |
| | | |
| | | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_CASE_IGNORE_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the CaseExactIA5EqualityMatchingRule. |
| | | */ |
| | | /** Test the CaseExactIA5EqualityMatchingRule. */ |
| | | public class CaseIgnoreIA5EqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | { "ABC45678", "abc45678", ConditionResult.TRUE }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_CASE_IGNORE_IA5_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the CaseIgnoreOrderingMatchingRule. |
| | | */ |
| | | /** Test the CaseIgnoreOrderingMatchingRule. */ |
| | | public class CaseIgnoreOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | |
| | | { "a", "\u00f8", -1 }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(OMR_CASE_IGNORE_OID); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class CollationEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule("fr.eq"); |
| | |
| | | ByteString normalizedValue = matchingRule.normalizeAttributeValue(value); |
| | | assertEquals(indexQuery, "exactMatch(fr.shared, value=='" + normalizedValue.toHexString() + "')"); |
| | | } |
| | | |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class CollationGreaterThanMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule("fr.gt"); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class CollationGreaterThanOrEqualMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule("fr.gte"); |
| | | |
| | | } |
| | | |
| | | @Test |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class CollationLessThanMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule("fr.lt"); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class CollationLessThanOrEqualMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule("fr.lte"); |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class CollationSubstringMatchingRuleTest extends SubstringMatchingRuleTest { |
| | | |
| | | @Override |
| | | @DataProvider(name = "substringInvalidAssertionValues") |
| | | public Object[][] createMatchingRuleInvalidAssertionValues() { |
| | |
| | | return new Object[][] { }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "substringFinalMatchData") |
| | | public Object[][] createSubstringFinalMatchData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "substringInitialMatchData") |
| | | public Object[][] createSubstringInitialMatchData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "substringMiddleMatchData") |
| | | public Object[][] createSubstringMiddleMatchData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule("fr.sub"); |
| | |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012 Manuel Gaupp |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Country String syntax tests. |
| | | */ |
| | | /** Country String syntax tests. */ |
| | | @Test |
| | | public class CountryStringSyntaxTest extends AbstractSyntaxTestCase { |
| | | @Override |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_COUNTRY_STRING_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * DIT content rule syntax tests. |
| | | */ |
| | | /** DIT content rule syntax tests. */ |
| | | public class DITContentRuleSyntaxTest extends AbstractSyntaxTestCase { |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_DIT_CONTENT_RULE_OID); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the DirectoryStringFirstComponentEqualityMatchingRule. |
| | | */ |
| | | /** Test the DirectoryStringFirstComponentEqualityMatchingRule. */ |
| | | @Test |
| | | public class DirectoryStringFirstComponentEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] {}; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_DIRECTORY_STRING_FIRST_COMPONENT_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import static org.forgerock.opendj.ldap.schema.SchemaConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Enum syntax tests. |
| | | */ |
| | | /** Enum syntax tests. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class EnumSyntaxTestCase extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | builder.toSchema(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() throws SchemaException, DecodeException { |
| | | final SchemaBuilder builder = new SchemaBuilder(Schema.getCoreSchema()); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the GeneralizedTimeEqualityMatchingRule. |
| | | */ |
| | | /** Test the GeneralizedTimeEqualityMatchingRule. */ |
| | | public class GeneralizedTimeEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_GENERALIZED_TIME_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the GeneralizedTimeOrderingMatchingRule. |
| | | */ |
| | | /** Test the GeneralizedTimeOrderingMatchingRule. */ |
| | | public class GeneralizedTimeOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(OMR_GENERALIZED_TIME_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Generalized time syntax tests. |
| | | */ |
| | | /** Generalized time syntax tests. */ |
| | | public class GeneralizedTimeSyntaxTest extends AbstractSyntaxTestCase { |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | |
| | | { "2006", false }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_GENERALIZED_TIME_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Guide syntax tests. |
| | | */ |
| | | /** Guide syntax tests. */ |
| | | public class GuideSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "sn$EQ|(cn$APPROX&?false)", true }, { "sn$EQ|(cn$APPROX&|?false)", false }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_GUIDE_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * IA5 string syntax tests. |
| | | */ |
| | | /** IA5 string syntax tests. */ |
| | | public class IA5StringSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | | return new Object[][] { { "12345678", true }, { "12345678\u2163", false }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_IA5_STRING_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the IntegerEqualityMatchingRule. |
| | | */ |
| | | /** Test the IntegerEqualityMatchingRule. */ |
| | | public class IntegerEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_INTEGER_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the IntegerOrderingMatchingRule. |
| | | */ |
| | | /** Test the IntegerOrderingMatchingRule. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class IntegerOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(OMR_INTEGER_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Integer syntax tests. |
| | | */ |
| | | /** Integer syntax tests. */ |
| | | @Test |
| | | public class IntegerSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_INTEGER_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * LDAP syntax tests. |
| | | */ |
| | | /** LDAP syntax tests. */ |
| | | @Test |
| | | public class LDAPSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_LDAP_SYNTAX_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Matching rule syntax tests. |
| | | */ |
| | | /** Matching rule syntax tests. */ |
| | | @Test |
| | | public class MatchingRuleSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | + " X-name ( 'this is an extension' ) ", false }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_MATCHING_RULE_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Matching rule use syntax tests. |
| | | */ |
| | | /** Matching rule use syntax tests. */ |
| | | @Test |
| | | public class MatchingRuleUseSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | + " X-name ( 'this is an extension' ) ", false }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_MATCHING_RULE_USE_OID); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the NumericStringEqualityMatchingRule. |
| | | */ |
| | | /** Test the NumericStringEqualityMatchingRule. */ |
| | | @Test |
| | | public class NumericStringEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_NUMERIC_STRING_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the NumericStringOrderingMatchingRule. |
| | | */ |
| | | /** Test the NumericStringOrderingMatchingRule. */ |
| | | @Test |
| | | public class NumericStringOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(OMR_NUMERIC_STRING_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Other mailbox syntax tests. |
| | | */ |
| | | /** Other mailbox syntax tests. */ |
| | | @Test |
| | | public class OtherMailboxSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | | return new Object[][] { { "MyMail$Mymailbox", true }, { "MyMailMymailbox", false }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_OTHER_MAILBOX_OID); |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class PartialDateAndTimeMatchingRuleTestCase extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return CoreSchema.getInstance().getMatchingRule(SchemaConstants.MR_PARTIAL_DATE_AND_TIME_OID); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the PresentationAddressEqualityMatchingRule. |
| | | */ |
| | | /** Test the PresentationAddressEqualityMatchingRule. */ |
| | | public class PresentationAddressEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_PRESENTATION_ADDRESS_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the ProtocolInformationEqualityMatchingRule. |
| | | */ |
| | | /** Test the ProtocolInformationEqualityMatchingRule. */ |
| | | public class ProtocolInformationEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_PROTOCOL_INFORMATION_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Regex syntax tests. |
| | | */ |
| | | /** Regex syntax tests. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class RegexSyntaxTestCase extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | Assert.assertFalse(builder.toSchema().getWarnings().isEmpty()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | final SchemaBuilder builder = new SchemaBuilder(Schema.getCoreSchema()); |
| | |
| | | .compile("^[a-z-A-Z]+:[0-9.]+\\d$"), false); |
| | | return builder.toSchema().getSyntax("1.1.1"); |
| | | } |
| | | |
| | | } |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class RelativeTimeGreaterThanMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return CoreSchema.getInstance().getMatchingRule(SchemaConstants.OMR_RELATIVE_TIME_GREATER_THAN_OID); |
| | |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class RelativeTimeLessThanMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return CoreSchema.getInstance().getMatchingRule(SchemaConstants.OMR_RELATIVE_TIME_LESS_THAN_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Substitution syntax tests. |
| | | */ |
| | | /** Substitution syntax tests. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class SubstitutionSyntaxTestCase extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | Assert.assertFalse(builder.toSchema().getWarnings().isEmpty()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | // Use IA5String syntax as our substitute. |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2015 ForgeRock AS. |
| | | * Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Telephone number syntax tests. |
| | | */ |
| | | /** Telephone number syntax tests. */ |
| | | @Test |
| | | public class TelephoneNumberSyntaxTest extends AbstractSyntaxTestCase { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "", false } }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | SchemaBuilder builder = new SchemaBuilder(getCoreSchema()).setOption(ALLOW_NON_STANDARD_TELEPHONE_NUMBERS, |
| | | false); |
| | | return builder.toSchema().getSyntax(SYNTAX_TELEPHONE_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Telex syntax tests. |
| | | */ |
| | | /** Telex syntax tests. */ |
| | | @Test |
| | | public class TelexSyntaxTest extends AbstractSyntaxTestCase { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "12345$67890$()+,-./:? ", true }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_TELEX_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * UTC time syntax tests. |
| | | */ |
| | | /** UTC time syntax tests. */ |
| | | public class UTCTimeSyntaxTest extends AbstractSyntaxTestCase { |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_UTC_TIME_OID); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the UUIDEqualityMatchingRule. |
| | | */ |
| | | /** Test the UUIDEqualityMatchingRule. */ |
| | | public class UUIDEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_UUID_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the UUIDOrderingMatchingRule. |
| | | */ |
| | | /** Test the UUIDOrderingMatchingRule. */ |
| | | public class UUIDOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(OMR_UUID_OID); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * UUID syntax tests. |
| | | */ |
| | | /** UUID syntax tests. */ |
| | | @Test |
| | | public class UUIDSyntaxTest extends AbstractSyntaxTestCase { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "acceptableValues") |
| | | public Object[][] createAcceptableValues() { |
| | |
| | | { "12345678-9abc-def0-1234-1234567890a", false }, }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Syntax getRule() { |
| | | return Schema.getCoreSchema().getSyntax(SYNTAX_UUID_OID); |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the UniqueMemberEqualityMatchingRule. |
| | | */ |
| | | /** Test the UniqueMemberEqualityMatchingRule. */ |
| | | @Test |
| | | public class UniqueMemberEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_UNIQUE_MEMBER_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the UserPasswordExactEqualityMatchingRule. |
| | | */ |
| | | /** Test the UserPasswordExactEqualityMatchingRule. */ |
| | | public class UserPasswordExactEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_USER_PASSWORD_EXACT_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.schema; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | |
| | | /** |
| | | * Test the WordEqualityMatchingRule. |
| | | */ |
| | | /** Test the WordEqualityMatchingRule. */ |
| | | public class WordEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected MatchingRule getRule() { |
| | | return Schema.getCoreSchema().getMatchingRule(EMR_WORD_OID); |
| | | } |
| | | |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.ldap.spi; |
| | | |
| | |
| | | return new BasicLDAPListener(address, factory, options); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() { |
| | | return "Basic"; |
| | | } |
| | | |
| | | } |
| | |
| | | import org.apache.maven.project.MavenProject; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * Generates an XML file of log messages found in properties files. |
| | | */ |
| | | /** Generates an XML file of log messages found in properties files. */ |
| | | @Mojo(name = "generate-xml-messages-doc", defaultPhase = PRE_SITE) |
| | | public class GenerateMessageFileMojo extends AbstractMojo { |
| | | |
| | | /** |
| | | * The Maven Project. |
| | | */ |
| | | /** The Maven Project. */ |
| | | @Parameter(property = "project", readonly = true, required = true) |
| | | private MavenProject project; |
| | | |
| | | /** |
| | | * The tag of the locale for which to generate the documentation. |
| | | */ |
| | | /** The tag of the locale for which to generate the documentation. */ |
| | | @Parameter(defaultValue = "en") |
| | | private String locale; |
| | | |
| | | /** |
| | | * The path to the directory containing the message properties files. |
| | | */ |
| | | /** The path to the directory containing the message properties files. */ |
| | | @Parameter(required = true) |
| | | private String messagesDirectory; |
| | | |
| | |
| | | @Parameter(required = true) |
| | | private String outputDirectory; |
| | | |
| | | /** |
| | | * A list which contains all file names, the extension is not needed. |
| | | */ |
| | | /** A list which contains all file names, the extension is not needed. */ |
| | | @Parameter(required = true) |
| | | private List<String> messageFileNames; |
| | | |
| | | /** |
| | | * One-line descriptions for log reference categories. |
| | | */ |
| | | private static final HashMap<String, LocalizableMessage> CATEGORY_DESCRIPTIONS = new HashMap<>(); |
| | | /** One-line descriptions for log reference categories. */ |
| | | private static final Map<String, LocalizableMessage> CATEGORY_DESCRIPTIONS = new HashMap<>(); |
| | | static { |
| | | CATEGORY_DESCRIPTIONS.put("ACCESS_CONTROL", CATEGORY_ACCESS_CONTROL.get()); |
| | | CATEGORY_DESCRIPTIONS.put("ADMIN", CATEGORY_ADMIN.get()); |
| | |
| | | /** Message giving formatting rules for string keys. */ |
| | | public static final String KEY_FORM_MSG = ".\n\nOpenDJ message property keys must be of the form\n\n" |
| | | + "\t\'[CATEGORY]_[SEVERITY]_[DESCRIPTION]_[ORDINAL]\'\n\n"; |
| | | |
| | | private static final String ERROR_SEVERITY_IDENTIFIER_STRING = "ERR_"; |
| | | |
| | | /** FreeMarker template configuration. */ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Represents a log reference entry for an individual message. |
| | | */ |
| | | /** Represents a log reference entry for an individual message. */ |
| | | private static class MessageRefEntry implements Comparable<MessageRefEntry> { |
| | | private Integer ordinal; |
| | | private String xmlId; |
| | | private String formatString; |
| | | |
| | | /** |
| | | * Build log reference entry for an log message. |
| | | */ |
| | | /** Build log reference entry for an log message. */ |
| | | public MessageRefEntry(final String msgPropKey, final Integer ordinal, final String formatString) { |
| | | this.formatString = formatString; |
| | | this.ordinal = ordinal; |
| | |
| | | return this.ordinal; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | if (ordinal != null) { |
| | |
| | | return description; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(MessagePropertyKey k) { |
| | | if (ordinal == k.ordinal) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.grizzly; |
| | | |
| | | import java.io.IOException; |
| | |
| | | */ |
| | | final class LDAPServerFilter extends LDAPBaseFilter { |
| | | |
| | | /** |
| | | * Provides an arbitrary write operation on a LDAP writer. |
| | | */ |
| | | /** Provides an arbitrary write operation on a LDAP writer. */ |
| | | private interface LDAPWrite<T> { |
| | | void perform(LDAPWriter<ASN1BufferWriter> writer, int messageID, T message) |
| | | throws IOException; |
| | | } |
| | | |
| | | /** |
| | | * Write operation for intermediate responses. |
| | | */ |
| | | /** Write operation for intermediate responses. */ |
| | | private static final LDAPWrite<IntermediateResponse> INTERMEDIATE = |
| | | new LDAPWrite<IntermediateResponse>() { |
| | | @Override |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | |
| | | protected void writeResult(LDAPWriter<ASN1BufferWriter> writer, CompareResult result) |
| | | throws IOException { |
| | | writer.writeCompareResult(messageID, result); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | }; |
| | | |
| | | // @formatter:on |
| | | /** |
| | | * Default maximum request size for incoming requests. |
| | | */ |
| | | /** Default maximum request size for incoming requests. */ |
| | | private static final int DEFAULT_MAX_REQUEST_SIZE = 5 * 1024 * 1024; |
| | | |
| | | private static final Attribute<ClientContextImpl> LDAP_CONNECTION_ATTR = |
| | |
| | | |
| | | private static final class ServerRequestHandler extends AbstractLDAPMessageHandler implements |
| | | LDAPBaseHandler { |
| | | |
| | | private final Connection<?> connection; |
| | | private final LDAPReader<ASN1BufferReader> reader; |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.grizzly; |
| | | |
| | |
| | | import static org.forgerock.util.Options.defaultOptions; |
| | | import static org.mockito.Mockito.*; |
| | | |
| | | /** |
| | | * Tests the LDAPListener class. |
| | | */ |
| | | /** Tests the LDAPListener class. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class GrizzlyLDAPListenerTestCase extends SdkTestCase { |
| | | |
| | |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAbandon(final Integer requestContext, final AbandonRequest request) |
| | | throws UnsupportedOperationException { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAdd(final Integer requestContext, final AddRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final Integer requestContext, final int version, |
| | | final BindRequest request, |
| | |
| | | resultHandler.handleResult(Responses.newBindResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleCompare(final Integer requestContext, final CompareRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newCompareResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionClosed(final Integer requestContext, final UnbindRequest request) { |
| | | isClosed.countDown(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionDisconnected(final ResultCode resultCode, final String message) { |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleConnectionError(final Throwable error) { |
| | | connectionError.handleResult(error); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleDelete(final Integer requestContext, final DeleteRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R extends ExtendedResult> void handleExtendedRequest(final Integer requestContext, |
| | | final ExtendedRequest<R> request, |
| | |
| | | "Extended operation " + request.getOID() + " not supported"))); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModify(final Integer requestContext, final ModifyRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModifyDN(final Integer requestContext, final ModifyDNRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleSearch(final Integer requestContext, final SearchRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler, |
| | | final LdapResultHandler<Result> resultHandler) throws UnsupportedOperationException { |
| | | resultHandler.handleResult(Responses.newResult(ResultCode.SUCCESS)); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static class MockServerConnectionFactory implements |
| | | ServerConnectionFactory<LDAPClientContext, Integer> { |
| | | |
| | | private final MockServerConnection serverConnection; |
| | | |
| | | private MockServerConnectionFactory(final MockServerConnection serverConnection) { |
| | | this.serverConnection = serverConnection; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ServerConnection<Integer> handleAccept(final LDAPClientContext clientContext) throws LdapException { |
| | | serverConnection.context.handleResult(clientContext); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Disables logging before the tests. |
| | | */ |
| | | /** Disables logging before the tests. */ |
| | | @BeforeClass |
| | | public void disableLogging() { |
| | | TestCaseUtils.setDefaultLogLevel(Level.SEVERE); |
| | | } |
| | | |
| | | /** |
| | | * Re-enable logging after the tests. |
| | | */ |
| | | /** Re-enable logging after the tests. */ |
| | | @AfterClass |
| | | public void enableLogging() { |
| | | TestCaseUtils.setDefaultLogLevel(Level.INFO); |
| | | } |
| | | |
| | | /** |
| | | * Test creation of LDAP listener with default transport provider. |
| | | */ |
| | | /** Test creation of LDAP listener with default transport provider. */ |
| | | @SuppressWarnings("unchecked") |
| | | @Test |
| | | public void testCreateLDAPListener() throws Exception { |
| | |
| | | listener.close(); |
| | | } |
| | | |
| | | /** |
| | | * Test creation of LDAP listener with default transport provider and custom class loader. |
| | | */ |
| | | /** Test creation of LDAP listener with default transport provider and custom class loader. */ |
| | | @SuppressWarnings("unchecked") |
| | | @Test |
| | | public void testCreateLDAPListenerWithCustomClassLoader() throws Exception { |
| | |
| | | listener.close(); |
| | | } |
| | | |
| | | /** |
| | | * Test creation of LDAP listener with unknown transport provider. |
| | | */ |
| | | /** Test creation of LDAP listener with unknown transport provider. */ |
| | | @SuppressWarnings({ "unchecked" }) |
| | | @Test(expectedExceptions = { ProviderNotFoundException.class }, |
| | | @Test(expectedExceptions = ProviderNotFoundException.class, |
| | | expectedExceptionsMessageRegExp = "^The requested provider 'unknown' .*") |
| | | public void testCreateLDAPListenerFailureProviderNotFound() throws Exception { |
| | | Options options = defaultOptions().set(TRANSPORT_PROVIDER, "unknown"); |
| | |
| | | |
| | | final MockServerConnection proxyServerConnection = new MockServerConnection() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final Integer requestContext, final int version, |
| | | final BindRequest request, |
| | |
| | | try { |
| | | final MockServerConnection proxyServerConnection = new MockServerConnection() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final Integer requestContext, final int version, |
| | | final BindRequest request, |
| | |
| | | this.bindFactory = bindFactory; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleAdd(final RequestContext requestContext, final AddRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final LdapResultHandler<Result> resultHandler) { |
| | |
| | | }).thenOnResult(resultHandler).thenOnException(resultHandler).thenAlways(close(connectionHolder)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleBind(final RequestContext requestContext, final int version, final BindRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | }).thenOnException(resultHandler).thenAlways(close(connectionHolder)); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleCompare(final RequestContext requestContext, final CompareRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | }).thenOnResult(resultHandler).thenOnException(resultHandler).thenAlways(close(connectionHolder)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleDelete(final RequestContext requestContext, final DeleteRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | }).thenOnResult(resultHandler).thenOnException(resultHandler).thenAlways(close(connectionHolder)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R extends ExtendedResult> void handleExtendedRequest(final RequestContext requestContext, |
| | | final ExtendedRequest<R> request, final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModify(final RequestContext requestContext, final ModifyRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | |
| | | }).thenOnResult(resultHandler).thenOnException(resultHandler).thenAlways(close(connectionHolder)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleModifyDN(final RequestContext requestContext, final ModifyDNRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final LdapResultHandler<Result> resultHandler) { |
| | |
| | | }).thenOnResult(resultHandler).thenOnException(resultHandler).thenAlways(close(connectionHolder)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void handleSearch(final RequestContext requestContext, final SearchRequest request, |
| | | final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler, |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2015 ForgeRock AS. |
| | | * Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.examples; |
| | | |
| | |
| | | public final class SearchAsync { |
| | | // --- JCite search result handler --- |
| | | private static final class SearchResultHandlerImpl implements SearchResultHandler { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public synchronized boolean handleEntry(final SearchResultEntry entry) { |
| | | try { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public synchronized boolean handleReference(final SearchResultReference reference) { |
| | | try { |
| | |
| | | |
| | | /** Thread local copies of the data sources. */ |
| | | private final ThreadLocal<DataSource[]> dataSources = new ThreadLocal<DataSource[]>() { |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected DataSource[] initialValue() { |
| | | final DataSource[] prototypes = getDataSources(); |
| | |
| | | |
| | | private int targetThroughput; |
| | | private int maxIterations; |
| | | /** Warm-up duration time in ms. **/ |
| | | /** Warm-up duration time in ms. */ |
| | | private long warmUpDurationMs; |
| | | /** Max duration time in ms, 0 for unlimited. **/ |
| | | /** Max duration time in ms, 0 for unlimited. */ |
| | | private long maxDurationTimeMs; |
| | | private boolean noRebind; |
| | | private BindRequest bindRequest; |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.rest2ldap; |
| | | |
| | |
| | | private static final class CachedRead implements SearchResultHandler, LdapResultHandler<Result> { |
| | | private SearchResultEntry cachedEntry; |
| | | private final String cachedFilterString; |
| | | /** Guarded by cachedPromiseLatch.*/ |
| | | /** Guarded by cachedPromiseLatch. */ |
| | | private LdapPromise<Result> cachedPromise; |
| | | private final CountDownLatch cachedPromiseLatch = new CountDownLatch(1); |
| | | private final SearchRequest cachedRequest; |
| | |
| | | searchResultHandler.handleEntry(cachedEntry); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | this.config = config; |
| | | this.context = context; |
| | | |
| | | /* |
| | | * Re-use the pre-authenticated connection if available and the |
| | | * authorization policy allows. |
| | | */ |
| | | /* Re-use the pre-authenticated connection if available and the authorization policy allows. */ |
| | | if (config.getAuthorizationPolicy() != AuthorizationPolicy.NONE |
| | | && context.containsContext(AuthenticatedConnectionContext.class)) { |
| | | this.connection = wrap(context.asContext(AuthenticatedConnectionContext.class).getConnection()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() { |
| | | connection.close(); |
| | |
| | | * if needed. |
| | | */ |
| | | private Connection wrap(final Connection connection) { |
| | | /* |
| | | * We only use async methods so no need to wrap sync methods. |
| | | */ |
| | | /* We only use async methods so no need to wrap sync methods. */ |
| | | return new AbstractAsynchronousConnection() { |
| | | @Override |
| | | public LdapPromise<Void> abandonAsync(final AbandonRequest request) { |
| | |
| | | } |
| | | }; |
| | | } |
| | | |
| | | } |