340 changed files with 12202 additions and 4717 deletions
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,222 +0,0 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.controller; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.core.io.ByteArrayResource; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import org.thingsboard.server.common.data.EntityType; |
|||
import org.thingsboard.server.common.data.Firmware; |
|||
import org.thingsboard.server.common.data.FirmwareInfo; |
|||
import org.thingsboard.server.common.data.audit.ActionType; |
|||
import org.thingsboard.server.common.data.exception.ThingsboardException; |
|||
import org.thingsboard.server.common.data.firmware.ChecksumAlgorithm; |
|||
import org.thingsboard.server.common.data.firmware.FirmwareType; |
|||
import org.thingsboard.server.common.data.id.DeviceProfileId; |
|||
import org.thingsboard.server.common.data.id.FirmwareId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
import org.thingsboard.server.queue.util.TbCoreComponent; |
|||
import org.thingsboard.server.service.security.permission.Operation; |
|||
import org.thingsboard.server.service.security.permission.Resource; |
|||
|
|||
import java.nio.ByteBuffer; |
|||
|
|||
@Slf4j |
|||
@RestController |
|||
@TbCoreComponent |
|||
@RequestMapping("/api") |
|||
public class FirmwareController extends BaseController { |
|||
|
|||
public static final String FIRMWARE_ID = "firmwareId"; |
|||
public static final String CHECKSUM_ALGORITHM = "checksumAlgorithm"; |
|||
|
|||
@PreAuthorize("hasAnyAuthority( 'TENANT_ADMIN')") |
|||
@RequestMapping(value = "/firmware/{firmwareId}/download", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public ResponseEntity<org.springframework.core.io.Resource> downloadFirmware(@PathVariable(FIRMWARE_ID) String strFirmwareId) throws ThingsboardException { |
|||
checkParameter(FIRMWARE_ID, strFirmwareId); |
|||
try { |
|||
FirmwareId firmwareId = new FirmwareId(toUUID(strFirmwareId)); |
|||
Firmware firmware = checkFirmwareId(firmwareId, Operation.READ); |
|||
|
|||
ByteArrayResource resource = new ByteArrayResource(firmware.getData().array()); |
|||
return ResponseEntity.ok() |
|||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + firmware.getFileName()) |
|||
.header("x-filename", firmware.getFileName()) |
|||
.contentLength(resource.contentLength()) |
|||
.contentType(parseMediaType(firmware.getContentType())) |
|||
.body(resource); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/firmware/info/{firmwareId}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public FirmwareInfo getFirmwareInfoById(@PathVariable(FIRMWARE_ID) String strFirmwareId) throws ThingsboardException { |
|||
checkParameter(FIRMWARE_ID, strFirmwareId); |
|||
try { |
|||
FirmwareId firmwareId = new FirmwareId(toUUID(strFirmwareId)); |
|||
return checkNotNull(firmwareService.findFirmwareInfoById(getTenantId(), firmwareId)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/firmware/{firmwareId}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public Firmware getFirmwareById(@PathVariable(FIRMWARE_ID) String strFirmwareId) throws ThingsboardException { |
|||
checkParameter(FIRMWARE_ID, strFirmwareId); |
|||
try { |
|||
FirmwareId firmwareId = new FirmwareId(toUUID(strFirmwareId)); |
|||
return checkFirmwareId(firmwareId, Operation.READ); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/firmware", method = RequestMethod.POST) |
|||
@ResponseBody |
|||
public FirmwareInfo saveFirmwareInfo(@RequestBody FirmwareInfo firmwareInfo) throws ThingsboardException { |
|||
boolean created = firmwareInfo.getId() == null; |
|||
try { |
|||
firmwareInfo.setTenantId(getTenantId()); |
|||
checkEntity(firmwareInfo.getId(), firmwareInfo, Resource.FIRMWARE); |
|||
FirmwareInfo savedFirmwareInfo = firmwareService.saveFirmwareInfo(firmwareInfo); |
|||
logEntityAction(savedFirmwareInfo.getId(), savedFirmwareInfo, |
|||
null, created ? ActionType.ADDED : ActionType.UPDATED, null); |
|||
return savedFirmwareInfo; |
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.FIRMWARE), firmwareInfo, |
|||
null, created ? ActionType.ADDED : ActionType.UPDATED, e); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/firmware/{firmwareId}", method = RequestMethod.POST) |
|||
@ResponseBody |
|||
public Firmware saveFirmwareData(@PathVariable(FIRMWARE_ID) String strFirmwareId, |
|||
@RequestParam(required = false) String checksum, |
|||
@RequestParam(CHECKSUM_ALGORITHM) String checksumAlgorithmStr, |
|||
@RequestBody MultipartFile file) throws ThingsboardException { |
|||
checkParameter(FIRMWARE_ID, strFirmwareId); |
|||
checkParameter(CHECKSUM_ALGORITHM, checksumAlgorithmStr); |
|||
try { |
|||
FirmwareId firmwareId = new FirmwareId(toUUID(strFirmwareId)); |
|||
FirmwareInfo info = checkFirmwareInfoId(firmwareId, Operation.READ); |
|||
|
|||
Firmware firmware = new Firmware(firmwareId); |
|||
firmware.setCreatedTime(info.getCreatedTime()); |
|||
firmware.setTenantId(getTenantId()); |
|||
firmware.setDeviceProfileId(info.getDeviceProfileId()); |
|||
firmware.setType(info.getType()); |
|||
firmware.setTitle(info.getTitle()); |
|||
firmware.setVersion(info.getVersion()); |
|||
firmware.setAdditionalInfo(info.getAdditionalInfo()); |
|||
|
|||
ChecksumAlgorithm checksumAlgorithm = ChecksumAlgorithm.valueOf(checksumAlgorithmStr.toUpperCase()); |
|||
|
|||
byte[] bytes = file.getBytes(); |
|||
if (StringUtils.isEmpty(checksum)) { |
|||
checksum = firmwareService.generateChecksum(checksumAlgorithm, ByteBuffer.wrap(bytes)); |
|||
} |
|||
|
|||
firmware.setChecksumAlgorithm(checksumAlgorithm); |
|||
firmware.setChecksum(checksum); |
|||
firmware.setFileName(file.getOriginalFilename()); |
|||
firmware.setContentType(file.getContentType()); |
|||
firmware.setData(ByteBuffer.wrap(bytes)); |
|||
firmware.setDataSize((long) bytes.length); |
|||
Firmware savedFirmware = firmwareService.saveFirmware(firmware); |
|||
logEntityAction(savedFirmware.getId(), savedFirmware, null, ActionType.UPDATED, null); |
|||
return savedFirmware; |
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.FIRMWARE), null, null, ActionType.UPDATED, e, strFirmwareId); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/firmwares", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public PageData<FirmwareInfo> getFirmwares(@RequestParam int pageSize, |
|||
@RequestParam int page, |
|||
@RequestParam(required = false) String textSearch, |
|||
@RequestParam(required = false) String sortProperty, |
|||
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|||
try { |
|||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|||
return checkNotNull(firmwareService.findTenantFirmwaresByTenantId(getTenantId(), pageLink)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/firmwares/{deviceProfileId}/{type}/{hasData}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public PageData<FirmwareInfo> getFirmwares(@PathVariable("deviceProfileId") String strDeviceProfileId, |
|||
@PathVariable("type") String strType, |
|||
@PathVariable("hasData") boolean hasData, |
|||
@RequestParam int pageSize, |
|||
@RequestParam int page, |
|||
@RequestParam(required = false) String textSearch, |
|||
@RequestParam(required = false) String sortProperty, |
|||
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|||
checkParameter("deviceProfileId", strDeviceProfileId); |
|||
checkParameter("type", strType); |
|||
try { |
|||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|||
return checkNotNull(firmwareService.findTenantFirmwaresByTenantIdAndDeviceProfileIdAndTypeAndHasData(getTenantId(), |
|||
new DeviceProfileId(toUUID(strDeviceProfileId)), FirmwareType.valueOf(strType), hasData, pageLink)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/firmware/{firmwareId}", method = RequestMethod.DELETE) |
|||
@ResponseBody |
|||
public void deleteFirmware(@PathVariable("firmwareId") String strFirmwareId) throws ThingsboardException { |
|||
checkParameter(FIRMWARE_ID, strFirmwareId); |
|||
try { |
|||
FirmwareId firmwareId = new FirmwareId(toUUID(strFirmwareId)); |
|||
FirmwareInfo info = checkFirmwareInfoId(firmwareId, Operation.DELETE); |
|||
firmwareService.deleteFirmware(getTenantId(), firmwareId); |
|||
logEntityAction(firmwareId, info, null, ActionType.DELETED, null, strFirmwareId); |
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.FIRMWARE), null, null, ActionType.DELETED, e, strFirmwareId); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,225 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.controller; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.core.io.ByteArrayResource; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import org.thingsboard.server.common.data.EntityType; |
|||
import org.thingsboard.server.common.data.OtaPackage; |
|||
import org.thingsboard.server.common.data.OtaPackageInfo; |
|||
import org.thingsboard.server.common.data.audit.ActionType; |
|||
import org.thingsboard.server.common.data.exception.ThingsboardException; |
|||
import org.thingsboard.server.common.data.ota.ChecksumAlgorithm; |
|||
import org.thingsboard.server.common.data.ota.OtaPackageType; |
|||
import org.thingsboard.server.common.data.id.DeviceProfileId; |
|||
import org.thingsboard.server.common.data.id.OtaPackageId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
import org.thingsboard.server.queue.util.TbCoreComponent; |
|||
import org.thingsboard.server.service.security.permission.Operation; |
|||
import org.thingsboard.server.service.security.permission.Resource; |
|||
|
|||
import java.nio.ByteBuffer; |
|||
|
|||
@Slf4j |
|||
@RestController |
|||
@TbCoreComponent |
|||
@RequestMapping("/api") |
|||
public class OtaPackageController extends BaseController { |
|||
|
|||
public static final String OTA_PACKAGE_ID = "otaPackageId"; |
|||
public static final String CHECKSUM_ALGORITHM = "checksumAlgorithm"; |
|||
|
|||
@PreAuthorize("hasAnyAuthority( 'TENANT_ADMIN')") |
|||
@RequestMapping(value = "/otaPackage/{otaPackageId}/download", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public ResponseEntity<org.springframework.core.io.Resource> downloadOtaPackage(@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException { |
|||
checkParameter(OTA_PACKAGE_ID, strOtaPackageId); |
|||
try { |
|||
OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); |
|||
OtaPackage otaPackage = checkOtaPackageId(otaPackageId, Operation.READ); |
|||
|
|||
if (otaPackage.hasUrl()) { |
|||
return ResponseEntity.badRequest().build(); |
|||
} |
|||
|
|||
ByteArrayResource resource = new ByteArrayResource(otaPackage.getData().array()); |
|||
return ResponseEntity.ok() |
|||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + otaPackage.getFileName()) |
|||
.header("x-filename", otaPackage.getFileName()) |
|||
.contentLength(resource.contentLength()) |
|||
.contentType(parseMediaType(otaPackage.getContentType())) |
|||
.body(resource); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/otaPackage/info/{otaPackageId}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public OtaPackageInfo getOtaPackageInfoById(@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException { |
|||
checkParameter(OTA_PACKAGE_ID, strOtaPackageId); |
|||
try { |
|||
OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); |
|||
return checkNotNull(otaPackageService.findOtaPackageInfoById(getTenantId(), otaPackageId)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public OtaPackage getOtaPackageById(@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId) throws ThingsboardException { |
|||
checkParameter(OTA_PACKAGE_ID, strOtaPackageId); |
|||
try { |
|||
OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); |
|||
return checkOtaPackageId(otaPackageId, Operation.READ); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/otaPackage", method = RequestMethod.POST) |
|||
@ResponseBody |
|||
public OtaPackageInfo saveOtaPackageInfo(@RequestBody OtaPackageInfo otaPackageInfo) throws ThingsboardException { |
|||
boolean created = otaPackageInfo.getId() == null; |
|||
try { |
|||
otaPackageInfo.setTenantId(getTenantId()); |
|||
checkEntity(otaPackageInfo.getId(), otaPackageInfo, Resource.OTA_PACKAGE); |
|||
OtaPackageInfo savedOtaPackageInfo = otaPackageService.saveOtaPackageInfo(otaPackageInfo); |
|||
logEntityAction(savedOtaPackageInfo.getId(), savedOtaPackageInfo, |
|||
null, created ? ActionType.ADDED : ActionType.UPDATED, null); |
|||
return savedOtaPackageInfo; |
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.OTA_PACKAGE), otaPackageInfo, |
|||
null, created ? ActionType.ADDED : ActionType.UPDATED, e); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.POST) |
|||
@ResponseBody |
|||
public OtaPackage saveOtaPackageData(@PathVariable(OTA_PACKAGE_ID) String strOtaPackageId, |
|||
@RequestParam(required = false) String checksum, |
|||
@RequestParam(CHECKSUM_ALGORITHM) String checksumAlgorithmStr, |
|||
@RequestBody MultipartFile file) throws ThingsboardException { |
|||
checkParameter(OTA_PACKAGE_ID, strOtaPackageId); |
|||
checkParameter(CHECKSUM_ALGORITHM, checksumAlgorithmStr); |
|||
try { |
|||
OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); |
|||
OtaPackageInfo info = checkOtaPackageInfoId(otaPackageId, Operation.READ); |
|||
|
|||
OtaPackage otaPackage = new OtaPackage(otaPackageId); |
|||
otaPackage.setCreatedTime(info.getCreatedTime()); |
|||
otaPackage.setTenantId(getTenantId()); |
|||
otaPackage.setDeviceProfileId(info.getDeviceProfileId()); |
|||
otaPackage.setType(info.getType()); |
|||
otaPackage.setTitle(info.getTitle()); |
|||
otaPackage.setVersion(info.getVersion()); |
|||
otaPackage.setAdditionalInfo(info.getAdditionalInfo()); |
|||
|
|||
ChecksumAlgorithm checksumAlgorithm = ChecksumAlgorithm.valueOf(checksumAlgorithmStr.toUpperCase()); |
|||
|
|||
byte[] bytes = file.getBytes(); |
|||
if (StringUtils.isEmpty(checksum)) { |
|||
checksum = otaPackageService.generateChecksum(checksumAlgorithm, ByteBuffer.wrap(bytes)); |
|||
} |
|||
|
|||
otaPackage.setChecksumAlgorithm(checksumAlgorithm); |
|||
otaPackage.setChecksum(checksum); |
|||
otaPackage.setFileName(file.getOriginalFilename()); |
|||
otaPackage.setContentType(file.getContentType()); |
|||
otaPackage.setData(ByteBuffer.wrap(bytes)); |
|||
otaPackage.setDataSize((long) bytes.length); |
|||
OtaPackage savedOtaPackage = otaPackageService.saveOtaPackage(otaPackage); |
|||
logEntityAction(savedOtaPackage.getId(), savedOtaPackage, null, ActionType.UPDATED, null); |
|||
return savedOtaPackage; |
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.OTA_PACKAGE), null, null, ActionType.UPDATED, e, strOtaPackageId); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/otaPackages", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public PageData<OtaPackageInfo> getOtaPackages(@RequestParam int pageSize, |
|||
@RequestParam int page, |
|||
@RequestParam(required = false) String textSearch, |
|||
@RequestParam(required = false) String sortProperty, |
|||
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|||
try { |
|||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|||
return checkNotNull(otaPackageService.findTenantOtaPackagesByTenantId(getTenantId(), pageLink)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/otaPackages/{deviceProfileId}/{type}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public PageData<OtaPackageInfo> getOtaPackages(@PathVariable("deviceProfileId") String strDeviceProfileId, |
|||
@PathVariable("type") String strType, |
|||
@RequestParam int pageSize, |
|||
@RequestParam int page, |
|||
@RequestParam(required = false) String textSearch, |
|||
@RequestParam(required = false) String sortProperty, |
|||
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|||
checkParameter("deviceProfileId", strDeviceProfileId); |
|||
checkParameter("type", strType); |
|||
try { |
|||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|||
return checkNotNull(otaPackageService.findTenantOtaPackagesByTenantIdAndDeviceProfileIdAndTypeAndHasData(getTenantId(), |
|||
new DeviceProfileId(toUUID(strDeviceProfileId)), OtaPackageType.valueOf(strType), pageLink)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/otaPackage/{otaPackageId}", method = RequestMethod.DELETE) |
|||
@ResponseBody |
|||
public void deleteOtaPackage(@PathVariable("otaPackageId") String strOtaPackageId) throws ThingsboardException { |
|||
checkParameter(OTA_PACKAGE_ID, strOtaPackageId); |
|||
try { |
|||
OtaPackageId otaPackageId = new OtaPackageId(toUUID(strOtaPackageId)); |
|||
OtaPackageInfo info = checkOtaPackageInfoId(otaPackageId, Operation.DELETE); |
|||
otaPackageService.deleteOtaPackage(getTenantId(), otaPackageId); |
|||
logEntityAction(otaPackageId, info, null, ActionType.DELETED, null, strOtaPackageId); |
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.OTA_PACKAGE), null, null, ActionType.DELETED, e, strOtaPackageId); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,256 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.action; |
|||
|
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import com.fasterxml.jackson.databind.node.ArrayNode; |
|||
import com.fasterxml.jackson.databind.node.ObjectNode; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.thingsboard.server.common.data.DataConstants; |
|||
import org.thingsboard.server.common.data.EntityType; |
|||
import org.thingsboard.server.common.data.HasName; |
|||
import org.thingsboard.server.common.data.HasTenantId; |
|||
import org.thingsboard.server.common.data.User; |
|||
import org.thingsboard.server.common.data.audit.ActionType; |
|||
import org.thingsboard.server.common.data.id.CustomerId; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
|||
import org.thingsboard.server.common.data.kv.DataType; |
|||
import org.thingsboard.server.common.data.kv.KvEntry; |
|||
import org.thingsboard.server.common.data.kv.TsKvEntry; |
|||
import org.thingsboard.server.common.msg.TbMsg; |
|||
import org.thingsboard.server.common.msg.TbMsgDataType; |
|||
import org.thingsboard.server.common.msg.TbMsgMetaData; |
|||
import org.thingsboard.server.queue.util.TbCoreComponent; |
|||
import org.thingsboard.server.service.queue.TbClusterService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@TbCoreComponent |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class RuleEngineEntityActionService { |
|||
private final TbClusterService tbClusterService; |
|||
|
|||
private static final ObjectMapper json = new ObjectMapper(); |
|||
|
|||
public void pushEntityActionToRuleEngine(EntityId entityId, HasName entity, TenantId tenantId, CustomerId customerId, |
|||
ActionType actionType, User user, Object... additionalInfo) { |
|||
String msgType = null; |
|||
switch (actionType) { |
|||
case ADDED: |
|||
msgType = DataConstants.ENTITY_CREATED; |
|||
break; |
|||
case DELETED: |
|||
msgType = DataConstants.ENTITY_DELETED; |
|||
break; |
|||
case UPDATED: |
|||
msgType = DataConstants.ENTITY_UPDATED; |
|||
break; |
|||
case ASSIGNED_TO_CUSTOMER: |
|||
msgType = DataConstants.ENTITY_ASSIGNED; |
|||
break; |
|||
case UNASSIGNED_FROM_CUSTOMER: |
|||
msgType = DataConstants.ENTITY_UNASSIGNED; |
|||
break; |
|||
case ATTRIBUTES_UPDATED: |
|||
msgType = DataConstants.ATTRIBUTES_UPDATED; |
|||
break; |
|||
case ATTRIBUTES_DELETED: |
|||
msgType = DataConstants.ATTRIBUTES_DELETED; |
|||
break; |
|||
case ALARM_ACK: |
|||
msgType = DataConstants.ALARM_ACK; |
|||
break; |
|||
case ALARM_CLEAR: |
|||
msgType = DataConstants.ALARM_CLEAR; |
|||
break; |
|||
case ALARM_DELETE: |
|||
msgType = DataConstants.ALARM_DELETE; |
|||
break; |
|||
case ASSIGNED_FROM_TENANT: |
|||
msgType = DataConstants.ENTITY_ASSIGNED_FROM_TENANT; |
|||
break; |
|||
case ASSIGNED_TO_TENANT: |
|||
msgType = DataConstants.ENTITY_ASSIGNED_TO_TENANT; |
|||
break; |
|||
case PROVISION_SUCCESS: |
|||
msgType = DataConstants.PROVISION_SUCCESS; |
|||
break; |
|||
case PROVISION_FAILURE: |
|||
msgType = DataConstants.PROVISION_FAILURE; |
|||
break; |
|||
case TIMESERIES_UPDATED: |
|||
msgType = DataConstants.TIMESERIES_UPDATED; |
|||
break; |
|||
case TIMESERIES_DELETED: |
|||
msgType = DataConstants.TIMESERIES_DELETED; |
|||
break; |
|||
case ASSIGNED_TO_EDGE: |
|||
msgType = DataConstants.ENTITY_ASSIGNED_TO_EDGE; |
|||
break; |
|||
case UNASSIGNED_FROM_EDGE: |
|||
msgType = DataConstants.ENTITY_UNASSIGNED_FROM_EDGE; |
|||
break; |
|||
} |
|||
if (!StringUtils.isEmpty(msgType)) { |
|||
try { |
|||
TbMsgMetaData metaData = new TbMsgMetaData(); |
|||
if (user != null) { |
|||
metaData.putValue("userId", user.getId().toString()); |
|||
metaData.putValue("userName", user.getName()); |
|||
} |
|||
if (customerId != null && !customerId.isNullUid()) { |
|||
metaData.putValue("customerId", customerId.toString()); |
|||
} |
|||
if (actionType == ActionType.ASSIGNED_TO_CUSTOMER) { |
|||
String strCustomerId = extractParameter(String.class, 1, additionalInfo); |
|||
String strCustomerName = extractParameter(String.class, 2, additionalInfo); |
|||
metaData.putValue("assignedCustomerId", strCustomerId); |
|||
metaData.putValue("assignedCustomerName", strCustomerName); |
|||
} else if (actionType == ActionType.UNASSIGNED_FROM_CUSTOMER) { |
|||
String strCustomerId = extractParameter(String.class, 1, additionalInfo); |
|||
String strCustomerName = extractParameter(String.class, 2, additionalInfo); |
|||
metaData.putValue("unassignedCustomerId", strCustomerId); |
|||
metaData.putValue("unassignedCustomerName", strCustomerName); |
|||
} else if (actionType == ActionType.ASSIGNED_FROM_TENANT) { |
|||
String strTenantId = extractParameter(String.class, 0, additionalInfo); |
|||
String strTenantName = extractParameter(String.class, 1, additionalInfo); |
|||
metaData.putValue("assignedFromTenantId", strTenantId); |
|||
metaData.putValue("assignedFromTenantName", strTenantName); |
|||
} else if (actionType == ActionType.ASSIGNED_TO_TENANT) { |
|||
String strTenantId = extractParameter(String.class, 0, additionalInfo); |
|||
String strTenantName = extractParameter(String.class, 1, additionalInfo); |
|||
metaData.putValue("assignedToTenantId", strTenantId); |
|||
metaData.putValue("assignedToTenantName", strTenantName); |
|||
} else if (actionType == ActionType.ASSIGNED_TO_EDGE) { |
|||
String strEdgeId = extractParameter(String.class, 1, additionalInfo); |
|||
String strEdgeName = extractParameter(String.class, 2, additionalInfo); |
|||
metaData.putValue("assignedEdgeId", strEdgeId); |
|||
metaData.putValue("assignedEdgeName", strEdgeName); |
|||
} else if (actionType == ActionType.UNASSIGNED_FROM_EDGE) { |
|||
String strEdgeId = extractParameter(String.class, 1, additionalInfo); |
|||
String strEdgeName = extractParameter(String.class, 2, additionalInfo); |
|||
metaData.putValue("unassignedEdgeId", strEdgeId); |
|||
metaData.putValue("unassignedEdgeName", strEdgeName); |
|||
} |
|||
ObjectNode entityNode; |
|||
if (entity != null) { |
|||
entityNode = json.valueToTree(entity); |
|||
if (entityId.getEntityType() == EntityType.DASHBOARD) { |
|||
entityNode.put("configuration", ""); |
|||
} |
|||
} else { |
|||
entityNode = json.createObjectNode(); |
|||
if (actionType == ActionType.ATTRIBUTES_UPDATED) { |
|||
String scope = extractParameter(String.class, 0, additionalInfo); |
|||
@SuppressWarnings("unchecked") |
|||
List<AttributeKvEntry> attributes = extractParameter(List.class, 1, additionalInfo); |
|||
metaData.putValue(DataConstants.SCOPE, scope); |
|||
if (attributes != null) { |
|||
for (AttributeKvEntry attr : attributes) { |
|||
addKvEntry(entityNode, attr); |
|||
} |
|||
} |
|||
} else if (actionType == ActionType.ATTRIBUTES_DELETED) { |
|||
String scope = extractParameter(String.class, 0, additionalInfo); |
|||
@SuppressWarnings("unchecked") |
|||
List<String> keys = extractParameter(List.class, 1, additionalInfo); |
|||
metaData.putValue(DataConstants.SCOPE, scope); |
|||
ArrayNode attrsArrayNode = entityNode.putArray("attributes"); |
|||
if (keys != null) { |
|||
keys.forEach(attrsArrayNode::add); |
|||
} |
|||
} else if (actionType == ActionType.TIMESERIES_UPDATED) { |
|||
@SuppressWarnings("unchecked") |
|||
List<TsKvEntry> timeseries = extractParameter(List.class, 0, additionalInfo); |
|||
addTimeseries(entityNode, timeseries); |
|||
} else if (actionType == ActionType.TIMESERIES_DELETED) { |
|||
@SuppressWarnings("unchecked") |
|||
List<String> keys = extractParameter(List.class, 0, additionalInfo); |
|||
if (keys != null) { |
|||
ArrayNode timeseriesArrayNode = entityNode.putArray("timeseries"); |
|||
keys.forEach(timeseriesArrayNode::add); |
|||
} |
|||
entityNode.put("startTs", extractParameter(Long.class, 1, additionalInfo)); |
|||
entityNode.put("endTs", extractParameter(Long.class, 2, additionalInfo)); |
|||
} |
|||
} |
|||
TbMsg tbMsg = TbMsg.newMsg(msgType, entityId, customerId, metaData, TbMsgDataType.JSON, json.writeValueAsString(entityNode)); |
|||
if (tenantId.isNullUid()) { |
|||
if (entity instanceof HasTenantId) { |
|||
tenantId = ((HasTenantId) entity).getTenantId(); |
|||
} |
|||
} |
|||
tbClusterService.pushMsgToRuleEngine(tenantId, entityId, tbMsg, null); |
|||
} catch (Exception e) { |
|||
log.warn("[{}] Failed to push entity action to rule engine: {}", entityId, actionType, e); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
private <T> T extractParameter(Class<T> clazz, int index, Object... additionalInfo) { |
|||
T result = null; |
|||
if (additionalInfo != null && additionalInfo.length > index) { |
|||
Object paramObject = additionalInfo[index]; |
|||
if (clazz.isInstance(paramObject)) { |
|||
result = clazz.cast(paramObject); |
|||
} |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
private void addTimeseries(ObjectNode entityNode, List<TsKvEntry> timeseries) throws Exception { |
|||
if (timeseries != null && !timeseries.isEmpty()) { |
|||
ArrayNode result = entityNode.putArray("timeseries"); |
|||
Map<Long, List<TsKvEntry>> groupedTelemetry = timeseries.stream() |
|||
.collect(Collectors.groupingBy(TsKvEntry::getTs)); |
|||
for (Map.Entry<Long, List<TsKvEntry>> entry : groupedTelemetry.entrySet()) { |
|||
ObjectNode element = json.createObjectNode(); |
|||
element.put("ts", entry.getKey()); |
|||
ObjectNode values = element.putObject("values"); |
|||
for (TsKvEntry tsKvEntry : entry.getValue()) { |
|||
addKvEntry(values, tsKvEntry); |
|||
} |
|||
result.add(element); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private void addKvEntry(ObjectNode entityNode, KvEntry kvEntry) throws Exception { |
|||
if (kvEntry.getDataType() == DataType.BOOLEAN) { |
|||
kvEntry.getBooleanValue().ifPresent(value -> entityNode.put(kvEntry.getKey(), value)); |
|||
} else if (kvEntry.getDataType() == DataType.DOUBLE) { |
|||
kvEntry.getDoubleValue().ifPresent(value -> entityNode.put(kvEntry.getKey(), value)); |
|||
} else if (kvEntry.getDataType() == DataType.LONG) { |
|||
kvEntry.getLongValue().ifPresent(value -> entityNode.put(kvEntry.getKey(), value)); |
|||
} else if (kvEntry.getDataType() == DataType.JSON) { |
|||
if (kvEntry.getJsonValue().isPresent()) { |
|||
entityNode.set(kvEntry.getKey(), json.readTree(kvEntry.getJsonValue().get())); |
|||
} |
|||
} else { |
|||
entityNode.put(kvEntry.getKey(), kvEntry.getValueAsString()); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.security.auth.oauth2; |
|||
|
|||
public interface TbOAuth2ParameterNames { |
|||
|
|||
String CALLBACK_URL_SCHEME = "callback_url_scheme"; |
|||
|
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.service.ttl.alarms; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
import org.springframework.stereotype.Service; |
|||
import org.thingsboard.server.common.data.alarm.Alarm; |
|||
import org.thingsboard.server.common.data.audit.ActionType; |
|||
import org.thingsboard.server.common.data.id.AlarmId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
import org.thingsboard.server.common.data.page.SortOrder; |
|||
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration; |
|||
import org.thingsboard.server.common.msg.queue.ServiceType; |
|||
import org.thingsboard.server.dao.alarm.AlarmDao; |
|||
import org.thingsboard.server.dao.alarm.AlarmService; |
|||
import org.thingsboard.server.dao.relation.RelationService; |
|||
import org.thingsboard.server.dao.tenant.TbTenantProfileCache; |
|||
import org.thingsboard.server.dao.tenant.TenantDao; |
|||
import org.thingsboard.server.dao.util.PsqlDao; |
|||
import org.thingsboard.server.queue.discovery.PartitionService; |
|||
import org.thingsboard.server.queue.util.TbCoreComponent; |
|||
import org.thingsboard.server.service.action.RuleEngineEntityActionService; |
|||
import org.thingsboard.server.service.ttl.AbstractCleanUpService; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.SQLException; |
|||
import java.util.Date; |
|||
import java.util.Optional; |
|||
import java.util.UUID; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@TbCoreComponent |
|||
@Service |
|||
@Slf4j |
|||
@RequiredArgsConstructor |
|||
public class AlarmsCleanUpService { |
|||
@Value("${sql.ttl.alarms.removal_batch_size}") |
|||
private Integer removalBatchSize; |
|||
|
|||
private final TenantDao tenantDao; |
|||
private final AlarmDao alarmDao; |
|||
private final AlarmService alarmService; |
|||
private final RelationService relationService; |
|||
private final RuleEngineEntityActionService ruleEngineEntityActionService; |
|||
private final PartitionService partitionService; |
|||
private final TbTenantProfileCache tenantProfileCache; |
|||
|
|||
@Scheduled(initialDelayString = "#{T(org.apache.commons.lang3.RandomUtils).nextLong(0, ${sql.ttl.alarms.checking_interval})}", fixedDelayString = "${sql.ttl.alarms.checking_interval}") |
|||
public void cleanUp() { |
|||
PageLink tenantsBatchRequest = new PageLink(10_000, 0); |
|||
PageLink removalBatchRequest = new PageLink(removalBatchSize, 0 ); |
|||
PageData<TenantId> tenantsIds; |
|||
do { |
|||
tenantsIds = tenantDao.findTenantsIds(tenantsBatchRequest); |
|||
for (TenantId tenantId : tenantsIds.getData()) { |
|||
if (!partitionService.resolve(ServiceType.TB_CORE, tenantId, tenantId).isMyPartition()) { |
|||
continue; |
|||
} |
|||
|
|||
Optional<DefaultTenantProfileConfiguration> tenantProfileConfiguration = tenantProfileCache.get(tenantId).getProfileConfiguration(); |
|||
if (tenantProfileConfiguration.isEmpty() || tenantProfileConfiguration.get().getAlarmsTtlDays() == 0) { |
|||
continue; |
|||
} |
|||
|
|||
long ttl = TimeUnit.DAYS.toMillis(tenantProfileConfiguration.get().getAlarmsTtlDays()); |
|||
long expirationTime = System.currentTimeMillis() - ttl; |
|||
|
|||
long totalRemoved = 0; |
|||
while (true) { |
|||
PageData<AlarmId> toRemove = alarmDao.findAlarmsIdsByEndTsBeforeAndTenantId(expirationTime, tenantId, removalBatchRequest); |
|||
toRemove.getData().forEach(alarmId -> { |
|||
relationService.deleteEntityRelations(tenantId, alarmId); |
|||
Alarm alarm = alarmService.deleteAlarm(tenantId, alarmId).getAlarm(); |
|||
ruleEngineEntityActionService.pushEntityActionToRuleEngine(alarm.getOriginator(), alarm, tenantId, null, ActionType.ALARM_DELETE, null); |
|||
}); |
|||
|
|||
totalRemoved += toRemove.getTotalElements(); |
|||
if (!toRemove.hasNext()) { |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (totalRemoved > 0) { |
|||
log.info("Removed {} outdated alarm(s) for tenant {} older than {}", totalRemoved, tenantId, new Date(expirationTime)); |
|||
} |
|||
} |
|||
|
|||
tenantsBatchRequest = tenantsBatchRequest.nextPageLink(); |
|||
} while (tenantsIds.hasNext()); |
|||
} |
|||
|
|||
} |
|||
Binary file not shown.
Binary file not shown.
@ -1,52 +0,0 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.dao.firmware; |
|||
|
|||
import com.google.common.util.concurrent.ListenableFuture; |
|||
import org.thingsboard.server.common.data.Firmware; |
|||
import org.thingsboard.server.common.data.FirmwareInfo; |
|||
import org.thingsboard.server.common.data.firmware.ChecksumAlgorithm; |
|||
import org.thingsboard.server.common.data.firmware.FirmwareType; |
|||
import org.thingsboard.server.common.data.id.DeviceProfileId; |
|||
import org.thingsboard.server.common.data.id.FirmwareId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
|
|||
import java.nio.ByteBuffer; |
|||
|
|||
public interface FirmwareService { |
|||
|
|||
FirmwareInfo saveFirmwareInfo(FirmwareInfo firmwareInfo); |
|||
|
|||
Firmware saveFirmware(Firmware firmware); |
|||
|
|||
String generateChecksum(ChecksumAlgorithm checksumAlgorithm, ByteBuffer data); |
|||
|
|||
Firmware findFirmwareById(TenantId tenantId, FirmwareId firmwareId); |
|||
|
|||
FirmwareInfo findFirmwareInfoById(TenantId tenantId, FirmwareId firmwareId); |
|||
|
|||
ListenableFuture<FirmwareInfo> findFirmwareInfoByIdAsync(TenantId tenantId, FirmwareId firmwareId); |
|||
|
|||
PageData<FirmwareInfo> findTenantFirmwaresByTenantId(TenantId tenantId, PageLink pageLink); |
|||
|
|||
PageData<FirmwareInfo> findTenantFirmwaresByTenantIdAndDeviceProfileIdAndTypeAndHasData(TenantId tenantId, DeviceProfileId deviceProfileId, FirmwareType firmwareType, boolean hasData, PageLink pageLink); |
|||
|
|||
void deleteFirmware(TenantId tenantId, FirmwareId firmwareId); |
|||
|
|||
void deleteFirmwaresByTenantId(TenantId tenantId); |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.dao.ota; |
|||
|
|||
import com.google.common.util.concurrent.ListenableFuture; |
|||
import org.thingsboard.server.common.data.OtaPackage; |
|||
import org.thingsboard.server.common.data.OtaPackageInfo; |
|||
import org.thingsboard.server.common.data.ota.ChecksumAlgorithm; |
|||
import org.thingsboard.server.common.data.ota.OtaPackageType; |
|||
import org.thingsboard.server.common.data.id.DeviceProfileId; |
|||
import org.thingsboard.server.common.data.id.OtaPackageId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
|
|||
import java.nio.ByteBuffer; |
|||
|
|||
public interface OtaPackageService { |
|||
|
|||
OtaPackageInfo saveOtaPackageInfo(OtaPackageInfo otaPackageInfo); |
|||
|
|||
OtaPackage saveOtaPackage(OtaPackage otaPackage); |
|||
|
|||
String generateChecksum(ChecksumAlgorithm checksumAlgorithm, ByteBuffer data); |
|||
|
|||
OtaPackage findOtaPackageById(TenantId tenantId, OtaPackageId otaPackageId); |
|||
|
|||
OtaPackageInfo findOtaPackageInfoById(TenantId tenantId, OtaPackageId otaPackageId); |
|||
|
|||
ListenableFuture<OtaPackageInfo> findOtaPackageInfoByIdAsync(TenantId tenantId, OtaPackageId otaPackageId); |
|||
|
|||
PageData<OtaPackageInfo> findTenantOtaPackagesByTenantId(TenantId tenantId, PageLink pageLink); |
|||
|
|||
PageData<OtaPackageInfo> findTenantOtaPackagesByTenantIdAndDeviceProfileIdAndTypeAndHasData(TenantId tenantId, DeviceProfileId deviceProfileId, OtaPackageType otaPackageType, PageLink pageLink); |
|||
|
|||
void deleteOtaPackage(TenantId tenantId, OtaPackageId otaPackageId); |
|||
|
|||
void deleteOtaPackagesByTenantId(TenantId tenantId); |
|||
|
|||
long sumDataSizeByTenantId(TenantId tenantId); |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.exception; |
|||
|
|||
public class ApiUsageLimitsExceededException extends RuntimeException { |
|||
public ApiUsageLimitsExceededException(String message) { |
|||
super(message); |
|||
} |
|||
|
|||
public ApiUsageLimitsExceededException() { |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.id; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonCreator; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
|
|||
import java.util.UUID; |
|||
|
|||
public class OAuth2DomainId extends UUIDBased { |
|||
|
|||
@JsonCreator |
|||
public OAuth2DomainId(@JsonProperty("id") UUID id) { |
|||
super(id); |
|||
} |
|||
|
|||
public static OAuth2DomainId fromString(String oauth2DomainId) { |
|||
return new OAuth2DomainId(UUID.fromString(oauth2DomainId)); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.id; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonCreator; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
|
|||
import java.util.UUID; |
|||
|
|||
public class OAuth2MobileId extends UUIDBased { |
|||
|
|||
@JsonCreator |
|||
public OAuth2MobileId(@JsonProperty("id") UUID id) { |
|||
super(id); |
|||
} |
|||
|
|||
public static OAuth2MobileId fromString(String oauth2MobileId) { |
|||
return new OAuth2MobileId(UUID.fromString(oauth2MobileId)); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.id; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonCreator; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
|
|||
import java.util.UUID; |
|||
|
|||
public class OAuth2ParamsId extends UUIDBased { |
|||
|
|||
@JsonCreator |
|||
public OAuth2ParamsId(@JsonProperty("id") UUID id) { |
|||
super(id); |
|||
} |
|||
|
|||
public static OAuth2ParamsId fromString(String oauth2ParamsId) { |
|||
return new OAuth2ParamsId(UUID.fromString(oauth2ParamsId)); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.id; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonCreator; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
|
|||
import java.util.UUID; |
|||
|
|||
public class OAuth2RegistrationId extends UUIDBased { |
|||
|
|||
@JsonCreator |
|||
public OAuth2RegistrationId(@JsonProperty("id") UUID id) { |
|||
super(id); |
|||
} |
|||
|
|||
public static OAuth2RegistrationId fromString(String oauth2RegistrationId) { |
|||
return new OAuth2RegistrationId(UUID.fromString(oauth2RegistrationId)); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2; |
|||
|
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.data.BaseData; |
|||
import org.thingsboard.server.common.data.id.OAuth2DomainId; |
|||
import org.thingsboard.server.common.data.id.OAuth2ParamsId; |
|||
|
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
@ToString |
|||
@NoArgsConstructor |
|||
public class OAuth2Domain extends BaseData<OAuth2DomainId> { |
|||
|
|||
private OAuth2ParamsId oauth2ParamsId; |
|||
private String domainName; |
|||
private SchemeType domainScheme; |
|||
|
|||
public OAuth2Domain(OAuth2Domain domain) { |
|||
super(domain); |
|||
this.oauth2ParamsId = domain.oauth2ParamsId; |
|||
this.domainName = domain.domainName; |
|||
this.domainScheme = domain.domainScheme; |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.ToString; |
|||
|
|||
@EqualsAndHashCode |
|||
@Data |
|||
@ToString |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@Builder |
|||
public class OAuth2DomainInfo { |
|||
private SchemeType scheme; |
|||
private String name; |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2; |
|||
|
|||
import lombok.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
@EqualsAndHashCode |
|||
@Data |
|||
@ToString |
|||
@Builder(toBuilder = true) |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class OAuth2Info { |
|||
private boolean enabled; |
|||
private List<OAuth2ParamsInfo> oauth2ParamsInfos; |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2; |
|||
|
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.data.BaseData; |
|||
import org.thingsboard.server.common.data.id.OAuth2MobileId; |
|||
import org.thingsboard.server.common.data.id.OAuth2ParamsId; |
|||
|
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
@ToString |
|||
@NoArgsConstructor |
|||
public class OAuth2Mobile extends BaseData<OAuth2MobileId> { |
|||
|
|||
private OAuth2ParamsId oauth2ParamsId; |
|||
private String pkgName; |
|||
private String callbackUrlScheme; |
|||
|
|||
public OAuth2Mobile(OAuth2Mobile mobile) { |
|||
super(mobile); |
|||
this.oauth2ParamsId = mobile.oauth2ParamsId; |
|||
this.pkgName = mobile.pkgName; |
|||
this.callbackUrlScheme = mobile.callbackUrlScheme; |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.ToString; |
|||
|
|||
@EqualsAndHashCode |
|||
@Data |
|||
@ToString |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@Builder |
|||
public class OAuth2MobileInfo { |
|||
private String pkgName; |
|||
private String callbackUrlScheme; |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2; |
|||
|
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.data.BaseData; |
|||
import org.thingsboard.server.common.data.id.OAuth2ParamsId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
|
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
@ToString |
|||
@NoArgsConstructor |
|||
public class OAuth2Params extends BaseData<OAuth2ParamsId> { |
|||
|
|||
private boolean enabled; |
|||
private TenantId tenantId; |
|||
|
|||
public OAuth2Params(OAuth2Params oauth2Params) { |
|||
super(oauth2Params); |
|||
this.enabled = oauth2Params.enabled; |
|||
this.tenantId = oauth2Params.tenantId; |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.ToString; |
|||
|
|||
import java.util.List; |
|||
|
|||
@EqualsAndHashCode |
|||
@Data |
|||
@ToString |
|||
@Builder(toBuilder = true) |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class OAuth2ParamsInfo { |
|||
|
|||
private List<OAuth2DomainInfo> domainInfos; |
|||
private List<OAuth2MobileInfo> mobileInfos; |
|||
private List<OAuth2RegistrationInfo> clientRegistrations; |
|||
|
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.data.HasName; |
|||
import org.thingsboard.server.common.data.SearchTextBasedWithAdditionalInfo; |
|||
import org.thingsboard.server.common.data.id.OAuth2ParamsId; |
|||
import org.thingsboard.server.common.data.id.OAuth2RegistrationId; |
|||
|
|||
import java.util.List; |
|||
|
|||
@EqualsAndHashCode(callSuper = true) |
|||
@Data |
|||
@ToString(exclude = {"clientSecret"}) |
|||
@NoArgsConstructor |
|||
public class OAuth2Registration extends SearchTextBasedWithAdditionalInfo<OAuth2RegistrationId> implements HasName { |
|||
|
|||
private OAuth2ParamsId oauth2ParamsId; |
|||
private OAuth2MapperConfig mapperConfig; |
|||
private String clientId; |
|||
private String clientSecret; |
|||
private String authorizationUri; |
|||
private String accessTokenUri; |
|||
private List<String> scope; |
|||
private String userInfoUri; |
|||
private String userNameAttributeName; |
|||
private String jwkSetUri; |
|||
private String clientAuthenticationMethod; |
|||
private String loginButtonLabel; |
|||
private String loginButtonIcon; |
|||
|
|||
public OAuth2Registration(OAuth2Registration registration) { |
|||
super(registration); |
|||
this.oauth2ParamsId = registration.oauth2ParamsId; |
|||
this.mapperConfig = registration.mapperConfig; |
|||
this.clientId = registration.clientId; |
|||
this.clientSecret = registration.clientSecret; |
|||
this.authorizationUri = registration.authorizationUri; |
|||
this.accessTokenUri = registration.accessTokenUri; |
|||
this.scope = registration.scope; |
|||
this.userInfoUri = registration.userInfoUri; |
|||
this.userNameAttributeName = registration.userNameAttributeName; |
|||
this.jwkSetUri = registration.jwkSetUri; |
|||
this.clientAuthenticationMethod = registration.clientAuthenticationMethod; |
|||
this.loginButtonLabel = registration.loginButtonLabel; |
|||
this.loginButtonIcon = registration.loginButtonIcon; |
|||
} |
|||
|
|||
@Override |
|||
@JsonProperty(access = JsonProperty.Access.READ_ONLY) |
|||
public String getName() { |
|||
return loginButtonLabel; |
|||
} |
|||
|
|||
@Override |
|||
public String getSearchText() { |
|||
return getName(); |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.data.oauth2.deprecated; |
|||
|
|||
import com.fasterxml.jackson.databind.JsonNode; |
|||
import lombok.*; |
|||
import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Deprecated |
|||
@EqualsAndHashCode |
|||
@Data |
|||
@ToString(exclude = {"clientSecret"}) |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@Builder |
|||
public class ClientRegistrationDto { |
|||
private OAuth2MapperConfig mapperConfig; |
|||
private String clientId; |
|||
private String clientSecret; |
|||
private String authorizationUri; |
|||
private String accessTokenUri; |
|||
private List<String> scope; |
|||
private String userInfoUri; |
|||
private String userNameAttributeName; |
|||
private String jwkSetUri; |
|||
private String clientAuthenticationMethod; |
|||
private String loginButtonLabel; |
|||
private String loginButtonIcon; |
|||
private JsonNode additionalInfo; |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue