How can I enable ws-addressing in spring so that replyTo is understood? - spring

I created a ws endpoint with spring using spring-boot-starter-webservices.
I have used #org.springframework.ws.server.endpoint.annotation.Endpoint.It works fine.
But when I am trying to add the wsa:ReplyTo addressing header to the request with mustUnderstand=true the server prints:
Could not handle mustUnderstand headers: {http://www.w3.org/2005/08/addressing}ReplyTo. Returning fault
and returns a similar Fault as a response.
How can I enable addressing so that ReplyTo is understood and replies with 202, sending the response to the differrent endpoint described in ReplyTo?
I tried adding #javax.xml.ws.soap.Addressing(enabled=true) next to #Endpoint annotation but I still get the above behaviour.

Related

RestTemplate: Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter

I am using RestTemplate with custom HttpClient. My request is getting redirected to S3 but somehow it is carrying Authorization header along with it after redirection.
Httpclient is configured to use LaxRedirectStrategy, cookies are ignored.
Is there a way how to fix this issue or any insight?

Post request from angular to spring boot server params are not seen

I am quite new with angular and spring boot and I am trying to send a post request from angular to the spring server but it gives me bad request with message "Required String parameter 'key' is not present"
however the post is sent with request payload containing the key and the value, but it is a request payload not a form data and I don't know whether it differs or not :/
spring code:
https://drive.google.com/open?id=1oRMAtICuS0TaoPVMgDxd1ApGALnCOq-o

404 when do logout in Spring Security Rest Plugin for Grails

I'm setting the security system on my project (Grails - Angularjs) with Spring Security Rest Plugin v1.5.4 (using spring security core 2.0.0) for Grails 2.4.4. Doc about this plugin can be found here.
I'm testing the login and logout with postman chrome rest client and I'm able to do a login OK, but I'm getting a 404 when I do logout.
In the documentation clearly says:
The logout filter exposes an endpoint for deleting tokens. It will
read the token from an HTTP header. If found, will delete it from the
storage, sending a 200 response. Otherwise, it will send a 404
response
You can configure it in Config.groovy using this properties:
Config key...................................................................................Default
value
grails.plugin.springsecurity.rest.logout.endpointUrl....................../api/logout
grails.plugin.springsecurity.rest.token.validation.headerName....X-Auth-Token
So, after doing a login successfully, I tried to do a logout to that url (my_host_url/api/logout) with a GET method and sending a header X-Auth-Token with the token I got previously from login.
But I keep getting a 404. See image below
Edit: I'm setting the chain map like this (in order to get a stateless behavior):
grails.plugin.springsecurity.filterChain.chainMap = [
'/api/**': 'JOINED_FILTERS,-exceptionTranslationFilter,-authenticationProcessingFilter,-securityContextPersistenceFilter,-rememberMeAuthenticationFilter', // Stateless chain
'/**': 'JOINED_FILTERS,-restTokenValidationFilter,-restExceptionTranslationFilter' // Traditional chain
]
So. What am I doing wrong here, or what am I missing?
Thanks in advance!
You missed another excerpt from the docs. It's a warning message literally before the chunk you quoted, and says:
Logout is not possible when using JWT tokens (the default strategy), as no state is kept in the server.
If you still want to have logout, you can provide your own implementation by creating a subclass of JwtTokenStorageService and overriding the methods storeToken and removeToken. Then, register your implementation in resources.groovy as tokenStorageService.

Response with non-OK status does not respect content-type in producer annotation

I encountered an odd while I was using Jersey..
I had the #Producer (MediaType.APPLICATION_JSON) for the whole resource class.
I have one class CustomerResponse, which is just normal)
If I return Response.status(Stauts.OK).entity(customerResponse).build(), on the client side, I will receive the json entity as I expected.
However, if I return Response.status(Stauts.BAD_REQUEST).entity(customerResponse).build(), the content-type become text/html.
If I change the Producer to APPLICATION_XML, the same thing happens. It seems to me that only response with 400 will return with content-type specified in the #Producer annotation. For all responses with other status code, it will simply return text/html.
Can anyone help me on this? Thank you very much.
This is turns out to be really interesting.
I started grizzly servlet instead grizzly server by using following code
WebappContext webappContext = new WebappContext("GRIZZLY Web Server WebappContext");
ServletRegistration servletRegistration = webappContext.addServlet("JerseyServletContainer", ServletContainer.class);
servletRegistration.setInitParameter("jersey.config.server.provider.packages", WebServiceConstants.ROOT_PACKAGE);
servletRegistration.addMapping("/*");
webappContext.deploy(grizzlyWebServer);
startGrizzlyWebServer(grizzlyWebServer);
It seems like the servlet somehow convert the content-type for all non-OK (not 400) http response to type=text/html; charset=ISO-8859-1.
If I started the grizzly-http-server, everything works fine.
We use like the following:
Response.status(Response.Status.BAD_REQUEST).entity(myObject)
.type(MediaType.APPLICATION_JSON_TYPE).build()

Can I add cookie with Spring SockJs websocket implementation

Can I add custom cookies over websocket in Spring SockJS implementation? The way we can add it with http request/ response?
Forget to mention that I see way to read cookie from headers :: HttpHeaders headers= session.getHandshakeHeaders(); -But I do not see a way to set headers. With headers I can read the cookies -but how to set it?
This is all work-in-progress still, but at this time you can configure a HandshakeInterceptor on the DefaultSockJsService. That gives you access to the request and response before and after the handshake.

Resources