response=JacksonUtil.newObjectNode().put("error","There was a Timeout and all retry attempts have been exhausted. Retry attempts set: "+maxRpcRetries);
}else{
@ -631,17 +654,18 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso
@ApiOperation(value="Get the Administration Settings object using key (getAdminSettings)",
notes="Get the Administration Settings object using specified string key. Referencing non-existing key will cause an error."+SYSTEM_AUTHORITY_PARAGRAPH)
@ -99,6 +135,7 @@ public class AdminController extends BaseController {
AdminSettingsadminSettings=checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID,key),"No Administration settings found for key: "+key);
@ -352,4 +408,84 @@ public class AdminController extends BaseController {
returnsystemInfoService.getFeaturesInfo();
}
@ApiOperation(value="Get OAuth2 log in processing URL (getMailProcessingUrl)",notes="Returns the URL enclosed in "+
"double quotes. After successful authentication with OAuth2 provider and user consent for requested scope, it makes a redirect to this path so that the platform can do "+
"further log in processing and generating access tokens. "+SYSTEM_AUTHORITY_PARAGRAPH)
AdminSettingsadminSettings=checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID,MAIL_SETTINGS_KEY),"No Administration mail settings found");
JsonNodejsonValue=adminSettings.getJsonValue();
StringclientId=checkNotNull(jsonValue.get("clientId"),"No clientId was configured").asText();
StringauthUri=checkNotNull(jsonValue.get("authUri"),"No authorization uri was configured").asText();
StringredirectUri=checkNotNull(jsonValue.get("redirectUri"),"No Redirect uri was configured").asText();
List<String>scope=JacksonUtil.convertValue(checkNotNull(jsonValue.get("scope"),"No scope was configured"),newTypeReference<>(){
AdminSettingsadminSettings=checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID,MAIL_SETTINGS_KEY),"No Administration mail settings found");
JsonNodejsonValue=adminSettings.getJsonValue();
StringclientId=checkNotNull(jsonValue.get("clientId"),"No clientId was configured").asText();
StringclientSecret=checkNotNull(jsonValue.get("clientSecret"),"No client secret was configured").asText();
StringclientRedirectUri=checkNotNull(jsonValue.get("redirectUri"),"No Redirect uri was configured").asText();
StringtokenUri=checkNotNull(jsonValue.get("tokenUri"),"No authorization uri was configured").asText();
@ -77,7 +77,7 @@ public class AlarmCommentController extends BaseController {
@PathVariable(ALARM_ID)StringstrAlarmId,@ApiParam(value="A JSON value representing the comment.")@RequestBodyAlarmCommentalarmComment)throwsThingsboardException{
protectedstaticfinalStringRESOURCE_TYPE="A string value representing the resource type.";
protectedstaticfinalStringLWM2M_OBJECT_DESCRIPTION="LwM2M Object is a object that includes information about the LwM2M model which can be used in transport configuration for the LwM2M device profile. ";
@ -204,42 +207,222 @@ public class ControllerConstants {
protectedstaticfinalStringIS_BOOTSTRAP_SERVER_PARAM_DESCRIPTION="A Boolean value representing the Server SecurityInfo for future Bootstrap client mode settings. Values: 'true' for Bootstrap Server; 'false' for Lwm2m Server. ";
protectedstaticfinalStringFILTER_VALUE_TYPE=NEW_LINE+"## Value Type and Operations"+NEW_LINE+
@ -251,7 +434,7 @@ public class ControllerConstants {
" * 'BOOLEAN' - used for boolean values. Operations: EQUAL, NOT_EQUAL;\n"+
" * 'DATE_TIME' - similar to numeric, transforms value to milliseconds since epoch. Operations: EQUAL, NOT_EQUAL, GREATER, LESS, GREATER_OR_EQUAL, LESS_OR_EQUAL; \n";
"- Credentials type: <b>\"X509\"</b> with <b>device profile ID</b> below: \n\n"+
"Note: <b>credentialsId</b> - format <b>Sha3Hash</b>, <b>certificateValue</b> - format <b>PEM</b> (with \"--BEGIN CERTIFICATE----\" and -\"----END CERTIFICATE-\").\n\n"+
"Use this method to update the device credentials. First use 'getDeviceCredentialsByDeviceId' to get the credentials id and value. "+
"Then use current method to update the credentials type and value. It is not possible to create multiple device credentials for the same device. "+
"The structure of device credentials id and value is simple for the 'ACCESS_TOKEN' but is much more complex for the 'MQTT_BASIC' or 'LWM2M_CREDENTIALS'."+TENANT_AUTHORITY_PARAGRAPH)
notes="During device creation, platform generates random 'ACCESS_TOKEN' credentials. \" +\n"+
"Use this method to update the device credentials. First use 'getDeviceCredentialsByDeviceId' to get the credentials id and value.\n"+
"Then use current method to update the credentials type and value. It is not possible to create multiple device credentials for the same device.\n"+
"The structure of device credentials id and value is simple for the 'ACCESS_TOKEN' but is much more complex for the 'MQTT_BASIC' or 'LWM2M_CREDENTIALS'.\n"+
"You may find the example of device with different type of credentials below: \n\n"+
"- Credentials type: <b>\"Access token\"</b> with <b>device ID</b> and with <b>device ID</b> below: \n\n"+
"- Credentials type: <b>\"X509\"</b> with <b>device profile ID</b> below: \n\n"+
"Note: <b>credentialsId</b> - format <b>Sha3Hash</b>, <b>certificateValue</b> - format <b>PEM</b> (with \"--BEGIN CERTIFICATE----\" and -\"----END CERTIFICATE-\").\n\n"+
privatestaticfinalStringMAIL_CONFIG_TEMPLATE_DEFINITION="Mail configuration template is set of default smtp settings for mail server that specific provider supports";
privatestaticfinalStringDOWNLOAD_RESOURCE_IF_NOT_CHANGED="Download Resource based on the provided Resource Id or return 304 status code if resource was not changed.";
privatefinalTbResourceServicetbResourceService;
publicstaticfinalStringRESOURCE_ID="resourceId";
@ -94,6 +104,47 @@ public class TbResourceController extends BaseController {
sessionMd.sendMsg("{\"subscriptionId\":"+subscriptionId+", \"errorCode\":"+ThingsboardErrorCode.TOO_MANY_UPDATES.getErrorCode()+", \"errorMsg\":\"Too many updates!\"}");
}
return;
}else{
log.debug("[{}][{}][{}] Session is no longer blacklisted.",sessionRef.getSecurityCtx().getTenantId(),sessionRef.getSecurityCtx().getId(),externalId);
sessionMd.sendMsg("{\"subscriptionId\":"+subscriptionId+", \"errorCode\":"+ThingsboardErrorCode.TOO_MANY_UPDATES.getErrorCode()+", \"errorMsg\":\"Too many updates!\"}");
}
return;
}else{
log.debug("[{}][{}][{}] Session is no longer blacklisted.",tenantId,sessionRef.getSecurityCtx().getId(),externalId);
blacklistedSessions.remove(externalId);
}
sessionMd.sendMsg(msg);
}else{
@ -464,7 +459,7 @@ public class TbWebSocketHandler extends TextWebSocketHandler implements WebSocke
mapper.writeValue(response.getWriter(),ThingsboardErrorResponse.of("Invalid username or password",ThingsboardErrorCode.AUTHENTICATION,HttpStatus.UNAUTHORIZED));
JacksonUtil.writeValue(response.getWriter(),ThingsboardErrorResponse.of("Invalid username or password",ThingsboardErrorCode.AUTHENTICATION,HttpStatus.UNAUTHORIZED));
mapper.writeValue(response.getWriter(),ThingsboardErrorResponse.of("User account is not active",ThingsboardErrorCode.AUTHENTICATION,HttpStatus.UNAUTHORIZED));
JacksonUtil.writeValue(response.getWriter(),ThingsboardErrorResponse.of("User account is not active",ThingsboardErrorCode.AUTHENTICATION,HttpStatus.UNAUTHORIZED));
mapper.writeValue(response.getWriter(),ThingsboardErrorResponse.of("User account is locked due to security policy",ThingsboardErrorCode.AUTHENTICATION,HttpStatus.UNAUTHORIZED));
JacksonUtil.writeValue(response.getWriter(),ThingsboardErrorResponse.of("User account is locked due to security policy",ThingsboardErrorCode.AUTHENTICATION,HttpStatus.UNAUTHORIZED));
mapper.writeValue(response.getWriter(),ThingsboardErrorResponse.of("Token has expired",ThingsboardErrorCode.JWT_TOKEN_EXPIRED,HttpStatus.UNAUTHORIZED));
JacksonUtil.writeValue(response.getWriter(),ThingsboardErrorResponse.of("Token has expired",ThingsboardErrorCode.JWT_TOKEN_EXPIRED,HttpStatus.UNAUTHORIZED));
log.error("RuleNode [{}] has version {} but does not implement TbVersionedNode interface! Any update procedures for this rule node will be skipped!",clazzName,annotation.version());