Minor improvement for OPENDJ-419: exposing SIMPLE and SASL authentication types in BindRequest.
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2012 ForgeRock AS |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.examples; |
| | |
| | | final IntermediateResponseHandler intermediateResponseHandler, |
| | | final ResultHandler<? super BindResult> resultHandler) { |
| | | |
| | | if (request.getAuthenticationType() != ((byte) 0x80)) { |
| | | if (request.getAuthenticationType() != BindRequest.AUTHENTICATION_TYPE_SIMPLE) { |
| | | // TODO: SASL authentication not implemented. |
| | | resultHandler.handleErrorResult(newErrorResult(ResultCode.PROTOCOL_ERROR, |
| | | "non-SIMPLE authentication not supported: " |
| | |
| | | |
| | | @Override |
| | | public void bindRequest(final FilterChainContext ctx, final int messageID, |
| | | final int version, final GenericBindRequest bindContext) |
| | | final int version, final GenericBindRequest request) |
| | | throws UnexpectedRequestException { |
| | | final ClientContextImpl clientContext = |
| | | LDAP_CONNECTION_ATTR.get(ctx.getConnection()); |
| | | if (clientContext != null) { |
| | | final ServerConnection<Integer> conn = clientContext.getServerConnection(); |
| | | final BindHandler handler = new BindHandler(clientContext, messageID); |
| | | conn.handleBind(messageID, version, bindContext, handler, handler); |
| | | conn.handleBind(messageID, version, request, handler, handler); |
| | | } |
| | | } |
| | | |
| | |
| | | if (request instanceof SimpleBindRequest) { |
| | | password = ((SimpleBindRequest) request).getPassword(); |
| | | } else if (request instanceof GenericBindRequest |
| | | && request.getAuthenticationType() == ((byte) 0x80)) { |
| | | && request.getAuthenticationType() == BindRequest.AUTHENTICATION_TYPE_SIMPLE) { |
| | | password = ((GenericBindRequest) request).getAuthenticationValue(); |
| | | } else { |
| | | throw newErrorResult(ResultCode.PROTOCOL_ERROR, |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldap.requests; |
| | |
| | | */ |
| | | public interface BindRequest extends Request { |
| | | |
| | | /** |
| | | * The authentication type value (0x80) reserved for simple authentication. |
| | | */ |
| | | public static final byte AUTHENTICATION_TYPE_SIMPLE = (byte) 0x80; |
| | | |
| | | /** |
| | | * The authentication type value (0xA3) reserved for SASL authentication. |
| | | */ |
| | | public static final byte AUTHENTICATION_TYPE_SASL = (byte) 0xA3; |
| | | |
| | | |
| | | @Override |
| | | BindRequest addControl(Control control); |
| | | |
| | |
| | | |
| | | /** |
| | | * Returns the authentication mechanism identifier for this generic bind |
| | | * request as defined by the LDAP protocol. Note that value {@code 0x80} is |
| | | * reserved for simple authentication and {@code 0xA3} is reserved for SASL |
| | | * authentication. |
| | | * request as defined by the LDAP protocol. Note that the value |
| | | * {@link #AUTHENTICATION_TYPE_SIMPLE} ({@code 0x80}) is reserved for simple |
| | | * authentication and the value {@link #AUTHENTICATION_TYPE_SASL} ( |
| | | * {@code 0xA3}) is reserved for SASL authentication. |
| | | * |
| | | * @return The authentication mechanism identifier. |
| | | */ |