Axis SecureSocketFactory - Setting the constructor attributes

China☆狼群 提交于 2019-12-12 12:27:52

问题


I have a customer SecureSocketFactory set to be used by Axis when making an https connection using the following property:

AxisProperties.setProperty("axis.socketSecureFactory",
    "com.metavante.csp.model.manager.mobilepayments.MonitiseSSLSocketFactory");

When this class is instantiated by Axis, the constructor with a Hashtable (attributes) is called. I see the timeout attribute is set in this table. Is there anyway to set more values in this? I would like to be able to configure the Socket Factory on a per-instance scenario instead of globally by using static or system properties.

Edit: I found out these attributes are actually the HttpSender (BasicHandler) options. I still am unable to set these dynamically though.


回答1:


I figured out a way around the problem. In my code where I wanted to set the property I use: serviceLocator.getEngine().setOption(USE_CERT_PROPERTY, new Boolean(true));

where getEngine returns the AxisEngine in use. Then in the socket factory I can:

Boolean useSMS = (Boolean) MessageContext.getCurrentContext().getProperty(OtherClass.USE_CERT_PROPERTY);

I could set the object to whatever, maybe I'll go with the certificate name I needed. Hope this helps someone.




回答2:


You can retrieve the SocketFactory instance and then change or add attributes, if you are interested in modify SocketFactory behavior. But if you do this, you also should inject the HashTable attribute (with the timeout). I think there is not a final and pretty solution.

AxisProperties.setProperty("org.apache.axis.components.net.SecureSocketFactory", MyAxisSocketFactory.class.getName());
MyAxisSocketFactory factory = (MyAxisSocketFactory) SocketFactoryFactory.getFactory("https", myHashTableParams);
factory.setMyStuff();

After this code, the instance of SocketFactory will be created and configured, and ready to use in web services, or whatever ^_^



来源:https://stackoverflow.com/questions/651684/axis-securesocketfactory-setting-the-constructor-attributes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!