Search in sources :

Example 1 with DeviceCredentialsId

use of org.thingsboard.server.common.data.id.DeviceCredentialsId in project thingsboard by thingsboard.

the class BaseDeviceCredentialsCacheTest method createDummyDeviceCredentialsEntity.

private DeviceCredentials createDummyDeviceCredentialsEntity(String deviceCredentialsId) {
    DeviceCredentials result = new DeviceCredentials(new DeviceCredentialsId(UUID.randomUUID()));
    result.setCredentialsId(deviceCredentialsId);
    return result;
}
Also used : DeviceCredentialsId(org.thingsboard.server.common.data.id.DeviceCredentialsId) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials)

Example 2 with DeviceCredentialsId

use of org.thingsboard.server.common.data.id.DeviceCredentialsId in project thingsboard by thingsboard.

the class DeviceCredentialsEntity method toData.

@Override
public DeviceCredentials toData() {
    DeviceCredentials deviceCredentials = new DeviceCredentials(new DeviceCredentialsId(getId()));
    deviceCredentials.setCreatedTime(UUIDs.unixTimestamp(getId()));
    if (deviceId != null) {
        deviceCredentials.setDeviceId(new DeviceId(toUUID(deviceId)));
    }
    deviceCredentials.setCredentialsType(credentialsType);
    deviceCredentials.setCredentialsId(credentialsId);
    deviceCredentials.setCredentialsValue(credentialsValue);
    return deviceCredentials;
}
Also used : DeviceId(org.thingsboard.server.common.data.id.DeviceId) DeviceCredentialsId(org.thingsboard.server.common.data.id.DeviceCredentialsId) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials)

Example 3 with DeviceCredentialsId

use of org.thingsboard.server.common.data.id.DeviceCredentialsId in project thingsboard by thingsboard.

the class DeviceCredentialsEntity method toData.

@Override
public DeviceCredentials toData() {
    DeviceCredentials deviceCredentials = new DeviceCredentials(new DeviceCredentialsId(id));
    deviceCredentials.setCreatedTime(UUIDs.unixTimestamp(id));
    if (deviceId != null) {
        deviceCredentials.setDeviceId(new DeviceId(deviceId));
    }
    deviceCredentials.setCredentialsType(credentialsType);
    deviceCredentials.setCredentialsId(credentialsId);
    deviceCredentials.setCredentialsValue(credentialsValue);
    return deviceCredentials;
}
Also used : DeviceId(org.thingsboard.server.common.data.id.DeviceId) DeviceCredentialsId(org.thingsboard.server.common.data.id.DeviceCredentialsId) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials)

Example 4 with DeviceCredentialsId

use of org.thingsboard.server.common.data.id.DeviceCredentialsId in project thingsboard by thingsboard.

the class BaseDeviceControllerTest method testSaveNonExistentDeviceCredentials.

@Test
public void testSaveNonExistentDeviceCredentials() throws Exception {
    Device device = new Device();
    device.setName("My device");
    device.setType("default");
    Device savedDevice = doPost("/api/device", device, Device.class);
    DeviceCredentials deviceCredentials = doGet("/api/device/" + savedDevice.getId().getId().toString() + "/credentials", DeviceCredentials.class);
    DeviceCredentials newDeviceCredentials = new DeviceCredentials(new DeviceCredentialsId(UUIDs.timeBased()));
    newDeviceCredentials.setCreatedTime(deviceCredentials.getCreatedTime());
    newDeviceCredentials.setDeviceId(deviceCredentials.getDeviceId());
    newDeviceCredentials.setCredentialsType(deviceCredentials.getCredentialsType());
    newDeviceCredentials.setCredentialsId(deviceCredentials.getCredentialsId());
    doPost("/api/device/credentials", newDeviceCredentials).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("Unable to update non-existent device credentials")));
}
Also used : DeviceCredentialsId(org.thingsboard.server.common.data.id.DeviceCredentialsId) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials) Test(org.junit.Test)

Example 5 with DeviceCredentialsId

use of org.thingsboard.server.common.data.id.DeviceCredentialsId in project thingsboard by thingsboard.

the class BaseDeviceCredentialsCacheTest method createDummyDeviceCredentials.

private DeviceCredentials createDummyDeviceCredentials(UUID id, String deviceCredentialsId, UUID deviceId) {
    DeviceCredentials result = new DeviceCredentials();
    result.setId(new DeviceCredentialsId(id));
    result.setDeviceId(new DeviceId(deviceId));
    result.setCredentialsId(deviceCredentialsId);
    result.setCredentialsType(DeviceCredentialsType.ACCESS_TOKEN);
    return result;
}
Also used : DeviceId(org.thingsboard.server.common.data.id.DeviceId) DeviceCredentialsId(org.thingsboard.server.common.data.id.DeviceCredentialsId) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials)

Aggregations

DeviceCredentialsId (org.thingsboard.server.common.data.id.DeviceCredentialsId)6 DeviceCredentials (org.thingsboard.server.common.data.security.DeviceCredentials)6 DeviceId (org.thingsboard.server.common.data.id.DeviceId)3 Test (org.junit.Test)2 Device (org.thingsboard.server.common.data.Device)1