Hi Hasini,

On Wed, 2018-07-25 at 00:22 +0530, Hasini Witharana wrote:
> Hi all,
> 
> I am trying to get the service Authenticator in
> "org.apache.sling.api.auth.Authenticator" inside a service class
> using "
> org.osgi.service.component.annotations.Reference" annotation.
> 
> But I am getting an error saying @Reference not applicable to field.
> How to
> solve this?

(snip)

I'll reply with a larger context and say that probably this is not what
you need :-) Since you're working on setting the 'current' user in
Apache Sling, you don't want to run Authenticator#login(request,
response) .

I've taken a look at the Sling authentication framework ( which TBH is
new to me as well ). The way this should be done is to register an
AuthenicationHandler [1] implementation which extracts the credentials
based on the OIDC flow you have already implemented.

A basic AuthenticationHandler example is the HTTP one, which can be
found at [2].

So what you should do now is find out how the operations you have
implemented so far map to the AuthenticationHandler API:

- extractCredentials
- requestCredentials
- dropCredentials

and register that as an OSGi component.

Thanks,

Robert


[1]: 
https://github.com/apache/sling-org-apache-sling-auth-core/blob/master/src/main/java/org/apache/sling/auth/core/spi/AuthenticationHandler.java
[2]: 
https://github.com/apache/sling-org-apache-sling-auth-core/blob/master/src/main/java/org/apache/sling/auth/core/impl/HttpBasicAuthenticationHandler.java

Reply via email to