| | |
| | | import java.util.Collection; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.concurrent.atomic.AtomicLong; |
| | | |
| | | import javax.servlet.ServletRequest; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.opendj.ldap.ResultHandler; |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.loggers.HTTPAccessLogger; |
| | | import org.opends.server.loggers.HTTPRequestInfo; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.protocols.ldap.AddResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | |
| | | * connection that will be accepted by an instance of the HTTP connection |
| | | * handler. |
| | | */ |
| | | final class HTTPClientConnection extends ClientConnection |
| | | final class HTTPClientConnection extends ClientConnection implements |
| | | HTTPRequestInfo |
| | | { |
| | | |
| | | // TODO JNR Confirm with Matt that persistent searches are inapplicable to |
| | |
| | | /** The protocol in use for this client connection. */ |
| | | private String protocol; |
| | | |
| | | /** The HTTP method/verb used for this request. */ |
| | | private final String method; |
| | | /** The query issued by the client. */ |
| | | private final String query; |
| | | /** The user agent used by the client. */ |
| | | private final String userAgent; |
| | | |
| | | /** The username that was used to authenticate. */ |
| | | private String authUser; |
| | | /** |
| | | * The HTTP status code returned to the client. Using 0 to say no status code |
| | | * was set since it is not . |
| | | */ |
| | | private AtomicInteger statusCode = new AtomicInteger(0); |
| | | |
| | | /** The client (remote) address. */ |
| | | private String clientAddress; |
| | | |
| | | /** The client (remote) host name. */ |
| | | private String clientHost; |
| | | |
| | | /** The client (remote) port. */ |
| | | private int clientPort; |
| | | |
| | |
| | | /** The server (local) address. */ |
| | | private String serverAddress; |
| | | |
| | | /** The server (local) host name. */ |
| | | private String serverHost; |
| | | |
| | | /** The server (local) port. */ |
| | | private int serverPort; |
| | | |
| | |
| | | * represents this client connection. |
| | | */ |
| | | public HTTPClientConnection(HTTPConnectionHandler connectionHandler, |
| | | ServletRequest request) |
| | | HttpServletRequest request) |
| | | { |
| | | this.connectionHandler = connectionHandler; |
| | | |
| | | // memoize all the fields we need from the request before Grizzly decides to |
| | | // recycle it |
| | | this.protocol = request.getProtocol(); |
| | | this.clientAddress = request.getRemoteAddr(); |
| | | this.clientPort = request.getRemotePort(); |
| | | this.serverAddress = request.getLocalAddr(); |
| | |
| | | this.isSecure = request.isSecure(); |
| | | this.securityStrengthFactor = |
| | | calcSSF(request.getAttribute(SERVLET_SSF_CONSTANT)); |
| | | this.method = request.getMethod(); |
| | | this.query = request.getRequestURI() + "/" + request.getQueryString(); |
| | | this.protocol = request.getProtocol(); |
| | | this.userAgent = request.getHeader("User-Agent"); |
| | | |
| | | this.statTracker = this.connectionHandler.getStatTracker(); |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getAuthUser() |
| | | { |
| | | return this.authUser; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public long getConnectionID() |
| | | { |
| | | return connectionID; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getClientHost() |
| | | { |
| | | return clientHost; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int getClientPort() |
| | | { |
| | | return clientPort; |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getServerHost() |
| | | { |
| | | return serverHost; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int getServerPort() |
| | | { |
| | | return serverPort; |
| | |
| | | { |
| | | time = operation.getProcessingTime(); |
| | | } |
| | | this.statTracker.updateRequestMonitoringData(getMethod(), time); |
| | | this.statTracker.updateOperationMonitoringData(operation |
| | | .getOperationType(), time); |
| | | } |
| | |
| | | throw new RuntimeException("Not implemented"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setAuthUser(String authUser) |
| | | { |
| | | this.authUser = authUser; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMethod() |
| | | { |
| | | return this.method; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getQuery() |
| | | { |
| | | return this.query; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int getStatusCode() |
| | | { |
| | | return this.statusCode.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getUserAgent() |
| | | { |
| | | return this.userAgent; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<Operation> getOperationsInProgress() |
| | | { |
| | | Collection<OperationWithFutureResult> values = |
| | |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void log(int statusCode) |
| | | { |
| | | if (this.statusCode.compareAndSet(0, statusCode)) |
| | | { // this request was not logged before |
| | | HTTPAccessLogger.logRequestInfo(this); |
| | | } |
| | | } |
| | | } |