Code-House / smarthome

Eclipse SmartHome project
Eclipse Public License 2.0
4 stars 0 forks source link

[esh-authz2] Missing service references #3

Open svilenvul opened 6 years ago

svilenvul commented 6 years ago

This was a strange one. I set up an OSGi runtime including several(I think two) AuthenticationProviders, but only one was injected into the DefaultAuthenticationManager.

What I did was to change the reference policy from static to dynamic, but I am not sure in this change:

@@ -63,7 +64,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
         throw new AuthenticationException("Could not authenticate credentials " + credentials);
     }

-    @Reference(cardinality = ReferenceCardinality.MULTIPLE)
+    @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC)
     public void addAuthenticationProvider(AuthenticationProvider provider) {
         providers.add(provider);
     }

I had similar problem in the AuthenticationHandler:

@@ -135,7 +148,7 @@ public class AuthenticationHandler implements Handler {
         }
     }

-    @Reference(cardinality = ReferenceCardinality.OPTIONAL)
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
     public void setAuthneticationManager(AuthenticationManager authenticationManager) {
         this.authenticationManager = authenticationManager;
     }
svilenvul commented 6 years ago

Same observed in SmartHomeHttpContext

splatch commented 6 years ago

This is likely to happen, as DS have its own semantics. This is good catch, lets switch to dynamic references and see if it improves situation.