| | |
| | | import javax.servlet.http.HttpServletResponseWrapper; |
| | | |
| | | import org.forgerock.json.resource.ResourceException; |
| | | import org.forgerock.opendj.adapter.server2x.Adapters; |
| | | import org.forgerock.opendj.ldap.*; |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.forgerock.opendj.ldap.requests.BindRequest; |
| | |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AddressMask; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.util.Base64; |
| | | |
| | | import static org.forgerock.opendj.adapter.server2x.Converters.*; |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.loggers.AccessLogger.*; |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | |
| | | // wipe it from memory for security reasons |
| | | ctx.password = null; |
| | | ctx.connection.bindAsync(bindRequest, null, |
| | | new CallDoFilterResultHandler(ctx, resultEntry)); |
| | | new CallDoFilterResultHandler(ctx)); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | |
| | | private final HTTPRequestContext ctx; |
| | | private final SearchResultEntry resultEntry; |
| | | |
| | | private CallDoFilterResultHandler(HTTPRequestContext ctx, |
| | | SearchResultEntry resultEntry) |
| | | private CallDoFilterResultHandler(HTTPRequestContext ctx) |
| | | { |
| | | this.ctx = ctx; |
| | | this.resultEntry = resultEntry; |
| | | } |
| | | |
| | | @Override |
| | |
| | | { |
| | | ctx.clientConnection.setAuthUser(ctx.userName); |
| | | |
| | | final AuthenticationInfo authInfo = new AuthenticationInfo( |
| | | to(resultEntry), to(resultEntry.getName()), false); |
| | | try |
| | | { |
| | | doFilter(ctx, authInfo); |
| | | doFilter(ctx); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | ctx.asyncContext = getAsyncContext(request); |
| | | |
| | | ctx.connection.searchSingleEntryAsync(buildSearchRequest(ctx.userName), |
| | | new DoBindResultHandler(ctx)); |
| | | Adapters.newRootConnection().searchSingleEntryAsync( |
| | | buildSearchRequest(ctx.userName), new DoBindResultHandler(ctx)); |
| | | } |
| | | else if (this.connectionHandler.acceptUnauthenticatedRequests()) |
| | | { |
| | | // use unauthenticated user |
| | | doFilter(ctx, new AuthenticationInfo()); |
| | | doFilter(ctx); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void doFilter(HTTPRequestContext ctx, AuthenticationInfo authInfo) |
| | | private void doFilter(HTTPRequestContext ctx) |
| | | throws Exception |
| | | { |
| | | ctx.clientConnection.setAuthenticationInfo(authInfo); |
| | | |
| | | /* |
| | | * WARNING: This action triggers 3-4 others: Set the connection for use with |
| | | * this request on the HttpServletRequest. It will make |