<groupId>org.opendaylight.aaa</groupId>
<artifactId>aaa-encrypt-service</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
</dependency>
</dependencies>
+ <!-- FIXME: AAA-204: remove all this once we do not have Blueprint -->
<build>
<plugins>
<plugin>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <!-- Mixed OSGi DS/Blueprint services, we have to override to get Blueprint bits here -->
+ <Provide-Capability>
+ osgi.service;objectClass:List<String>="org.opendaylight.aaa.encrypt.AAAEncryptionService";uses:="org.opendaylight.aaa.encrypt",
+ osgi.service;objectClass:List<String>="org.opendaylight.aaa.encrypt.impl.EncryptServiceConfigSupplier";uses:="org.opendaylight.aaa.encrypt.impl"
+ </Provide-Capability>
+ </instructions>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
* Intermediate component dealing with establishing initial configuration for {@link AAAEncryptionServiceImpl}. In
* particular it deals with generating and persisting of encryption salt and encryption password.
*/
-public final class AAAEncryptionServiceConfigurator implements EncryptServiceConfig {
+public final class AAAEncryptionServiceConfigurator implements EncryptServiceConfigSupplier, EncryptServiceConfig {
private static final Logger LOG = LoggerFactory.getLogger(AAAEncryptionServiceConfigurator.class);
// Note: this is a strong binding to Blueprint, which is loading etc/opendaylight/datastore/initial/config
}
}
+ @Override
+ public EncryptServiceConfig get() {
+ return this;
+ }
+
@Override
public Class<? extends EncryptServiceConfig> implementedInterface() {
throw new UnsupportedOperationException();
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import org.opendaylight.aaa.encrypt.AAAEncryptionService;
-import org.opendaylight.yang.gen.v1.config.aaa.authn.encrypt.service.config.rev160915.EncryptServiceConfig;
+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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @author - Sharon Aicler (saichler@gmail.com)
*/
@Deprecated
-public class AAAEncryptionServiceImpl implements AAAEncryptionService {
+@Component(immediate = true)
+public final class AAAEncryptionServiceImpl implements AAAEncryptionService {
private static final Logger LOG = LoggerFactory.getLogger(AAAEncryptionServiceImpl.class);
private final SecretKey key;
private final Cipher encryptCipher;
private final Cipher decryptCipher;
- public AAAEncryptionServiceImpl(final EncryptServiceConfig encrySrvConfig) {
+ @Activate
+ public AAAEncryptionServiceImpl(@Reference final EncryptServiceConfigSupplier configProvider) {
+ final var encrySrvConfig = configProvider.get();
+
final byte[] encryptionKeySalt = encrySrvConfig.requireEncryptSalt();
IvParameterSpec tempIvSpec = null;
SecretKey tempKey = null;
LOG.error("Failed to create decrypt cipher.", e);
}
decryptCipher = cipher;
+ LOG.info("AAAEncryptionService activated");
+ }
+
+ @Deactivate
+ void deactivate() {
+ LOG.info("AAAEncryptionService deactivated");
}
@Override
--- /dev/null
+/*
+ * Copyright (c) 2023 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.encrypt.impl;
+
+import java.util.function.Supplier;
+import org.opendaylight.yang.gen.v1.config.aaa.authn.encrypt.service.config.rev160915.EncryptServiceConfig;
+
+/**
+ * Blueprint compatibility hack. Direct injection would result in
+ * <pre>
+ * Caused by: java.lang.IncompatibleClassChangeError: class Proxy601f54db_5975_4863_a33b_758ee248518f cannot implement
+ * sealed interface org.opendaylight.yangtools.yang.binding.DataContainer
+ * </pre>
+ * and hence we wrap it with a DataObject, which is not sealed.
+ */
+@Deprecated
+public interface EncryptServiceConfigSupplier extends Supplier<EncryptServiceConfig> {
+
+}
<argument ref="dataBroker"/>
<argument ref="encryptConfig"/>
</bean>
-
- <bean id="encryptService" class="org.opendaylight.aaa.encrypt.impl.AAAEncryptionServiceImpl">
- <argument ref="encryptServiceConfigurator"/>
- </bean>
- <service ref="encryptService" interface="org.opendaylight.aaa.encrypt.AAAEncryptionService"/>
+ <service ref="encryptServiceConfigurator" interface="org.opendaylight.aaa.encrypt.impl.EncryptServiceConfigSupplier"/>
</blueprint>