@Override
protected void configure() {
- install(new EncryptModule());
install(new CertModule());
install(new ShiroModule());
}
package org.opendaylight.aaa.simple;
import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import java.io.IOException;
+import java.security.Security;
+import javax.inject.Singleton;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.opendaylight.aaa.cert.api.ICertificateManager;
+import org.opendaylight.aaa.cert.impl.AaaCertRpcServiceImpl;
+import org.opendaylight.aaa.cert.impl.CertificateManagerService;
+import org.opendaylight.aaa.encrypt.AAAEncryptionService;
+import org.opendaylight.controller.simple.ConfigReader;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.yang.aaa.cert.rev151126.AaaCertServiceConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.yang.aaa.cert.rpc.rev151215.AaaCertRpcService;
/**
* Guice wiring equivalent of AAA Cert BP XML in
*/
public class CertModule extends AbstractModule {
- @Override
- protected void configure() {
+ static {
+ Security.addProvider(new BouncyCastleProvider());
}
-/*
@Override
protected void configure() {
- // as per aaa-cert-config.xml
- // TODO read this from XML with that helper I once wrote somewhere for tests instead of duplicating here..
- bind(AaaCertServiceConfig.class).toInstance(new AaaCertServiceConfigBuilder().setUseConfig(true)
- .setUseMdsal(true).setBundleName("opendaylight").build());
- // TODO ctlKeystore & trustKeystore, but what are those, where are the stores, and needed for what?
+ install(new EncryptModule());
}
@Provides
- @Singleton public ICertificateManager certificateManagerService(AaaCertServiceConfig config, DataBroker db,
+ @Singleton ICertificateManager certificateManagerService(AaaCertServiceConfig config, DataBroker db,
AAAEncryptionService crypto) {
return new CertificateManagerService(config, db, crypto);
}
+ @Provides
+ @Singleton AaaCertServiceConfig getAaaCertServiceConfig(ConfigReader configReader) throws IOException {
+ // TODO Urgh, CertificateManagerService is hard-coded to expect aaa-cert-config.xml to be in
+ // etc/opendaylight/datastore/initial/config/aaa-cert-config.xml instead of in initial/aaa-cert-config.xml
+ // and -more importantly- it *WRITES INTO IT* - OMG, what is that?!
+ //
+ // This _HACK_ prevents the WARN, but it should be changed in AAA:
+// File file = new File("etc/opendaylight/datastore/initial/config/aaa-cert-config.xml");
+// file.getParentFile().mkdirs();
+// Resources.asByteSource(Resources.getResource("initial/aaa-cert-config.xml")).copyTo(Files.asByteSink(file));
+
+ return configReader.read("/initial/aaa-cert-config", AaaCertServiceConfig.class);
+ }
+
@Provides
@Singleton
- public AaaCertRpcService aaaCertRpcService(AaaCertServiceConfig config, DataBroker db, AAAEncryptionService crypt) {
+ AaaCertRpcService aaaCertRpcService(AaaCertServiceConfig config, DataBroker db, AAAEncryptionService crypt) {
return new AaaCertRpcServiceImpl(config, db, crypt);
}
-*/
}
package org.opendaylight.aaa.simple;
import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import javax.inject.Singleton;
+import org.opendaylight.aaa.encrypt.AAAEncryptionService;
+import org.opendaylight.aaa.encrypt.impl.AAAEncryptionServiceImpl;
+import org.opendaylight.controller.simple.ConfigReader;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.yang.gen.v1.config.aaa.authn.encrypt.service.config.rev160915.AaaEncryptServiceConfig;
public class EncryptModule extends AbstractModule {
- @Override
- protected void configure() {
- }
-
-/*
- @Override
- protected void configure() {
- // as per aaa-encrypt-service-config.xml
- // TODO read this from XML with that helper I once wrote somewhere for tests instead of duplicating here..
- bind(AaaEncryptServiceConfig.class).toInstance(new AaaEncryptServiceConfigBuilder()
- .setEncryptKey("V1S1ED4OMeEh").setPasswordLength(12).setEncryptSalt("TdtWeHbch/7xP52/rp3Usw==")
- .setEncryptMethod("PBKDF2WithHmacSHA1").setEncryptType("AES").setEncryptIterationCount(32768)
- .setEncryptKeyLength(128).setCipherTransforms("AES/CBC/PKCS5Padding").build());
+ @Provides
+ @Singleton AaaEncryptServiceConfig getEncryptServiceConfig(ConfigReader configReader) {
+ return configReader.read("/initial/aaa-encrypt-service-config", AaaEncryptServiceConfig.class);
}
@Provides
public AAAEncryptionService aaaEncryptionService(AaaEncryptServiceConfig config, DataBroker db) {
return new AAAEncryptionServiceImpl(config, db);
}
-*/
+
+ @Override
+ protected void configure() {
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Red Hat, Inc. 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.simple.test;
+
+import javax.inject.Inject;
+import org.junit.Rule;
+import org.opendaylight.aaa.cert.api.ICertificateManager;
+import org.opendaylight.aaa.simple.CertModule;
+import org.opendaylight.controller.simple.InMemoryControllerModule;
+import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
+
+public class CertModuleTest extends AbstractSimpleDistributionTest {
+
+ public @Rule GuiceRule2 guice = new GuiceRule2(
+ new CertModule(), new InMemoryControllerModule(), new AnnotationsModule());
+
+ @Inject ICertificateManager certificateManager;
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Red Hat, Inc. 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.simple.test;
+
+import javax.inject.Inject;
+import org.junit.Rule;
+import org.opendaylight.aaa.encrypt.AAAEncryptionService;
+import org.opendaylight.aaa.simple.EncryptModule;
+import org.opendaylight.controller.simple.InMemoryControllerModule;
+import org.opendaylight.infrautils.inject.guice.testutils.AnnotationsModule;
+import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule2;
+import org.opendaylight.infrautils.simple.testutils.AbstractSimpleDistributionTest;
+
+public class EncryptModuleTest extends AbstractSimpleDistributionTest {
+
+ public @Rule GuiceRule2 guice = new GuiceRule2(
+ new EncryptModule(), new InMemoryControllerModule(), new AnnotationsModule());
+
+ @Inject AAAEncryptionService encryptionService;
+
+}