Simple FTP Client authentication? - c++

I have written a simle FTP Client-Server code using WinSocks. But I am confused in "How to use a simple Username-Password Authentication" ? I have gone through the Authentication links given in MSDN but that made me more confused. Any help will be appreciated.

The FTP authentication process is done with the USER and PASS commands:
Command: USER AbhineetK7
Response: 331 Password required for AbhineetK7.
Command: PASS **********
Response: 230 Hello!
You can find more details here.

If I understand you correctly you are looking for something like this:
FTP Winapi
As you can see that URL contains full description with examples about FTP connection between Client and Server, with Username-Password Authentication.

Related

Retrieve github releases with libcurl while being anonymous

With this minimal program, I can download a text file and print it using libcurl. And I do this anonymously, just like any https get request.
Now this URL: https://api.github.com/repos/bitcoin/bitcoin
Is an example of a Restful API case I don't understand but interests me because I need to retrieve the releases of my project anonymously on Github. If you click on it, you get the JSON information anonymously on your web browser with no problems. It works without any authentication. But then when I put that URL in my minimal program, I get error 403!
So any normal https URL works fine in my minimal program, but this Github URL doesn't.
Why am I getting error 403? Do I have to authenticate in some way (and I don't mean with my personal username and password because my requirement is to get this anonymously)? Is this a bug in Github or my code?
OK. I know now what my mistake is. I seem to have confused authentication username/password with the so called "user agent". Adding this line to libcurl configuration:
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0");
will make it work. No authentication is required.

How do I use certificate based authentication with SOAP?

I'm trying to get the wsdl from a soap ws but I'm getting a:
ERR_BAD_SSL_CLIENT_AUTH_CERT
error, when I tried to access https://dummyurl.com:8446/data.php?wsdl from my browser.
I've been given 3 files: ca.crt, pablo.crt and pablo.key but I don't know how to use these files in order to authenticate with this service.
I've also tried to use curl to get the wsdl (without any luck)
curl -k https://dummyurl.com:8446/data.php?wsdl -v -key=pablo.key -cacert=ca.crt -cert=pablo.crt
So my question is, how can I use this certificates and key in order to authenticate and and get the wsdl?
You might find documentation useful
https://curl.haxx.se/docs/sslcerts.html

wsimport with special character and Xauthfile

I'm facing the same problem that this guy here:
wsimport Xauthfile error
Since he didn't gave a feedback and I'm new here and can't ask him if he solved his problem I'm opening a new question.
I'm using ubuntu and have JDK7 from java oracle installed.
I'm consuming a thirdparty web service. The password (...GT##ED...) for the webservice have a character that conflicts with de -Xauthfile syntax (http[s]://user:password#host:port//) because of the "#". The dots (...) represents the rest of my password.
Here is the command I'm running:
wsimport -p loa -Xauthfile "path_to_auth.txt" https://myWS?wsdl
In my auth.txt file I have:
https://user:...GT##ED...#myWS?wsdl
In return a get
parsing WSDL...
[ERROR] Server returned HTTP response code: 401 for URL: https://myWS?wsdl,
"https://myWS?wsdl" needs authorization, please provide authorization file with
read access at /home/user_name/.metro/auth or use -Xauthfile to give the
authorization file and on each line provide authorization information using this
format : http[s]://user:password#host:port//<url-path>
I search all over the net, but no success.
When I try to import the WS using SoapUI like in this tutorial I got a
[ERROR] sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid
certification path to requested target
and I don't know where to specify the ssl file for SoapUI. I tryed in
preferences -> SSL Settings
but no lucky.
That's it. I'll apreciate any help.
EDIT
OK, so I pass through the authorization, changing the characters using the HTML URL Encoding Reference, but now I'm getting the following error
[ERROR] Server redirected too many times (20), "https://ws?wsdl" needs
authorization, please provide authorization file with read access at /home/user
/.metro/auth or use -Xauthfile to give the authorization file and on each line
provide authorization information using this format :
http[s]://user:password#host:port//<url-path>
I am using Apache axis2 instead of wsimport. first this problem happened for me, and I write a bash script and it worked.
#!/bin/bash
/axis2-1.7.9/bin/wsdl2java.sh -uri http://username:password#domain/x?wsdl
I also use encoding password and username by 'url encoding' such as bellow:
##%g3E99! -(URL encoding)-> %40%23%25g3E99%21
First create auth.txt file where you need to put the following and save it in C drive:
http://username:password#localhost:port/wsdlurl
Now run the following command:
wsimport -Xauthfile C:\auth.txt -keep http://example.com/test?wsdl
This worked for me.

How to Add Basic Auth(Pre-emptive) to Web Service Client genrated with Web Platform Tools (WTP0 in Eclipse

I have a web service that I want to consume that requires a username and password. It does not prompt you for the u/p. In SOAPUI 4.5 it is very easy to go to the Auth tab for the web service , choose auth type: premeptive, add the username and password and run the service. I have generated a web service client for this service using Eclipse WTP but I cannot figure out what code to add and where in order to provide this same u/p that works in Soapui. I am fairly new so be specific please (does the code go in the servicebindingstub, serviceporttype, serviceporttypeproxy, and what method ? _init, etc., include imports pls. The wtp client works but returns a error code stating that the username and password are missing. If there is a way to externalize this in the descriptor that would be great also.
Solved this by adding Username and Password lines (last two below) to the Call for each method in the Stub file.
call.setUseSOAPAction(true);
_call.setSOAPActionURI("urn:webservicesapi#getAllVirtualServerConnStats");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(or`enter code here`g.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("", "getAllVirtualServerConnStats"));
_call.setProperty (Call.USERNAME_PROPERTY, "wstest"); //added this
_call.setProperty (Call.PASSWORD_PROPERTY, "WsTest"); // added this
setRequestHeaders(_call);

How to send HTTP request with authentication basic?

I'm using SOCKET (WINSOCK2.H) to connect to IP camera.
After connect, I want to send the command "GET /nphMotionJpeg?Resolution=640x480&Quality=Standard HTTP/1.1\r\n\r\n" to get video stream.
But this command is not successful because the camera is protected by authentication basic.
Now, I want to insert into request command username and password but i don't know the syntax to do it.
the syntax is explained in the related wikipedia article: https://en.wikipedia.org/wiki/Basic_access_authentication