Bump MRI upstreams
[aaa.git] / aaa-shiro / impl / src / main / java / org / opendaylight / aaa / shiro / idm / OSGIIdmLightProxy.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.aaa.shiro.idm;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ForwardingObject;
12 import java.util.List;
13 import org.opendaylight.aaa.api.AuthenticationException;
14 import org.opendaylight.aaa.api.Claim;
15 import org.opendaylight.aaa.api.ClaimCache;
16 import org.opendaylight.aaa.api.CredentialAuth;
17 import org.opendaylight.aaa.api.IDMStoreException;
18 import org.opendaylight.aaa.api.IIDMStore;
19 import org.opendaylight.aaa.api.IdMService;
20 import org.opendaylight.aaa.api.PasswordCredentialAuth;
21 import org.opendaylight.aaa.api.PasswordCredentials;
22 import org.opendaylight.aaa.api.password.service.PasswordHashService;
23 import org.osgi.service.component.annotations.Activate;
24 import org.osgi.service.component.annotations.Component;
25 import org.osgi.service.component.annotations.Deactivate;
26 import org.osgi.service.component.annotations.Reference;
27
28 @Beta
29 @Component(immediate = true, property = "type=default",
30            service = { CredentialAuth.class, PasswordCredentialAuth.class, IdMService.class, ClaimCache.class })
31 public class OSGIIdmLightProxy extends ForwardingObject implements PasswordCredentialAuth, IdMService, ClaimCache {
32
33     @Reference
34     IIDMStore iidmStore;
35
36     @Reference
37     PasswordHashService passwordHashService;
38
39     private IdmLightProxy delegate;
40
41     @Activate
42     void activate() {
43         delegate = new IdmLightProxy(iidmStore, passwordHashService);
44     }
45
46     @Deactivate
47     void deactivate() {
48         delegate = null;
49     }
50
51     @Override
52     protected IdmLightProxy delegate() {
53         return delegate;
54     }
55
56     @Override
57     public void clear() {
58         delegate().clear();
59     }
60
61     @Override
62     public List<String> listDomains(String userId) {
63         return delegate().listDomains(userId);
64     }
65
66     @Override
67     public List<String> listRoles(String userId, String domainName) {
68         return delegate().listRoles(userId, domainName);
69     }
70
71     @Override
72     public List<String> listUserIDs() throws IDMStoreException {
73         return delegate().listUserIDs();
74     }
75
76     @Override
77     public Claim authenticate(PasswordCredentials cred) throws AuthenticationException {
78         return delegate().authenticate(cred);
79     }
80 }