|
|
@ -15,19 +15,19 @@ |
|
|
*/ |
|
|
*/ |
|
|
package org.thingsboard.server.transport.lwm2m.security.sql; |
|
|
package org.thingsboard.server.transport.lwm2m.security.sql; |
|
|
|
|
|
|
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
import org.eclipse.leshan.client.object.Security; |
|
|
import org.eclipse.leshan.client.object.Security; |
|
|
import org.eclipse.leshan.core.util.Hex; |
|
|
import org.eclipse.leshan.core.util.Hex; |
|
|
import org.junit.Test; |
|
|
import org.junit.Test; |
|
|
import org.springframework.test.web.servlet.MvcResult; |
|
|
import org.springframework.test.web.servlet.MvcResult; |
|
|
import org.springframework.util.Base64Utils; |
|
|
|
|
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MDeviceCredentials; |
|
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MDeviceCredentials; |
|
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.X509ClientCredential; |
|
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.X509ClientCredential; |
|
|
import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration; |
|
|
import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration; |
|
|
import org.thingsboard.server.transport.lwm2m.security.AbstractSecurityLwM2MIntegrationTest; |
|
|
import org.thingsboard.server.transport.lwm2m.security.AbstractSecurityLwM2MIntegrationTest; |
|
|
|
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
|
|
import java.security.PrivateKey; |
|
|
import java.security.PrivateKey; |
|
|
import java.security.cert.X509Certificate; |
|
|
import java.security.cert.X509Certificate; |
|
|
|
|
|
import java.util.Base64; |
|
|
|
|
|
|
|
|
import static org.eclipse.leshan.client.object.Security.x509; |
|
|
import static org.eclipse.leshan.client.object.Security.x509; |
|
|
import static org.eclipse.leshan.client.object.Security.x509Bootstrap; |
|
|
import static org.eclipse.leshan.client.object.Security.x509Bootstrap; |
|
|
@ -48,7 +48,7 @@ public class X509_NoTrustLwM2MIntegrationTest extends AbstractSecurityLwM2MInteg |
|
|
PrivateKey privateKey = clientPrivateKeyFromCertTrustNo; |
|
|
PrivateKey privateKey = clientPrivateKeyFromCertTrustNo; |
|
|
X509ClientCredential clientCredentials = new X509ClientCredential(); |
|
|
X509ClientCredential clientCredentials = new X509ClientCredential(); |
|
|
clientCredentials.setEndpoint(clientEndpoint); |
|
|
clientCredentials.setEndpoint(clientEndpoint); |
|
|
clientCredentials.setCert(Base64Utils.encodeToString(certificate.getEncoded())); |
|
|
clientCredentials.setCert(Base64.getEncoder().encodeToString(certificate.getEncoded())); |
|
|
Security security = x509(SECURE_URI, |
|
|
Security security = x509(SECURE_URI, |
|
|
shortServerId, |
|
|
shortServerId, |
|
|
certificate.getEncoded(), |
|
|
certificate.getEncoded(), |
|
|
@ -93,7 +93,7 @@ public class X509_NoTrustLwM2MIntegrationTest extends AbstractSecurityLwM2MInteg |
|
|
PrivateKey privateKey = clientPrivateKeyFromCertTrustNo; |
|
|
PrivateKey privateKey = clientPrivateKeyFromCertTrustNo; |
|
|
X509ClientCredential clientCredentials = new X509ClientCredential(); |
|
|
X509ClientCredential clientCredentials = new X509ClientCredential(); |
|
|
clientCredentials.setEndpoint(clientEndpoint); |
|
|
clientCredentials.setEndpoint(clientEndpoint); |
|
|
clientCredentials.setCert(Base64Utils.encodeToString(certificate.getEncoded())); |
|
|
clientCredentials.setCert(Base64.getEncoder().encodeToString(certificate.getEncoded())); |
|
|
Lwm2mDeviceProfileTransportConfiguration transportConfiguration = getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsSecure(X509, NONE)); |
|
|
Lwm2mDeviceProfileTransportConfiguration transportConfiguration = getTransportConfiguration(OBSERVE_ATTRIBUTES_WITHOUT_PARAMS, getBootstrapServerCredentialsSecure(X509, NONE)); |
|
|
LwM2MDeviceCredentials deviceCredentials = getDeviceCredentialsSecure(clientCredentials, privateKey, certificate, X509, true); |
|
|
LwM2MDeviceCredentials deviceCredentials = getDeviceCredentialsSecure(clientCredentials, privateKey, certificate, X509, true); |
|
|
createDeviceProfile(transportConfiguration); |
|
|
createDeviceProfile(transportConfiguration); |
|
|
@ -111,7 +111,7 @@ public class X509_NoTrustLwM2MIntegrationTest extends AbstractSecurityLwM2MInteg |
|
|
PrivateKey privateKey = clientPrivateKeyFromCertTrustNo; |
|
|
PrivateKey privateKey = clientPrivateKeyFromCertTrustNo; |
|
|
X509ClientCredential clientCredentials = new X509ClientCredential(); |
|
|
X509ClientCredential clientCredentials = new X509ClientCredential(); |
|
|
clientCredentials.setEndpoint(clientEndpoint); |
|
|
clientCredentials.setEndpoint(clientEndpoint); |
|
|
clientCredentials.setCert(Base64Utils.encodeToString(certificate.getEncoded())); |
|
|
clientCredentials.setCert(Base64.getEncoder().encodeToString(certificate.getEncoded())); |
|
|
Security security = x509Bootstrap(SECURE_URI_BS, |
|
|
Security security = x509Bootstrap(SECURE_URI_BS, |
|
|
certificate.getEncoded(), |
|
|
certificate.getEncoded(), |
|
|
privateKey.getEncoded(), |
|
|
privateKey.getEncoded(), |
|
|
|