I'm working on a legacy project that recently upgraded to AEM 6.3. It uses shared cookies to authenticate user across AEM instances. It specifically uses TokenUtil
to create the credentials through createCredentials
method. However, i had this requirement where i should use Service User to login instead the usual loginAdministrative
.
I've tried to authenticate the repository first before creating the token.
this.repositorySession = this.repository.loginService("myAuthenticatorService", "");
authInfo = TokenUtil.createCredentials(request, response, this.repository, uid, true);
Apparently, the createCredentials
do calls loginAdministrative
which is undesirable. So, even though i authenticate the SlingRepository
against service user it will keep throwing RepositoryException
.
// <editor-fold defaultstate="collapsed" desc="Compiled Code">
/* 0: aconst_null
* 1: astore 5
* 3: aconst_null
* 4: astore 6
* 6: aload_2
* 7: aconst_null
* 8: invokeinterface org/apache/sling/jcr/api/SlingRepository.loginAdministrative:(Ljava/lang/String;)Ljavax/jcr/Session;
* 13: astore 5
* 15: new org/apache/sling/auth/core/spi/AuthenticationInfo
* 18: dup
* 19: ldc TOKEN
* 21: aload_3
* 22: invokespecial org/apache/sling/auth/core/spi/AuthenticationInfo."<init>":(Ljava/lang/String;Ljava/lang/String;)V
....
Above is the excerpts from Netbeans inspecting the compiled code.
My question is, are there any alternatives to create a token for given user id properly without relying on loginAdministrative
? Before i try to implement my own TokenUtil
by taking a peek on the original implementation..
ps. i could just add my bundle(s) to Apache Sling Login Admin Whitelist Configuration Fragment but i don't think this will survive in the long term..
EDIT
It seems i cant implement my own TokenUtil as a workaround. Adobe did not expose the com.day.crx.sling.crx-auth-token
bundle for version 2.5.30. On Maven Repository only 2.4.30 publicly available. i should have contacted Day Care Team for help. The method TokenAuthenticationHandler.getRepositoryId(bool)
only available for 2.5.30 which used by AEM 6.3.