I am working on a QT application in which I would like to authenticate against a local server running a Spring-MVC based webapp. I tried authentication via curl and it works, and with some help from SO, I got the code for authenticating via QT on the webapp.
The problem is, when I send a post request to the webapp, the username is always '' or empty. I don't know why, I also tried using urlencode, but that does not seem to have any effect. Can anyone tell me what is going wrong. Thanks a lot. :-)
QT code :
void Person::authenticate (){
QString url_str = "http://localhost:8080/j_spring_security_check";
QNetworkAccessManager *manager = new QNetworkAccessManager();
manager->setCookieJar (new QNetworkCookieJar(manager));
connect (manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slotRequestFinished(QNetworkReply*)));
QNetworkRequest request;
request.setUrl (url_str);
request.setHeader(QNetworkRequest::ContentTypeHeader,"application/json");
QByteArray postData = QUrl::toPercentEncoding ("j_username=user@email.de & j_password=password");
qDebug(postData.constData ());
manager->post (request,postData);
}
void Person::slotRequestFinished(QNetworkReply *reply)
{
qDebug() << "We are here";
qDebug()<< reply->readAll ();
}
Output of the code :
qt.network.ssl: QSslSocket: cannot resolve SSLv2_client_method
qt.network.ssl: QSslSocket: cannot resolve SSLv2_server_method
"ABC"
We are here
""
Debug log from Spring webapp :
DEBUG: org.springframework.security.web.FilterChainProxy - /j_spring_security_check at position 1 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
DEBUG: org.springframework.security.web.context.HttpSessionSecurityContextRepository - No HttpSession currently exists
DEBUG: org.springframework.security.web.context.HttpSessionSecurityContextRepository - No SecurityContext was available from the HttpSession: null. A new one will be created.
DEBUG: org.springframework.security.web.FilterChainProxy - /j_spring_security_check at position 2 of 12 in additional filter chain; firing Filter: 'ConcurrentSessionFilter'
DEBUG: org.springframework.security.web.FilterChainProxy - /j_spring_security_check at position 3 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
DEBUG: org.springframework.security.web.FilterChainProxy - /j_spring_security_check at position 4 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
DEBUG: org.springframework.security.web.FilterChainProxy - /j_spring_security_check at position 5 of 12 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
DEBUG: org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter - Request is to process authentication
DEBUG: org.springframework.security.authentication.ProviderManager - Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
DEBUG: org.springframework.security.authentication.dao.DaoAuthenticationProvider - User '' not found
Please note the last line in above debug log. Any help would be nice. Thanks a lot.. :-)
Aucun commentaire:
Enregistrer un commentaire