2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.aaa.impl.password.service;
10 import org.opendaylight.aaa.api.password.service.PasswordHash;
11 import org.opendaylight.aaa.api.password.service.PasswordHashService;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.password.service.config.rev170619.PasswordServiceConfig;
13 import org.osgi.service.component.annotations.Component;
14 import org.osgi.service.component.annotations.Reference;
15 import org.osgi.service.component.annotations.ReferenceCardinality;
16 import org.osgi.service.component.annotations.ReferencePolicy;
18 @Component(immediate = true, property = "type=default")
19 public final class OSGiPasswordHashService implements PasswordHashService {
20 private volatile DefaultPasswordHashService delegate = null;
23 public PasswordHash getPasswordHash(final String password) {
24 return delegate.getPasswordHash(password);
28 public PasswordHash getPasswordHash(final String password, final String salt) {
29 return delegate.getPasswordHash(password, salt);
33 public boolean passwordsMatch(final String plaintext, final String stored, final String salt) {
34 return delegate.passwordsMatch(plaintext, stored, salt);
37 @Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY)
38 void bindConfig(final PasswordServiceConfig config) {
39 updatedConfig(config);
42 void unbindConfig(final PasswordServiceConfig config) {
46 void updatedConfig(final PasswordServiceConfig config) {
47 delegate = new DefaultPasswordHashService(config);