From b231195429e28098e1baceda8a2a2f553a58ca33 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 22 Apr 2013 12:13:00 +0000
Subject: [PATCH] Minor improvement for OPENDJ-419: exposing SIMPLE and SASL authentication types in BindRequest.

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindRequest.java |   20 ++++++++++++++++----
 opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPServerFilter.java     |    4 ++--
 opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java   |    4 ++--
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java        |    2 +-
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
index ea156ff..949f7a0 100644
--- a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
+++ b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2009-2010 Sun Microsystems, Inc.
- *      Portions copyright 2011-2012 ForgeRock AS
+ *      Portions copyright 2011-2013 ForgeRock AS
  */
 
 package org.forgerock.opendj.examples;
@@ -208,7 +208,7 @@
                 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: "
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPServerFilter.java b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPServerFilter.java
index 336979c..abd829a 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPServerFilter.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPServerFilter.java
@@ -688,14 +688,14 @@
 
                 @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);
                     }
                 }
 
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java
index 2ef4040..23c4dbd 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java
@@ -196,7 +196,7 @@
                 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,
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindRequest.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindRequest.java
index 58c974e..9807567 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindRequest.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/requests/BindRequest.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions copyright 2012 ForgeRock AS.
+ *      Portions copyright 2012-2013 ForgeRock AS.
  */
 
 package org.forgerock.opendj.ldap.requests;
@@ -42,6 +42,17 @@
  */
 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);
 
@@ -61,9 +72,10 @@
 
     /**
      * 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.
      */

--
Gitblit v1.10.0