I'm trying to access rest api through my companies proxy server this requires me authenticate with the proxy.
I can access the outside world using curl with the parameters:
curl -v -s -user $kerbrosId -x $ProxyServer:$proxyPort --proxy-negotiate https://google.com
I receive the following output:
Enter proxy password for user '$user':
* Trying $proxyIP:$proxyPort...
* Connected to $proxyURL ($proxyIP) port $proxyPort (#0)
* allocate connect buffer
* Establish HTTP proxy tunnel to google.com:443
* Proxy auth using Negotiate with user 'bradsw'
> CONNECT google.com:443 HTTP/1.1
> Host: google.com:443
> Proxy-Authorization: Negotiate ${shortBase64token}
> User-Agent: curl/7.83.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 407 Proxy Authentication Required
< Proxy-Authenticate: NEGOTIATE ${longerBase64token}
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: text/html; charset=utf-8
< Proxy-Connection: Keep-Alive
< Connection: Keep-Alive
< Content-Length: 5621
<
* Ignore 5621 bytes of response-body
* Establish HTTP proxy tunnel to google.com:443
* Proxy auth using Negotiate with user '$user'
> CONNECT google.com:443 HTTP/1.1
> Host: google.com:443
> Proxy-Authorization: Negotiate ${evenLongerBase64token}
> User-Agent: curl/7.83.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed
* schannel: disabled automatic use of client certificate
* ALPN: offers http/1.1
* ALPN: server accepted http/1.1
> GET / HTTP/1.1
> Host: google.com
> User-Agent: curl/7.83.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Location: https://www.google.com/
< Content-Type: text/html; charset=UTF-8
< Date: Thu, 29 Sep 2022 22:09:00 GMT
< Expires: Sat, 29 Oct 2022 22:09:00 GMT
< Cache-Control: public, max-age=2592000
< Server: gws
< Content-Length: 220
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
I have tried a million variations of
RestTemplate(HttpComponentsClientHttpRequestFactory(
HttpClientBuilder.create()
.setProxy(HttpHost(proxyUrl, proxyPort))
//other calls here to set things up
.build()
)
)
Nothing seems to authenticate correctly. I get back a 407 PROXY_AUTHENTICATION_REQUIRED with the companies default call the help desk if your browser doesn't work page in my stack trace.
Our systems are configured with an appropriate kbr5.config file so that should not be the issue & in other places in the code we are getting an SSO token a based on a ticket stored by kinit using the equivalent of RestTemplate().getForEntity("${sso-endpoint}", String::class.java).
I would ideally like to be able to delegate credentials to the OS via logged on user (either windows or REL based Linux systems) though I would consider simply authenticating at all a win at this point. I'm working in Kotlin but can easily translate a Java solution to Kotlin.
Any ideas appreciated?
I'm using Apache HttpClient to work with a web service that returns a multipart/form-data response which contains json.
I'm having a very hard time extracting each JSON string separately so I can read the json string.
I did read similar posts on Stackoverflow, and some suggested using Apache commons fileupload, but I am not sure how that can separate the JSON strings from the whole response that has a bunch of other text such as the boundary string, content type, etc
The response looks something like below.
--Boundary_16003419_2104021487_1483424496169
Content-Type: application/json
Content-RequestId: GetMailboxes
Status-Code: 200
X-Server-Response-Time: 4ms
X-Server-Chain: domain.com
Content-RequestDuration: 5
{JSON}
--Boundary_16003419_2104021487_1483424496169
Content-Type: application/json
Content-RequestId: GetFolders
Status-Code: 200
X-Server-Response-Time: 8ms
X-Server-Chain: domain.com
Content-RequestDuration: 10
{JSON}
--Boundary_16003419_2104021487_1483424496169
Content-Type: application/json
Content-RequestId: GetAlerts
Status-Code: 200
X-Server-Response-Time: 10ms
X-Server-Chain: domain.com
Content-RequestDuration: 12
{JSON}
--Boundary_16003419_2104021487_1483424496169
Content-Type: application/json
Content-RequestId: GetAccounts
Status-Code: 200
X-Server-Response-Time: 11ms
X-Server-Chain: domain.com
Content-RequestDuration: 12
{JSON}
--Boundary_16003419_2104021487_1483424496169
Content-Type: application/json
Content-RequestId: GetAllSavedSearches
Status-Code: 200
X-Server-Response-Time: 10ms
X-Server-Chain: domain.com
Content-RequestDuration: 12
{JSON}
--Boundary_16003419_2104021487_1483424496169
Content-Type: application/json
Content-RequestId: GetAthenaSegment
Status-Code: 200
X-Server-Response-Time: 14ms
Content-RequestDuration: 21
{JSON}
--Boundary_16003419_2104021487_1483424496169
Content-Type: application/json
Content-RequestId: ListFolderThreads
Status-Code: 200
X-Server-Response-Time: 110ms
Content-RequestDuration: 116
{JSON}
--Boundary_16003419_2104021487_1483424496169
Content-Type: application/json
Content-RequestId: GetUserInfo
Status-Code: 200
X-Server-Response-Time: 197ms
Content-RequestDuration: 204
{JSON}
--Boundary_16003419_2104021487_1483424496169
Content-RequestId: Status
Content-Type: application/json
{JSON}
--Boundary_16003419_2104021487_1483424496169--
Any way to do this reliably?
One option would be Apache Mime4j. You would likely want to use MimeTokenStream or MimeStreamParser as described here if you want your application to handle response content without building a complete DOM tree in memory.
I am trying to call an API using cURL.
Using the Advanced Rest Client(ARC) when I send a request using this URL:
http://localhost:8080/jcr/root/myfolder/integrationTestNode
I receive this response:
Status:
500: Internal Server Error
Loading time: 37 ms
Date: Thu, 28 Jul 2016 06:20:11 GMT
Content-Type: text/plain
Content-Length: 88
And a message
Failed to delete filejavax.jcr.PathNotFoundException: /root/myfolder/integrationTestNode
Which is exactly what I want.
But when I try the same using cURL in a shell script I am unable to see the message.
Here is the script:
url="http://localhost:8080/jcr/root/myfolder/integrationTestNode"
echo ${url}
curl -u amit:pass --verbose -I -X DELETE \
--url "${url}"
echo " ----------------------------------------------------------------------------"
And here is the response of the script:
http://localhost:8080/jcr/root/myfolder/integrationTestNode
* timeout on name lookup is not supported
* Trying ::1...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to localhost (::1) port 8080 (#0)
* Server auth using Basic with user 'amit'
> DELETE /jcr/root/myfolder/integrationTestNode HTTP/1.1
> Host: localhost:8080
> Authorization: Basic YW1pdDpwYXNz
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
< Date: Thu, 28 Jul 2016 06:25:26 GMT
< Content-Type: text/plain
< Content-Length: 88
<
* Excess found in a non pipelined read: excess = 88 url = /jcr/root/myfolder/int egrationTestNode (zero-length body)
0 88 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HT TP/1.1 500 Internal Server Error
Date: Thu, 28 Jul 2016 06:25:26 GMT
Content-Type: text/plain
Content-Length: 88
How can I see the response message using cURL ?
I am using javax.ws.rs.core.Response.status().entity("").build() to send the message.
I am using JSIP (JAIN-SIP) version 1.2 (implementation build 2384). I am trying to send the following SIP message (I removed actual IP addresses in the post):
INVITE sip:bob#miniims.net SIP/2.0
Via: SIP/2.0/UDP xxx.yyy.zzz.www:5065;branch=z9hG4bKbranch1
Route: <sip:xxx.yyy.zzz.www>,<sip:xxx.yyy.zzz.www:5062>
Max-Forwards: 70
From: "Alice" <sip:alice#miniims.net>;tag=rawclientv1.0
To: "Bob" <sip:bob#miniims.net>
Call-ID: f2927406a96b0b3d3ef8213aa338d1c4#xxx.yyy.zzz.www
CSeq: 1 INVITE
Contact: "alice" <sip:alice#xxx.yyy.zzz.www:5065>
P-Preferred-Identity: <sip:alice#miniims.net>
Content-Length: 141
v=0
o=alice 2890844526 2890844526 IN IP4 xxx.yyy.zzz.www
s=
c=IN IP4 xxx.yyy.zzz.www
t=0 0
m=audio 12346 RTP/AVP 0 8 96
a=rtpmap:96 L16/8000
When I print it after parsing, it is correct. However, when I send it, the request URI is put to the end of the list of Route headers, and the first Route header is moved into SIP URI. No RFC or 3GPP standard prescribes such behavior. WireShark already captures the wrong message:
INVITE sip:xxx.yyy.zzz.www SIP/2.0
Via: SIP/2.0/UDP xxx.yyy.zzz.www:5065;branch=z9hG4bKbranch1
Route: <sip:xxx.yyy.zzz.www:5062>,<sip:bob#miniims.net>
Max-Forwards: 70
From: "Alice" <sip:alice#miniims.net>;tag=rawclientv1.0
To: "Bob" <sip:bob#miniims.net>
Call-ID: f2927406a96b0b3d3ef8213aa338d1c4#xxx.yyy.zzz.www
CSeq: 1 INVITE
Contact: "alice" <sip:alice#xxx.yyy.zzz.www:5065>
P-Preferred-Identity: <sip:alice#miniims.net>
Content-Length: 141
v=0
o=alice 2890844526 2890844526 IN IP4 xxx.yyy.zzz.www
s=
c=IN IP4 xxx.yyy.zzz.www
t=0 0
m=audio 12346 RTP/AVP 0 8 96
a=rtpmap:96 L16/8000
Is it normal behavior in JSIP? Or a bug? Is there a way to prevent it, i.e. a workaround? Thanks in advance!
Use lr; parameter in the Route Header.
I need to implement next flow using SIP servlets:
1) My SIP Servlet should catch INVITE message
2) Look on SIP TO header, and if it match by some pattern I need comeback REFER message.
I google it, and found this manual (Basic Transfer): www.dialogic.com/webhelp/IMG1010/10.5.1/WebHelp/sip_rfr_calltrans.htm
As I understood correctly, this flow looks like bellow:
1) userA send INVITE message to SIP App
2) SIP App should send 200 OK back
3) UserA sending ACK message
4) SIP App send REFER message to UserA
5) UserA should send back 202Accepted and than NOTIFY
My enviroment:
1) mss-2.0.0.FINAL-jboss-as-7.1.2.Final as SIP PROXY Server 127.0.0.1:5080
2) user3#127.0.0.1:5060 --- MicroSIP (http://www.microsip.org/)
3) user2#127.0.0.1:5090 --- Zoiper_Free_2.41
DAR File:
INVITE:("org.call.forwarding.CallForward","DAR:From","ORIGINATING","","NO_ROUTE", "0")
REGISTER:("org.call.forwarding.CallForward","DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
SUBSCRIBE:("org.call.forwarding.CallForward","DAR:From","ORIGINATING","","NO_ROUTE", "0")
OPTIONS:("org.call.forwarding.CallForward","DAR:From","ORIGINATING", "", "NO_ROUTE", "0")
NOTIFY:("org.call.forwarding.CallForward", "DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
REFER:("org.call.forwarding.CallForward", "DAR:From", "ORIGINATING", "", "NO_ROUTE", "0")
From user3#127.0.0.1 I calling to refuser#127.0.0.1
So my source code looks like bellow:
1) Catching INVITE package and make 200 OK response:
#Override
protected void doInvite(SipServletRequest request) throws Exception {
// Pattern match logic ommited
SipServletResponse response = request.createResponse(SipServletResponse.SC_OK);
String str = response.toString();
response.send()
}
INVITE sip:refuser#127.0.0.1:5080 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.17:5060;rport=5060;branch=z9hG4bKPjb1570e34df4c442093af6fb2fa238667;received=127.0.0.1
Max-Forwards: 70
From: "user3" <sip:user3#127.0.0.1>;tag=87be8901c4e242fbb5c696d90d0ec068
To: <sip:refuser#127.0.0.1>
Contact: "user3" <sip:user3#127.0.0.1:5060;ob>
Call-ID: 983d9572c4a541d49566699b3edec1e0
CSeq: 22256 INVITE
Allow: PRACK,INVITE,ACK,BYE,CANCEL,UPDATE,INFO,SUBSCRIBE,NOTIFY,REFER,MESSAGE,OPTIONS
Supported: replaces,100rel,timer,norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.3.21
Content-Type: application/sdp
Content-Length: 673
And my response: 200 OK Respnose like bellow:
SIP/2.0 200 OK
To: <sip:refuser#127.0.0.1>;tag=25395207_da1be872_8479416b-da5c-4dca-baef-f9b7db279b9e
Via: SIP/2.0/UDP 192.168.0.17:5060;rport=5060;branch=z9hG4bKPjb1570e34df4c442093af6fb2fa238667;received=127.0.0.1
CSeq: 22256 INVITE
Call-ID: 983d9572c4a541d49566699b3edec1e0
From: "user3" <sip:user3#127.0.0.1>;tag=87be8901c4e242fbb5c696d90d0ec068
Contact: <sip:127.0.0.1:5080>
Content-Length: 0
Then I trying to process ACK package and generate REFER package:
#Override
protected void doAck(SipServletRequest request) throws ServletException, IOException {
String ack = request.toString();
logger.info("Got ASK!!!: " + request.toString());
SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
SipApplicationSession appSession = request.getApplicationSession();
SipServletRequest refer = sipFactory.createRequest(appSession, "REFER",
sipFactory.createURI("sip:user#127.0.0.1:5080"), // from sipFactory.createURI("sip:user2#127.0.0.1:5090")); // to
refer.addHeader("Refer-To", "sip:user3#127.0.0.1:5080");
refer.addHeader("Referred-By", "sip:user#127.0.0.1:5080");
logger.info("!!!!!!!!!!!THIS IS REFER: \n" + refer.toString());
String strRefer = refer.toString();
refer.send();
}
ACK sip:127.0.0.1:5080 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.17:5060;rport=5060;branch=z9hG4bKPje03842cfb4104d379db989f2d77a871a;received=127.0.0.1
Max-Forwards: 70
From: "user3" <sip:user3#127.0.0.1>;tag=87be8901c4e242fbb5c696d90d0ec068
To: <sip:refuser#127.0.0.1>;tag=25395207_da1be872_8479416b-da5c-4dca-baef-f9b7db279b9e
Call-ID: 983d9572c4a541d49566699b3edec1e0
CSeq: 22256 ACK
Content-Length: 0
And my REFER package:
REFER sip:user2#127.0.0.1:5090 SIP/2.0
Call-ID: ca002d9261fe165c0a4eaedc99ead2c7#127.0.0.1
CSeq: 1 REFER
From: <sip:user#127.0.0.1:5080>;tag=14387494_da1be872_8479416b-da5c-4dca-baef-f9b7db279b9e
To: <sip:user2#127.0.0.1:5090>
Max-Forwards: 70
Contact: <sip:user#127.0.0.1:5080>
Refer-To: <sip:user3#127.0.0.1:5080>
Referred-By: <sip:user#127.0.0.1:5080>
Content-Length: 0
Then I see at log file TRYING message:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 127.0.0.1:5080;branch=z9hG4bK8479416b-da5c-4dca-baef- f9b7db279b9e_da1be872_1872624593941
To: <sip:user2#127.0.0.1:5090>
From: <sip:user#127.0.0.1:5080>;tag=14387494_da1be872_8479416b-da5c-4dca-baef-f9b7db279b9e
Call-ID: ca002d9261fe165c0a4eaedc99ead2c7#127.0.0.1
CSeq: 1 REFER
Content-Length: 0
And after ~30 secs I see that Microsip show "Not Acceptable" message:
SIP/2.0 408 Request timeout
To: <sip:user2#127.0.0.1:5090>;tag=37903989_da1be872_8479416b-da5c-4dca-baef-f9b7db279b9e
Via: SIP/2.0/UDP 127.0.0.1:5080;branch=z9hG4bK8479416b-da5c-4dca-baef-f9b7db279b9e_da1be872_1872624593941
CSeq: 1 REFER
Call-ID: ca002d9261fe165c0a4eaedc99ead2c7#127.0.0.1
From: <sip:user#127.0.0.1:5080>;tag=14387494_da1be872_8479416b-da5c-4dca-baef-f9b7db279b9e
Contact: <sip:127.0.0.1:5080>
Content-Length: 0
Can any body explaine: whats wrong with this guy???
Also another point that blow my brain: in some cases after sending 200 OK message (when I processed INVITE) I immediatly recive BYE message before ACK... Why its happens?
It looks like in your REFER header that your Contact and CallID does not link up with your original ACK and 200OK messages. So that's why you are getting a 100 Trying eventually because there is no outstanding message waiting for any sort of response.