Giter Site home page Giter Site logo

AS2 Client - https about as2-lib HOT 15 CLOSED

phax avatar phax commented on July 29, 2024
AS2 Client - https

from as2-lib.

Comments (15)

cairnechan avatar cairnechan commented on July 29, 2024 3

it works now, many thanks

	@Bean
	public ServletRegistrationBean AS2ReceiveServlet(ServletContext servletContext) {
		WebScopeManager.onGlobalBegin(servletContext);
		ServletRegistrationBean register = new ServletRegistrationBean(new AS2ReceiveServlet(), "/as2");
		register.addInitParameter("as2-servlet-config-filename", "config/config.xml");
		return register;
	}

from as2-lib.

kalkrishnan avatar kalkrishnan commented on July 29, 2024 1

WHen I removed it from the servlet, it again gave me an error of no global scope. I ended up keeping it in my servlet and defining my own listener which doesnt define a global scope and that worked.

from as2-lib.

phax avatar phax commented on July 29, 2024

Version 2.2.8 was a long time ago :)
You are right, there are no explicit APIs for this.
This was a fix #20 where you are allowed to overload some stuff in the AbstractHttpSenderModule (namely createSSLContext () and createHostnameVerifier ()). That ,means you can create a sublcass of AS2SenderModule where you overload these methods, and than invoke as2Client.setAS2SenderModuleFactory (MyAS2SenderModule::new); to set the new factory.
hth

from as2-lib.

cairnechan avatar cairnechan commented on July 29, 2024

@phax thanks, what's more, may I ask how to add https(ssl_protocol, ssl_keystore, ssl_keystore_password) on AS2ReceiverModule

from as2-lib.

phax avatar phax commented on July 29, 2024

I don't fully understand your request.
You need a server-like component to request something - e.g. the standalone as2-server or an application server based solution using e.g. as2-servlet. The configuration on how to receive something via https depends on what you are using to receive something.
With the AS2Client directly, you can only get synchronous MDNs back. Asnychronous MDNs must be handled externally and cannot be dealt with by AS2Client.
hth

from as2-lib.

cairnechan avatar cairnechan commented on July 29, 2024

@phax yes, I configure AS2ReceiverModule in standalone as2-server which can successfully handle as2(http) request. For https, I add these attributes(ssl_protocol, ssl_keystore, ssl_keystore_password) on AS2ReceiverModule but it does not works with as2(https)

from as2-lib.

phax avatar phax commented on July 29, 2024

I must admit I have no idea.
I'm using https only on Tomcat, by adding an httpd in front, to perform the SSL handshake. I have no experience on how to perform this "standalone" :(

Closed by accident

from as2-lib.

cairnechan avatar cairnechan commented on July 29, 2024

@phax I enable https service by using tomcat embed in spring-boot. But now I have trouble reusing AS2ReceiverHandler since it use socket io(I can retrieve ServletRequest and ServletResponse from sprint-boot controller). Could you please adivse, thanks

from as2-lib.

phax avatar phax commented on July 29, 2024

Well okay, here are some questions:
a) are you using as2-servlet or are you using the as2-server?
b) Did you have a look at how this can be configured in Tomcat: (e.g. https://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html for Tomcat 7)?

from as2-lib.

cairnechan avatar cairnechan commented on July 29, 2024

I use as2-server at the beginning, find it was using socket io. Shall I turn to as2-servlet?
Because I am using spring-boot, which contain a tomcat server inside and simplify the configuration, I follow this configuration to enable https (step2 https://drissamri.be/blog/java/enable-https-in-spring-boot ), it looks like

server.port=8443
server.ssl.key-store=keystore/client-certs.p12
server.ssl.key-store-password=mypassword
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=fwks

from as2-lib.

phax avatar phax commented on July 29, 2024

Yes, please switch to the as2-servlet. Spring boot obviously embedds Tomcat, and Tomcat can (to my knowledge) only handle Servlets.
If you can provide a wrapper around the as2-demo-webapp I'm also happy to publish it here....

from as2-lib.

cairnechan avatar cairnechan commented on July 29, 2024

I turn to as2-servlet now, and regist AS2ReceiveServlet into spring-boot in this way

@Configuration
public class ServletConfiguration {

	@Bean
	public ServletRegistrationBean AS2ReceiveServlet() {
		ServletRegistrationBean register = new ServletRegistrationBean(new AS2ReceiveServlet(), "/as2");
		register.addInitParameter("as2-servlet-config-filename", "config/config.xml");
		return register;
	}
	
}

However it fail to initialze this servlet, and throw the following exception

......
Caused by: java.lang.IllegalStateException: No global scope object has been set!
	at com.helger.scope.mgr.ScopeManager.getGlobalScope(ScopeManager.java:158)
	at com.helger.scope.singleton.AbstractGlobalSingleton._getStaticScope(AbstractGlobalSingleton.java:48)
	at com.helger.scope.singleton.AbstractGlobalSingleton.getGlobalSingleton(AbstractGlobalSingleton.java:65)
	at com.helger.xservlet.servletstatus.ServletStatusManager.getInstance(ServletStatusManager.java:67)
	at com.helger.xservlet.AbstractXServlet.<init>(AbstractXServlet.java:182)
	at com.helger.as2servlet.AS2ReceiveServlet.<init>(AS2ReceiveServlet.java:32)

Could you please advise

from as2-lib.

phax avatar phax commented on July 29, 2024

You need an additional bean that requires the ServletContext.
Upon creation, you need to call:

WebScopeManager.onGlobalBegin (ServletContext);

and for shutdown you need to invoke:

WebScopeManager.onGlobalEnd ();

hth

from as2-lib.

kalkrishnan avatar kalkrishnan commented on July 29, 2024

I did this but when I register the AS2WebAppListener, it also tries to set the global scope and throws an exception that global scope has already been set

from as2-lib.

phax avatar phax commented on July 29, 2024

@kalkrishnan This is preferrably used in the WebAppListener - remove it from the servlet than

from as2-lib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.