I recently migrated my web services from Axis to CXF (2.1). It appears that while Axis needed the "axis.socketSecureFactory" set, CXF grabs the default. How do I set the default SocketFactory in Java to my own implementation (such as a property)?
What I am not looking to do is to set the default SocketFactory properties like setting the property for my truststore, keystore and passwords.
SocketFactory class is used to create sockets. It must be subclassed by other factories, which create particular subclasses of sockets and thus provide a general framework for the addition of public socket-level functionality. (See, for example, SSLSocketFactory .) The javax. net.
ssl. SSLSocketFactory is used for creating SSLSocket objects. This class contains three groups of APIs. The first group consists of a single static getDefault() method used to retrieve the default instance which, in turn, can create SSLSocket instances.
If we are talking about the standard sockets then Socket.setSocketImplFactory(SocketImplFactory)
is used to change factory for ordinary sockets and ServerSocket.setSocketFactory(SocketImplFactory)
for server sockets.
If you are using these, then take note of the fact that you can only set these factories once.
Note the java socket implementation defaults to using SocksSocketImpl (a package visible class in java.net) if the it discovers that the factory is null
in case you want a factory that can switch pack to the standard java implementation.
According to the OpenJDK7 source code for javax.net.SocketFactory
, the Sun JVM is hard coded to return a javax.net.DefaultSocketFactory
for getDefault();
Edit: However, the default SSLSocketFactory can be set by the security property ssl.SocketFactory.provider
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With