Migrate IdmLightProxy to OSGI DS 04/93604/2
authorTomas Cere <tomas.cere@pantheon.tech>
Thu, 5 Nov 2020 11:10:05 +0000 (12:10 +0100)
committerTomas Cere <tomas.cere@pantheon.tech>
Fri, 6 Nov 2020 12:42:00 +0000 (13:42 +0100)
JIRA: AAA-209
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
Change-Id: Ife92b83c32a3e1e6743658d2f19e9f783905769e

aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/idm/OSGIIdmLightProxy.java [new file with mode: 0644]
aaa-shiro/impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml

diff --git a/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/idm/OSGIIdmLightProxy.java b/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/idm/OSGIIdmLightProxy.java
new file mode 100644 (file)
index 0000000..e613430
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.shiro.idm;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ForwardingObject;
+import java.util.List;
+import org.opendaylight.aaa.api.AuthenticationException;
+import org.opendaylight.aaa.api.Claim;
+import org.opendaylight.aaa.api.ClaimCache;
+import org.opendaylight.aaa.api.CredentialAuth;
+import org.opendaylight.aaa.api.IDMStoreException;
+import org.opendaylight.aaa.api.IIDMStore;
+import org.opendaylight.aaa.api.IdMService;
+import org.opendaylight.aaa.api.PasswordCredentialAuth;
+import org.opendaylight.aaa.api.PasswordCredentials;
+import org.opendaylight.aaa.api.password.service.PasswordHashService;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+
+@Beta
+@Component(immediate = true, service = {CredentialAuth.class, PasswordCredentialAuth.class, IdMService.class,
+        ClaimCache.class}, property = "type=default")
+public class OSGIIdmLightProxy extends ForwardingObject implements PasswordCredentialAuth, IdMService, ClaimCache {
+
+    @Reference
+    IIDMStore iidmStore;
+
+    @Reference
+    PasswordHashService passwordHashService;
+
+    private IdmLightProxy delegate;
+
+    @Activate
+    void activate() {
+        delegate = new IdmLightProxy(iidmStore, passwordHashService);
+    }
+
+    @Deactivate
+    void deactivate() {
+        delegate = null;
+    }
+
+    @Override
+    protected IdmLightProxy delegate() {
+        return delegate;
+    }
+
+    @Override
+    public void clear() {
+        delegate().clear();
+    }
+
+    @Override
+    public List<String> listDomains(String userId) {
+        return delegate().listDomains(userId);
+    }
+
+    @Override
+    public List<String> listRoles(String userId, String domainName) {
+        return delegate().listRoles(userId, domainName);
+    }
+
+    @Override
+    public List<String> listUserIDs() throws IDMStoreException {
+        return delegate().listUserIDs();
+    }
+
+    @Override
+    public Claim authenticate(PasswordCredentials cred) throws AuthenticationException {
+        return delegate().authenticate(cred);
+    }
+}
index 284ec45fce33501ff7e695728eb08e871240dd1f..c50ff4b015183b0e9cc073f7d702b0bb53f3e3bd 100644 (file)
@@ -24,19 +24,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <reference id="passwordService" interface="org.opendaylight.aaa.api.password.service.PasswordHashService"/>
   <reference id="idmStore" interface ="org.opendaylight.aaa.api.IIDMStore"/>
 
-  <bean id="idmLightProxy" class="org.opendaylight.aaa.shiro.idm.IdmLightProxy">
-    <argument ref="idmStore" />
-    <argument ref="passwordService" />
-  </bean>
-
-  <service ref="idmLightProxy" odl:type="default">
-    <interfaces>
-      <value>org.opendaylight.aaa.api.IdMService</value>
-      <value>org.opendaylight.aaa.api.ClaimCache</value>
-      <value>org.opendaylight.aaa.api.CredentialAuth</value>
-      <value>org.opendaylight.aaa.api.PasswordCredentialAuth</value>
-    </interfaces>
-  </service>
+  <reference id="passwordCredentialAuth" interface="org.opendaylight.aaa.api.PasswordCredentialAuth"/>
+  <reference id="claimCache" interface="org.opendaylight.aaa.api.ClaimCache"/>
 
   <reference id="dataBroker"
     interface="org.opendaylight.mdsal.binding.api.DataBroker"
@@ -54,7 +43,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         init-method="init" destroy-method="close">
     <argument ref="dataBroker" />
     <argument ref="certManager" />
-    <argument ref="idmLightProxy" />
+    <argument ref="passwordCredentialAuth" />
     <argument ref="shiroConfiguration" />
     <argument ref="httpService" />
     <argument value="/moon" />
@@ -96,7 +85,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 
   <bean id="webInitializer" class="org.opendaylight.aaa.shiro.web.env.WebInitializer" destroy-method="close">
     <argument ref="webServer"/>
-    <argument ref="idmLightProxy"/>
+    <argument ref="claimCache"/>
     <argument ref="idmStore"/>
     <argument ref="webContextSecurer"/>
     <argument ref="servletSupport"/>