From 4b6d1e29766abcbb92f798c445b6f8f844518c26 Mon Sep 17 00:00:00 2001 From: Scott Kurz Date: Tue, 18 Mar 2025 07:20:43 -0400 Subject: [PATCH] Add getRequestSocket() SPI method and add impl to impls Signed-off-by: Scott Kurz --- .../ssl/internal/SSLConnectionLink.java | 9 ++++ .../ssl/internal/SSLReadServiceContext.java | 9 +++- .../ssl/internal/SSLWriteServiceContext.java | 10 +++- .../internal/TCPBaseRequestContext.java | 40 ++++++++++----- .../ws/tcpchannel/internal/TCPConnLink.java | 51 ++++++++++++++----- .../wsspi/tcpchannel/TCPRequestContext.java | 25 ++++++--- .../sip/container/was/message/SipMessage.java | 8 +++ .../h2internal/H2TCPReadRequestContext.java | 9 +++- .../h2internal/H2TCPWriteRequestContext.java | 8 ++- .../request/extended/IRequestExtended.java | 4 ++ .../osgi/request/IRequestImpl.java | 12 +++++ 11 files changed, 147 insertions(+), 38 deletions(-) diff --git a/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLConnectionLink.java b/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLConnectionLink.java index 55c70ca4b36f..e67a41262aea 100644 --- a/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLConnectionLink.java +++ b/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLConnectionLink.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.net.InetAddress; +import java.net.Socket; import java.nio.ReadOnlyBufferException; import java.util.Map; import java.util.concurrent.locks.Lock; @@ -1368,4 +1369,12 @@ protected void setAlpnNegotiator(ThirdPartyAlpnNegotiator negotiator) { protected ThirdPartyAlpnNegotiator getAlpnNegotiator() { return this.alpnNegotiator; } + + /** + * @return + */ + public Socket getSocket() { + // TODO Auto-generated method stub + return deviceServiceContext.getReadInterface().getSocket(); + } } diff --git a/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLReadServiceContext.java b/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLReadServiceContext.java index b08e9db6a3c8..bd81eddeb833 100644 --- a/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLReadServiceContext.java +++ b/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLReadServiceContext.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -13,6 +13,7 @@ package com.ibm.ws.channel.ssl.internal; import java.io.IOException; +import java.net.Socket; import javax.net.ssl.SSLEngineResult; import javax.net.ssl.SSLEngineResult.HandshakeStatus; @@ -1995,4 +1996,10 @@ public void run() { } } } + + @Override + public Socket getSocket() { + // TODO - is this correct? + return deviceReadContext.getSocket(); + } } diff --git a/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLWriteServiceContext.java b/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLWriteServiceContext.java index 06c3da65a13d..85a0a674a945 100644 --- a/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLWriteServiceContext.java +++ b/dev/com.ibm.ws.channel.ssl/src/com/ibm/ws/channel/ssl/internal/SSLWriteServiceContext.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -13,6 +13,7 @@ package com.ibm.ws.channel.ssl.internal; import java.io.IOException; +import java.net.Socket; import java.nio.ReadOnlyBufferException; import javax.net.ssl.SSLEngine; @@ -1006,4 +1007,11 @@ public void run() { } } } + + @Override + public Socket getSocket() { + // TODO Auto-generated method stub + throw new IllegalStateException("getSocket() not implemented for class: " + this.getClass().getCanonicalName()); + + } } diff --git a/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPBaseRequestContext.java b/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPBaseRequestContext.java index 93797b28c198..fe9d34509424 100644 --- a/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPBaseRequestContext.java +++ b/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPBaseRequestContext.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -13,6 +13,7 @@ package com.ibm.ws.tcpchannel.internal; import java.io.IOException; +import java.net.Socket; import java.nio.ByteBuffer; import java.util.LinkedList; import java.util.List; @@ -61,7 +62,7 @@ public class TCPBaseRequestContext implements TCPRequestContext, FFDCSelfIntrosp protected TCPChannelConfiguration config; protected long timeoutTime; private int timeoutInterval; - private WsByteBuffer[] defaultBuffers = new WsByteBuffer[1]; + private final WsByteBuffer[] defaultBuffers = new WsByteBuffer[1]; private ByteBuffer byteBufferArray[] = null; private ByteBuffer byteBufferArrayDirect[] = null; private boolean missedSet = false; @@ -80,7 +81,7 @@ public class TCPBaseRequestContext implements TCPRequestContext, FFDCSelfIntrosp /** * Constructor. - * + * * @param link */ protected TCPBaseRequestContext(TCPConnLink link) { @@ -100,7 +101,7 @@ protected void abort() { /** * Check whether this context has been aborted previously or not. - * + * * @return boolean */ protected boolean isAborted() { @@ -109,7 +110,7 @@ protected boolean isAborted() { /** * Access the connection link for this context object. - * + * * @return TCPConnLink */ public TCPConnLink getTCPConnLink() { @@ -123,6 +124,7 @@ protected TCPChannelConfiguration getConfig() { /** * @see TCPRequestContext#getInterface() */ + @Override public TCPConnectionContext getInterface() { return this.oTCPConnLink; } @@ -132,11 +134,13 @@ public TCPConnectionContext getInterface() { /* =================================================================== */ /** @see TCPRequestContext#getBuffers() */ + @Override public WsByteBuffer[] getBuffers() { return this.buffers; } /** @see TCPRequestContext#setBuffers(WsByteBuffer[]) */ + @Override public void setBuffers(WsByteBuffer[] bufs) { this.missedSet = false; this.buffers = bufs; @@ -278,6 +282,7 @@ protected void setBuffersToDirect(WsByteBuffer[] bufs) { /** * @return WsByteBuffer */ + @Override public WsByteBuffer getBuffer() { if (this.buffers == null) { return null; @@ -288,6 +293,7 @@ public WsByteBuffer getBuffer() { /** * @param buf */ + @Override public void setBuffer(WsByteBuffer buf) { this.missedSet = false; @@ -333,6 +339,7 @@ public void setBuffer(WsByteBuffer buf) { /** * Clear any buffers that are currently stored. */ + @Override public void clearBuffers() { if (null != this.buffers) { for (int i = 0; i < this.buffers.length; i++) { @@ -392,7 +399,7 @@ protected long getIOCompleteAmount() { * comparable format to System.currentTimeMillis) when this request * will time out. Should only be invoked if the 'hasTimeout' method * returns true for this request. - * + * * @return long Point in time when request will timeout. */ public long getTimeoutTime() { @@ -401,7 +408,7 @@ public long getTimeoutTime() { /** * Sets the timeout value returned by 'getTimeoutTime'. - * + * * @param time */ protected void setTimeoutTime(int time) { @@ -425,7 +432,7 @@ protected void setTimeoutTime(int time) { /** * Returns true if this request has an associated timeout. - * + * * @return boolean */ protected boolean hasTimeout() { @@ -434,7 +441,7 @@ protected boolean hasTimeout() { /** * Returns timoutInterval of this request. - * + * * @return int */ public int getTimeoutInterval() { @@ -443,7 +450,7 @@ public int getTimeoutInterval() { /** * Introspect this object for FFDC output. - * + * * @return List */ public List introspect() { @@ -468,6 +475,7 @@ public List introspect() { /* * @see com.ibm.ws.ffdc.FFDCSelfIntrospectable#introspectSelf() */ + @Override public String[] introspectSelf() { List rc = introspect(); return rc.toArray(new String[rc.size()]); @@ -513,11 +521,11 @@ protected ByteBuffer[] getByteBufferArrayDirect() { /** * Updates the IO byte counters, checks if IO operation is complete - * + * * @param byteCount - * number of IO bytes for latest read/write + * number of IO bytes for latest read/write * @param type - * 0 for read. 1 for write + * 0 for read. 1 for write * @return true if IO operation has read/wrote enough bytes, false if not */ // IMPROVEMENT: this shouldn't be public, but needs to be for now. @@ -564,4 +572,10 @@ public boolean updateIOCounts(long byteCount, int type) { return rc; } + @Override + public Socket getSocket() { + TCPConnLink connLink = getTCPConnLink(); + return connLink.getSocket(); + } + } diff --git a/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPConnLink.java b/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPConnLink.java index 9d907613a935..e45b60d6bad9 100644 --- a/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPConnLink.java +++ b/dev/com.ibm.ws.channelfw/src/com/ibm/ws/tcpchannel/internal/TCPConnLink.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -36,12 +36,12 @@ /** * TCP channel's connection link object. - * + * */ public class TCPConnLink extends TCPProxyConnLink implements ConnectionLink, OutboundConnectionLink, TCPConnectionContext, FFDCSelfIntrospectable { private static final TraceComponent tc = Tr.register(TCPConnLink.class, TCPChannelMessageConstants.TCP_TRACE_NAME, TCPChannelMessageConstants.TCP_BUNDLE); - private TCPChannelConfiguration config; + private final TCPChannelConfiguration config; private TCPChannel tcpChannel = null; private int numReads = 0; private int numWrites = 0; @@ -64,7 +64,7 @@ public class TCPConnLink extends TCPProxyConnLink implements ConnectionLink, Out /** * Constructor. - * + * * @param vc * @param channel * @param cfg @@ -93,6 +93,7 @@ public TCPConnLink(VirtualConnection vc, TCPChannel channel, TCPChannelConfigura * com.ibm.wsspi.channelfw.ConnectionReadyCallback#ready(com.ibm.wsspi.channelfw * .VirtualConnection) */ + @Override public void ready(VirtualConnection inVC) { // This should not be called because the TCPConnLink is always // ready since it is the first in the chain. @@ -104,13 +105,14 @@ public void ready(VirtualConnection inVC) { /* * @see com.ibm.wsspi.channelfw.ConnectionLink#getChannelAccessor() */ + @Override public Object getChannelAccessor() { return this; } /** * Access the channel that owns this connection link. - * + * * @return TCPChannel */ public TCPChannel getTCPChannel() { @@ -120,6 +122,7 @@ public TCPChannel getTCPChannel() { /* * @see com.ibm.wsspi.tcpchannel.TCPConnectionContext#getReadInterface() */ + @Override public TCPReadRequestContext getReadInterface() { return this.reader; } @@ -127,6 +130,7 @@ public TCPReadRequestContext getReadInterface() { /* * @see com.ibm.wsspi.tcpchannel.TCPConnectionContext#getWriteInterface() */ + @Override public TCPWriteRequestContext getWriteInterface() { return this.writer; } @@ -143,6 +147,7 @@ protected TCPWriteRequestContextImpl getTCPWriteConnLink() { * @see * com.ibm.wsspi.channelfw.OutboundConnectionLink#connect(java.lang.Object) */ + @Override public void connect(Object context) throws Exception { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "connect"); @@ -171,6 +176,7 @@ public void connect(Object context) throws Exception { * com.ibm.wsspi.channelfw.OutboundConnectionLink#connectAsynch(java.lang. * Object) */ + @Override public void connectAsynch(Object context) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "connectAsynch"); @@ -297,18 +303,20 @@ protected void connectComplete(SocketIOChannel socket) throws IOException { /** * Query whether this connect is asynchronous or not. - * + * * @return boolean */ + @Override protected boolean isAsyncConnect() { return (null == this.syncObject); } /** * Query if an error has occurred. - * + * * @return boolean */ + @Override protected boolean isSyncError() { return (null != this.syncError); } @@ -317,6 +325,7 @@ protected void setCallCompleteLocal(boolean newValue) { this.callCompleteLocal = newValue; } + @Override protected void connectFailed(IOException e) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "connectFailed"); @@ -346,7 +355,7 @@ protected void setSocketIOChannel(SocketIOChannel s) { /** * Returns the SocketIOChannel associated with this request - * + * * @return SocketIOChannel */ public SocketIOChannel getSocketIOChannel() { @@ -355,7 +364,7 @@ public SocketIOChannel getSocketIOChannel() { /** * Access the channel configuration for this connection link. - * + * * @return TCPChannelConfiguration */ public TCPChannelConfiguration getConfig() { @@ -365,6 +374,7 @@ public TCPChannelConfiguration getConfig() { /* * @see com.ibm.wsspi.tcpchannel.TCPConnectionContext#getRemoteAddress() */ + @Override public InetAddress getRemoteAddress() { return this.socketIOChannel.getSocket().getInetAddress(); } @@ -372,6 +382,7 @@ public InetAddress getRemoteAddress() { /* * @see com.ibm.wsspi.tcpchannel.TCPConnectionContext#getRemotePort() */ + @Override public int getRemotePort() { return this.socketIOChannel.getSocket().getPort(); } @@ -379,6 +390,7 @@ public int getRemotePort() { /* * @see com.ibm.wsspi.tcpchannel.TCPConnectionContext#getLocalAddress() */ + @Override public InetAddress getLocalAddress() { return this.socketIOChannel.getSocket().getLocalAddress(); } @@ -386,6 +398,7 @@ public InetAddress getLocalAddress() { /* * @see com.ibm.wsspi.tcpchannel.TCPConnectionContext#getLocalPort() */ + @Override public int getLocalPort() { return this.socketIOChannel.getSocket().getLocalPort(); } @@ -393,6 +406,7 @@ public int getLocalPort() { /* * @see com.ibm.wsspi.tcpchannel.TCPConnectionContext#getSSLContext() */ + @Override public SSLConnectionContext getSSLContext() { // This TCPConnectionContext does not support SSL so return null. return null; @@ -400,7 +414,7 @@ public SSLConnectionContext getSSLContext() { /** * Query the number of reads performed on this connection. - * + * * @return int */ protected int getNumReads() { @@ -409,7 +423,7 @@ protected int getNumReads() { /** * Query the number of writes performed on this connection. - * + * * @return int */ protected int getNumWrites() { @@ -435,6 +449,7 @@ public void incrementNumWrites() { * com.ibm.wsspi.channelfw.base.OutboundConnectorLink#close(com.ibm.wsspi. * channelfw.VirtualConnection, java.lang.Exception) */ + @Override public void close(VirtualConnection inVC, Exception e) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { Tr.entry(tc, "close(), " + this); @@ -474,7 +489,7 @@ public void close(VirtualConnection inVC, Exception e) { /** * Query whether this connection link is closed or not. - * + * * @return boolean */ public boolean isClosed() { @@ -486,6 +501,7 @@ public boolean isClosed() { * com.ibm.wsspi.channelfw.base.OutboundConnectorLink#destroy(java.lang.Exception * ) */ + @Override public void destroy(Exception e) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { if (e == null) { @@ -520,7 +536,7 @@ public void destroy(Exception e) { /** * Introspect this object for FFDC output. - * + * * @return List */ public List introspect() { @@ -541,9 +557,18 @@ public List introspect() { /* * @see com.ibm.ws.ffdc.FFDCSelfIntrospectable#introspectSelf() */ + @Override public String[] introspectSelf() { List rc = introspect(); return rc.toArray(new String[rc.size()]); } + /** + * @return Socket + */ + public Socket getSocket() { + SocketIOChannel channel = getSocketIOChannel(); + return channel.getSocket(); + } + } diff --git a/dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/tcpchannel/TCPRequestContext.java b/dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/tcpchannel/TCPRequestContext.java index 8cbe54e5ede5..d50bb59cbb28 100644 --- a/dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/tcpchannel/TCPRequestContext.java +++ b/dev/com.ibm.ws.channelfw/src/com/ibm/wsspi/tcpchannel/TCPRequestContext.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -12,13 +12,15 @@ *******************************************************************************/ package com.ibm.wsspi.tcpchannel; +import java.net.Socket; + import com.ibm.wsspi.bytebuffer.WsByteBuffer; /** * A context object encapsulating all of the data related to a TCPChannel * read data request. This context can be obtained via the getReadInterface * method on the TCPConnectionContext. - * + * * @ibm-spi */ @@ -26,7 +28,7 @@ public interface TCPRequestContext { /** * Link back to the TCPConnectionContext from whence this interface came. - * + * * @return TCPConnectionContext - originating context */ TCPConnectionContext getInterface(); @@ -41,16 +43,16 @@ public interface TCPRequestContext { /** * Returns the set of read buffers associated with this * request. - * + * * @return WsByteBuffer[] */ WsByteBuffer[] getBuffers(); /** * Sets the array of read buffers associated with this request. - * + * * @param bufs - * - the array of WsByteBuffers to be set + * - the array of WsByteBuffers to be set */ void setBuffers(WsByteBuffer[] bufs); @@ -58,7 +60,7 @@ public interface TCPRequestContext { * Returns the first read buffer in the buffer array associated with this * request. * This is a convenience method for when only one buffer is needed. - * + * * @return WsByteBuffer */ WsByteBuffer getBuffer(); @@ -67,11 +69,18 @@ public interface TCPRequestContext { * Sets the first read buffer in the buffer array associated with this * request. This is * a convenience method for when only one buffer is needed - * + * * @param buf */ void setBuffer(WsByteBuffer buf); + /** + * Returns a java.net.Socket associated with the request + * + * @return Socket + */ + Socket getSocket(); + /** * A special value for the timeout parm used on the request calls. * Specifying this value will cause the TCPChannel to use the default diff --git a/dev/com.ibm.ws.sipcontainer/src/com/ibm/ws/sip/container/was/message/SipMessage.java b/dev/com.ibm.ws.sipcontainer/src/com/ibm/ws/sip/container/was/message/SipMessage.java index 531924b4319f..f8c66698a017 100644 --- a/dev/com.ibm.ws.sipcontainer/src/com/ibm/ws/sip/container/was/message/SipMessage.java +++ b/dev/com.ibm.ws.sipcontainer/src/com/ibm/ws/sip/container/was/message/SipMessage.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.io.InputStream; +import java.net.Socket; import java.nio.charset.Charset; import java.security.cert.X509Certificate; import java.util.ArrayList; @@ -1698,4 +1699,11 @@ public ServletOutputStream getOutputStream() throws IOException { public HttpInboundConnection getHttpInboundConnection() { return null; } + + @Override + public Socket getRequestSocket() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPReadRequestContext.java b/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPReadRequestContext.java index 9acbcac0e13f..33918856c274 100644 --- a/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPReadRequestContext.java +++ b/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPReadRequestContext.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -13,6 +13,7 @@ package com.ibm.ws.http.channel.h2internal; import java.io.IOException; +import java.net.Socket; import java.nio.ByteBuffer; import java.util.concurrent.TimeUnit; @@ -276,4 +277,10 @@ public boolean getJITAllocateAction() { return this.jitAllocateAction; } + @Override + public Socket getSocket() { + // TODO - not sure this is correct + return getInterface().getReadInterface().getSocket(); + } + } diff --git a/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPWriteRequestContext.java b/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPWriteRequestContext.java index 9df65675950d..0b2f067a935c 100644 --- a/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPWriteRequestContext.java +++ b/dev/com.ibm.ws.transport.http/src/com/ibm/ws/http/channel/h2internal/H2TCPWriteRequestContext.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -13,6 +13,7 @@ package com.ibm.ws.http.channel.h2internal; import java.io.IOException; +import java.net.Socket; import java.nio.ByteBuffer; import com.ibm.websphere.ras.Tr; @@ -242,4 +243,9 @@ public void setBuffer(WsByteBuffer buf) { // // } + @Override + public Socket getSocket() { + // TODO Auto-generated method stub + throw new IllegalStateException("getSocket() not implemented for class: " + this.getClass().getCanonicalName()); + } } diff --git a/dev/com.ibm.ws.webcontainer/src/com/ibm/websphere/servlet/request/extended/IRequestExtended.java b/dev/com.ibm.ws.webcontainer/src/com/ibm/websphere/servlet/request/extended/IRequestExtended.java index eeedd821931c..41afc64c2e6c 100644 --- a/dev/com.ibm.ws.webcontainer/src/com/ibm/websphere/servlet/request/extended/IRequestExtended.java +++ b/dev/com.ibm.ws.webcontainer/src/com/ibm/websphere/servlet/request/extended/IRequestExtended.java @@ -12,6 +12,8 @@ *******************************************************************************/ package com.ibm.websphere.servlet.request.extended; +import java.net.Socket; + import com.ibm.websphere.servlet.request.IRequest; import com.ibm.ws.util.ThreadPool; import com.ibm.wsspi.http.HttpInboundConnection; @@ -25,4 +27,6 @@ public interface IRequestExtended extends IRequest { public ThreadPool getThreadPool(); public HttpInboundConnection getHttpInboundConnection(); + + public Socket getRequestSocket(); } diff --git a/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/request/IRequestImpl.java b/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/request/IRequestImpl.java index 0ff0633a93ad..cdc874bc1730 100644 --- a/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/request/IRequestImpl.java +++ b/dev/com.ibm.ws.webcontainer/src/com/ibm/ws/webcontainer/osgi/request/IRequestImpl.java @@ -15,6 +15,8 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.Socket; +import java.net.Socket; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.text.ParseException; @@ -45,6 +47,8 @@ import com.ibm.wsspi.http.channel.values.HttpHeaderKeys; import com.ibm.wsspi.http.channel.values.VersionValues; import com.ibm.wsspi.http.ee7.HttpInboundConnectionExtended; +import com.ibm.wsspi.tcpchannel.TCPConnectionContext; +import com.ibm.wsspi.tcpchannel.TCPReadRequestContext; import com.ibm.wsspi.webcontainer.WCCustomProperties; import io.openliberty.http.ext.HttpRequestExt; @@ -984,4 +988,12 @@ public ThreadPool getThreadPool() public HttpInboundConnection getHttpInboundConnection() { return this.conn; } + + @Override + public Socket getRequestSocket() { + HttpInboundConnectionExtended connExt = (HttpInboundConnectionExtended)conn; + TCPConnectionContext tcpConnCtx = connExt.getTCPConnectionContext(); + TCPReadRequestContext tcpReadReqCtx = tcpConnCtx.getReadInterface(); + return tcpReadReqCtx.getSocket(); + } }