|
26 | 26 | import javax.crypto.spec.PBEKeySpec; |
27 | 27 |
|
28 | 28 | import org.eclipse.jdt.annotation.NonNullByDefault; |
| 29 | +import org.eclipse.jdt.annotation.Nullable; |
29 | 30 | import org.openhab.core.auth.AuthenticatedUser; |
30 | 31 | import org.openhab.core.auth.Authentication; |
31 | 32 | import org.openhab.core.auth.AuthenticationException; |
|
39 | 40 | import org.openhab.core.auth.UserSession; |
40 | 41 | import org.openhab.core.auth.UsernamePasswordCredentials; |
41 | 42 | import org.openhab.core.common.registry.AbstractRegistry; |
| 43 | +import org.openhab.core.common.registry.ManagedProvider; |
| 44 | +import org.openhab.core.common.registry.Provider; |
42 | 45 | import org.osgi.framework.BundleContext; |
43 | 46 | import org.osgi.service.component.annotations.Activate; |
44 | 47 | import org.osgi.service.component.annotations.Component; |
@@ -256,6 +259,19 @@ public void removeUserApiToken(User user, UserApiToken userApiToken) { |
256 | 259 | update(user); |
257 | 260 | } |
258 | 261 |
|
| 262 | + @Override |
| 263 | + public @Nullable User update(User element) { |
| 264 | + String key = element.getName(); |
| 265 | + Provider<User> provider = getProvider(key); |
| 266 | + // If the provider of this element is a ManagedProvider, |
| 267 | + // invoke the update method of that provider instead of the default one |
| 268 | + // This allows for registering additional ManagedProviders, e.g., for providing LDAP users |
| 269 | + if (provider instanceof ManagedProvider<User, ?> managedProvider) { |
| 270 | + return managedProvider.update(element); |
| 271 | + } |
| 272 | + return super.update(element); |
| 273 | + } |
| 274 | + |
259 | 275 | @Override |
260 | 276 | public boolean supports(Class<? extends Credentials> type) { |
261 | 277 | return (UsernamePasswordCredentials.class.isAssignableFrom(type)); |
|
0 commit comments