Expand my Community achievements bar.

SOLVED

Login user via Servlet

Avatar

Former Community Member

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);
1 Accepted Solution

Avatar

Correct answer by
Administrator

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-authentication...

 

~kautuk



Kautuk Sahni

View solution in original post

3 Replies

Avatar

Level 10

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. 

Avatar

Correct answer by
Administrator

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-authentication...

 

~kautuk



Kautuk Sahni

Avatar

Level 7

Hi Terry,

 

Were you able to achieve this functionality?

 

Thanks

Tuhin