A rest service using spring 2 and jersey, unable to get response for some consumers - spring-boot

We have an application that uses asyncresponse and writes the data into a stream.
I upgraded to spring2 from 1.5.
And not sure if it could be releated but now with postman I get this error "Unexpected end of file".
Even in a java client , I get error "java.IO.EOFException: Unexpected end of zlib input stream".
But I get expected result in a curl command.
Now I suspect, this could be something either with user-agent or somewhere in spring2 or jersey , I need to set some properties to get rid of this.
There is no security , I excluded SecurityAutoConfiguration.java, in case somewhere it checks some user-agent.
Because of error I see in java client, I tried with server.compression.enabled=false (which is default anyway), but no luck.
I suppose I need to edit the question.
It seems there is some issue using StreamingOutput using spring2x. This is not streaming which I assumes results in all of above stated issues.
Any help is appreciated.

Related

How do I capture csrf / xsrf token/cookie in Postman with Interceptor from Spring Boot with Spring Security?

`
First of all I am sorry about the format of this question. I tried to format the code but I only got error messages.
I have been trying for quite some time now, searching StackOverflow and all over the webb. I am following a Tutorial on Spring Security etc...and specifically Basic Authentication where I am supposed to capture csrf-token in Postman with Enterceptor. I have searched many threads here on StackOverflow and tried many things but I have not been able to solve it yet.
I have been reading about problems with security and SameSite= Lax and so on but I am not very confident in what to do and do where...
Since the "websecurityconfigureradapter" is deprecated, I tried to write my own SecurityConfig-file...
maybe there is something wrong with that?
I would very much appreciate any help.`
have been trying the following in my config-file:
http.csrf(csrf -> csr
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()));
with the following script in Postman test tab in the request:
var xsrfCookie = postman.getResponseCookie("XSRF-TOKEN");
pm.environment.set("xsrf-token", decodeURIComponent(pm.cookies.get("XSRF-TOKEN")));
with Header: X-XSRF {{xsrf-token}}
I have tried to install some kind of SSL-certificate in Postman, but I am not quite sure
how that works.
I have also read about how to set Flags in Google Chrome to control SameSite in some way but I have a version of Chrome (109) where I can´t set flags anymore.
And I have read somewhere that there is some problem with SameSite...and localhost?

Apache NiFi - 'unexpected end of stream' error

When I call NiFi's API (/flow/about), I get 'unexpected end of stream on' .. in invokehttp.java.exception.message flow file's attribute after it passes from InvokeHTTP processor. (NiFi v1.19.1 running on Linux VM).
Other API tools are also failing when I call NiFi's API.
I would like to use NiFi API, but I suspect that something is not working properly in this version.
(Examples: (1) HTTP GET to google.com is working properly, (2) I receive some raw content from the browser when I call http://localhost:8443/nifi/flow/about)
Could you please advise?
Thank you.
Update #20230130#1
Some errors in nifi-user.log:
No errors in nifi-app logs:
Meanwhile, I learned that in order to make any calls to NiFi by Rest API, I have to use a token for access (before of this I supposed that this is optional).
I was able to get the token and use it in subsequent calls to "nifi-api".
I'm expecting that the same procedure is going to work also in the latest NiFi version (current procedure was tested with NiFi 1.16.3).

SonarQube REST APIs : Read Metrics

I am using SonarQube version 6.7.1
I am trying to get JSON Response for our projects sonarQube statistics
Just want simple details like
Bug count, vulnerability count , % code duplication , code coverage
Tried URL http://sonar-server:9000/api/metrics&json=true but got error Unknown url, can someone point out correct URL
End Aim is to store Above counts for each run in time series DB .. any suggestions how to do it ?
May be i am not reading / understanding documentation clearly , possibly a pointer to tutorial or example or some other pointers will help me,
Try to use sonarqube.server.com:9000/api/metrics/domains, I am able to get json response from this.
APIs that you can use are listed at:
sonarqube.server.com:9000/web_api/api/metrics/domains/search
but just remove "web_api" while calling, to get json response.

What is the GlobalIdentity and how do I set it in the FileNet web service?

I'm trying to upload a document into filenet via CEWS, but I'm getting this error:
“The unexpected exception is chained to this exception. Message was: com.filenet.apiimpl.core.GlobalIdentity incompatible with com.filenet.apiimpl.core.RepositoryIdentity“
Our Filenet people don't seem to know what that means. They've provided working code that basically looks the same as mine (but which I can't compile directly at the moment because it references parts of their project I don't have.)
So is the GlobalIdentity something I need to pass in through the web service? If so, how? If not, where is it configured?
Ok I finally spotted my mistake.
I had incorrectly set crt.TargetSpecification.classId to the name of the repository I was trying to use rather than to the correct classId.

Problems attempting to upload image to Twitter via POST in Sinatra

I'm using Sinatra 1.2.6 in Ruby 1.8.7 and I have something like a Twitter client that I'm writing. I am using the Twitter gem version 1.7.2 written by John Nunemaker. For database ORM I'm using Sequel 3.29.0.
Overall, things are working great. I've got a good Oauth sequence working and any user who goes through the Oauth process can post Tweets to my application.
I cannot however for the life of me get media upload working using update_with_media. I'm trying to upload a multi-part octet-stream image file, keep it in memory and then give it to Twitter.
post '/file_upload' do
user_name = params[:user]
if params[:action] == "FILE-UPLOAD"
unless params[:name].match(/\.jpg|png|jpeg/).nil?
#Assume these 3 lines work, and properly authorize to Twitter
current_user = User[:user_name => user_name, :current_account => "1"]
client = current_user.authorize_to_twitter #Handles the Oauth keys/process
client.update("Text status updates work properly")
#Something incorrect is happening in the next two lines.
#I'm either handling the file upload wrong, or posting wrong to Twitter
datafile = params[:file]
client.update_with_media("File upload from Skype: ", datafile)
return "File uploaded ok"
end
end
end
Yet, when I try this, I'm getting:
Twitter::Unauthorized - POST https://upload.twitter.com/1/statuses/update_with_media.json: 401: Could not authenticate with OAuth.
Its saying the line causing this error is the client.update_with_media line.
I am trying to use Rack::RawUpload, but I don't know if I'm using it incorrectly. If I don't need to use it I won't, but I'm just currently stuck. The only thing outside of this code snippet that's using it is this at the top of my code:
require 'rack/raw_upload'
use Rack::RawUpload
Any help on this would be massively appreciated. I've tried messing around with Tempfile.new() as well, but that didn't seem to help much, and I was either getting 401 or 403 errors. I'm fairly new to Ruby, so being as explicit as possible about changes needed would be really helpful.
I should note that I'd like to avoid putting the file on the filesystem if possible. I'm really just passing along the upload here, and I never need access in my scenario to the file on-disk afterward. Keeping the files in-memory is much preferred.
You need to check how your library HTTP headers are setup and logically connected to the POST method you have written here. The thing is that for upload_with_media, twitter api in this gem version requires you to use http://upload.twitter.com upload endpoint instead of the default api endpoint.
The gem may be forcing the api site so while the OAuth based status update works fine, it crashes when you try it with an image. You will need to check the gem documentation to figure out how to force the upload twitter site into the HTTP headers for this method.
Alternatively, consider updating to the latest twitter gem. This is what I got from http://rdoc.info/gems/twitter
The Twitter::API#update_with_media method no longer uses the custom upload.twitter.com endpoint, so media_endpoint configuration has been removed. Likewise, the Twitter::API#search method no longer uses the custom search.twitter.com endpoint, so search_endpoint configuration has also been removed.

Resources