Search in sources :

Example 1 with LwM2MSecurityMode

use of org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode in project thingsboard by thingsboard.

the class LwM2MBootstrapSecurityStore method getValidatedSecurityMode.

/**
 * Bootstrap security have to sync between (bootstrapServer in credential and  bootstrapServer in profile)
 * and (lwm2mServer  in credential and lwm2mServer  in profile
 *
 * @return false if not sync between SecurityMode of Bootstrap credential and profile
 */
private boolean getValidatedSecurityMode(LwM2MBootstrapConfig lwM2MBootstrapConfig) {
    LwM2MSecurityMode bootstrapServerSecurityMode = lwM2MBootstrapConfig.getBootstrapServer().getSecurityMode();
    LwM2MSecurityMode lwm2mServerSecurityMode = lwM2MBootstrapConfig.getLwm2mServer().getSecurityMode();
    AtomicBoolean validBs = new AtomicBoolean(true);
    AtomicBoolean validLw = new AtomicBoolean(true);
    lwM2MBootstrapConfig.getServerConfiguration().forEach(serverCredential -> {
        if (((AbstractLwM2MBootstrapServerCredential) serverCredential).isBootstrapServerIs()) {
            if (!bootstrapServerSecurityMode.equals(serverCredential.getSecurityMode())) {
                validBs.set(false);
            }
        } else {
            if (!lwm2mServerSecurityMode.equals(serverCredential.getSecurityMode())) {
                validLw.set(false);
            }
        }
    });
    return validBs.get() && validLw.get();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AbstractLwM2MBootstrapServerCredential(org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.AbstractLwM2MBootstrapServerCredential) LwM2MSecurityMode(org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode)

Aggregations

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 LwM2MSecurityMode (org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode)1 AbstractLwM2MBootstrapServerCredential (org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.AbstractLwM2MBootstrapServerCredential)1