| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | |
| | | final int protocolVersion = (int) reader.readInteger(); |
| | | final String authName = reader.readOctetStringAsString(); |
| | | final byte authType = reader.peekType(); |
| | | final ByteString authBytes = reader.readOctetString(authType); |
| | | final byte[] authBytes = reader.readOctetString(authType).toByteArray(); |
| | | |
| | | final GenericBindRequest request = Requests.newGenericBindRequest( |
| | | authName, authType, authBytes); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.ldap; |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package com.forgerock.opendj.util; |
| | |
| | | import static org.forgerock.opendj.ldap.CoreMessages.ERR_HEX_DECODE_INVALID_LENGTH; |
| | | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.CharBuffer; |
| | | import java.nio.charset.Charset; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | import java.util.concurrent.Executors; |
| | |
| | | */ |
| | | public static final String EOL = System.getProperty("line.separator"); |
| | | |
| | | /** |
| | | * A zero-length byte array. |
| | | */ |
| | | public static final byte[] EMPTY_BYTES = new byte[0]; |
| | | |
| | | // The name of the time zone for universal coordinated time (UTC). |
| | | private static final String TIME_ZONE_UTC = "UTC"; |
| | | |
| | |
| | | |
| | | /** |
| | | * Construct a byte array containing the UTF-8 encoding of the provided |
| | | * character array. |
| | | * |
| | | * @param chars |
| | | * The character array to convert to a UTF-8 byte array. |
| | | * @return A byte array containing the UTF-8 encoding of the provided |
| | | * character array. |
| | | */ |
| | | public static byte[] getBytes(final char[] chars) |
| | | { |
| | | final Charset utf8 = Charset.forName("UTF-8"); |
| | | final ByteBuffer buffer = utf8.encode(CharBuffer.wrap(chars)); |
| | | final byte[] bytes = new byte[buffer.remaining()]; |
| | | buffer.get(bytes); |
| | | return bytes; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Construct a byte array containing the UTF-8 encoding of the provided |
| | | * string. This is significantly faster than calling |
| | | * {@link String#getBytes(String)} for ASCII strings. |
| | | * |
| | |
| | | |
| | | |
| | | /** |
| | | * Returns a copy of the provided byte array. |
| | | * |
| | | * @param bytes |
| | | * The byte array to be copied. |
| | | * @return A copy of the provided byte array. |
| | | */ |
| | | public static byte[] copyOfBytes(final byte[] bytes) |
| | | { |
| | | return Arrays.copyOf(bytes, bytes.length); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the printable ASCII representation of the provided byte. |
| | | * |
| | | * @param b |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.asn1; |
| | | |
| | |
| | | * The type tag of the element. |
| | | * @param value |
| | | * The byte array containing the octet string data. |
| | | * @return A reference to this ASN.1 writer. |
| | | * @throws IOException |
| | | * If an error occurs while writing the element. |
| | | */ |
| | | ASN1Writer writeOctetString(byte type, byte[] value) throws IOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes an octet string element using the provided type tag. |
| | | * |
| | | * @param type |
| | | * The type tag of the element. |
| | | * @param value |
| | | * The byte array containing the octet string data. |
| | | * @param offset |
| | | * The offset in the byte array. |
| | | * @param length |
| | |
| | | * |
| | | * @param value |
| | | * The byte array containing the octet string data. |
| | | * @return A reference to this ASN.1 writer. |
| | | * @throws IOException |
| | | * If an error occurs while writing the element. |
| | | */ |
| | | ASN1Writer writeOctetString(byte[] value) throws IOException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes an octet string element using the Universal Octet String ASN.1 type |
| | | * tag. |
| | | * |
| | | * @param value |
| | | * The byte array containing the octet string data. |
| | | * @param offset |
| | | * The offset in the byte array. |
| | | * @param length |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.asn1; |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ASN1Writer writeOctetString(byte type, byte[] value) |
| | | throws IOException |
| | | { |
| | | return writeOctetString(type, value, 0, value.length); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ASN1Writer writeOctetString(byte[] value) throws IOException |
| | | { |
| | | return writeOctetString(value, 0, value.length); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ASN1Writer writeOctetString(final byte[] value, final int offset, |
| | | final int length) throws IOException |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.ldap; |
| | | |
| | |
| | | */ |
| | | public static ByteString valueOf(final char[] chars) |
| | | { |
| | | Charset utf8 = Charset.forName("UTF-8"); |
| | | ByteBuffer buffer = utf8.encode(CharBuffer.wrap(chars)); |
| | | byte[] bytes = new byte[buffer.remaining()]; |
| | | buffer.get(bytes); |
| | | return wrap(bytes); |
| | | return wrap(StaticUtils.getBytes(chars)); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConnectionSecurityLayer; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | |
| | | */ |
| | | BindClientImpl(final BindRequest initialBindRequest) |
| | | { |
| | | this.nextBindRequest = new GenericBindRequestImpl(initialBindRequest |
| | | .getName(), initialBindRequest.getAuthenticationType(), ByteString |
| | | .empty(), this); |
| | | this.nextBindRequest = new GenericBindRequestImpl( |
| | | initialBindRequest.getName(), |
| | | initialBindRequest.getAuthenticationType(), new byte[0], this); |
| | | for (final Control control : initialBindRequest.getControls()) |
| | | { |
| | | this.nextBindRequest.addControl(control); |
| | |
| | | * The authentication value to be used in the next bind request. |
| | | * @return A reference to this bind client. |
| | | */ |
| | | final BindClient setNextAuthenticationValue( |
| | | final ByteString authenticationValue) |
| | | final BindClient setNextAuthenticationValue(final byte[] authenticationValue) |
| | | { |
| | | nextBindRequest.setAuthenticationValue(authenticationValue); |
| | | return this; |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | |
| | | |
| | | /** |
| | | * Returns the password of the user that the client wishes to bind as. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * returned password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * |
| | | * @return The password of the user that the client wishes to bind as. |
| | | */ |
| | | ByteString getPassword(); |
| | | byte[] getPassword(); |
| | | |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * Sets the password of the user that the client wishes to bind as. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * provided password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as, which |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | CRAMMD5SASLBindRequest setPassword(ByteString password) |
| | | CRAMMD5SASLBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.copyOfBytes; |
| | | import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult; |
| | | |
| | | import javax.security.auth.callback.NameCallback; |
| | |
| | | import org.forgerock.opendj.ldap.responses.BindResult; |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | |
| | |
| | | super(initialBindRequest); |
| | | |
| | | this.authenticationID = initialBindRequest.getAuthenticationID(); |
| | | this.password = initialBindRequest.getPassword(); |
| | | this.password = ByteString.wrap(initialBindRequest.getPassword()); |
| | | |
| | | try |
| | | { |
| | |
| | | |
| | | private String authenticationID; |
| | | |
| | | private ByteString password; |
| | | private byte[] password; |
| | | |
| | | |
| | | |
| | | CRAMMD5SASLBindRequestImpl(final String authenticationID, |
| | | final ByteString password) |
| | | final byte[] password) |
| | | { |
| | | Validator.ensureNotNull(authenticationID, password); |
| | | this.authenticationID = authenticationID; |
| | |
| | | { |
| | | super(cramMD5SASLBindRequest); |
| | | this.authenticationID = cramMD5SASLBindRequest.getAuthenticationID(); |
| | | this.password = cramMD5SASLBindRequest.getPassword(); |
| | | this.password = copyOfBytes(cramMD5SASLBindRequest.getPassword()); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ByteString getPassword() |
| | | public byte[] getPassword() |
| | | { |
| | | return password; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public CRAMMD5SASLBindRequest setPassword(final ByteString password) |
| | | public CRAMMD5SASLBindRequest setPassword(final byte[] password) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | | this.password = ByteString.valueOf(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | | |
| | |
| | | builder.append(", authenticationID="); |
| | | builder.append(authenticationID); |
| | | builder.append(", password="); |
| | | builder.append(password); |
| | | builder.append(ByteString.wrap(password)); |
| | | builder.append(", controls="); |
| | | builder.append(getControls()); |
| | | builder.append(")"); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | |
| | | |
| | | /** |
| | | * Returns the password of the user that the client wishes to bind as. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * returned password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * |
| | | * @return The password of the user that the client wishes to bind as. |
| | | */ |
| | | ByteString getPassword(); |
| | | byte[] getPassword(); |
| | | |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * Sets the password of the user that the client wishes to bind as. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * provided password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as, which |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | DigestMD5SASLBindRequest setPassword(ByteString password) |
| | | DigestMD5SASLBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.copyOfBytes; |
| | | import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage; |
| | | import static com.forgerock.opendj.util.StaticUtils.joinCollection; |
| | | import static org.forgerock.opendj.ldap.CoreMessages.ERR_SASL_PROTOCOL_ERROR; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.responses.BindResult; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | |
| | |
| | | super(initialBindRequest); |
| | | |
| | | this.authenticationID = initialBindRequest.getAuthenticationID(); |
| | | this.password = initialBindRequest.getPassword(); |
| | | this.password = ByteString.wrap(initialBindRequest.getPassword()); |
| | | this.realm = initialBindRequest.getRealm(); |
| | | |
| | | // Create property map containing all the parameters. |
| | |
| | | |
| | | private String authenticationID; |
| | | private String authorizationID = null; |
| | | private ByteString password; |
| | | private byte[] password; |
| | | private String realm = null; |
| | | |
| | | |
| | | |
| | | DigestMD5SASLBindRequestImpl(final String authenticationID, |
| | | final ByteString password) |
| | | final byte[] password) |
| | | { |
| | | Validator.ensureNotNull(authenticationID, password); |
| | | this.authenticationID = authenticationID; |
| | |
| | | |
| | | this.authenticationID = digestMD5SASLBindRequest.getAuthenticationID(); |
| | | this.authorizationID = digestMD5SASLBindRequest.getAuthorizationID(); |
| | | this.password = digestMD5SASLBindRequest.getPassword(); |
| | | this.password = copyOfBytes(digestMD5SASLBindRequest.getPassword()); |
| | | this.realm = digestMD5SASLBindRequest.getRealm(); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ByteString getPassword() |
| | | public byte[] getPassword() |
| | | { |
| | | return password; |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DigestMD5SASLBindRequest setPassword(final ByteString password) |
| | | public DigestMD5SASLBindRequest setPassword(final byte[] password) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | | this.password = ByteString.valueOf(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | | |
| | |
| | | builder.append(", realm="); |
| | | builder.append(realm); |
| | | builder.append(", password="); |
| | | builder.append(password); |
| | | builder.append(ByteString.wrap(password)); |
| | | builder.append(", controls="); |
| | | builder.append(getControls()); |
| | | builder.append(")"); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | import javax.security.auth.Subject; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | |
| | | /** |
| | | * Returns the password of the user that the client wishes to bind as. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * returned password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * <p> |
| | | * <b>NOTE</b>: this will not be used if a {@code Subject} is specified. |
| | | * |
| | | * @return The password of the user that the client wishes to bind as. |
| | | */ |
| | | ByteString getPassword(); |
| | | byte[] getPassword(); |
| | | |
| | | |
| | | |
| | |
| | | /** |
| | | * Sets the password of the user that the client wishes to bind as. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * provided password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * <p> |
| | | * <b>NOTE</b>: this will not be used if a {@code Subject} is specified. |
| | | * |
| | | * @param password |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | GSSAPISASLBindRequest setPassword(ByteString password) |
| | | GSSAPISASLBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.copyOfBytes; |
| | | import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage; |
| | | import static com.forgerock.opendj.util.StaticUtils.joinCollection; |
| | | import static org.forgerock.opendj.ldap.CoreMessages.*; |
| | |
| | | } |
| | | else |
| | | { |
| | | this.subject = kerberos5Login(initialBindRequest.getAuthenticationID(), |
| | | initialBindRequest.getPassword(), initialBindRequest.getRealm(), |
| | | this.subject = kerberos5Login( |
| | | initialBindRequest.getAuthenticationID(), |
| | | ByteString.wrap(initialBindRequest.getPassword()), |
| | | initialBindRequest.getRealm(), |
| | | initialBindRequest.getKDCAddress()); |
| | | } |
| | | |
| | |
| | | |
| | | // Ignored if subject is non-null. |
| | | private String authenticationID = null; |
| | | private ByteString password = null; |
| | | private byte[] password = null; |
| | | private String realm = null; |
| | | |
| | | private String kdcAddress = null; |
| | |
| | | |
| | | |
| | | GSSAPISASLBindRequestImpl(final String authenticationID, |
| | | final ByteString password) |
| | | final byte[] password) |
| | | { |
| | | Validator.ensureNotNull(authenticationID, password); |
| | | this.authenticationID = authenticationID; |
| | |
| | | this.subject = gssapiSASLBindRequest.getSubject(); |
| | | |
| | | this.authenticationID = gssapiSASLBindRequest.getAuthenticationID(); |
| | | this.password = gssapiSASLBindRequest.getPassword(); |
| | | this.password = copyOfBytes(gssapiSASLBindRequest.getPassword()); |
| | | this.realm = gssapiSASLBindRequest.getRealm(); |
| | | |
| | | this.kdcAddress = gssapiSASLBindRequest.getKDCAddress(); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ByteString getPassword() |
| | | public byte[] getPassword() |
| | | { |
| | | return password; |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public GSSAPISASLBindRequest setPassword(final ByteString password) |
| | | public GSSAPISASLBindRequest setPassword(final byte[] password) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | | this.password = ByteString.valueOf(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | | |
| | |
| | | builder.append(", realm="); |
| | | builder.append(realm); |
| | | builder.append(", password="); |
| | | builder.append(password); |
| | | builder.append(ByteString.wrap(password)); |
| | | } |
| | | builder.append(", controls="); |
| | | builder.append(getControls()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | /** |
| | | * Returns the authentication information for this bind request. The content |
| | | * is defined by the authentication mechanism. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * returned byte array, allowing applications to overwrite any sensitive data |
| | | * such as passwords after it has been used. |
| | | * |
| | | * @return The authentication information. |
| | | */ |
| | | ByteString getAuthenticationValue(); |
| | | byte[] getAuthenticationValue(); |
| | | |
| | | |
| | | |
| | |
| | | /** |
| | | * Sets the authentication information for this generic bind request in a form |
| | | * defined by the authentication mechanism. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * returned byte array, allowing applications to overwrite any sensitive data |
| | | * such as passwords after it has been used. |
| | | * |
| | | * @param bytes |
| | | * The authentication information for this generic bind request in a |
| | |
| | | * @throws NullPointerException |
| | | * If {@code bytes} was {@code null}. |
| | | */ |
| | | GenericBindRequest setAuthenticationValue(ByteString bytes) |
| | | GenericBindRequest setAuthenticationValue(byte[] bytes) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.copyOfBytes; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | |
| | |
| | | |
| | | private String name; |
| | | |
| | | private ByteString authenticationValue; |
| | | private byte[] authenticationValue; |
| | | |
| | | private byte authenticationType; |
| | | |
| | |
| | | * Creates a new generic bind request using a generic bind client. |
| | | */ |
| | | GenericBindRequestImpl(final String name, final byte authenticationType, |
| | | final ByteString authenticationValue) |
| | | final byte[] authenticationValue) |
| | | { |
| | | this.name = name; |
| | | this.authenticationType = authenticationType; |
| | |
| | | * package. |
| | | */ |
| | | GenericBindRequestImpl(final String name, final byte authenticationType, |
| | | final ByteString authenticationValue, final BindClient bindClient) |
| | | final byte[] authenticationValue, final BindClient bindClient) |
| | | { |
| | | this.name = name; |
| | | this.authenticationType = authenticationType; |
| | |
| | | { |
| | | super(genericBindRequest); |
| | | this.name = genericBindRequest.getName(); |
| | | this.authenticationType = genericBindRequest.getAuthenticationType(); |
| | | this.authenticationValue = genericBindRequest.getAuthenticationValue(); |
| | | this.authenticationType = genericBindRequest |
| | | .getAuthenticationType(); |
| | | this.authenticationValue = copyOfBytes(genericBindRequest |
| | | .getAuthenticationValue()); |
| | | this.bindClient = null; // Create a new bind client each time. |
| | | } |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ByteString getAuthenticationValue() |
| | | public byte[] getAuthenticationValue() |
| | | { |
| | | return authenticationValue; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public GenericBindRequest setAuthenticationValue(final ByteString bytes) |
| | | public GenericBindRequest setAuthenticationValue(final byte[] bytes) |
| | | throws UnsupportedOperationException, NullPointerException |
| | | { |
| | | Validator.ensureNotNull(bytes); |
| | |
| | | builder.append(", authenticationType="); |
| | | builder.append(getAuthenticationType()); |
| | | builder.append(", authenticationValue="); |
| | | builder.append(getAuthenticationValue()); |
| | | builder.append(ByteString.wrap(getAuthenticationValue())); |
| | | builder.append(", controls="); |
| | | builder.append(getControls()); |
| | | builder.append(")"); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | |
| | | |
| | | /** |
| | | * Returns the password of the user that the client wishes to bind as. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * returned password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * |
| | | * @return The password of the user that the client wishes to bind as. |
| | | */ |
| | | ByteString getPassword(); |
| | | byte[] getPassword(); |
| | | |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * Sets the password of the user that the client wishes to bind as. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * provided password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as, which |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | PlainSASLBindRequest setPassword(ByteString password) |
| | | PlainSASLBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.responses.BindResult; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | |
| | |
| | | super(initialBindRequest); |
| | | |
| | | this.authenticationID = initialBindRequest.getAuthenticationID(); |
| | | this.password = initialBindRequest.getPassword(); |
| | | this.password = ByteString.wrap(initialBindRequest.getPassword()); |
| | | |
| | | try |
| | | { |
| | |
| | | private String authenticationID; |
| | | private String authorizationID; |
| | | |
| | | private ByteString password; |
| | | private byte[] password; |
| | | |
| | | |
| | | |
| | | PlainSASLBindRequestImpl(final String authenticationID, |
| | | final ByteString password) |
| | | final byte[] password) |
| | | { |
| | | Validator.ensureNotNull(authenticationID, password); |
| | | this.authenticationID = authenticationID; |
| | |
| | | super(plainSASLBindRequest); |
| | | this.authenticationID = plainSASLBindRequest.getAuthenticationID(); |
| | | this.authorizationID = plainSASLBindRequest.getAuthorizationID(); |
| | | this.password = plainSASLBindRequest.getPassword(); |
| | | this.password = StaticUtils.copyOfBytes(plainSASLBindRequest.getPassword()); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | public ByteString getPassword() |
| | | public byte[] getPassword() |
| | | { |
| | | return password; |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | public PlainSASLBindRequest setPassword(final ByteString password) |
| | | public PlainSASLBindRequest setPassword(final byte[] password) |
| | | { |
| | | Validator.ensureNotNull(password); |
| | | this.password = password; |
| | |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | | this.password = ByteString.valueOf(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | | |
| | |
| | | builder.append(", authorizationID="); |
| | | builder.append(authorizationID); |
| | | builder.append(", password="); |
| | | builder.append(password); |
| | | builder.append(ByteString.wrap(password)); |
| | | builder.append(", controls="); |
| | | builder.append(getControls()); |
| | | builder.append(")"); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.EMPTY_BYTES; |
| | | import static com.forgerock.opendj.util.StaticUtils.getBytes; |
| | | import static org.forgerock.opendj.ldap.CoreMessages.WARN_READ_LDIF_RECORD_CHANGE_RECORD_WRONG_TYPE; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | |
| | | * of the user, or "u:" followed by a user ID string, but other forms |
| | | * are permitted. |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as. |
| | | * @return The new CRAM-MD5 SASL bind request. |
| | | * @throws NullPointerException |
| | | * If {@code authenticationID} or {@code password} was {@code null}. |
| | | */ |
| | | public static CRAMMD5SASLBindRequest newCRAMMD5SASLBindRequest( |
| | | final String authenticationID, final byte[] password) |
| | | throws NullPointerException |
| | | { |
| | | return new CRAMMD5SASLBindRequestImpl(authenticationID, password); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new CRAM-MD5 SASL bind request having the provided authentication |
| | | * ID and password. |
| | | * |
| | | * @param authenticationID |
| | | * The authentication ID of the user. The authentication ID usually |
| | | * has the form "dn:" immediately followed by the distinguished name |
| | | * of the user, or "u:" followed by a user ID string, but other forms |
| | | * are permitted. |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as. The |
| | | * password will be converted to a UTF-8 octet string. |
| | | * @return The new CRAM-MD5 SASL bind request. |
| | |
| | | * If {@code authenticationID} or {@code password} was {@code null}. |
| | | */ |
| | | public static CRAMMD5SASLBindRequest newCRAMMD5SASLBindRequest( |
| | | final String authenticationID, final ByteString password) |
| | | final String authenticationID, final char[] password) |
| | | throws NullPointerException |
| | | { |
| | | return new CRAMMD5SASLBindRequestImpl(authenticationID, password); |
| | | return new CRAMMD5SASLBindRequestImpl(authenticationID, getBytes(password)); |
| | | } |
| | | |
| | | |
| | |
| | | * of the user, or "u:" followed by a user ID string, but other forms |
| | | * are permitted. |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as. |
| | | * @return The new DIGEST-MD5 SASL bind request. |
| | | * @throws NullPointerException |
| | | * If {@code authenticationID} or {@code password} was {@code null}. |
| | | */ |
| | | public static DigestMD5SASLBindRequest newDigestMD5SASLBindRequest( |
| | | final String authenticationID, final byte[] password) |
| | | throws NullPointerException |
| | | { |
| | | return new DigestMD5SASLBindRequestImpl(authenticationID, password); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new DIGEST-MD5 SASL bind request having the provided |
| | | * authentication ID and password, but no realm or authorization ID. |
| | | * |
| | | * @param authenticationID |
| | | * The authentication ID of the user. The authentication ID usually |
| | | * has the form "dn:" immediately followed by the distinguished name |
| | | * of the user, or "u:" followed by a user ID string, but other forms |
| | | * are permitted. |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as. The |
| | | * password will be converted to a UTF-8 octet string. |
| | | * @return The new DIGEST-MD5 SASL bind request. |
| | |
| | | * If {@code authenticationID} or {@code password} was {@code null}. |
| | | */ |
| | | public static DigestMD5SASLBindRequest newDigestMD5SASLBindRequest( |
| | | final String authenticationID, final ByteString password) |
| | | final String authenticationID, final char[] password) |
| | | throws NullPointerException |
| | | { |
| | | return new DigestMD5SASLBindRequestImpl(authenticationID, password); |
| | | return new DigestMD5SASLBindRequestImpl(authenticationID, |
| | | getBytes(password)); |
| | | } |
| | | |
| | | |
| | |
| | | * If {@code authenticationValue} was {@code null}. |
| | | */ |
| | | public static GenericBindRequest newGenericBindRequest( |
| | | final byte authenticationType, final ByteString authenticationValue) |
| | | final byte authenticationType, final byte[] authenticationValue) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(authenticationValue); |
| | |
| | | * If {@code name} or {@code authenticationValue} was {@code null}. |
| | | */ |
| | | public static GenericBindRequest newGenericBindRequest(final String name, |
| | | final byte authenticationType, final ByteString authenticationValue) |
| | | final byte authenticationType, final byte[] authenticationValue) |
| | | throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(name, authenticationValue); |
| | |
| | | * of the user, or "u:" followed by a user ID string, but other forms |
| | | * are permitted. |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as. |
| | | * @return The new GSSAPI SASL bind request. |
| | | * @throws NullPointerException |
| | | * If {@code authenticationID} or {@code password} was {@code null}. |
| | | */ |
| | | public static GSSAPISASLBindRequest newGSSAPISASLBindRequest( |
| | | final String authenticationID, final byte[] password) |
| | | throws NullPointerException |
| | | { |
| | | return new GSSAPISASLBindRequestImpl(authenticationID, password); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new GSSAPI SASL bind request having the provided authentication |
| | | * ID and password, but no realm, KDC address, or authorization ID. |
| | | * |
| | | * @param authenticationID |
| | | * The authentication ID of the user. The authentication ID usually |
| | | * has the form "dn:" immediately followed by the distinguished name |
| | | * of the user, or "u:" followed by a user ID string, but other forms |
| | | * are permitted. |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as. The |
| | | * password will be converted to a UTF-8 octet string. |
| | | * @return The new GSSAPI SASL bind request. |
| | |
| | | * If {@code authenticationID} or {@code password} was {@code null}. |
| | | */ |
| | | public static GSSAPISASLBindRequest newGSSAPISASLBindRequest( |
| | | final String authenticationID, final ByteString password) |
| | | final String authenticationID, final char[] password) |
| | | throws NullPointerException |
| | | { |
| | | return new GSSAPISASLBindRequestImpl(authenticationID, password); |
| | | return new GSSAPISASLBindRequestImpl(authenticationID, getBytes(password)); |
| | | } |
| | | |
| | | |
| | |
| | | * of the user, or "u:" followed by a user ID string, but other forms |
| | | * are permitted. |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as. |
| | | * @return The new Plain SASL bind request. |
| | | * @throws NullPointerException |
| | | * If {@code authenticationID} or {@code password} was {@code null}. |
| | | */ |
| | | public static PlainSASLBindRequest newPlainSASLBindRequest( |
| | | final String authenticationID, final byte[] password) |
| | | throws NullPointerException |
| | | { |
| | | return new PlainSASLBindRequestImpl(authenticationID, password); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new Plain SASL bind request having the provided authentication ID |
| | | * and password, but no authorization ID. |
| | | * |
| | | * @param authenticationID |
| | | * The authentication ID of the user. The authentication ID usually |
| | | * has the form "dn:" immediately followed by the distinguished name |
| | | * of the user, or "u:" followed by a user ID string, but other forms |
| | | * are permitted. |
| | | * @param password |
| | | * The password of the user that the client wishes to bind as. The |
| | | * password will be converted to a UTF-8 octet string. |
| | | * @return The new Plain SASL bind request. |
| | |
| | | * If {@code authenticationID} or {@code password} was {@code null}. |
| | | */ |
| | | public static PlainSASLBindRequest newPlainSASLBindRequest( |
| | | final String authenticationID, final ByteString password) |
| | | final String authenticationID, final char[] password) |
| | | throws NullPointerException |
| | | { |
| | | return new PlainSASLBindRequestImpl(authenticationID, password); |
| | | return new PlainSASLBindRequestImpl(authenticationID, getBytes(password)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public static SimpleBindRequest newSimpleBindRequest() |
| | | { |
| | | return new SimpleBindRequestImpl("", ByteString.empty()); |
| | | return new SimpleBindRequestImpl("", EMPTY_BYTES); |
| | | } |
| | | |
| | | |
| | |
| | | * If {@code name} or {@code password} was {@code null}. |
| | | */ |
| | | public static SimpleBindRequest newSimpleBindRequest(final String name, |
| | | final byte[] password) throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(name, password); |
| | | return new SimpleBindRequestImpl(name, password); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new simple bind request having the provided name and password |
| | | * suitable for name/password authentication. The name will be decoded using |
| | | * the default schema. |
| | | * <p> |
| | | * The LDAP protocol defines the Bind name to be a distinguished name, however |
| | | * some LDAP implementations have relaxed this constraint and allow other |
| | | * identities to be used, such as the user's email address. |
| | | * |
| | | * @param name |
| | | * The name of the Directory object that the client wishes to bind |
| | | * as, which may be empty. |
| | | * @param password |
| | | * The password of the Directory object that the client wishes to |
| | | * bind as, which may be empty indicating that an unauthenticated |
| | | * bind is to be performed. The password will be converted to a UTF-8 |
| | | * octet string. |
| | | * @return The new simple bind request. |
| | | * @throws NullPointerException |
| | | * If {@code name} or {@code password} was {@code null}. |
| | | */ |
| | | public static SimpleBindRequest newSimpleBindRequest(final String name, |
| | | final char[] password) throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(name, password); |
| | | return new SimpleBindRequestImpl(name, ByteString.valueOf(password)); |
| | | return new SimpleBindRequestImpl(name, getBytes(password)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * Creates an unmodifiable CRAM MD5 SASL bind request of the provided request. |
| | | * <p> |
| | | * The returned bind request creates defensive copies of the password in order |
| | | * to maintain immutability. |
| | | * |
| | | * @param request |
| | | * The CRAM MD5 SASL bind request to be copied. |
| | |
| | | /** |
| | | * Creates an unmodifiable digest MD5 SASL bind request of the provided |
| | | * request. |
| | | * <p> |
| | | * The returned bind request creates defensive copies of the password in order |
| | | * to maintain immutability. |
| | | * |
| | | * @param request |
| | | * The digest MD5 SASL bind request to be copied. |
| | |
| | | |
| | | /** |
| | | * Creates an unmodifiable generic bind request of the provided request. |
| | | * <p> |
| | | * The returned bind request creates defensive copies of the authentication |
| | | * value in order to maintain immutability. |
| | | * |
| | | * @param request |
| | | * The generic bind request to be copied. |
| | |
| | | |
| | | /** |
| | | * Creates an unmodifiable GSSAPI SASL bind request of the provided request. |
| | | * <p> |
| | | * The returned bind request creates defensive copies of the password in order |
| | | * to maintain immutability. |
| | | * |
| | | * @param request |
| | | * The GSSAPI SASL bind request to be copied. |
| | |
| | | |
| | | /** |
| | | * Creates an unmodifiable plain SASL bind request of the provided request. |
| | | * <p> |
| | | * The returned bind request creates defensive copies of the password in order |
| | | * to maintain immutability. |
| | | * |
| | | * @param request |
| | | * The plain SASL bind request to be copied. |
| | |
| | | |
| | | /** |
| | | * Creates an unmodifiable simple bind request of the provided request. |
| | | * <p> |
| | | * The returned bind request creates defensive copies of the password in order |
| | | * to maintain immutability. |
| | | * |
| | | * @param request |
| | | * The simple bind request to be copied. |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | throw new RuntimeException("Error encoding SaslCredentials"); |
| | | } |
| | | |
| | | return setNextAuthenticationValue(builder.toByteString()); |
| | | return setNextAuthenticationValue(builder.toByteString().toByteArray()); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.forgerock.opendj.ldap.DecodeOptions; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | |
| | | * Returns the password of the Directory object that the client wishes to bind |
| | | * as. The password may be empty (but never {@code null}) when used for of |
| | | * anonymous or unauthenticated binds. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * returned password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * |
| | | * @return The password of the Directory object that the client wishes to bind |
| | | * as. |
| | | */ |
| | | ByteString getPassword(); |
| | | byte[] getPassword(); |
| | | |
| | | |
| | | |
| | |
| | | * Sets the password of the Directory object that the client wishes to bind |
| | | * as. The password may be empty (but never {@code null}) when used for of |
| | | * anonymous or unauthenticated binds. |
| | | * <p> |
| | | * Unless otherwise indicated, implementations will store a reference to the |
| | | * provided password byte array, allowing applications to overwrite the |
| | | * password after it has been used. |
| | | * |
| | | * @param password |
| | | * The password of the Directory object that the client wishes to |
| | |
| | | * @throws NullPointerException |
| | | * If {@code password} was {@code null}. |
| | | */ |
| | | SimpleBindRequest setPassword(ByteString password) |
| | | SimpleBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException; |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.ldap.LDAPConstants.TYPE_AUTHENTICATION_SIMPLE; |
| | | import static com.forgerock.opendj.ldap.LDAPConstants.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | import com.forgerock.opendj.util.Validator; |
| | | |
| | | |
| | |
| | | final class SimpleBindRequestImpl extends |
| | | AbstractBindRequest<SimpleBindRequest> implements SimpleBindRequest |
| | | { |
| | | private ByteString password = ByteString.empty(); |
| | | private byte[] password = new byte[0]; |
| | | |
| | | private String name = "".intern(); |
| | | |
| | |
| | | * @throws NullPointerException |
| | | * If {@code name} or {@code password} was {@code null}. |
| | | */ |
| | | SimpleBindRequestImpl(final String name, final ByteString password) |
| | | SimpleBindRequestImpl(final String name, final byte[] password) |
| | | throws NullPointerException |
| | | { |
| | | this.name = name; |
| | |
| | | { |
| | | super(simpleBindRequest); |
| | | this.name = simpleBindRequest.getName(); |
| | | this.password = simpleBindRequest.getPassword(); |
| | | this.password = StaticUtils.copyOfBytes(simpleBindRequest.getPassword()); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ByteString getPassword() |
| | | public byte[] getPassword() |
| | | { |
| | | return password; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public SimpleBindRequest setPassword(final ByteString password) |
| | | public SimpleBindRequest setPassword(final byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | |
| | | throws UnsupportedOperationException, NullPointerException |
| | | { |
| | | Validator.ensureNotNull(password); |
| | | this.password = ByteString.valueOf(password); |
| | | this.password = StaticUtils.getBytes(password); |
| | | return this; |
| | | } |
| | | |
| | |
| | | builder.append(getName()); |
| | | builder.append(", authentication=simple"); |
| | | builder.append(", password="); |
| | | builder.append(getPassword()); |
| | | builder.append(ByteString.wrap(getPassword())); |
| | | builder.append(", controls="); |
| | | builder.append(getControls()); |
| | | builder.append(")"); |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * Unmodifiable CRAM-MD5 SASL bind request implementation. |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ByteString getPassword() { |
| | | return impl.getPassword(); |
| | | public byte[] getPassword() { |
| | | // Defensive copy. |
| | | return StaticUtils.copyOfBytes(impl.getPassword()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public CRAMMD5SASLBindRequest setPassword(ByteString password) |
| | | public CRAMMD5SASLBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * Unmodifiable digest-MD5 SASL bind request implementation. |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ByteString getPassword() { |
| | | return impl.getPassword(); |
| | | public byte[] getPassword() { |
| | | // Defensive copy. |
| | | return StaticUtils.copyOfBytes(impl.getPassword()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DigestMD5SASLBindRequest setPassword(ByteString password) |
| | | public DigestMD5SASLBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | import javax.security.auth.Subject; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * Unmodifiable GSSAPI SASL bind request implementation. |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ByteString getPassword() { |
| | | return impl.getPassword(); |
| | | public byte[] getPassword() { |
| | | // Defensive copy. |
| | | return StaticUtils.copyOfBytes(impl.getPassword()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public GSSAPISASLBindRequest setPassword(ByteString password) |
| | | public GSSAPISASLBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Unmodifiable generic bind request implementation. |
| | |
| | | super(impl); |
| | | } |
| | | |
| | | public ByteString getAuthenticationValue() { |
| | | return impl.getAuthenticationValue(); |
| | | public byte[] getAuthenticationValue() { |
| | | // Defensive copy. |
| | | return StaticUtils.copyOfBytes(impl.getAuthenticationValue()); |
| | | } |
| | | |
| | | public GenericBindRequest setAuthenticationType(byte type) |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public GenericBindRequest setAuthenticationValue(ByteString bytes) |
| | | public GenericBindRequest setAuthenticationValue(byte[] bytes) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | /** |
| | | * Unmodifiable plain SASL bind request implementation. |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ByteString getPassword() { |
| | | return impl.getPassword(); |
| | | public byte[] getPassword() { |
| | | // Defensive copy. |
| | | return StaticUtils.copyOfBytes(impl.getPassword()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public PlainSASLBindRequest setPassword(ByteString password) |
| | | public PlainSASLBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | |
| | | import com.forgerock.opendj.util.StaticUtils; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Unmodifiable simple bind request implementation. |
| | |
| | | super(impl); |
| | | } |
| | | |
| | | public ByteString getPassword() { |
| | | return impl.getPassword(); |
| | | public byte[] getPassword() { |
| | | // Defensive copy. |
| | | return StaticUtils.copyOfBytes(impl.getPassword()); |
| | | } |
| | | |
| | | public SimpleBindRequest setName(String name) |
| | |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | | |
| | | public SimpleBindRequest setPassword(ByteString password) |
| | | public SimpleBindRequest setPassword(byte[] password) |
| | | throws UnsupportedOperationException, NullPointerException { |
| | | throw new UnsupportedOperationException(); |
| | | } |
| | |
| | | factories[3][0] = new AuthenticatedConnectionFactory( |
| | | new LDAPConnectionFactory("localhost", TestCaseUtils.getLdapPort()), |
| | | Requests.newCRAMMD5SASLBindRequest("id:user", |
| | | ByteString.valueOf("password"))); |
| | | "password".toCharArray())); |
| | | |
| | | // LDAPConnectionFactory with default options |
| | | factories[4][0] = new LDAPConnectionFactory("localhost", |
| | |
| | | factories[6][0] = new AuthenticatedConnectionFactory( |
| | | new LDAPConnectionFactory(new InetSocketAddress("127.0.0.1", |
| | | TestCaseUtils.getLdapPort()), options), Requests |
| | | .newDigestMD5SASLBindRequest("id:user", |
| | | ByteString.valueOf("password")) |
| | | .newDigestMD5SASLBindRequest("id:user", "password".toCharArray()) |
| | | .addQOP(DigestMD5SASLBindRequest.QOP_AUTH_CONF) |
| | | .setCipher(DigestMD5SASLBindRequest.CIPHER_LOW)); |
| | | |
| | |
| | | // Use the handler to get the result asynchronously. |
| | | final CountDownLatch latch = new CountDownLatch(1); |
| | | final MyResultHandler handler = new MyResultHandler(latch); |
| | | final FutureResult<AsynchronousConnection> future = factory |
| | | .getAsynchronousConnection(handler); |
| | | factory.getAsynchronousConnection(handler); |
| | | |
| | | // Since we don't have anything to do, we would rather |
| | | // be notified by the latch when the other thread calls our handler. |
| | | latch.await(); // should do a timed wait rather? |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static com.forgerock.opendj.util.StaticUtils.EMPTY_BYTES; |
| | | import static com.forgerock.opendj.util.StaticUtils.getBytes; |
| | | |
| | | import org.forgerock.opendj.ldap.requests.CRAMMD5SASLBindRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | public Object[][] getCRAMMD5SASLBindRequests() throws Exception |
| | | { |
| | | final CRAMMD5SASLBindRequest[] requests = { |
| | | Requests.newCRAMMD5SASLBindRequest("id1", ByteString.empty()), |
| | | Requests.newCRAMMD5SASLBindRequest("id2", ByteString.valueOf("test")) }; |
| | | Requests.newCRAMMD5SASLBindRequest("id1", EMPTY_BYTES), |
| | | Requests.newCRAMMD5SASLBindRequest("id2", getBytes("test")) }; |
| | | final Object[][] objArray = new Object[requests.length][1]; |
| | | for (int i = 0; i < requests.length; i++) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.EMPTY_BYTES; |
| | | import static com.forgerock.opendj.util.StaticUtils.getBytes; |
| | | import static org.testng.Assert.assertEquals; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.requests.DigestMD5SASLBindRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests Digest MD5 SASL requests. |
| | | */ |
| | |
| | | public Object[][] getDigestMD5SASLBindRequests() throws Exception |
| | | { |
| | | final DigestMD5SASLBindRequest[] requests = { |
| | | Requests.newDigestMD5SASLBindRequest("id1", ByteString.empty()), |
| | | Requests.newDigestMD5SASLBindRequest("id2", ByteString |
| | | .valueOf("password")) }; |
| | | Requests.newDigestMD5SASLBindRequest("id1", EMPTY_BYTES), |
| | | Requests.newDigestMD5SASLBindRequest("id2", getBytes("password")) }; |
| | | final Object[][] objArray = new Object[requests.length][1]; |
| | | for (int i = 0; i < requests.length; i++) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.util.StaticUtils.EMPTY_BYTES; |
| | | import static com.forgerock.opendj.util.StaticUtils.getBytes; |
| | | import static org.testng.Assert.assertEquals; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.requests.BindRequest; |
| | | import org.forgerock.opendj.ldap.requests.GSSAPISASLBindRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | |
| | | public Object[][] getGSSAPISASLBindRequests() throws Exception |
| | | { |
| | | final GSSAPISASLBindRequest[] requests = { |
| | | Requests.newGSSAPISASLBindRequest("id1", ByteString.empty()), |
| | | Requests.newGSSAPISASLBindRequest("id1", EMPTY_BYTES), |
| | | Requests |
| | | .newGSSAPISASLBindRequest("id2", ByteString.valueOf("password")) }; |
| | | .newGSSAPISASLBindRequest("id2", getBytes("password")) }; |
| | | final Object[][] objArray = new Object[requests.length][1]; |
| | | for (int i = 0; i < requests.length; i++) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static com.forgerock.opendj.util.StaticUtils.EMPTY_BYTES; |
| | | import static com.forgerock.opendj.util.StaticUtils.getBytes; |
| | | |
| | | import org.forgerock.opendj.ldap.requests.GenericBindRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | { |
| | | final GenericBindRequest[] requests = { |
| | | Requests.newGenericBindRequest(LDAPConstants.TYPE_AUTHENTICATION_SASL, |
| | | ByteString.empty()), |
| | | EMPTY_BYTES), |
| | | Requests.newGenericBindRequest( |
| | | LDAPConstants.TYPE_AUTHENTICATION_SIMPLE, ByteString |
| | | .valueOf("password")), |
| | | LDAPConstants.TYPE_AUTHENTICATION_SIMPLE, getBytes("password")), |
| | | Requests.newGenericBindRequest("username", |
| | | LDAPConstants.TYPE_AUTHENTICATION_SIMPLE, ByteString |
| | | .valueOf("password")) }; |
| | | LDAPConstants.TYPE_AUTHENTICATION_SIMPLE, getBytes("password")) }; |
| | | final Object[][] objArray = new Object[requests.length][1]; |
| | | for (int i = 0; i < requests.length; i++) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | | |
| | | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static com.forgerock.opendj.util.StaticUtils.EMPTY_BYTES; |
| | | import static com.forgerock.opendj.util.StaticUtils.getBytes; |
| | | |
| | | import org.forgerock.opendj.ldap.requests.PlainSASLBindRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | public Object[][] getPlainSASLBindRequests() throws Exception |
| | | { |
| | | final PlainSASLBindRequest[] requests = { |
| | | Requests.newPlainSASLBindRequest("id1", ByteString.empty()), |
| | | Requests.newPlainSASLBindRequest("id2", ByteString.valueOf("password")) }; |
| | | Requests.newPlainSASLBindRequest("id1", EMPTY_BYTES), |
| | | Requests.newPlainSASLBindRequest("id2", getBytes("password")) }; |
| | | final Object[][] objArray = new Object[requests.length][1]; |
| | | for (int i = 0; i < requests.length; i++) |
| | | { |
| | |
| | | /** |
| | | * Creates the test requests. |
| | | * |
| | | * @param <T> |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | |
| | | { |
| | | bindRequest = Requests.newDigestMD5SASLBindRequest( |
| | | getAuthID(DigestMD5SASLBindRequest.SASL_MECHANISM_NAME), |
| | | ByteString.valueOf(getPassword())).setAuthorizationID(getAuthzID()) |
| | | getPassword()).setAuthorizationID(getAuthzID()) |
| | | .setRealm(getRealm()); |
| | | } |
| | | else if (mech.equals(CRAMMD5SASLBindRequest.SASL_MECHANISM_NAME)) |
| | | { |
| | | bindRequest = Requests.newCRAMMD5SASLBindRequest( |
| | | getAuthID(CRAMMD5SASLBindRequest.SASL_MECHANISM_NAME), ByteString |
| | | .valueOf(getPassword())); |
| | | getAuthID(CRAMMD5SASLBindRequest.SASL_MECHANISM_NAME), |
| | | getPassword()); |
| | | } |
| | | else if (mech.equals(GSSAPISASLBindRequest.SASL_MECHANISM_NAME)) |
| | | { |
| | | bindRequest = Requests.newGSSAPISASLBindRequest( |
| | | getAuthID(GSSAPISASLBindRequest.SASL_MECHANISM_NAME), |
| | | ByteString.valueOf(getPassword())).setKDCAddress(getKDC()).setRealm( |
| | | getPassword()).setKDCAddress(getKDC()).setRealm( |
| | | getRealm()).setAuthorizationID(getAuthzID()); |
| | | } |
| | | else if (mech.equals(ExternalSASLBindRequest.SASL_MECHANISM_NAME)) |
| | |
| | | { |
| | | bindRequest = Requests.newPlainSASLBindRequest( |
| | | getAuthID(PlainSASLBindRequest.SASL_MECHANISM_NAME), |
| | | ByteString.valueOf(getPassword())).setAuthorizationID(getAuthzID()); |
| | | getPassword()).setAuthorizationID(getAuthzID()); |
| | | } |
| | | else |
| | | { |