Лучшие методы реализации сервера начальной загрузки LWM2M с Leshan 1.5.0 с использованием конечных точек на основе PSK иJAVA

Программисты JAVA общаются здесь
Anonymous
Лучшие методы реализации сервера начальной загрузки LWM2M с Leshan 1.5.0 с использованием конечных точек на основе PSK и

Сообщение Anonymous »

Я строю автономный сервер начальной загрузки LWM2M в Java, используя Leshan 1.5.0 (Leshan-Server-CF) со следующими требованиями и ограничениями: < /p>
Идентификация клиента < /p>
обеспечивает свой imei как endpoint endpoint pstection. Identity + Ключ, который я делюсь вне полости с устройством. Endpoint).
Вторая пара идентификаторов PSK/ключей для сервера DM.
Параметры сервера LWM2M (срок службы, периоды по умолчанию, режим привязки, сервер).
Environmenthas
It ulcul on leshan 1. /> Я использую Maven только с Leshan-server-cf: 1.5.0 Зависимость. < /p>
Мне нужен введенный в память SecurityStore для начальной загрузки, без раскрытия внешней базы данных. />package fr.akensys;

import java.util.Arrays;
import java.util.Base64;
import org.eclipse.leshan.core.SecurityMode;
import org.eclipse.leshan.core.request.BindingMode;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig.ServerConfig;
import org.eclipse.leshan.server.bootstrap.BootstrapConfig.ServerSecurity;
import org.eclipse.leshan.server.bootstrap.EditableBootstrapConfigStore;
import org.eclipse.leshan.server.bootstrap.InvalidConfigurationException;
import org.eclipse.leshan.server.californium.bootstrap.LeshanBootstrapServer;
import org.eclipse.leshan.server.californium.bootstrap.LeshanBootstrapServerBuilder;
import org.eclipse.leshan.server.security.SecurityInfo;
import org.eclipse.leshan.server.security.InMemorySecurityStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class App
{
private static final Logger LOG = LoggerFactory.getLogger(App.class);

private static final String IMEI_CLIENT = "353141283470990";
private static final String BOOTSTRAP_PSK_IDENTITY = "bootstrap_client_identity";
private static final byte[] BOOTSTRAP_PSK_KEY = "my_super_secret_key_for_bs".getBytes();

private static final String DM_SERVER_URI = "coaps://leshan.eclipseprojects.io";
private static final int DM_SERVER_ID = 111;
private static final String DM_PSK_IDENTITY = "client_app_identity";
private static final byte[] DM_PSK_KEY = "another_secret_key_for_app".getBytes();

public static void main( String[] args )
{
LOG.info("Démarrage du serveur LwM2M Bootstrap pour configurer l'appareil {}", IMEI_CLIENT);

InMemorySecurityStore securityStore = new InMemorySecurityStore();

SecurityInfo securityInfoForClientToBootstrap = SecurityInfo.newPreSharedKeyInfo(
IMEI_CLIENT,
BOOTSTRAP_PSK_IDENTITY,
BOOTSTRAP_PSK_KEY
);
securityStore.add(securityInfoForClientToBootstrap);

LeshanBootstrapServerBuilder builder = new LeshanBootstrapServerBuilder();
builder.setSecurityStore(securityStore);

LeshanBootstrapServer bootstrapServer = builder.build();

BootstrapConfig config = new BootstrapConfig();

config.toDelete = Arrays.asList("/0", "/1");

ServerSecurity dmSecurity = new ServerSecurity();
dmSecurity.uri = DM_SERVER_URI;
dmSecurity.serverId = DM_SERVER_ID;
dmSecurity.securityMode = SecurityMode.PSK;
dmSecurity.publicKeyOrId = DM_PSK_IDENTITY.getBytes();
dmSecurity.secretKey = DM_PSK_KEY;
config.security.put(1, dmSecurity);

ServerConfig dmConfig = new ServerConfig();
dmConfig.shortId = dmSecurity.serverId;
dmConfig.lifetime = 5 * 60;
dmConfig.defaultMinPeriod = 10;
dmConfig.defaultMaxPeriod = 60;
dmConfig.binding = BindingMode.U;
config.servers.put(0, dmConfig);

EditableBootstrapConfigStore configStore = (EditableBootstrapConfigStore) bootstrapServer.getBoostrapStore();
try {
configStore.add(IMEI_CLIENT, config);
LOG.info("Configuration de bootstrap ajoutée pour l'IMEI : {}", IMEI_CLIENT);
} catch (InvalidConfigurationException e) {
LOG.error("Erreur: Configuration de bootstrap invalide pour {}: {}", IMEI_CLIENT, e.getMessage());
e.printStackTrace();
System.exit(1);
}

bootstrapServer.start();
LOG.info("Serveur Leshan Bootstrap démarré et prêt à servir les requêtes de {}", IMEI_CLIENT);
LOG.info("Port CoAP (non sécurisé) : 5683");
LOG.info("Port CoAPS (sécurisé) : 5684");

LOG.info("\n--- INFORMATIONS À FOURNIR AU CLIENT POUR SON APPAREIL ---");
LOG.info("Endpoint Name (IMEI) : {}", IMEI_CLIENT);
LOG.info("Adresse du Serveur BOOTSTRAP (votre machine) : coaps://:5784");
LOG.info("Identité PSK pour le BOOTSTRAP : {}", BOOTSTRAP_PSK_IDENTITY);
LOG.info("Clé PSK pour le BOOTSTRAP (en Base64 si nécessaire) : {}", Base64.getEncoder().encodeToString(BOOTSTRAP_PSK_KEY));
LOG.info("----------------------------------------------------------");
}
}
< /code>
ошибка компилятора: < /p>
The method setSecurityStore(BootstrapSecurityStore) in the type LeshanBootstrapServerBuilder is not applicable for the arguments (InMemorySecurityStore)Java(67108979)
LeshanBootstrapServerBuilder org.eclipse.leshan.server.californium.bootstrap.LeshanBootstrapServerBuilder.setSecurityStore(BootstrapSecurityStore securityStore)
Set the BootstrapSecurityStore which contains data needed to authenticate devices.

WARNING: without security store all devices will be accepted which is not really recommended in production environnement.

There is not default implementation.

Parameters:

securityStore the security store used to authenticate devices.
Returns:

the builder for fluent Bootstrap Server creation.
< /code>
Что я хотел бы знать
Правильное количество безопасности для Bootstrap < /p>
Какой класс или модуль обеспечивает реализацию в памяти Bootstrapsecuritystore в Leshan 1.5.0? Конфигурация
Как структурировать и управлять для каждого устройства BootstrapConfig (несколько IMEIS) в памяти? /> Должен ли я по-разному вращать клавиши или хранить секреты для клиента?>

Подробнее здесь: https://stackoverflow.com/questions/796 ... 1-5-0-usin

Вернуться в «JAVA»