Login user via Servlet | Community
Skip to main content
September 21, 2016
Solved

Login user via Servlet

  • September 21, 2016
  • 3 replies
  • 2278 views

I am trying to login users via a Servlet apposed to using a form with j_security_check. 

After a user fills in a registration form, I'm creating the user and also want to log them in.

The below code does create a login token under the users profile however it doesn't change the current login-token cookie. 

Is it possible?

 

byte[] bytes = "j_username=username&j_password=password".getBytes(StandardCharsets.UTF_8); HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:4503/j_security_check").openConnection(); connection.setDoOutput(true); connection.setRequestMethod("POST"); DataOutputStream writer = new DataOutputStream(connection.getOutputStream()); writer.write(bytes);
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

Hi

Please have a look at this Adobe Helpx article for your help:

Link:- https://helpx.adobe.com/experience-manager/using/secure_sites.html

//Building Secure Adobe Experience Manager Web Sites. AEM web site that requires a user to login to view the content of the web site.

 Git :- https://github.com/Adobe-Marketing-Cloud/aem-ask-the-experts-login

 

Reference material :- https://sling.apache.org/documentation/the-sling-engine/authentication/authentication-authenticationhandler/form-based-authenticationhandler.html

 

~kautuk

3 replies

Tuhin_Ghosh
New Participant
October 4, 2016

Hi Terry,

 

Were you able to achieve this functionality?

 

Thanks

Tuhin

kautuk_sahni
kautuk_sahniAccepted solution
Employee
September 22, 2016

Hi

Please have a look at this Adobe Helpx article for your help:

Link:- https://helpx.adobe.com/experience-manager/using/secure_sites.html

//Building Secure Adobe Experience Manager Web Sites. AEM web site that requires a user to login to view the content of the web site.

 Git :- https://github.com/Adobe-Marketing-Cloud/aem-ask-the-experts-login

 

Reference material :- https://sling.apache.org/documentation/the-sling-engine/authentication/authentication-authenticationhandler/form-based-authenticationhandler.html

 

~kautuk

Kautuk Sahni
smacdonald2008
New Participant
September 22, 2016

Watch this AEM Ask the Community Experts session on this subject done by Justin: 

Building login-based sites in AEM

He covers the proper way to create secure sites for AEM.