diff --git a/application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java b/application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java index b01ee4f6a6..50181c5771 100644 --- a/application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java +++ b/application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java @@ -229,10 +229,6 @@ public class ActorSystemContext { @Getter private JsInvokeService jsSandbox; - @Autowired - @Getter - private JsExecutorService jsExecutor; - @Autowired @Getter private MailExecutorService mailExecutor; diff --git a/application/src/main/java/org/thingsboard/server/actors/ruleChain/DefaultTbContext.java b/application/src/main/java/org/thingsboard/server/actors/ruleChain/DefaultTbContext.java index 7aee9030be..3a72ff4629 100644 --- a/application/src/main/java/org/thingsboard/server/actors/ruleChain/DefaultTbContext.java +++ b/application/src/main/java/org/thingsboard/server/actors/ruleChain/DefaultTbContext.java @@ -368,11 +368,6 @@ class DefaultTbContext implements TbContext { return nodeCtx.getTenantId(); } - @Override - public ListeningExecutor getJsExecutor() { - return mainCtx.getJsExecutor(); - } - @Override public ListeningExecutor getMailExecutor() { return mainCtx.getMailExecutor(); diff --git a/application/src/main/java/org/thingsboard/server/service/edge/rpc/fetch/AdminSettingsEdgeEventFetcher.java b/application/src/main/java/org/thingsboard/server/service/edge/rpc/fetch/AdminSettingsEdgeEventFetcher.java index 2675919c4a..ec9c65a4b2 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/rpc/fetch/AdminSettingsEdgeEventFetcher.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/rpc/fetch/AdminSettingsEdgeEventFetcher.java @@ -105,7 +105,7 @@ public class AdminSettingsEdgeEventFetcher implements EdgeEventFetcher { Template template = freemarkerConfig.getTemplate(templatesName); if (template != null) { String name = validateName(template.getName()); - Map mailTemplate = getMailTemplateFromFile(template.getRootTreeNode().toString()); + Map mailTemplate = getMailTemplateFromFile(template.toString()); if (mailTemplate != null) { mailTemplates.put(name, mailTemplate); } else { diff --git a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java index 11e0edfbe8..ebe727b6da 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java @@ -38,8 +38,6 @@ import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; import org.thingsboard.server.common.data.kv.ReadTsKvQuery; import org.thingsboard.server.common.data.kv.TsKvEntry; -import org.thingsboard.server.common.data.oauth2.OAuth2Info; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientsParams; import org.thingsboard.server.common.data.page.PageData; import org.thingsboard.server.common.data.page.PageLink; import org.thingsboard.server.common.data.page.TimePageLink; @@ -55,7 +53,6 @@ import org.thingsboard.server.dao.entity.EntityService; import org.thingsboard.server.dao.entityview.EntityViewService; import org.thingsboard.server.dao.model.sql.DeviceProfileEntity; import org.thingsboard.server.dao.oauth2.OAuth2Service; -import org.thingsboard.server.dao.oauth2.OAuth2Utils; import org.thingsboard.server.dao.rule.RuleChainService; import org.thingsboard.server.dao.sql.device.DeviceProfileRepository; import org.thingsboard.server.dao.tenant.TenantService; @@ -448,18 +445,7 @@ public class DefaultDataUpdateService implements DataUpdateService { } private void updateOAuth2Params() { - try { - OAuth2ClientsParams oauth2ClientsParams = oAuth2Service.findOAuth2Params(); - if (!oauth2ClientsParams.getDomainsParams().isEmpty()) { - log.info("Updating OAuth2 parameters ..."); - OAuth2Info oAuth2Info = OAuth2Utils.clientParamsToOAuth2Info(oauth2ClientsParams); - oAuth2Service.saveOAuth2Info(oAuth2Info); - oAuth2Service.saveOAuth2Params(new OAuth2ClientsParams(false, Collections.emptyList())); - log.info("Successfully updated OAuth2 parameters!"); - } - } catch (Exception e) { - log.error("Failed to update OAuth2 parameters", e); - } + log.warn("CAUTION: Update of Oauth2 parameters from 3.2.2 to 3.3.0 available only in ThingsBoard versions 3.3.0/3.3.1"); } } diff --git a/application/src/main/java/org/thingsboard/server/service/queue/processing/BatchTbRuleEngineSubmitStrategy.java b/application/src/main/java/org/thingsboard/server/service/queue/processing/BatchTbRuleEngineSubmitStrategy.java index dee3c26d6b..44f5228f00 100644 --- a/application/src/main/java/org/thingsboard/server/service/queue/processing/BatchTbRuleEngineSubmitStrategy.java +++ b/application/src/main/java/org/thingsboard/server/service/queue/processing/BatchTbRuleEngineSubmitStrategy.java @@ -72,7 +72,7 @@ public class BatchTbRuleEngineSubmitStrategy extends AbstractTbRuleEngineSubmitS synchronized (pendingPack) { pendingPack.clear(); for (int i = startIdx; i < endIdx; i++) { - IdMsgPair pair = orderedMsgList.get(i); + IdMsgPair pair = orderedMsgList.get(i); pendingPack.put(pair.uuid, pair.msg); } tmpPack = new LinkedHashMap<>(pendingPack); diff --git a/application/src/main/java/org/thingsboard/server/service/queue/processing/SequentialByEntityIdTbRuleEngineSubmitStrategy.java b/application/src/main/java/org/thingsboard/server/service/queue/processing/SequentialByEntityIdTbRuleEngineSubmitStrategy.java index 26c5825286..446e0dbe95 100644 --- a/application/src/main/java/org/thingsboard/server/service/queue/processing/SequentialByEntityIdTbRuleEngineSubmitStrategy.java +++ b/application/src/main/java/org/thingsboard/server/service/queue/processing/SequentialByEntityIdTbRuleEngineSubmitStrategy.java @@ -49,7 +49,7 @@ public abstract class SequentialByEntityIdTbRuleEngineSubmitStrategy extends Abs public void submitAttempt(BiConsumer> msgConsumer) { this.msgConsumer = msgConsumer; entityIdToListMap.forEach((entityId, queue) -> { - IdMsgPair msg = queue.peek(); + IdMsgPair msg = queue.peek(); if (msg != null) { msgConsumer.accept(msg.uuid, msg.msg); } @@ -68,9 +68,9 @@ public abstract class SequentialByEntityIdTbRuleEngineSubmitStrategy extends Abs if (entityId != null) { Queue> queue = entityIdToListMap.get(entityId); if (queue != null) { - IdMsgPair next = null; + IdMsgPair next = null; synchronized (queue) { - IdMsgPair expected = queue.peek(); + IdMsgPair expected = queue.peek(); if (expected != null && expected.uuid.equals(id)) { queue.poll(); next = queue.peek(); diff --git a/application/src/main/java/org/thingsboard/server/service/queue/processing/SequentialTbRuleEngineSubmitStrategy.java b/application/src/main/java/org/thingsboard/server/service/queue/processing/SequentialTbRuleEngineSubmitStrategy.java index dcbab1aff3..c4d5eaebf7 100644 --- a/application/src/main/java/org/thingsboard/server/service/queue/processing/SequentialTbRuleEngineSubmitStrategy.java +++ b/application/src/main/java/org/thingsboard/server/service/queue/processing/SequentialTbRuleEngineSubmitStrategy.java @@ -59,7 +59,7 @@ public class SequentialTbRuleEngineSubmitStrategy extends AbstractTbRuleEngineSu int listSize = orderedMsgList.size(); int idx = msgIdx.get(); if (idx < listSize) { - IdMsgPair pair = orderedMsgList.get(idx); + IdMsgPair pair = orderedMsgList.get(idx); expectedMsgId = pair.uuid; if (log.isDebugEnabled()) { log.debug("[{}] submitting [{}] message to rule engine", queueName, pair.msg); diff --git a/application/src/main/java/org/thingsboard/server/service/security/auth/oauth2/OAuth2ClientMapper.java b/application/src/main/java/org/thingsboard/server/service/security/auth/oauth2/OAuth2ClientMapper.java index 39957602d4..938e885fe6 100644 --- a/application/src/main/java/org/thingsboard/server/service/security/auth/oauth2/OAuth2ClientMapper.java +++ b/application/src/main/java/org/thingsboard/server/service/security/auth/oauth2/OAuth2ClientMapper.java @@ -17,7 +17,6 @@ package org.thingsboard.server.service.security.auth.oauth2; import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken; import org.thingsboard.server.common.data.oauth2.OAuth2Registration; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; import org.thingsboard.server.service.security.model.SecurityUser; import javax.servlet.http.HttpServletRequest; diff --git a/application/src/test/java/org/thingsboard/server/service/resource/sql/BaseTbResourceServiceTest.java b/application/src/test/java/org/thingsboard/server/service/resource/sql/BaseTbResourceServiceTest.java index b1d1745ac2..caf4431e7d 100644 --- a/application/src/test/java/org/thingsboard/server/service/resource/sql/BaseTbResourceServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/resource/sql/BaseTbResourceServiceTest.java @@ -117,6 +117,7 @@ public class BaseTbResourceServiceTest extends AbstractControllerTest { .andExpect(status().isOk()); } + @SuppressWarnings("deprecation") @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/application/src/test/java/org/thingsboard/server/transport/coap/telemetry/attributes/AbstractCoapAttributesIntegrationTest.java b/application/src/test/java/org/thingsboard/server/transport/coap/telemetry/attributes/AbstractCoapAttributesIntegrationTest.java index b71d448e7e..ccaf221c46 100644 --- a/application/src/test/java/org/thingsboard/server/transport/coap/telemetry/attributes/AbstractCoapAttributesIntegrationTest.java +++ b/application/src/test/java/org/thingsboard/server/transport/coap/telemetry/attributes/AbstractCoapAttributesIntegrationTest.java @@ -114,8 +114,8 @@ public abstract class AbstractCoapAttributesIntegrationTest extends AbstractCoap assertEquals(CoAP.ResponseCode.CREATED, coapResponse.getCode()); } - @SuppressWarnings("unchecked") - protected void assertAttributesValues(List> deviceValues, Set keySet) throws JsonProcessingException { + @SuppressWarnings({"unchecked", "rawtypes"}) + protected void assertAttributesValues(List> deviceValues, Set keySet) { for (Map map : deviceValues) { String key = (String) map.get("key"); Object value = map.get("value"); @@ -145,6 +145,7 @@ public abstract class AbstractCoapAttributesIntegrationTest extends AbstractCoap } } + @SuppressWarnings({"unchecked", "rawtypes"}) private void assertAttributesProtoValues(List> values, Set keySet) { for (Map map : values) { String key = (String) map.get("key"); diff --git a/application/src/test/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportServerHelperTest.java b/application/src/test/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportServerHelperTest.java index cefbd25940..15af28284e 100644 --- a/application/src/test/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportServerHelperTest.java +++ b/application/src/test/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportServerHelperTest.java @@ -29,6 +29,7 @@ import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.willReturn; import static org.mockito.Mockito.mock; @@ -71,7 +72,7 @@ class LwM2mTransportServerHelperTest { assertThat(helper.getTs(emptyList(), keyTsLatestMap)).isEqualTo(now); assertThat(helper.getTs(kvList, null)).isEqualTo(now); - verify(helper, never()).getTsByKey(anyString(), any(ConcurrentMap.class), anyLong()); + verify(helper, never()).getTsByKey(anyString(), anyMap(), anyLong()); verify(helper, times(5)).getCurrentTimeMillis(); } @@ -80,7 +81,7 @@ class LwM2mTransportServerHelperTest { assertThat(helper.getTs(kvList, keyTsLatestMap)).isEqualTo(now); verify(helper, times(1)).getTsByKey(kvList.get(0).getKey(), keyTsLatestMap, now); - verify(helper, times(1)).getTsByKey(anyString(), any(ConcurrentMap.class), anyLong()); + verify(helper, times(1)).getTsByKey(anyString(), anyMap(), anyLong()); } @Test @@ -126,4 +127,4 @@ class LwM2mTransportServerHelperTest { assertThat(helper.compareAndSwapOrIncrementTsAtomically(keyTsLatestMap.get(KEY_SW_STATE), now)).isEqualTo(nextHourTs + 1); } -} \ No newline at end of file +} diff --git a/application/src/test/java/org/thingsboard/server/transport/mqtt/telemetry/attributes/AbstractMqttAttributesIntegrationTest.java b/application/src/test/java/org/thingsboard/server/transport/mqtt/telemetry/attributes/AbstractMqttAttributesIntegrationTest.java index 2ad4377f5b..6a45ab5989 100644 --- a/application/src/test/java/org/thingsboard/server/transport/mqtt/telemetry/attributes/AbstractMqttAttributesIntegrationTest.java +++ b/application/src/test/java/org/thingsboard/server/transport/mqtt/telemetry/attributes/AbstractMqttAttributesIntegrationTest.java @@ -183,6 +183,7 @@ public abstract class AbstractMqttAttributesIntegrationTest extends AbstractMqtt } } + @SuppressWarnings({"unchecked", "rawtypes"}) private void assertAttributesProtoValues(List> values, Set keySet) { for (Map map : values) { String key = (String) map.get("key"); diff --git a/common/dao-api/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2Service.java b/common/dao-api/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2Service.java index 9764137cf2..20b73fc0ed 100644 --- a/common/dao-api/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2Service.java +++ b/common/dao-api/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2Service.java @@ -19,8 +19,6 @@ import org.thingsboard.server.common.data.oauth2.OAuth2ClientInfo; import org.thingsboard.server.common.data.oauth2.OAuth2Info; import org.thingsboard.server.common.data.oauth2.OAuth2Registration; import org.thingsboard.server.common.data.oauth2.PlatformType; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientsParams; import java.util.List; import java.util.UUID; @@ -28,12 +26,6 @@ import java.util.UUID; public interface OAuth2Service { List getOAuth2Clients(String domainScheme, String domainName, String pkgName, PlatformType platformType); - @Deprecated - void saveOAuth2Params(OAuth2ClientsParams oauth2Params); - - @Deprecated - OAuth2ClientsParams findOAuth2Params(); - void saveOAuth2Info(OAuth2Info oauth2Info); OAuth2Info findOAuth2Info(); diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/id/deprecated/OAuth2ClientRegistrationId.java b/common/data/src/main/java/org/thingsboard/server/common/data/id/deprecated/OAuth2ClientRegistrationId.java deleted file mode 100644 index 616fc3b29c..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/id/deprecated/OAuth2ClientRegistrationId.java +++ /dev/null @@ -1,35 +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.common.data.id.deprecated; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.thingsboard.server.common.data.id.UUIDBased; - -import java.util.UUID; - -@Deprecated -public class OAuth2ClientRegistrationId extends UUIDBased { - - @JsonCreator - public OAuth2ClientRegistrationId(@JsonProperty("id") UUID id) { - super(id); - } - - public static OAuth2ClientRegistrationId fromString(String clientRegistrationId) { - return new OAuth2ClientRegistrationId(UUID.fromString(clientRegistrationId)); - } -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/id/deprecated/OAuth2ClientRegistrationInfoId.java b/common/data/src/main/java/org/thingsboard/server/common/data/id/deprecated/OAuth2ClientRegistrationInfoId.java deleted file mode 100644 index 6ba959318c..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/id/deprecated/OAuth2ClientRegistrationInfoId.java +++ /dev/null @@ -1,35 +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.common.data.id.deprecated; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.thingsboard.server.common.data.id.UUIDBased; - -import java.util.UUID; - -@Deprecated -public class OAuth2ClientRegistrationInfoId extends UUIDBased { - - @JsonCreator - public OAuth2ClientRegistrationInfoId(@JsonProperty("id") UUID id) { - super(id); - } - - public static OAuth2ClientRegistrationInfoId fromString(String clientRegistrationInfoId) { - return new OAuth2ClientRegistrationInfoId(UUID.fromString(clientRegistrationInfoId)); - } -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/ClientRegistrationDto.java b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/ClientRegistrationDto.java deleted file mode 100644 index 4f491a2d8a..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/ClientRegistrationDto.java +++ /dev/null @@ -1,45 +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.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 scope; - private String userInfoUri; - private String userNameAttributeName; - private String jwkSetUri; - private String clientAuthenticationMethod; - private String loginButtonLabel; - private String loginButtonIcon; - private JsonNode additionalInfo; -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/DomainInfo.java b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/DomainInfo.java deleted file mode 100644 index 5078c4483f..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/DomainInfo.java +++ /dev/null @@ -1,31 +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.common.data.oauth2.deprecated; - -import lombok.*; -import org.thingsboard.server.common.data.oauth2.SchemeType; - -@Deprecated -@EqualsAndHashCode -@Data -@ToString -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class DomainInfo { - private SchemeType scheme; - private String name; -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/ExtendedOAuth2ClientRegistrationInfo.java b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/ExtendedOAuth2ClientRegistrationInfo.java deleted file mode 100644 index d071a6f1d4..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/ExtendedOAuth2ClientRegistrationInfo.java +++ /dev/null @@ -1,42 +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.common.data.oauth2.deprecated; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.thingsboard.server.common.data.oauth2.SchemeType; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; - -@Deprecated -@EqualsAndHashCode(callSuper = true) -@Data -public class ExtendedOAuth2ClientRegistrationInfo extends OAuth2ClientRegistrationInfo { - - private String domainName; - private SchemeType domainScheme; - - public ExtendedOAuth2ClientRegistrationInfo() { - super(); - } - - public ExtendedOAuth2ClientRegistrationInfo(OAuth2ClientRegistrationInfo oAuth2ClientRegistrationInfo, - SchemeType domainScheme, - String domainName) { - super(oAuth2ClientRegistrationInfo); - this.domainScheme = domainScheme; - this.domainName = domainName; - } -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientRegistration.java b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientRegistration.java deleted file mode 100644 index cfac2de329..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientRegistration.java +++ /dev/null @@ -1,44 +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.common.data.oauth2.deprecated; - -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.deprecated.OAuth2ClientRegistrationId; -import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationInfoId; -import org.thingsboard.server.common.data.oauth2.SchemeType; - -@Deprecated -@EqualsAndHashCode(callSuper = true) -@Data -@ToString -@NoArgsConstructor -public class OAuth2ClientRegistration extends BaseData { - - private OAuth2ClientRegistrationInfoId clientRegistrationId; - private String domainName; - private SchemeType domainScheme; - - public OAuth2ClientRegistration(OAuth2ClientRegistration clientRegistration) { - super(clientRegistration); - this.clientRegistrationId = clientRegistration.clientRegistrationId; - this.domainName = clientRegistration.domainName; - this.domainScheme = clientRegistration.domainScheme; - } -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientRegistrationInfo.java b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientRegistrationInfo.java deleted file mode 100644 index a99f56689b..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientRegistrationInfo.java +++ /dev/null @@ -1,78 +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.common.data.oauth2.deprecated; - -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.deprecated.OAuth2ClientRegistrationInfoId; -import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig; - -import java.util.List; - -@Deprecated -@EqualsAndHashCode(callSuper = true) -@Data -@ToString(exclude = {"clientSecret"}) -@NoArgsConstructor -public class OAuth2ClientRegistrationInfo extends SearchTextBasedWithAdditionalInfo implements HasName { - - private boolean enabled; - private OAuth2MapperConfig mapperConfig; - private String clientId; - private String clientSecret; - private String authorizationUri; - private String accessTokenUri; - private List scope; - private String userInfoUri; - private String userNameAttributeName; - private String jwkSetUri; - private String clientAuthenticationMethod; - private String loginButtonLabel; - private String loginButtonIcon; - - public OAuth2ClientRegistrationInfo(OAuth2ClientRegistrationInfo clientRegistration) { - super(clientRegistration); - this.enabled = clientRegistration.enabled; - this.mapperConfig = clientRegistration.mapperConfig; - this.clientId = clientRegistration.clientId; - this.clientSecret = clientRegistration.clientSecret; - this.authorizationUri = clientRegistration.authorizationUri; - this.accessTokenUri = clientRegistration.accessTokenUri; - this.scope = clientRegistration.scope; - this.userInfoUri = clientRegistration.userInfoUri; - this.userNameAttributeName = clientRegistration.userNameAttributeName; - this.jwkSetUri = clientRegistration.jwkSetUri; - this.clientAuthenticationMethod = clientRegistration.clientAuthenticationMethod; - this.loginButtonLabel = clientRegistration.loginButtonLabel; - this.loginButtonIcon = clientRegistration.loginButtonIcon; - } - - @Override - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - public String getName() { - return loginButtonLabel; - } - - @Override - public String getSearchText() { - return getName(); - } -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientsDomainParams.java b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientsDomainParams.java deleted file mode 100644 index ff17fe2819..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientsDomainParams.java +++ /dev/null @@ -1,32 +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.common.data.oauth2.deprecated; - -import lombok.*; - -import java.util.List; - -@Deprecated -@EqualsAndHashCode -@Data -@ToString -@Builder(toBuilder = true) -@NoArgsConstructor -@AllArgsConstructor -public class OAuth2ClientsDomainParams { - private List domainInfos; - private List clientRegistrations; -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientsParams.java b/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientsParams.java deleted file mode 100644 index 4f7735ef04..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/oauth2/deprecated/OAuth2ClientsParams.java +++ /dev/null @@ -1,32 +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.common.data.oauth2.deprecated; - -import lombok.*; - -import java.util.List; - -@Deprecated -@EqualsAndHashCode -@Data -@ToString -@Builder(toBuilder = true) -@NoArgsConstructor -@AllArgsConstructor -public class OAuth2ClientsParams { - private boolean enabled; - private List domainsParams; -} diff --git a/common/queue/src/test/java/org/thingsboard/server/queue/common/DefaultTbQueueRequestTemplateTest.java b/common/queue/src/test/java/org/thingsboard/server/queue/common/DefaultTbQueueRequestTemplateTest.java index 9979e9ac43..580245e3ab 100644 --- a/common/queue/src/test/java/org/thingsboard/server/queue/common/DefaultTbQueueRequestTemplateTest.java +++ b/common/queue/src/test/java/org/thingsboard/server/queue/common/DefaultTbQueueRequestTemplateTest.java @@ -75,12 +75,12 @@ public class DefaultTbQueueRequestTemplateTest { long maxPendingRequests = 32; long pollInterval = 5; - DefaultTbQueueRequestTemplate inst; + DefaultTbQueueRequestTemplate inst; @Before public void setUp() throws Exception { willReturn(topic).given(responseTemplate).getTopic(); - inst = spy(new DefaultTbQueueRequestTemplate( + inst = spy(new DefaultTbQueueRequestTemplate<>( queueAdmin, requestTemplate, responseTemplate, maxRequestTimeout, maxPendingRequests, pollInterval, executorMock)); @@ -170,6 +170,7 @@ public class DefaultTbQueueRequestTemplateTest { verify(inst, times((int) inst.maxPendingRequests)).sendToRequestTemplate(any(), any(), any(), any()); } + @SuppressWarnings("unchecked") @Test public void givenNothing_whenSendAndFetchAndProcessResponsesWithTimeout_thenFail() { //given @@ -208,4 +209,4 @@ public class DefaultTbQueueRequestTemplateTest { TbQueueMsg getRequestMsgMock() { return mock(TbQueueMsg.class, RETURNS_DEEP_STUBS); } -} \ No newline at end of file +} diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/secure/TbLwM2MDtlsCertificateVerifier.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/secure/TbLwM2MDtlsCertificateVerifier.java index 6710152c60..fe04410c17 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/secure/TbLwM2MDtlsCertificateVerifier.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/secure/TbLwM2MDtlsCertificateVerifier.java @@ -81,6 +81,7 @@ public class TbLwM2MDtlsCertificateVerifier implements NewAdvancedCertificateVer return Arrays.asList(CertificateType.X_509, CertificateType.RAW_PUBLIC_KEY); } + @SuppressWarnings("deprecation") @PostConstruct public void init() { try { diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportServerHelper.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportServerHelper.java index f91aea84f7..f3b35004f9 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportServerHelper.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportServerHelper.java @@ -38,7 +38,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ConcurrentMap; +import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import static org.thingsboard.server.gen.transport.TransportProtos.KeyValueType.BOOLEAN_V; @@ -62,7 +62,7 @@ public class LwM2mTransportServerHelper { sendParametersOnThingsboardTelemetry(kvList, sessionInfo, null); } - public void sendParametersOnThingsboardTelemetry(List kvList, SessionInfoProto sessionInfo, @Nullable ConcurrentMap keyTsLatestMap) { + public void sendParametersOnThingsboardTelemetry(List kvList, SessionInfoProto sessionInfo, @Nullable Map keyTsLatestMap) { TransportProtos.TsKvListProto tsKvList = toTsKvList(kvList, keyTsLatestMap); PostTelemetryMsg postTelemetryMsg = PostTelemetryMsg.newBuilder() @@ -72,14 +72,14 @@ public class LwM2mTransportServerHelper { context.getTransportService().process(sessionInfo, postTelemetryMsg, TransportServiceCallback.EMPTY); } - TransportProtos.TsKvListProto toTsKvList(List kvList, ConcurrentMap keyTsLatestMap) { + TransportProtos.TsKvListProto toTsKvList(List kvList, Map keyTsLatestMap) { return TransportProtos.TsKvListProto.newBuilder() .setTs(getTs(kvList, keyTsLatestMap)) .addAllKv(kvList) .build(); } - long getTs(List kvList, ConcurrentMap keyTsLatestMap) { + long getTs(List kvList, Map keyTsLatestMap) { if (keyTsLatestMap == null || kvList == null || kvList.isEmpty()) { return getCurrentTimeMillis(); } @@ -87,7 +87,7 @@ public class LwM2mTransportServerHelper { return getTsByKey(kvList.get(0).getKey(), keyTsLatestMap, getCurrentTimeMillis()); } - long getTsByKey(@Nonnull String key, @Nonnull ConcurrentMap keyTsLatestMap, final long tsNow) { + long getTsByKey(@Nonnull String key, @Nonnull Map keyTsLatestMap, final long tsNow) { AtomicLong tsLatestAtomic = keyTsLatestMap.putIfAbsent(key, new AtomicLong(tsNow)); if (tsLatestAtomic == null) { return tsNow; // it is a first known timestamp for this key. return as the latest diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java index 6fb5fd195e..c3451c0900 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.transport.lwm2m.server; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -31,6 +32,7 @@ import org.eclipse.leshan.core.request.SimpleDownlinkRequest; import org.eclipse.leshan.core.request.WriteAttributesRequest; import org.eclipse.leshan.core.util.Hex; import org.eclipse.leshan.server.registration.Registration; +import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.DeviceProfile; import org.thingsboard.server.common.data.DeviceTransportType; import org.thingsboard.server.common.data.device.data.lwm2m.BootstrapConfiguration; @@ -286,8 +288,7 @@ public class LwM2mTransportUtil { private static Attribute[] createWriteAttributes(Object params, DefaultLwM2MUplinkMsgHandler serviceImpl, String target) { List attributeLists = new ArrayList<>(); - ObjectMapper oMapper = new ObjectMapper(); - Map map = oMapper.convertValue(params, ConcurrentHashMap.class); + Map map = JacksonUtil.convertValue(params, new TypeReference<>() {}); map.forEach((k, v) -> { if (StringUtils.trimToNull(v.toString()) != null) { Object attrValue = convertWriteAttributes(k, v, serviceImpl, target); @@ -374,6 +375,7 @@ public class LwM2mTransportUtil { return lwm2mResourceValue; } + @SuppressWarnings("unchecked") public static Optional contentToString(Object content) { try { String value = null; diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/downlink/HasVersionedIds.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/downlink/HasVersionedIds.java index d0b920ca1c..5ccef5ecea 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/downlink/HasVersionedIds.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/downlink/HasVersionedIds.java @@ -25,11 +25,11 @@ public interface HasVersionedIds { String[] getVersionedIds(); default String[] getObjectIds() { - Set objectIds = ConcurrentHashMap.newKeySet(); + Set objectIds = ConcurrentHashMap.newKeySet(); for (String versionedId : getVersionedIds()) { objectIds.add(LwM2mTransportUtil.fromVersionedIdToObjectId(versionedId)); } - return (String[]) objectIds.toArray(String[]::new); + return objectIds.toArray(String[]::new); } } diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/rpc/DefaultLwM2MRpcRequestHandler.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/rpc/DefaultLwM2MRpcRequestHandler.java index 14d83d1db5..bdc5dcc819 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/rpc/DefaultLwM2MRpcRequestHandler.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/rpc/DefaultLwM2MRpcRequestHandler.java @@ -18,6 +18,8 @@ package org.thingsboard.server.transport.lwm2m.server.rpc; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.eclipse.leshan.core.ResponseCode; +import org.eclipse.leshan.core.request.ReadCompositeRequest; +import org.eclipse.leshan.core.response.ReadCompositeResponse; import org.springframework.stereotype.Service; import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.StringUtils; @@ -176,7 +178,7 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler { String[] versionedIds = getIdsFromParameters(client, requestMsg); TbLwM2MReadCompositeRequest request = TbLwM2MReadCompositeRequest.builder().versionedIds(versionedIds).timeout(clientContext.getRequestTimeout(client)).build(); var mainCallback = new TbLwM2MReadCompositeCallback(uplinkHandler, logService, client, versionedIds); - var rpcCallback = new RpcReadResponseCompositeCallback(transportService, client, requestMsg, mainCallback); + var rpcCallback = new RpcReadResponseCompositeCallback<>(transportService, client, requestMsg, mainCallback); downlinkHandler.sendReadCompositeRequest(client, request, rpcCallback); } @@ -292,14 +294,14 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler { private String[] getIdsFromParameters(LwM2mClient client, TransportProtos.ToDeviceRpcRequestMsg rpcRequst) { RpcReadCompositeRequest requestParams = JacksonUtil.fromString(rpcRequst.getParams(), RpcReadCompositeRequest.class); if (requestParams.getKeys() != null && requestParams.getKeys().length > 0) { - Set targetIds = ConcurrentHashMap.newKeySet(); + Set targetIds = ConcurrentHashMap.newKeySet(); for (String key : requestParams.getKeys()) { String targetId = clientContext.getObjectIdByKeyNameFromProfile(client, key); if (targetId != null) { targetIds.add(targetId); } } - return (String[]) targetIds.toArray(String[]::new); + return targetIds.toArray(String[]::new); } else if (requestParams.getIds() != null && requestParams.getIds().length > 0) { return requestParams.getIds(); } else { diff --git a/common/transport/snmp/src/test/java/org/thingsboard/server/transport/snmp/SnmpDeviceSimulatorV2.java b/common/transport/snmp/src/test/java/org/thingsboard/server/transport/snmp/SnmpDeviceSimulatorV2.java index c97f47d573..7bccee7365 100644 --- a/common/transport/snmp/src/test/java/org/thingsboard/server/transport/snmp/SnmpDeviceSimulatorV2.java +++ b/common/transport/snmp/src/test/java/org/thingsboard/server/transport/snmp/SnmpDeviceSimulatorV2.java @@ -57,6 +57,7 @@ import java.util.Scanner; import java.util.function.Consumer; import java.util.stream.Collectors; +@SuppressWarnings("deprecation") public class SnmpDeviceSimulatorV2 extends BaseAgent { public static class RequestProcessor extends CommandProcessor { @@ -167,6 +168,7 @@ public class SnmpDeviceSimulatorV2 extends BaseAgent { protected void addUsmUser(USM usm) { } + @SuppressWarnings({"unchecked"}) protected void initTransportMappings() { transportMappings = new TransportMapping[]{TransportMappings.getInstance().createTransportMapping(address)}; } diff --git a/common/transport/snmp/src/test/java/org/thingsboard/server/transport/snmp/SnmpDeviceSimulatorV3.java b/common/transport/snmp/src/test/java/org/thingsboard/server/transport/snmp/SnmpDeviceSimulatorV3.java index da7f984267..1c8d4983b2 100644 --- a/common/transport/snmp/src/test/java/org/thingsboard/server/transport/snmp/SnmpDeviceSimulatorV3.java +++ b/common/transport/snmp/src/test/java/org/thingsboard/server/transport/snmp/SnmpDeviceSimulatorV3.java @@ -86,6 +86,7 @@ import java.util.Map; * And don't remove snmp users * */ +@SuppressWarnings("deprecation") public class SnmpDeviceSimulatorV3 extends BaseAgent { protected String address; private Snmp4jHeartbeatMib heartbeatMIB; @@ -458,6 +459,7 @@ public class SnmpDeviceSimulatorV3 extends BaseAgent { this.usm = usm; } + @SuppressWarnings({"unchecked", "rawtypes"}) private static DefaultMOTable createStaticIfXTable() { MOTableSubIndex[] subIndexes = new MOTableSubIndex[] { new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER) }; @@ -573,6 +575,7 @@ public class SnmpDeviceSimulatorV3 extends BaseAgent { return ifXTable; } + @SuppressWarnings({"unchecked", "rawtypes"}) private static DefaultMOTable createStaticIfTable() { MOTableSubIndex[] subIndexes = new MOTableSubIndex[] { new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER) }; @@ -632,54 +635,7 @@ public class SnmpDeviceSimulatorV3 extends BaseAgent { ifTable.setVolatile(true); return ifTable; } - - private static DefaultMOTable createStaticSnmp4sTable() { - MOTableSubIndex[] subIndexes = - new MOTableSubIndex[] { new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER) }; - MOTableIndex indexDef = new MOTableIndex(subIndexes, false); - MOColumn[] columns = new MOColumn[8]; - int c = 0; - columns[c++] = new MOColumn(c, SMIConstants.SYNTAX_NULL, MOAccessImpl.ACCESS_READ_ONLY); // testNull - columns[c++] = new MOColumn(c, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY); // testBoolean - columns[c++] = new MOColumn(c, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY); // ifType - columns[c++] = new MOColumn(c, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY); // ifMtu - columns[c++] = new MOColumn(c, SMIConstants.SYNTAX_GAUGE32, MOAccessImpl.ACCESS_READ_ONLY); // ifSpeed - columns[c++] = new MOColumn(c, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY); //ifPhysAddress - columns[c++] = new MOMutableColumn(c, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_WRITE, - null); - // ifAdminStatus - columns[c++] = new MOColumn(c, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY); - // ifOperStatus - - DefaultMOTable ifTable = - new DefaultMOTable(new OID("1.3.6.1.4.1.50000.1.1"), indexDef, columns); - MOMutableTableModel model = (MOMutableTableModel) ifTable.getModel(); - Variable[] rowValues1 = new Variable[] { - new Integer32(1), - new OctetString("eth0"), - new Integer32(6), - new Integer32(1500), - new Gauge32(100000000), - new OctetString("00:00:00:00:01"), - new Integer32(1), - new Integer32(1) - }; - Variable[] rowValues2 = new Variable[] { - new Integer32(2), - new OctetString("loopback"), - new Integer32(24), - new Integer32(1500), - new Gauge32(10000000), - new OctetString("00:00:00:00:02"), - new Integer32(1), - new Integer32(1) - }; - model.addRow(new DefaultMOMutableRow2PC(new OID("1"), rowValues1)); - model.addRow(new DefaultMOMutableRow2PC(new OID("2"), rowValues2)); - ifTable.setVolatile(true); - return ifTable; - } - + @SuppressWarnings({"unchecked", "rawtypes"}) protected void initTransportMappings() throws IOException { transportMappings = new TransportMapping[2]; Address addr = GenericAddress.parse(address); @@ -715,10 +671,10 @@ public class SnmpDeviceSimulatorV3 extends BaseAgent { new Integer32(StorageType.nonVolatile), // storage type new Integer32(RowStatus.active) // row status }; - MOTableRow row = + SnmpCommunityMIB.SnmpCommunityEntryRow row = communityMIB.getSnmpCommunityEntry().createRow( new OctetString("public2public").toSubIndex(true), com2sec); - communityMIB.getSnmpCommunityEntry().addRow((SnmpCommunityMIB.SnmpCommunityEntryRow) row); + communityMIB.getSnmpCommunityEntry().addRow(row); // snmpCommunityMIB.setSourceAddressFiltering(true); } @@ -742,4 +698,4 @@ public class SnmpDeviceSimulatorV3 extends BaseAgent { this.initSnmpSession(); } -} \ No newline at end of file +} diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/AbstractOAuth2ClientRegistrationInfoEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/AbstractOAuth2ClientRegistrationInfoEntity.java deleted file mode 100644 index 616f128920..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/AbstractOAuth2ClientRegistrationInfoEntity.java +++ /dev/null @@ -1,234 +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.model.sql.deprecated; - -import com.fasterxml.jackson.databind.JsonNode; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.hibernate.annotations.Type; -import org.hibernate.annotations.TypeDef; -import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationInfoId; -import org.thingsboard.server.common.data.oauth2.*; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; -import org.thingsboard.server.dao.model.BaseSqlEntity; -import org.thingsboard.server.dao.model.ModelConstants; -import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationInfoEntity; -import org.thingsboard.server.dao.util.mapping.JsonStringType; - -import javax.persistence.*; -import java.util.Arrays; - -@Deprecated -@Data -@EqualsAndHashCode(callSuper = true) -@TypeDef(name = "json", typeClass = JsonStringType.class) -@MappedSuperclass -public abstract class AbstractOAuth2ClientRegistrationInfoEntity extends BaseSqlEntity { - - @Column(name = ModelConstants.OAUTH2_ENABLED_PROPERTY) - private Boolean enabled; - @Column(name = ModelConstants.OAUTH2_CLIENT_ID_PROPERTY) - private String clientId; - @Column(name = ModelConstants.OAUTH2_CLIENT_SECRET_PROPERTY) - private String clientSecret; - @Column(name = ModelConstants.OAUTH2_AUTHORIZATION_URI_PROPERTY) - private String authorizationUri; - @Column(name = ModelConstants.OAUTH2_TOKEN_URI_PROPERTY) - private String tokenUri; - @Column(name = ModelConstants.OAUTH2_SCOPE_PROPERTY) - private String scope; - @Column(name = ModelConstants.OAUTH2_USER_INFO_URI_PROPERTY) - private String userInfoUri; - @Column(name = ModelConstants.OAUTH2_USER_NAME_ATTRIBUTE_NAME_PROPERTY) - private String userNameAttributeName; - @Column(name = ModelConstants.OAUTH2_JWK_SET_URI_PROPERTY) - private String jwkSetUri; - @Column(name = ModelConstants.OAUTH2_CLIENT_AUTHENTICATION_METHOD_PROPERTY) - private String clientAuthenticationMethod; - @Column(name = ModelConstants.OAUTH2_LOGIN_BUTTON_LABEL_PROPERTY) - private String loginButtonLabel; - @Column(name = ModelConstants.OAUTH2_LOGIN_BUTTON_ICON_PROPERTY) - private String loginButtonIcon; - @Column(name = ModelConstants.OAUTH2_ALLOW_USER_CREATION_PROPERTY) - private Boolean allowUserCreation; - @Column(name = ModelConstants.OAUTH2_ACTIVATE_USER_PROPERTY) - private Boolean activateUser; - @Enumerated(EnumType.STRING) - @Column(name = ModelConstants.OAUTH2_MAPPER_TYPE_PROPERTY) - private MapperType type; - @Column(name = ModelConstants.OAUTH2_EMAIL_ATTRIBUTE_KEY_PROPERTY) - private String emailAttributeKey; - @Column(name = ModelConstants.OAUTH2_FIRST_NAME_ATTRIBUTE_KEY_PROPERTY) - private String firstNameAttributeKey; - @Column(name = ModelConstants.OAUTH2_LAST_NAME_ATTRIBUTE_KEY_PROPERTY) - private String lastNameAttributeKey; - @Enumerated(EnumType.STRING) - @Column(name = ModelConstants.OAUTH2_TENANT_NAME_STRATEGY_PROPERTY) - private TenantNameStrategyType tenantNameStrategy; - @Column(name = ModelConstants.OAUTH2_TENANT_NAME_PATTERN_PROPERTY) - private String tenantNamePattern; - @Column(name = ModelConstants.OAUTH2_CUSTOMER_NAME_PATTERN_PROPERTY) - private String customerNamePattern; - @Column(name = ModelConstants.OAUTH2_DEFAULT_DASHBOARD_NAME_PROPERTY) - private String defaultDashboardName; - @Column(name = ModelConstants.OAUTH2_ALWAYS_FULL_SCREEN_PROPERTY) - private Boolean alwaysFullScreen; - @Column(name = ModelConstants.OAUTH2_MAPPER_URL_PROPERTY) - private String url; - @Column(name = ModelConstants.OAUTH2_MAPPER_USERNAME_PROPERTY) - private String username; - @Column(name = ModelConstants.OAUTH2_MAPPER_PASSWORD_PROPERTY) - private String password; - @Column(name = ModelConstants.OAUTH2_MAPPER_SEND_TOKEN_PROPERTY) - private Boolean sendToken; - - @Type(type = "json") - @Column(name = ModelConstants.OAUTH2_ADDITIONAL_INFO_PROPERTY) - private JsonNode additionalInfo; - - public AbstractOAuth2ClientRegistrationInfoEntity() { - super(); - } - - public AbstractOAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfo clientRegistrationInfo) { - if (clientRegistrationInfo.getId() != null) { - this.setUuid(clientRegistrationInfo.getId().getId()); - } - this.createdTime = clientRegistrationInfo.getCreatedTime(); - this.enabled = clientRegistrationInfo.isEnabled(); - this.clientId = clientRegistrationInfo.getClientId(); - this.clientSecret = clientRegistrationInfo.getClientSecret(); - this.authorizationUri = clientRegistrationInfo.getAuthorizationUri(); - this.tokenUri = clientRegistrationInfo.getAccessTokenUri(); - this.scope = clientRegistrationInfo.getScope().stream().reduce((result, element) -> result + "," + element).orElse(""); - this.userInfoUri = clientRegistrationInfo.getUserInfoUri(); - this.userNameAttributeName = clientRegistrationInfo.getUserNameAttributeName(); - this.jwkSetUri = clientRegistrationInfo.getJwkSetUri(); - this.clientAuthenticationMethod = clientRegistrationInfo.getClientAuthenticationMethod(); - this.loginButtonLabel = clientRegistrationInfo.getLoginButtonLabel(); - this.loginButtonIcon = clientRegistrationInfo.getLoginButtonIcon(); - this.additionalInfo = clientRegistrationInfo.getAdditionalInfo(); - OAuth2MapperConfig mapperConfig = clientRegistrationInfo.getMapperConfig(); - if (mapperConfig != null) { - this.allowUserCreation = mapperConfig.isAllowUserCreation(); - this.activateUser = mapperConfig.isActivateUser(); - this.type = mapperConfig.getType(); - OAuth2BasicMapperConfig basicConfig = mapperConfig.getBasic(); - if (basicConfig != null) { - this.emailAttributeKey = basicConfig.getEmailAttributeKey(); - this.firstNameAttributeKey = basicConfig.getFirstNameAttributeKey(); - this.lastNameAttributeKey = basicConfig.getLastNameAttributeKey(); - this.tenantNameStrategy = basicConfig.getTenantNameStrategy(); - this.tenantNamePattern = basicConfig.getTenantNamePattern(); - this.customerNamePattern = basicConfig.getCustomerNamePattern(); - this.defaultDashboardName = basicConfig.getDefaultDashboardName(); - this.alwaysFullScreen = basicConfig.isAlwaysFullScreen(); - } - OAuth2CustomMapperConfig customConfig = mapperConfig.getCustom(); - if (customConfig != null) { - this.url = customConfig.getUrl(); - this.username = customConfig.getUsername(); - this.password = customConfig.getPassword(); - this.sendToken = customConfig.isSendToken(); - } - } - } - - public AbstractOAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfoEntity oAuth2ClientRegistrationInfoEntity) { - this.setId(oAuth2ClientRegistrationInfoEntity.getId()); - this.setCreatedTime(oAuth2ClientRegistrationInfoEntity.getCreatedTime()); - this.enabled = oAuth2ClientRegistrationInfoEntity.getEnabled(); - this.clientId = oAuth2ClientRegistrationInfoEntity.getClientId(); - this.clientSecret = oAuth2ClientRegistrationInfoEntity.getClientSecret(); - this.authorizationUri = oAuth2ClientRegistrationInfoEntity.getAuthorizationUri(); - this.tokenUri = oAuth2ClientRegistrationInfoEntity.getTokenUri(); - this.scope = oAuth2ClientRegistrationInfoEntity.getScope(); - this.userInfoUri = oAuth2ClientRegistrationInfoEntity.getUserInfoUri(); - this.userNameAttributeName = oAuth2ClientRegistrationInfoEntity.getUserNameAttributeName(); - this.jwkSetUri = oAuth2ClientRegistrationInfoEntity.getJwkSetUri(); - this.clientAuthenticationMethod = oAuth2ClientRegistrationInfoEntity.getClientAuthenticationMethod(); - this.loginButtonLabel = oAuth2ClientRegistrationInfoEntity.getLoginButtonLabel(); - this.loginButtonIcon = oAuth2ClientRegistrationInfoEntity.getLoginButtonIcon(); - this.additionalInfo = oAuth2ClientRegistrationInfoEntity.getAdditionalInfo(); - this.allowUserCreation = oAuth2ClientRegistrationInfoEntity.getAllowUserCreation(); - this.activateUser = oAuth2ClientRegistrationInfoEntity.getActivateUser(); - this.type = oAuth2ClientRegistrationInfoEntity.getType(); - this.emailAttributeKey = oAuth2ClientRegistrationInfoEntity.getEmailAttributeKey(); - this.firstNameAttributeKey = oAuth2ClientRegistrationInfoEntity.getFirstNameAttributeKey(); - this.lastNameAttributeKey = oAuth2ClientRegistrationInfoEntity.getLastNameAttributeKey(); - this.tenantNameStrategy = oAuth2ClientRegistrationInfoEntity.getTenantNameStrategy(); - this.tenantNamePattern = oAuth2ClientRegistrationInfoEntity.getTenantNamePattern(); - this.customerNamePattern = oAuth2ClientRegistrationInfoEntity.getCustomerNamePattern(); - this.defaultDashboardName = oAuth2ClientRegistrationInfoEntity.getDefaultDashboardName(); - this.alwaysFullScreen = oAuth2ClientRegistrationInfoEntity.getAlwaysFullScreen(); - this.url = oAuth2ClientRegistrationInfoEntity.getUrl(); - this.username = oAuth2ClientRegistrationInfoEntity.getUsername(); - this.password = oAuth2ClientRegistrationInfoEntity.getPassword(); - this.sendToken = oAuth2ClientRegistrationInfoEntity.getSendToken(); - } - - - protected OAuth2ClientRegistrationInfo toOAuth2ClientRegistrationInfo() { - OAuth2ClientRegistrationInfo clientRegistrationInfo = new OAuth2ClientRegistrationInfo(); - clientRegistrationInfo.setId(new OAuth2ClientRegistrationInfoId(id)); - clientRegistrationInfo.setEnabled(enabled); - clientRegistrationInfo.setCreatedTime(createdTime); - clientRegistrationInfo.setAdditionalInfo(additionalInfo); - clientRegistrationInfo.setMapperConfig( - OAuth2MapperConfig.builder() - .allowUserCreation(allowUserCreation) - .activateUser(activateUser) - .type(type) - .basic( - (type == MapperType.BASIC || type == MapperType.GITHUB) ? - OAuth2BasicMapperConfig.builder() - .emailAttributeKey(emailAttributeKey) - .firstNameAttributeKey(firstNameAttributeKey) - .lastNameAttributeKey(lastNameAttributeKey) - .tenantNameStrategy(tenantNameStrategy) - .tenantNamePattern(tenantNamePattern) - .customerNamePattern(customerNamePattern) - .defaultDashboardName(defaultDashboardName) - .alwaysFullScreen(alwaysFullScreen) - .build() - : null - ) - .custom( - type == MapperType.CUSTOM ? - OAuth2CustomMapperConfig.builder() - .url(url) - .username(username) - .password(password) - .sendToken(sendToken) - .build() - : null - ) - .build() - ); - clientRegistrationInfo.setClientId(clientId); - clientRegistrationInfo.setClientSecret(clientSecret); - clientRegistrationInfo.setAuthorizationUri(authorizationUri); - clientRegistrationInfo.setAccessTokenUri(tokenUri); - clientRegistrationInfo.setScope(Arrays.asList(scope.split(","))); - clientRegistrationInfo.setUserInfoUri(userInfoUri); - clientRegistrationInfo.setUserNameAttributeName(userNameAttributeName); - clientRegistrationInfo.setJwkSetUri(jwkSetUri); - clientRegistrationInfo.setClientAuthenticationMethod(clientAuthenticationMethod); - clientRegistrationInfo.setLoginButtonLabel(loginButtonLabel); - clientRegistrationInfo.setLoginButtonIcon(loginButtonIcon); - return clientRegistrationInfo; - } -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/ExtendedOAuth2ClientRegistrationInfoEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/ExtendedOAuth2ClientRegistrationInfoEntity.java deleted file mode 100644 index beb525e2e0..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/ExtendedOAuth2ClientRegistrationInfoEntity.java +++ /dev/null @@ -1,49 +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.model.sql.deprecated; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.thingsboard.server.common.data.oauth2.deprecated.ExtendedOAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.SchemeType; - -@Deprecated -@Data -@EqualsAndHashCode(callSuper = true) -public class ExtendedOAuth2ClientRegistrationInfoEntity extends AbstractOAuth2ClientRegistrationInfoEntity { - - private String domainName; - private SchemeType domainScheme; - - public ExtendedOAuth2ClientRegistrationInfoEntity() { - super(); - } - - public ExtendedOAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfoEntity oAuth2ClientRegistrationInfoEntity, - String domainName, - SchemeType domainScheme) { - super(oAuth2ClientRegistrationInfoEntity); - this.domainName = domainName; - this.domainScheme = domainScheme; - } - - @Override - public ExtendedOAuth2ClientRegistrationInfo toData() { - return new ExtendedOAuth2ClientRegistrationInfo(super.toOAuth2ClientRegistrationInfo(), - domainScheme, - domainName); - } -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/OAuth2ClientRegistrationEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/OAuth2ClientRegistrationEntity.java deleted file mode 100644 index 9de0b9daea..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/OAuth2ClientRegistrationEntity.java +++ /dev/null @@ -1,76 +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.model.sql.deprecated; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.hibernate.annotations.TypeDef; -import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationId; -import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationInfoId; -import org.thingsboard.server.common.data.oauth2.*; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistration; -import org.thingsboard.server.dao.model.BaseSqlEntity; -import org.thingsboard.server.dao.model.ModelConstants; -import org.thingsboard.server.dao.util.mapping.JsonStringType; - -import javax.persistence.*; -import java.util.UUID; - -@Deprecated -@Data -@EqualsAndHashCode(callSuper = true) -@Entity -@TypeDef(name = "json", typeClass = JsonStringType.class) -@Table(name = ModelConstants.OAUTH2_CLIENT_REGISTRATION_COLUMN_FAMILY_NAME) -public class OAuth2ClientRegistrationEntity extends BaseSqlEntity { - - @Column(name = ModelConstants.OAUTH2_CLIENT_REGISTRATION_INFO_ID_PROPERTY, columnDefinition = "uuid") - private UUID clientRegistrationInfoId; - - @Column(name = ModelConstants.OAUTH2_DOMAIN_NAME_PROPERTY) - private String domainName; - - @Enumerated(EnumType.STRING) - @Column(name = ModelConstants.OAUTH2_DOMAIN_SCHEME_PROPERTY) - private SchemeType domainScheme; - - public OAuth2ClientRegistrationEntity() { - super(); - } - - public OAuth2ClientRegistrationEntity(OAuth2ClientRegistration clientRegistration) { - if (clientRegistration.getId() != null) { - this.setUuid(clientRegistration.getId().getId()); - } - if (clientRegistration.getClientRegistrationId() != null){ - this.clientRegistrationInfoId = clientRegistration.getClientRegistrationId().getId(); - } - this.createdTime = clientRegistration.getCreatedTime(); - this.domainName = clientRegistration.getDomainName(); - this.domainScheme = clientRegistration.getDomainScheme(); - } - - @Override - public OAuth2ClientRegistration toData() { - OAuth2ClientRegistration clientRegistration = new OAuth2ClientRegistration(); - clientRegistration.setId(new OAuth2ClientRegistrationId(id)); - clientRegistration.setClientRegistrationId(new OAuth2ClientRegistrationInfoId(clientRegistrationInfoId)); - clientRegistration.setCreatedTime(createdTime); - clientRegistration.setDomainName(domainName); - clientRegistration.setDomainScheme(domainScheme); - return clientRegistration; - } -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/OAuth2ClientRegistrationInfoEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/OAuth2ClientRegistrationInfoEntity.java deleted file mode 100644 index fbb9ec3fca..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/deprecated/OAuth2ClientRegistrationInfoEntity.java +++ /dev/null @@ -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.model.sql.deprecated; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.hibernate.annotations.TypeDef; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; -import org.thingsboard.server.dao.model.ModelConstants; -import org.thingsboard.server.dao.util.mapping.JsonStringType; - -import javax.persistence.Entity; -import javax.persistence.Table; - -@Deprecated -@Data -@EqualsAndHashCode(callSuper = true) -@Entity -@TypeDef(name = "json", typeClass = JsonStringType.class) -@Table(name = ModelConstants.OAUTH2_CLIENT_REGISTRATION_INFO_COLUMN_FAMILY_NAME) -public class OAuth2ClientRegistrationInfoEntity extends AbstractOAuth2ClientRegistrationInfoEntity { - - public OAuth2ClientRegistrationInfoEntity() { - super(); - } - - public OAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfo clientRegistration) { - super(clientRegistration); - } - - public OAuth2ClientRegistrationInfoEntity(OAuth2ClientRegistrationInfoEntity oAuth2ClientRegistrationInfoEntity) { - super(oAuth2ClientRegistrationInfoEntity); - } - - @Override - public OAuth2ClientRegistrationInfo toData() { - return super.toOAuth2ClientRegistrationInfo(); - } -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2ServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2ServiceImpl.java index 6d7dde1f21..3cb0445d78 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2ServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2ServiceImpl.java @@ -38,18 +38,9 @@ import org.thingsboard.server.common.data.oauth2.OAuth2RegistrationInfo; import org.thingsboard.server.common.data.oauth2.PlatformType; import org.thingsboard.server.common.data.oauth2.SchemeType; import org.thingsboard.server.common.data.oauth2.TenantNameStrategyType; -import org.thingsboard.server.common.data.oauth2.deprecated.ClientRegistrationDto; -import org.thingsboard.server.common.data.oauth2.deprecated.DomainInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.ExtendedOAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistration; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientsDomainParams; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientsParams; import org.thingsboard.server.dao.entity.AbstractEntityService; import org.thingsboard.server.dao.exception.DataValidationException; import org.thingsboard.server.dao.exception.IncorrectParameterException; -import org.thingsboard.server.dao.oauth2.deprecated.OAuth2ClientRegistrationDao; -import org.thingsboard.server.dao.oauth2.deprecated.OAuth2ClientRegistrationInfoDao; import javax.transaction.Transactional; import java.util.ArrayList; @@ -71,10 +62,6 @@ public class OAuth2ServiceImpl extends AbstractEntityService implements OAuth2Se public static final String INCORRECT_DOMAIN_NAME = "Incorrect domainName "; public static final String INCORRECT_DOMAIN_SCHEME = "Incorrect domainScheme "; - @Autowired - private OAuth2ClientRegistrationInfoDao clientRegistrationInfoDao; - @Autowired - private OAuth2ClientRegistrationDao clientRegistrationDao; @Autowired private OAuth2ParamsDao oauth2ParamsDao; @Autowired @@ -104,27 +91,6 @@ public class OAuth2ServiceImpl extends AbstractEntityService implements OAuth2Se .collect(Collectors.toList()); } - @Deprecated - @Override - @Transactional - public void saveOAuth2Params(OAuth2ClientsParams oauth2Params) { - log.trace("Executing saveOAuth2Params [{}]", oauth2Params); - clientParamsValidator.accept(oauth2Params); - clientRegistrationDao.deleteAll(); - clientRegistrationInfoDao.deleteAll(); - oauth2Params.getDomainsParams().forEach(domainParams -> { - domainParams.getClientRegistrations().forEach(clientRegistrationDto -> { - OAuth2ClientRegistrationInfo oAuth2ClientRegistrationInfo = OAuth2Utils.toClientRegistrationInfo(oauth2Params.isEnabled(), clientRegistrationDto); - OAuth2ClientRegistrationInfo savedClientRegistrationInfo = clientRegistrationInfoDao.save(TenantId.SYS_TENANT_ID, oAuth2ClientRegistrationInfo); - domainParams.getDomainInfos().forEach(domainInfo -> { - OAuth2ClientRegistration oAuth2ClientRegistration = OAuth2Utils.toClientRegistration(savedClientRegistrationInfo.getId(), - domainInfo.getScheme(), domainInfo.getName()); - clientRegistrationDao.save(TenantId.SYS_TENANT_ID, oAuth2ClientRegistration); - }); - }); - }); - } - @Override @Transactional public void saveOAuth2Info(OAuth2Info oauth2Info) { @@ -151,14 +117,6 @@ public class OAuth2ServiceImpl extends AbstractEntityService implements OAuth2Se }); } - @Deprecated - @Override - public OAuth2ClientsParams findOAuth2Params() { - log.trace("Executing findOAuth2Params"); - List extendedInfos = clientRegistrationInfoDao.findAllExtended(); - return OAuth2Utils.toOAuth2Params(extendedInfos); - } - @Override public OAuth2Info findOAuth2Info() { log.trace("Executing findOAuth2Info"); @@ -198,114 +156,6 @@ public class OAuth2ServiceImpl extends AbstractEntityService implements OAuth2Se return oauth2RegistrationDao.find(TenantId.SYS_TENANT_ID); } - private final Consumer clientParamsValidator = oauth2Params -> { - if (oauth2Params == null - || oauth2Params.getDomainsParams() == null) { - throw new DataValidationException("Domain params should be specified!"); - } - for (OAuth2ClientsDomainParams domainParams : oauth2Params.getDomainsParams()) { - if (domainParams.getDomainInfos() == null - || domainParams.getDomainInfos().isEmpty()) { - throw new DataValidationException("List of domain configuration should be specified!"); - } - for (DomainInfo domainInfo : domainParams.getDomainInfos()) { - if (StringUtils.isEmpty(domainInfo.getName())) { - throw new DataValidationException("Domain name should be specified!"); - } - if (domainInfo.getScheme() == null) { - throw new DataValidationException("Domain scheme should be specified!"); - } - } - domainParams.getDomainInfos().stream() - .collect(Collectors.groupingBy(DomainInfo::getName)) - .forEach((domainName, domainInfos) -> { - if (domainInfos.size() > 1 && domainInfos.stream().anyMatch(domainInfo -> domainInfo.getScheme() == SchemeType.MIXED)) { - throw new DataValidationException("MIXED scheme type shouldn't be combined with another scheme type!"); - } - }); - if (domainParams.getClientRegistrations() == null || domainParams.getClientRegistrations().isEmpty()) { - throw new DataValidationException("Client registrations should be specified!"); - } - for (ClientRegistrationDto clientRegistration : domainParams.getClientRegistrations()) { - if (StringUtils.isEmpty(clientRegistration.getClientId())) { - throw new DataValidationException("Client ID should be specified!"); - } - if (StringUtils.isEmpty(clientRegistration.getClientSecret())) { - throw new DataValidationException("Client secret should be specified!"); - } - if (StringUtils.isEmpty(clientRegistration.getAuthorizationUri())) { - throw new DataValidationException("Authorization uri should be specified!"); - } - if (StringUtils.isEmpty(clientRegistration.getAccessTokenUri())) { - throw new DataValidationException("Token uri should be specified!"); - } - if (StringUtils.isEmpty(clientRegistration.getScope())) { - throw new DataValidationException("Scope should be specified!"); - } - if (StringUtils.isEmpty(clientRegistration.getUserInfoUri())) { - throw new DataValidationException("User info uri should be specified!"); - } - if (StringUtils.isEmpty(clientRegistration.getUserNameAttributeName())) { - throw new DataValidationException("User name attribute name should be specified!"); - } - if (StringUtils.isEmpty(clientRegistration.getClientAuthenticationMethod())) { - throw new DataValidationException("Client authentication method should be specified!"); - } - if (StringUtils.isEmpty(clientRegistration.getLoginButtonLabel())) { - throw new DataValidationException("Login button label should be specified!"); - } - OAuth2MapperConfig mapperConfig = clientRegistration.getMapperConfig(); - if (mapperConfig == null) { - throw new DataValidationException("Mapper config should be specified!"); - } - if (mapperConfig.getType() == null) { - throw new DataValidationException("Mapper config type should be specified!"); - } - if (mapperConfig.getType() == MapperType.BASIC) { - OAuth2BasicMapperConfig basicConfig = mapperConfig.getBasic(); - if (basicConfig == null) { - throw new DataValidationException("Basic config should be specified!"); - } - if (StringUtils.isEmpty(basicConfig.getEmailAttributeKey())) { - throw new DataValidationException("Email attribute key should be specified!"); - } - if (basicConfig.getTenantNameStrategy() == null) { - throw new DataValidationException("Tenant name strategy should be specified!"); - } - if (basicConfig.getTenantNameStrategy() == TenantNameStrategyType.CUSTOM - && StringUtils.isEmpty(basicConfig.getTenantNamePattern())) { - throw new DataValidationException("Tenant name pattern should be specified!"); - } - } - if (mapperConfig.getType() == MapperType.GITHUB) { - OAuth2BasicMapperConfig basicConfig = mapperConfig.getBasic(); - if (basicConfig == null) { - throw new DataValidationException("Basic config should be specified!"); - } - if (!StringUtils.isEmpty(basicConfig.getEmailAttributeKey())) { - throw new DataValidationException("Email attribute key cannot be configured for GITHUB mapper type!"); - } - if (basicConfig.getTenantNameStrategy() == null) { - throw new DataValidationException("Tenant name strategy should be specified!"); - } - if (basicConfig.getTenantNameStrategy() == TenantNameStrategyType.CUSTOM - && StringUtils.isEmpty(basicConfig.getTenantNamePattern())) { - throw new DataValidationException("Tenant name pattern should be specified!"); - } - } - if (mapperConfig.getType() == MapperType.CUSTOM) { - OAuth2CustomMapperConfig customConfig = mapperConfig.getCustom(); - if (customConfig == null) { - throw new DataValidationException("Custom config should be specified!"); - } - if (StringUtils.isEmpty(customConfig.getUrl())) { - throw new DataValidationException("Custom mapper URL should be specified!"); - } - } - } - } - }; - private final Consumer oauth2InfoValidator = oauth2Info -> { if (oauth2Info == null || oauth2Info.getOauth2ParamsInfos() == null) { diff --git a/dao/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2Utils.java b/dao/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2Utils.java index c34875d014..ce7449a1b5 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2Utils.java +++ b/dao/src/main/java/org/thingsboard/server/dao/oauth2/OAuth2Utils.java @@ -18,15 +18,7 @@ package org.thingsboard.server.dao.oauth2; import org.thingsboard.server.common.data.BaseData; import org.thingsboard.server.common.data.id.OAuth2ParamsId; import org.thingsboard.server.common.data.id.TenantId; -import org.thingsboard.server.common.data.id.deprecated.OAuth2ClientRegistrationInfoId; import org.thingsboard.server.common.data.oauth2.*; -import org.thingsboard.server.common.data.oauth2.deprecated.ClientRegistrationDto; -import org.thingsboard.server.common.data.oauth2.deprecated.DomainInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.ExtendedOAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistration; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientsDomainParams; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientsParams; import java.util.*; import java.util.stream.Collectors; @@ -42,75 +34,6 @@ public class OAuth2Utils { return client; } - public static OAuth2ClientsParams toOAuth2Params(List extendedOAuth2ClientRegistrationInfos) { - Map> domainsByInfoId = new LinkedHashMap<>(); - Map infoById = new LinkedHashMap<>(); - for (ExtendedOAuth2ClientRegistrationInfo extendedClientRegistrationInfo : extendedOAuth2ClientRegistrationInfos) { - String domainName = extendedClientRegistrationInfo.getDomainName(); - SchemeType domainScheme = extendedClientRegistrationInfo.getDomainScheme(); - domainsByInfoId.computeIfAbsent(extendedClientRegistrationInfo.getId(), key -> new ArrayList<>()) - .add(new DomainInfo(domainScheme, domainName)); - infoById.put(extendedClientRegistrationInfo.getId(), extendedClientRegistrationInfo); - } - Map, OAuth2ClientsDomainParams> domainParamsMap = new LinkedHashMap<>(); - domainsByInfoId.forEach((clientRegistrationInfoId, domainInfos) -> { - domainParamsMap.computeIfAbsent(domainInfos, - key -> new OAuth2ClientsDomainParams(key, new ArrayList<>()) - ) - .getClientRegistrations() - .add(toClientRegistrationDto(infoById.get(clientRegistrationInfoId))); - }); - boolean enabled = extendedOAuth2ClientRegistrationInfos.stream() - .map(OAuth2ClientRegistrationInfo::isEnabled) - .findFirst().orElse(false); - return new OAuth2ClientsParams(enabled, new ArrayList<>(domainParamsMap.values())); - } - - public static ClientRegistrationDto toClientRegistrationDto(OAuth2ClientRegistrationInfo oAuth2ClientRegistrationInfo) { - return ClientRegistrationDto.builder() - .mapperConfig(oAuth2ClientRegistrationInfo.getMapperConfig()) - .clientId(oAuth2ClientRegistrationInfo.getClientId()) - .clientSecret(oAuth2ClientRegistrationInfo.getClientSecret()) - .authorizationUri(oAuth2ClientRegistrationInfo.getAuthorizationUri()) - .accessTokenUri(oAuth2ClientRegistrationInfo.getAccessTokenUri()) - .scope(oAuth2ClientRegistrationInfo.getScope()) - .userInfoUri(oAuth2ClientRegistrationInfo.getUserInfoUri()) - .userNameAttributeName(oAuth2ClientRegistrationInfo.getUserNameAttributeName()) - .jwkSetUri(oAuth2ClientRegistrationInfo.getJwkSetUri()) - .clientAuthenticationMethod(oAuth2ClientRegistrationInfo.getClientAuthenticationMethod()) - .loginButtonLabel(oAuth2ClientRegistrationInfo.getLoginButtonLabel()) - .loginButtonIcon(oAuth2ClientRegistrationInfo.getLoginButtonIcon()) - .additionalInfo(oAuth2ClientRegistrationInfo.getAdditionalInfo()) - .build(); - } - - public static OAuth2ClientRegistrationInfo toClientRegistrationInfo(boolean enabled, ClientRegistrationDto clientRegistrationDto) { - OAuth2ClientRegistrationInfo clientRegistrationInfo = new OAuth2ClientRegistrationInfo(); - clientRegistrationInfo.setEnabled(enabled); - clientRegistrationInfo.setMapperConfig(clientRegistrationDto.getMapperConfig()); - clientRegistrationInfo.setClientId(clientRegistrationDto.getClientId()); - clientRegistrationInfo.setClientSecret(clientRegistrationDto.getClientSecret()); - clientRegistrationInfo.setAuthorizationUri(clientRegistrationDto.getAuthorizationUri()); - clientRegistrationInfo.setAccessTokenUri(clientRegistrationDto.getAccessTokenUri()); - clientRegistrationInfo.setScope(clientRegistrationDto.getScope()); - clientRegistrationInfo.setUserInfoUri(clientRegistrationDto.getUserInfoUri()); - clientRegistrationInfo.setUserNameAttributeName(clientRegistrationDto.getUserNameAttributeName()); - clientRegistrationInfo.setJwkSetUri(clientRegistrationDto.getJwkSetUri()); - clientRegistrationInfo.setClientAuthenticationMethod(clientRegistrationDto.getClientAuthenticationMethod()); - clientRegistrationInfo.setLoginButtonLabel(clientRegistrationDto.getLoginButtonLabel()); - clientRegistrationInfo.setLoginButtonIcon(clientRegistrationDto.getLoginButtonIcon()); - clientRegistrationInfo.setAdditionalInfo(clientRegistrationDto.getAdditionalInfo()); - return clientRegistrationInfo; - } - - public static OAuth2ClientRegistration toClientRegistration(OAuth2ClientRegistrationInfoId clientRegistrationInfoId, SchemeType domainScheme, String domainName) { - OAuth2ClientRegistration clientRegistration = new OAuth2ClientRegistration(); - clientRegistration.setClientRegistrationId(clientRegistrationInfoId); - clientRegistration.setDomainName(domainName); - clientRegistration.setDomainScheme(domainScheme); - return clientRegistration; - } - public static OAuth2ParamsInfo toOAuth2ParamsInfo(List registrations, List domains, List mobiles) { OAuth2ParamsInfo oauth2ParamsInfo = new OAuth2ParamsInfo(); oauth2ParamsInfo.setClientRegistrations(registrations.stream().sorted(Comparator.comparing(BaseData::getUuidId)).map(OAuth2Utils::toOAuth2RegistrationInfo).collect(Collectors.toList())); @@ -194,46 +117,4 @@ public class OAuth2Utils { mobile.setAppSecret(mobileInfo.getAppSecret()); return mobile; } - - @Deprecated - public static OAuth2Info clientParamsToOAuth2Info(OAuth2ClientsParams clientsParams) { - OAuth2Info oauth2Info = new OAuth2Info(); - oauth2Info.setEnabled(clientsParams.isEnabled()); - oauth2Info.setOauth2ParamsInfos(clientsParams.getDomainsParams().stream().map(OAuth2Utils::clientsDomainParamsToOAuth2ParamsInfo).collect(Collectors.toList())); - return oauth2Info; - } - - private static OAuth2ParamsInfo clientsDomainParamsToOAuth2ParamsInfo(OAuth2ClientsDomainParams clientsDomainParams) { - OAuth2ParamsInfo oauth2ParamsInfo = new OAuth2ParamsInfo(); - oauth2ParamsInfo.setMobileInfos(Collections.emptyList()); - oauth2ParamsInfo.setClientRegistrations(clientsDomainParams.getClientRegistrations().stream().map(OAuth2Utils::clientRegistrationDtoToOAuth2RegistrationInfo).collect(Collectors.toList())); - oauth2ParamsInfo.setDomainInfos(clientsDomainParams.getDomainInfos().stream().map(OAuth2Utils::domainInfoToOAuth2DomainInfo).collect(Collectors.toList())); - return oauth2ParamsInfo; - } - - private static OAuth2RegistrationInfo clientRegistrationDtoToOAuth2RegistrationInfo(ClientRegistrationDto clientRegistrationDto) { - return OAuth2RegistrationInfo.builder() - .mapperConfig(clientRegistrationDto.getMapperConfig()) - .clientId(clientRegistrationDto.getClientId()) - .clientSecret(clientRegistrationDto.getClientSecret()) - .authorizationUri(clientRegistrationDto.getAuthorizationUri()) - .accessTokenUri(clientRegistrationDto.getAccessTokenUri()) - .scope(clientRegistrationDto.getScope()) - .userInfoUri(clientRegistrationDto.getUserInfoUri()) - .userNameAttributeName(clientRegistrationDto.getUserNameAttributeName()) - .jwkSetUri(clientRegistrationDto.getJwkSetUri()) - .clientAuthenticationMethod(clientRegistrationDto.getClientAuthenticationMethod()) - .loginButtonLabel(clientRegistrationDto.getLoginButtonLabel()) - .loginButtonIcon(clientRegistrationDto.getLoginButtonIcon()) - .additionalInfo(clientRegistrationDto.getAdditionalInfo()) - .platforms(Collections.emptyList()) - .build(); - } - - private static OAuth2DomainInfo domainInfoToOAuth2DomainInfo(DomainInfo domainInfo) { - return OAuth2DomainInfo.builder() - .name(domainInfo.getName()) - .scheme(domainInfo.getScheme()) - .build(); - } } diff --git a/dao/src/main/java/org/thingsboard/server/dao/oauth2/deprecated/OAuth2ClientRegistrationDao.java b/dao/src/main/java/org/thingsboard/server/dao/oauth2/deprecated/OAuth2ClientRegistrationDao.java deleted file mode 100644 index 63b2c46034..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/oauth2/deprecated/OAuth2ClientRegistrationDao.java +++ /dev/null @@ -1,24 +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.oauth2.deprecated; - -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistration; -import org.thingsboard.server.dao.Dao; - -@Deprecated -public interface OAuth2ClientRegistrationDao extends Dao { - void deleteAll(); -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/oauth2/deprecated/OAuth2ClientRegistrationInfoDao.java b/dao/src/main/java/org/thingsboard/server/dao/oauth2/deprecated/OAuth2ClientRegistrationInfoDao.java deleted file mode 100644 index 9f44335602..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/oauth2/deprecated/OAuth2ClientRegistrationInfoDao.java +++ /dev/null @@ -1,34 +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.oauth2.deprecated; - -import org.thingsboard.server.common.data.oauth2.deprecated.ExtendedOAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.SchemeType; -import org.thingsboard.server.dao.Dao; - -import java.util.List; - -@Deprecated -public interface OAuth2ClientRegistrationInfoDao extends Dao { - List findAll(); - - List findAllExtended(); - - List findByDomainSchemesAndDomainName(List domainSchemes, String domainName); - - void deleteAll(); -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/ota/BaseOtaPackageService.java b/dao/src/main/java/org/thingsboard/server/dao/ota/BaseOtaPackageService.java index 5b034f7d00..205b2c447b 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/ota/BaseOtaPackageService.java +++ b/dao/src/main/java/org/thingsboard/server/dao/ota/BaseOtaPackageService.java @@ -133,6 +133,7 @@ public class BaseOtaPackageService implements OtaPackageService { return getHashFunction(checksumAlgorithm).hashBytes(data.array()).toString(); } + @SuppressWarnings("deprecation") private HashFunction getHashFunction(ChecksumAlgorithm checksumAlgorithm) { switch (checksumAlgorithm) { case MD5: diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/JpaOAuth2ClientRegistrationDao.java b/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/JpaOAuth2ClientRegistrationDao.java deleted file mode 100644 index 8dfe92b18d..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/JpaOAuth2ClientRegistrationDao.java +++ /dev/null @@ -1,48 +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.sql.oauth2.deprecated; - -import lombok.RequiredArgsConstructor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Component; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistration; -import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationEntity; -import org.thingsboard.server.dao.oauth2.deprecated.OAuth2ClientRegistrationDao; -import org.thingsboard.server.dao.sql.JpaAbstractDao; - -import java.util.UUID; - -@Deprecated -@Component -@RequiredArgsConstructor -public class JpaOAuth2ClientRegistrationDao extends JpaAbstractDao implements OAuth2ClientRegistrationDao { - private final OAuth2ClientRegistrationRepository repository; - - @Override - protected Class getEntityClass() { - return OAuth2ClientRegistrationEntity.class; - } - - @Override - protected CrudRepository getCrudRepository() { - return repository; - } - - @Override - public void deleteAll() { - repository.deleteAll(); - } -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/JpaOAuth2ClientRegistrationInfoDao.java b/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/JpaOAuth2ClientRegistrationInfoDao.java deleted file mode 100644 index d37ca981f2..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/JpaOAuth2ClientRegistrationInfoDao.java +++ /dev/null @@ -1,77 +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.sql.oauth2.deprecated; - -import lombok.RequiredArgsConstructor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Component; -import org.thingsboard.server.common.data.oauth2.deprecated.ExtendedOAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.deprecated.OAuth2ClientRegistrationInfo; -import org.thingsboard.server.common.data.oauth2.SchemeType; -import org.thingsboard.server.dao.DaoUtil; -import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationInfoEntity; -import org.thingsboard.server.dao.oauth2.deprecated.OAuth2ClientRegistrationInfoDao; -import org.thingsboard.server.dao.sql.JpaAbstractDao; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; - -@Deprecated -@Component -@RequiredArgsConstructor -public class JpaOAuth2ClientRegistrationInfoDao extends JpaAbstractDao implements OAuth2ClientRegistrationInfoDao { - private final OAuth2ClientRegistrationInfoRepository repository; - - @Override - protected Class getEntityClass() { - return OAuth2ClientRegistrationInfoEntity.class; - } - - @Override - protected CrudRepository getCrudRepository() { - return repository; - } - - @Override - public List findAll() { - Iterable entities = repository.findAll(); - List result = new ArrayList<>(); - entities.forEach(entity -> { - result.add(DaoUtil.getData(entity)); - }); - return result; - } - - @Override - public List findAllExtended() { - return repository.findAllExtended().stream() - .map(DaoUtil::getData) - .collect(Collectors.toList()); - } - - @Override - public List findByDomainSchemesAndDomainName(List domainSchemes, String domainName) { - List entities = repository.findAllByDomainSchemesAndName(domainSchemes, domainName); - return entities.stream().map(DaoUtil::getData).collect(Collectors.toList()); - } - - @Override - public void deleteAll() { - repository.deleteAll(); - } -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/OAuth2ClientRegistrationInfoRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/OAuth2ClientRegistrationInfoRepository.java deleted file mode 100644 index 73a2ca9bba..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/OAuth2ClientRegistrationInfoRepository.java +++ /dev/null @@ -1,42 +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.sql.oauth2.deprecated; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.thingsboard.server.common.data.oauth2.SchemeType; -import org.thingsboard.server.dao.model.sql.deprecated.ExtendedOAuth2ClientRegistrationInfoEntity; -import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationInfoEntity; - -import java.util.List; -import java.util.UUID; - -@Deprecated -public interface OAuth2ClientRegistrationInfoRepository extends CrudRepository { - @Query("SELECT new OAuth2ClientRegistrationInfoEntity(cr_info) " + - "FROM OAuth2ClientRegistrationInfoEntity cr_info " + - "LEFT JOIN OAuth2ClientRegistrationEntity cr on cr_info.id = cr.clientRegistrationInfoId " + - "WHERE cr.domainName = :domainName " + - "AND cr.domainScheme IN (:domainSchemes)") - List findAllByDomainSchemesAndName(@Param("domainSchemes") List domainSchemes, - @Param("domainName") String domainName); - - @Query("SELECT new org.thingsboard.server.dao.model.sql.deprecated.ExtendedOAuth2ClientRegistrationInfoEntity(cr_info, cr.domainName, cr.domainScheme) " + - "FROM OAuth2ClientRegistrationInfoEntity cr_info " + - "LEFT JOIN OAuth2ClientRegistrationEntity cr on cr_info.id = cr.clientRegistrationInfoId ") - List findAllExtended(); -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/OAuth2ClientRegistrationRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/OAuth2ClientRegistrationRepository.java deleted file mode 100644 index 1f4e4783ab..0000000000 --- a/dao/src/main/java/org/thingsboard/server/dao/sql/oauth2/deprecated/OAuth2ClientRegistrationRepository.java +++ /dev/null @@ -1,25 +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.sql.oauth2.deprecated; - -import org.springframework.data.repository.CrudRepository; -import org.thingsboard.server.dao.model.sql.deprecated.OAuth2ClientRegistrationEntity; - -import java.util.UUID; - -@Deprecated -public interface OAuth2ClientRegistrationRepository extends CrudRepository { -} diff --git a/dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceServiceTest.java b/dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceServiceTest.java index f1f081ad2c..48b8b427e0 100644 --- a/dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceServiceTest.java +++ b/dao/src/test/java/org/thingsboard/server/dao/service/BaseDeviceServiceTest.java @@ -71,6 +71,7 @@ public abstract class BaseDeviceServiceTest extends AbstractServiceTest { tenantProfileService.deleteTenantProfiles(anotherTenantId); } + @SuppressWarnings("deprecation") @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/dao/src/test/java/org/thingsboard/server/dao/service/BaseOtaPackageServiceTest.java b/dao/src/test/java/org/thingsboard/server/dao/service/BaseOtaPackageServiceTest.java index 1bf71370ea..4f110c73e6 100644 --- a/dao/src/test/java/org/thingsboard/server/dao/service/BaseOtaPackageServiceTest.java +++ b/dao/src/test/java/org/thingsboard/server/dao/service/BaseOtaPackageServiceTest.java @@ -77,6 +77,7 @@ public abstract class BaseOtaPackageServiceTest extends AbstractServiceTest { deviceProfileId = savedDeviceProfile.getId(); } + @SuppressWarnings("deprecation") @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/packaging/java/build.gradle b/packaging/java/build.gradle index fcc937e53f..bd204028bb 100644 --- a/packaging/java/build.gradle +++ b/packaging/java/build.gradle @@ -17,7 +17,7 @@ import org.apache.tools.ant.filters.ReplaceTokens buildscript { ext { - osPackageVersion = "8.3.0" + osPackageVersion = "8.6.3" } repositories { jcenter() diff --git a/packaging/js/build.gradle b/packaging/js/build.gradle index 9042eb68b9..9d9d52eddf 100644 --- a/packaging/js/build.gradle +++ b/packaging/js/build.gradle @@ -17,7 +17,7 @@ import org.apache.tools.ant.filters.ReplaceTokens buildscript { ext { - osPackageVersion = "8.3.0" + osPackageVersion = "8.6.3" } repositories { jcenter() diff --git a/rule-engine/rule-engine-api/src/main/java/org/thingsboard/rule/engine/api/TbContext.java b/rule-engine/rule-engine-api/src/main/java/org/thingsboard/rule/engine/api/TbContext.java index cdb2ffe9a1..3474ee2c9d 100644 --- a/rule-engine/rule-engine-api/src/main/java/org/thingsboard/rule/engine/api/TbContext.java +++ b/rule-engine/rule-engine-api/src/main/java/org/thingsboard/rule/engine/api/TbContext.java @@ -217,12 +217,6 @@ public interface TbContext { EdgeEventService getEdgeEventService(); - /** - * Js script executors call are completely asynchronous - * */ - @Deprecated - ListeningExecutor getJsExecutor(); - ListeningExecutor getMailExecutor(); ListeningExecutor getSmsExecutor();