AEM Custom Servlet Post Working in HTTP but not HTTPs

Avatar

Avatar
Validate 1
Level 1
pa_dc
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

2 solutions
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
pa_dc
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

2 solutions
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
pa_dc
Level 1

06-04-2020

Hi everyone,

I have a custom servlet which I am using to return folder information. I am able to return the information when I attempting to hit the servlet directly with HTTP and specifying the port number. However, we are setting AEM to be SSL by Default and I am unable to get the same information to be returned through HTTPS and when I do not specify the port which is the case I want. I'm assuming it has to do with the mapping I have in place but I am unsure.

 

I have updated the Apache Felix Jetty Based Http Service to enable HTTPS and messed around with the Sling Mapping but am getting nowhere. I have added error log information and some configuration information below when I attempt to hit the servlet from Postman.

Any help would be awesome.

 

Error Log Information

0 TIMER_START{Request Processing}
      2 COMMENT timer_end format is {<elapsed microseconds>,<timer name>} <optional message>
     12 LOG Method=POST, PathInfo=null
     16 TIMER_START{handleSecurity}
   2016 TIMER_END{1996,handleSecurity} authenticator org.apache.sling.auth.core.impl.SlingAuthenticator@576d3546 returns true
   2298 TIMER_START{ResourceResolution}
   6162 TIMER_END{3862,ResourceResolution} URI=/api/assets/v1/jobFolderInfo resolves to Resource=NonExistingResource, path=/api/assets/v1/jobFolderInfo
   6175 LOG Resource Path Info: SlingRequestPathInfo: path='/api/assets/v1/jobFolderInfo', selectorString='null', extension='null', suffix='null'
   6176 TIMER_START{ServletResolution}
   6182 TIMER_START{resolveServlet(/api/assets/v1/jobFolderInfo)}
   8231 LOG {0}: no servlet found
   8245 TIMER_END{2061,resolveServlet(/api/assets/v1/jobFolderInfo)} Using servlet org.apache.sling.servlets.post.impl.SlingPostServlet
   8251 TIMER_END{2074,ServletResolution} URI=/api/assets/v1/jobFolderInfo handled by Servlet=org.apache.sling.servlets.post.impl.SlingPostServlet
   8259 LOG Applying Requestfilters
   8265 LOG Calling filter: com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl
   8274 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter

Sling Mapping

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:Mapping"
sling:internalRedirect="/content/dam/site.$1.json"
sling:match="aem.site.com.4502/api/assets/v1/(.*)" />

Servlet Information

/**
* Servlet for creating folder using DAM assets APIs.
*/
@Component(service = Servlet.class,
property = {
Constants.SERVICE_DESCRIPTION + "=Get Job Folder Info API",
"sling.servlet.methods=" + HttpConstants.METHOD_POST,
"sling.servlet.resourceTypes=" + "sling/servlet/default",
"sling.servlet.selectors=" + "jobFolderInfo",
"sling.servlet.extensions=" + APIConstants.JSON_EXTENSION_TYPE
})
public class JobFolderInfoServlet extends SlingAllMethodsServlet {

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 1
pa_dc
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

2 solutions
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
pa_dc
Level 1

Like

1 like

Total Posts

12 posts

Correct reply

2 solutions
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
pa_dc
Level 1

08-04-2020

I was able resolve my issues because I figured out that I was missing a sling mapping file for https where I included a mapping which excluded the port number as part of the URL.

Answers (1)

Answers (1)

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

645 likes

Total Posts

607 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

645 likes

Total Posts

607 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

08-04-2020

Hello,

I don't think you can make a sling:internalRedirect with servlets; as this property causes the current path to be modified internally to continue with resource resolution; not script resolution. Documentation: https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html

Intern Solution:
Apache Redirects:

RewriteRule ^/api/assets/v1/(.*)$ /content/dam/site.$1.json [PT,L]

Documentation: https://sourcedcode.com/sugar-coating-servlet-scripts-and-paths

Hope this helps.