Fix OPENDJ-597: Remove superfluous ByteString based constructors
* use ByteString.valueOf(Object) where possible
* use byte[] instead of ByteString in remaining methods which handle sensitive information such as passwords.
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean addAll(final Collection<? extends ByteString> values, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | public <T> boolean addAll(final Collection<T> values, |
| | | final Collection<? super T> duplicateValues) { |
| | | boolean modified = false; |
| | | for (final ByteString value : values) { |
| | | for (final T value : values) { |
| | | if (add(value)) { |
| | | modified = true; |
| | | } else if (duplicateValues != null) { |
| | |
| | | */ |
| | | @Override |
| | | public boolean containsAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | final Attribute a = getAttribute(attribute.getAttributeDescription()); |
| | | if (a == null) { |
| | | if (missingValues != null) { |
| | |
| | | */ |
| | | @Override |
| | | public boolean removeAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | final Iterator<Attribute> i = getAllAttributes().iterator(); |
| | | final AttributeDescription attributeDescription = attribute.getAttributeDescription(); |
| | | while (i.hasNext()) { |
| | |
| | | */ |
| | | @Override |
| | | public final boolean addAttribute(final Attribute attribute, |
| | | final Collection<ByteString> duplicateValues) { |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | final AttributeDescription attributeDescription = attribute.getAttributeDescription(); |
| | | final Attribute oldAttribute = getAttribute(attributeDescription); |
| | | if (oldAttribute != null) { |
| | |
| | | */ |
| | | @Override |
| | | public final boolean removeAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | final AttributeDescription attributeDescription = attribute.getAttributeDescription(); |
| | | if (attribute.isEmpty()) { |
| | | if (attributes.remove(attributeDescription) != null) { |
| | |
| | | * equality matching rule associated with the attribute description. |
| | | * <p> |
| | | * Any methods which accept {@code Object} based attribute values convert the |
| | | * attribute values to instances of {@code ByteString} as follows: |
| | | * |
| | | * <pre> |
| | | * Object object = ...; |
| | | * ByteString value = null; |
| | | * if (object instanceof ByteSequence) |
| | | * { |
| | | * value = ((ByteSequence)object).toByteString(); |
| | | * } |
| | | * else |
| | | * { |
| | | * value = ByteString.valueOf(object.toString()); |
| | | * } |
| | | * </pre> |
| | | * <p> |
| | | * attribute values to instances of {@code ByteString} using |
| | | * {@link ByteString#valueOf(Object)}. |
| | | */ |
| | | public interface Attribute extends Set<ByteString> { |
| | | // TODO: matching against attribute value assertions. |
| | |
| | | * attribute if they are not already present (optional operation). Any |
| | | * attribute values which are already present will be added to |
| | | * {@code duplicateValues} if specified. |
| | | * <p> |
| | | * Any attribute values which are not instances of {@code ByteString} will |
| | | * be converted using the {@link ByteString#valueOf(Object)} method. |
| | | * |
| | | * @param <T> |
| | | * The type of the attribute value objects being added. |
| | | * @param values |
| | | * The attribute values to be added to this attribute. |
| | | * @param duplicateValues |
| | |
| | | * @throws NullPointerException |
| | | * If {@code values} was {@code null}. |
| | | */ |
| | | boolean addAll(Collection<? extends ByteString> values, |
| | | Collection<? super ByteString> duplicateValues); |
| | | <T> boolean addAll(Collection<T> values, Collection<? super T> duplicateValues); |
| | | |
| | | /** |
| | | * Removes all of the attribute values from this attribute (optional |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAll(final Collection<? extends ByteString> values, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | public <T> boolean addAll(final Collection<T> values, |
| | | final Collection<? super T> duplicateValues) { |
| | | return attribute.addAll(values, duplicateValues); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean addAll(final Collection<? extends ByteString> values, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | public <T> boolean addAll(final Collection<T> values, |
| | | final Collection<? super T> duplicateValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean addAttribute(final Attribute attribute, |
| | | final Collection<ByteString> duplicateValues) { |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public boolean containsAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | return entry.containsAttribute(attribute, missingValues); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean removeAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | * @throws NullPointerException |
| | | * If {@code attribute} was {@code null}. |
| | | */ |
| | | boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues); |
| | | boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues); |
| | | |
| | | /** |
| | | * Ensures that this entry contains the provided attribute and values |
| | |
| | | * @throws NullPointerException |
| | | * If {@code attribute} was {@code null}. |
| | | */ |
| | | boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues); |
| | | boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues); |
| | | |
| | | /** |
| | | * Returns {@code true} if this entry contains all of the attribute values |
| | |
| | | * @throws NullPointerException |
| | | * If {@code attribute} was {@code null}. |
| | | */ |
| | | boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues); |
| | | boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues); |
| | | |
| | | /** |
| | | * Removes the named attribute from this entry if it is present (optional |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean addAll(final Collection<? extends ByteString> values, |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | Validator.ensureNotNull(values); |
| | | |
| | | // TODO: could optimize if objects is a LinkedAttribute having the same |
| | | // equality matching rule. |
| | | boolean modified = false; |
| | | for (final ByteString value : values) { |
| | | if (add(value)) { |
| | | modified = true; |
| | | } else if (duplicateValues != null) { |
| | | duplicateValues.add(value); |
| | | } |
| | | } |
| | | return modified; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void clear() { |
| | | pimpl.clear(this); |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <T> boolean removeAll(final Collection<T> values, |
| | | final Collection<? super T> missingValues) { |
| | | Validator.ensureNotNull(values); |
| | | |
| | | // TODO: could optimize if objects is a LinkedAttribute having the same |
| | | // equality matching rule. |
| | | boolean modified = false; |
| | | for (final T value : values) { |
| | | if (remove(ByteString.valueOf(value))) { |
| | | modified = true; |
| | | } else if (missingValues != null) { |
| | | missingValues.add(value); |
| | | } |
| | | } |
| | | return modified; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <T> boolean retainAll(final Collection<T> values, |
| | | final Collection<? super T> missingValues) { |
| | | Validator.ensureNotNull(values); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues); |
| | | boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues); |
| | | boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues); |
| | | boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean addAttribute(final Attribute attribute, |
| | | final Collection<ByteString> duplicateValues) { |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | return entry.addAttribute(attribute, duplicateValues); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean containsAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | return entry.containsAttribute(attribute, missingValues); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean removeAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | return entry.removeAttribute(attribute, missingValues); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * Sets the assertion value to be compared. |
| | | * |
| | | * @param value |
| | | * The assertion value to be compared. |
| | | * @return This compare request. |
| | | * @throws UnsupportedOperationException |
| | | * If this compare request does not permit the assertion value |
| | | * to be set. |
| | | * @throws NullPointerException |
| | | * If {@code value} was {@code null}. |
| | | */ |
| | | CompareRequest setAssertionValue(ByteString value); |
| | | |
| | | /** |
| | | * Sets the assertion value to be compared. |
| | | * <p> |
| | | * If the assertion value is not an instance of {@code ByteString} then it |
| | | * will be converted using the {@link ByteString#valueOf(Object)} method. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public CompareRequest setAssertionValue(final ByteString value) { |
| | | Validator.ensureNotNull(value); |
| | | this.assertionValue = value; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public CompareRequest setAssertionValue(final Object value) { |
| | | Validator.ensureNotNull(value); |
| | | this.assertionValue = ByteString.valueOf(value); |
| | |
| | | /** |
| | | * Sets the value, if any, associated with this extended request. Its format |
| | | * is defined by the specification of this extended request. |
| | | * <p> |
| | | * If {@code value} is not an instance of {@code ByteString} then it will be |
| | | * converted using the {@link ByteString#valueOf(Object)} method. |
| | | * |
| | | * @param bytes |
| | | * The value associated with this extended request, or |
| | | * {@code null} if there is no value. |
| | | * @param value |
| | | * TThe value associated with this extended request, or |
| | | * {@code null} if there is no value. Its format is defined by |
| | | * the specification of this control. |
| | | * @return This generic extended request. |
| | | * @throws UnsupportedOperationException |
| | | * If this generic extended request does not permit the request |
| | | * value to be set. |
| | | */ |
| | | GenericExtendedRequest setValue(ByteString bytes); |
| | | GenericExtendedRequest setValue(Object value); |
| | | } |
| | |
| | | return (GenericExtendedRequest) request; |
| | | } else { |
| | | final GenericExtendedRequest newRequest = |
| | | new GenericExtendedRequestImpl(request.getOID(), request.getValue()); |
| | | new GenericExtendedRequestImpl(request.getOID()).setValue(request |
| | | .getValue()); |
| | | |
| | | for (final Control control : request.getControls()) { |
| | | newRequest.addControl(control); |
| | |
| | | private static final GenericExtendedResultDecoder RESULT_DECODER = |
| | | new GenericExtendedResultDecoder(); |
| | | |
| | | private ByteString requestValue = ByteString.empty(); |
| | | |
| | | private ByteString requestValue = null; |
| | | private String requestName; |
| | | |
| | | /** |
| | | * Creates a new generic extended request using the provided name and |
| | | * optional value. |
| | | * Creates a new generic extended request using the provided name. |
| | | * |
| | | * @param requestName |
| | | * The dotted-decimal representation of the unique OID |
| | | * corresponding to this extended request. |
| | | * @param requestValue |
| | | * The content of this generic extended request in a form defined |
| | | * by the extended operation, or {@code null} if there is no |
| | | * content. |
| | | * @throws NullPointerException |
| | | * If {@code requestName} was {@code null}. |
| | | */ |
| | | GenericExtendedRequestImpl(final String requestName, final ByteString requestValue) { |
| | | GenericExtendedRequestImpl(final String requestName) { |
| | | this.requestName = requestName; |
| | | this.requestValue = requestValue; |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public GenericExtendedRequest setValue(final ByteString bytes) { |
| | | this.requestValue = bytes; |
| | | public GenericExtendedRequest setValue(final Object value) { |
| | | this.requestValue = value != null ? ByteString.valueOf(value) : null; |
| | | return this; |
| | | } |
| | | |
| | |
| | | * @return The desired password for the user, or {@code null} if a new |
| | | * password should be generated. |
| | | */ |
| | | ByteString getNewPassword(); |
| | | byte[] getNewPassword(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | * @return The current password for the user, or {@code null} if the |
| | | * password is not known. |
| | | */ |
| | | ByteString getOldPassword(); |
| | | byte[] getOldPassword(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | * If this password modify extended request does not permit the |
| | | * new password to be set. |
| | | */ |
| | | PasswordModifyExtendedRequest setNewPassword(ByteString newPassword); |
| | | PasswordModifyExtendedRequest setNewPassword(byte[] newPassword); |
| | | |
| | | /** |
| | | * Sets the desired password for the user. The password will be converted to |
| | |
| | | * If this password modify extended request does not permit the |
| | | * old password to be set. |
| | | */ |
| | | PasswordModifyExtendedRequest setOldPassword(ByteString oldPassword); |
| | | PasswordModifyExtendedRequest setOldPassword(byte[] oldPassword); |
| | | |
| | | /** |
| | | * Sets the current password for the user. The password will be converted to |
| | |
| | | /** |
| | | * Sets the identity of the user whose password is to be modified. The |
| | | * identity may or may not be a distinguished name. |
| | | * <p> |
| | | * If {@code userIdentity} is not an instance of {@code ByteString} then it |
| | | * will be converted using the {@link ByteString#valueOf(Object)} method. |
| | | * |
| | | * @param userIdentity |
| | | * The identity of the user whose password is to be modified, or |
| | |
| | | * If this password modify extended request does not permit the |
| | | * user identity to be set. |
| | | */ |
| | | PasswordModifyExtendedRequest setUserIdentity(ByteString userIdentity); |
| | | |
| | | /** |
| | | * Sets the identity of the user whose password is to be modified. The |
| | | * identity may or may not be a distinguished name. The identity will be |
| | | * converted to a UTF-8 octet string. |
| | | * |
| | | * @param userIdentity |
| | | * The identity of the user whose password is to be modified, or |
| | | * {@code null} if the request should be applied to the user |
| | | * currently associated with the session. |
| | | * @return This password modify request. |
| | | * @throws UnsupportedOperationException |
| | | * If this password modify extended request does not permit the |
| | | * user identity to be set. |
| | | */ |
| | | PasswordModifyExtendedRequest setUserIdentity(String userIdentity); |
| | | PasswordModifyExtendedRequest setUserIdentity(Object userIdentity); |
| | | |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult; |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * Password modify extended request implementation. |
| | | */ |
| | |
| | | } |
| | | if (reader.hasNextElement() |
| | | && (reader.peekType() == TYPE_PASSWORD_MODIFY_OLD_PASSWORD)) { |
| | | newRequest.setOldPassword(reader.readOctetString()); |
| | | newRequest.setOldPassword(reader.readOctetString().toByteArray()); |
| | | } |
| | | if (reader.hasNextElement() |
| | | && (reader.peekType() == TYPE_PASSWORD_MODIFY_NEW_PASSWORD)) { |
| | | newRequest.setNewPassword(reader.readOctetString()); |
| | | newRequest.setNewPassword(reader.readOctetString().toByteArray()); |
| | | } |
| | | reader.readEndSequence(); |
| | | } catch (final IOException e) { |
| | |
| | | final ASN1Reader asn1Reader = ASN1.getReader(responseValue); |
| | | asn1Reader.readStartSequence(); |
| | | if (asn1Reader.peekType() == TYPE_PASSWORD_MODIFY_GENERATED_PASSWORD) { |
| | | newResult.setGeneratedPassword(asn1Reader.readOctetString()); |
| | | newResult.setGeneratedPassword(asn1Reader.readOctetString() |
| | | .toByteArray()); |
| | | } |
| | | asn1Reader.readEndSequence(); |
| | | } catch (final IOException e) { |
| | |
| | | private static final byte TYPE_PASSWORD_MODIFY_GENERATED_PASSWORD = (byte) 0x80; |
| | | |
| | | private ByteString userIdentity = null; |
| | | |
| | | private ByteString oldPassword = null; |
| | | |
| | | private ByteString newPassword = null; |
| | | private byte[] oldPassword = null; |
| | | private byte[] newPassword = null; |
| | | |
| | | private static final ExtendedResultDecoder<PasswordModifyExtendedResult> RESULT_DECODER = |
| | | new ResultDecoder(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ByteString getNewPassword() { |
| | | public byte[] getNewPassword() { |
| | | return newPassword; |
| | | } |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ByteString getOldPassword() { |
| | | public byte[] getOldPassword() { |
| | | return oldPassword; |
| | | } |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedRequest setNewPassword(final ByteString newPassword) { |
| | | public PasswordModifyExtendedRequest setNewPassword(final byte[] newPassword) { |
| | | this.newPassword = newPassword; |
| | | return this; |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedRequest setNewPassword(final char[] newPassword) { |
| | | this.newPassword = (newPassword != null) ? ByteString.valueOf(newPassword) : null; |
| | | this.newPassword = (newPassword != null) ? StaticUtils.getBytes(newPassword) : null; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedRequest setOldPassword(final ByteString oldPassword) { |
| | | public PasswordModifyExtendedRequest setOldPassword(final byte[] oldPassword) { |
| | | this.oldPassword = oldPassword; |
| | | return this; |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedRequest setOldPassword(final char[] oldPassword) { |
| | | this.oldPassword = (oldPassword != null) ? ByteString.valueOf(oldPassword) : null; |
| | | this.oldPassword = (oldPassword != null) ? StaticUtils.getBytes(oldPassword) : null; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedRequest setUserIdentity(final ByteString userIdentity) { |
| | | this.userIdentity = userIdentity; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedRequest setUserIdentity(final String userIdentity) { |
| | | public PasswordModifyExtendedRequest setUserIdentity(final Object userIdentity) { |
| | | this.userIdentity = (userIdentity != null) ? ByteString.valueOf(userIdentity) : null; |
| | | return this; |
| | | } |
| | |
| | | /** |
| | | * Creates a new compare request using the provided distinguished name, |
| | | * attribute name, and assertion value. |
| | | * <p> |
| | | * If the assertion value is not an instance of {@code ByteString} then it |
| | | * will be converted using the {@link ByteString#valueOf(Object)} method. |
| | | * |
| | | * @param name |
| | | * The distinguished name of the entry to be compared. |
| | |
| | | * {@code assertionValue} was {@code null}. |
| | | */ |
| | | public static CompareRequest newCompareRequest(final DN name, |
| | | final AttributeDescription attributeDescription, final ByteString assertionValue) { |
| | | final AttributeDescription attributeDescription, final Object assertionValue) { |
| | | Validator.ensureNotNull(name, attributeDescription, assertionValue); |
| | | return new CompareRequestImpl(name, attributeDescription, assertionValue); |
| | | return new CompareRequestImpl(name, attributeDescription, ByteString |
| | | .valueOf(assertionValue)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static GenericExtendedRequest newGenericExtendedRequest(final String requestName) { |
| | | Validator.ensureNotNull(requestName); |
| | | return new GenericExtendedRequestImpl(requestName, null); |
| | | return new GenericExtendedRequestImpl(requestName); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new generic extended request using the provided name and |
| | | * optional value. |
| | | * <p> |
| | | * If the request value is not an instance of {@code ByteString} then it |
| | | * will be converted using the {@link ByteString#valueOf(Object)} method. |
| | | * |
| | | * @param requestName |
| | | * The dotted-decimal representation of the unique OID |
| | |
| | | * If {@code requestName} was {@code null}. |
| | | */ |
| | | public static GenericExtendedRequest newGenericExtendedRequest(final String requestName, |
| | | final ByteString requestValue) { |
| | | final Object requestValue) { |
| | | Validator.ensureNotNull(requestName); |
| | | return new GenericExtendedRequestImpl(requestName, requestValue); |
| | | return new GenericExtendedRequestImpl(requestName).setValue(requestValue); |
| | | } |
| | | |
| | | /** |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues) { |
| | | public boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues) { |
| | | public boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues) { |
| | | return impl.containsAttribute(attribute, missingValues); |
| | | } |
| | | |
| | |
| | | return impl.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | public boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues) { |
| | | public boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | return impl.getName(); |
| | | } |
| | | |
| | | public CompareRequest setAssertionValue(ByteString value) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public CompareRequest setAssertionValue(Object value) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.responses.GenericExtendedResult; |
| | | |
| | | /** |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public GenericExtendedRequest setValue(ByteString bytes) { |
| | | public GenericExtendedRequest setValue(Object value) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * Unmodifiable password modify extended request implementation. |
| | | */ |
| | |
| | | super(impl); |
| | | } |
| | | |
| | | public ByteString getNewPassword() { |
| | | return impl.getNewPassword(); |
| | | public byte[] getNewPassword() { |
| | | // Defensive copy. |
| | | return StaticUtils.copyOfBytes(impl.getNewPassword()); |
| | | } |
| | | |
| | | public ByteString getOldPassword() { |
| | | return impl.getOldPassword(); |
| | | public byte[] getOldPassword() { |
| | | // Defensive copy. |
| | | return StaticUtils.copyOfBytes(impl.getOldPassword()); |
| | | } |
| | | |
| | | public ByteString getUserIdentity() { |
| | |
| | | return impl.getUserIdentityAsString(); |
| | | } |
| | | |
| | | public PasswordModifyExtendedRequest setNewPassword(ByteString newPassword) { |
| | | public PasswordModifyExtendedRequest setNewPassword(byte[] newPassword) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public PasswordModifyExtendedRequest setOldPassword(ByteString oldPassword) { |
| | | public PasswordModifyExtendedRequest setOldPassword(byte[] oldPassword) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public PasswordModifyExtendedRequest setUserIdentity(ByteString userIdentity) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public PasswordModifyExtendedRequest setUserIdentity(String userIdentity) { |
| | | public PasswordModifyExtendedRequest setUserIdentity(Object userIdentity) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Sets the value, if any, associated with this extended result. Its format |
| | | * is defined by the specification of this extended result. |
| | | * <p> |
| | | * If {@code value} is not an instance of {@code ByteString} then it will be |
| | | * converted using the {@link ByteString#valueOf(Object)} method. |
| | | * |
| | | * @param bytes |
| | | * @param value |
| | | * The value associated with this extended result, or |
| | | * {@code null} if there is no value. |
| | | * @return This generic extended result. |
| | |
| | | * If this generic extended result does not permit the result |
| | | * value to be set. |
| | | */ |
| | | GenericExtendedResult setValue(ByteString bytes); |
| | | GenericExtendedResult setValue(Object value); |
| | | |
| | | } |
| | |
| | | implements ExtendedResult, GenericExtendedResult { |
| | | |
| | | private String responseName = null; |
| | | |
| | | private ByteString responseValue = null; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public GenericExtendedResult setValue(final ByteString bytes) { |
| | | this.responseValue = bytes; |
| | | public GenericExtendedResult setValue(final Object value) { |
| | | this.responseValue = value != null ? ByteString.valueOf(value) : null; |
| | | return this; |
| | | } |
| | | |
| | |
| | | /** |
| | | * Sets the value, if any, associated with this intermediate response. Its |
| | | * format is defined by the specification of this intermediate response. |
| | | * <p> |
| | | * If {@code value} is not an instance of {@code ByteString} then it will be |
| | | * converted using the {@link ByteString#valueOf(Object)} method. |
| | | * |
| | | * @param bytes |
| | | * @param value |
| | | * The value associated with this intermediate response, or |
| | | * {@code null} if there is no value. |
| | | * @return This generic intermediate response. |
| | |
| | | * If this intermediate response does not permit the response |
| | | * value to be set. |
| | | */ |
| | | GenericIntermediateResponse setValue(ByteString bytes); |
| | | GenericIntermediateResponse setValue(Object value); |
| | | |
| | | } |
| | |
| | | GenericIntermediateResponse { |
| | | |
| | | private String responseName = null; |
| | | |
| | | private ByteString responseValue = null; |
| | | |
| | | /** |
| | | * Creates a new generic intermediate response using the provided response |
| | | * name and value. |
| | | * |
| | | * @param responseName |
| | | * The dotted-decimal representation of the unique OID |
| | | * corresponding to this intermediate response, which may be |
| | | * {@code null} indicating that none was provided. |
| | | * @param responseValue |
| | | * The response value associated with this generic intermediate |
| | | * response, which may be {@code null} indicating that none was |
| | | * provided. |
| | | * Creates a new generic intermediate response with no name or value. |
| | | */ |
| | | GenericIntermediateResponseImpl(final String responseName, final ByteString responseValue) { |
| | | this.responseName = responseName; |
| | | this.responseValue = responseValue; |
| | | GenericIntermediateResponseImpl() { |
| | | // Nothing to do. |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public GenericIntermediateResponse setValue(final ByteString bytes) { |
| | | this.responseValue = bytes; |
| | | public GenericIntermediateResponse setValue(final Object value) { |
| | | this.responseValue = value != null ? ByteString.valueOf(value) : null; |
| | | return this; |
| | | } |
| | | |
| | |
| | | * @return The newly generated password, or {@code null} if the password |
| | | * modify request failed or a generated password was not requested. |
| | | */ |
| | | ByteString getGeneratedPassword(); |
| | | byte[] getGeneratedPassword(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | * If this password modify extended result does not permit the |
| | | * generated password to be set. |
| | | */ |
| | | PasswordModifyExtendedResult setGeneratedPassword(ByteString password); |
| | | PasswordModifyExtendedResult setGeneratedPassword(byte[] password); |
| | | |
| | | /** |
| | | * Sets the generated password. The password will be converted to a UTF-8 |
| | |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * Password modify extended result implementation. |
| | | */ |
| | | final class PasswordModifyExtendedResultImpl extends |
| | | AbstractExtendedResult<PasswordModifyExtendedResult> implements |
| | | PasswordModifyExtendedResult { |
| | | private ByteString password; |
| | | private byte[] password; |
| | | |
| | | /** |
| | | * The ASN.1 element type that will be used to encode the genPasswd |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ByteString getGeneratedPassword() { |
| | | public byte[] getGeneratedPassword() { |
| | | return password; |
| | | } |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedResult setGeneratedPassword(final ByteString password) { |
| | | public PasswordModifyExtendedResult setGeneratedPassword(final byte[] password) { |
| | | this.password = password; |
| | | return this; |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public PasswordModifyExtendedResult setGeneratedPassword(final char[] password) { |
| | | this.password = (password != null) ? ByteString.valueOf(password) : null; |
| | | this.password = (password != null) ? StaticUtils.getBytes(password) : null; |
| | | return this; |
| | | } |
| | | |
| | |
| | | * @return The new generic intermediate response. |
| | | */ |
| | | public static GenericIntermediateResponse newGenericIntermediateResponse() { |
| | | return new GenericIntermediateResponseImpl(null, null); |
| | | return new GenericIntermediateResponseImpl(); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new generic intermediate response using the provided response |
| | | * name and value. |
| | | * <p> |
| | | * If the response value is not an instance of {@code ByteString} then it |
| | | * will be converted using the {@link ByteString#valueOf(Object)} method. |
| | | * |
| | | * @param responseName |
| | | * The dotted-decimal representation of the unique OID |
| | |
| | | * @return The new generic intermediate response. |
| | | */ |
| | | public static GenericIntermediateResponse newGenericIntermediateResponse( |
| | | final String responseName, final ByteString responseValue) { |
| | | return new GenericIntermediateResponseImpl(responseName, responseValue); |
| | | final String responseName, final Object responseValue) { |
| | | return new GenericIntermediateResponseImpl().setOID(responseName).setValue(responseValue); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues); |
| | | boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues); |
| | | boolean containsAttribute(Attribute attribute, Collection<? super ByteString> missingValues); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues); |
| | | boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean addAttribute(final Attribute attribute, |
| | | final Collection<ByteString> duplicateValues) { |
| | | final Collection<? super ByteString> duplicateValues) { |
| | | return entry.addAttribute(attribute, duplicateValues); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean containsAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | return entry.containsAttribute(attribute, missingValues); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean removeAttribute(final Attribute attribute, |
| | | final Collection<ByteString> missingValues) { |
| | | final Collection<? super ByteString> missingValues) { |
| | | return entry.removeAttribute(attribute, missingValues); |
| | | } |
| | | |
| | |
| | | |
| | | package org.forgerock.opendj.ldap.responses; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * Unmodifiable Generic extended result implementation. |
| | | */ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public GenericExtendedResult setValue(ByteString bytes) { |
| | | public GenericExtendedResult setValue(Object value) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | } |
| | |
| | | |
| | | package org.forgerock.opendj.ldap.responses; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * Unmodifiable Generic extended result implementation. |
| | | */ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public GenericIntermediateResponse setValue(ByteString bytes) { |
| | | public GenericIntermediateResponse setValue(Object value) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | } |
| | |
| | | |
| | | package org.forgerock.opendj.ldap.responses; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | /** |
| | | * Unmodifiable Password modify extended result implementation. |
| | | */ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ByteString getGeneratedPassword() { |
| | | public byte[] getGeneratedPassword() { |
| | | return impl.getGeneratedPassword(); |
| | | } |
| | | |
| | | @Override |
| | | public PasswordModifyExtendedResult setGeneratedPassword(ByteString password) { |
| | | public PasswordModifyExtendedResult setGeneratedPassword(byte[] password) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public boolean addAttribute(Attribute attribute, Collection<ByteString> duplicateValues) { |
| | | public boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public boolean containsAttribute(Attribute attribute, Collection<ByteString> missingValues) { |
| | | public boolean containsAttribute(Attribute attribute, |
| | | Collection<? super ByteString> missingValues) { |
| | | return impl.containsAttribute(attribute, missingValues); |
| | | } |
| | | |
| | |
| | | return impl.parseAttribute(attributeDescription); |
| | | } |
| | | |
| | | public boolean removeAttribute(Attribute attribute, Collection<ByteString> missingValues) { |
| | | public boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues) { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | |
| | | import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.Connection; |
| | | import org.forgerock.opendj.ldap.ConnectionFactory; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | |
| | | } |
| | | |
| | | if (currentPW.isPresent()) { |
| | | request.setOldPassword(ByteString.valueOf(currentPW.getValue())); |
| | | request.setOldPassword(currentPW.getValue().toCharArray()); |
| | | } else if (currentPWFile.isPresent()) { |
| | | request.setOldPassword(ByteString.valueOf(currentPWFile.getValue())); |
| | | request.setOldPassword(currentPWFile.getValue().toCharArray()); |
| | | } |
| | | |
| | | if (newPW.isPresent()) { |
| | | request.setNewPassword(ByteString.valueOf(newPW.getValue())); |
| | | request.setNewPassword(newPW.getValue().toCharArray()); |
| | | } else if (newPWFile.isPresent()) { |
| | | request.setNewPassword(ByteString.valueOf(newPWFile.getValue())); |
| | | request.setNewPassword(newPWFile.getValue().toCharArray()); |
| | | } |
| | | |
| | | PasswordModifyExtendedResult result; |