Implement Authentication for servlet on publish instance CQ5/AEM -


i have scenario , suggestions in implementing of great help. have servlet created on publish have post requests coming lot of other third party applications. servlet stores incoming posted data in jcr. have created servlet requirement make servlet secured applications hitting servlet particular username , password should entertained.

what can achieve this?

the way go it:

ask 3rd party applications send username , password can validate them on servlet, decide if allow or reject request.

from servlet calling (the 3rd party application)

 protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         // ...           request.setattribute("username", "a_valid_user");         request.setattribute("password", "a_valid_password");         request.getrequestdispatcher("yourapp/yourservlet").forward(req, resp); } 

on servlet:

string username = request.getparameter("username"); string password = request.getparameter("password");  if("a_valid_user".equals(username) && "a_valid_password".equals(password) {      // validate , go further } else {      // not process request } 

the above example valid in case can validate them on side.

if sample doesn't answer question, please provide more information 3rd party applications , way want validate them.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -