Skip to content

Commit

Permalink
💥 make DeviceKeystore classes concrete
Browse files Browse the repository at this point in the history
Signed-off-by: dseurotech <[email protected]>
  • Loading branch information
dseurotech committed Feb 10, 2025
1 parent 6ca575e commit 27aefd4
Show file tree
Hide file tree
Showing 45 changed files with 645 additions and 1,484 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
*******************************************************************************/
package org.eclipse.kapua.app.console.module.device.server;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.kapua.app.console.module.api.client.GwtKapuaException;
import org.eclipse.kapua.app.console.module.api.server.KapuaRemoteServiceServlet;
import org.eclipse.kapua.app.console.module.api.server.util.KapuaExceptionHandler;
import org.eclipse.kapua.app.console.module.api.setting.ConsoleSetting;
import org.eclipse.kapua.app.console.module.api.shared.model.GwtXSRFToken;
import org.eclipse.kapua.app.console.module.device.shared.model.management.keystore.GwtDeviceKeystore;
import org.eclipse.kapua.app.console.module.device.shared.model.management.keystore.GwtDeviceKeystoreCertificate;
Expand All @@ -26,7 +28,6 @@
import org.eclipse.kapua.commons.model.id.KapuaEid;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.service.device.management.keystore.DeviceKeystoreManagementFactory;
import org.eclipse.kapua.service.device.management.keystore.DeviceKeystoreManagementService;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystore;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreCSR;
Expand All @@ -38,22 +39,16 @@
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreKeypair;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystores;

import java.util.ArrayList;
import java.util.List;

/**
* The server side implementation of the Device RPC service.
*/
public class GwtDeviceKeystoreManagementServiceImpl extends KapuaRemoteServiceServlet implements GwtDeviceKeystoreManagementService {

private static final long serialVersionUID = -1391026997499175151L;

private static final ConsoleSetting CONSOLE_SETTING = ConsoleSetting.getInstance();

private static final KapuaLocator LOCATOR = KapuaLocator.getInstance();

private static final DeviceKeystoreManagementService DEVICE_KEYSTORE_MANAGEMENT_SERVICE = LOCATOR.getService(DeviceKeystoreManagementService.class);
private static final DeviceKeystoreManagementFactory DEVICE_KEYSTORE_MANAGEMENT_FACTORY = LOCATOR.getFactory(DeviceKeystoreManagementFactory.class);

@Override
public List<GwtDeviceKeystore> getKeystores(String scopeIdString, String deviceIdString) throws GwtKapuaException {
Expand Down Expand Up @@ -99,14 +94,13 @@ public List<GwtDeviceKeystoreItem> getKeystoreItems(String scopeIdString, String
}
}


@Override
public List<GwtDeviceKeystoreItem> getKeystoreItems(String scopeIdString, String deviceIdString, String keystoreId) throws GwtKapuaException {
try {
KapuaId scopeId = KapuaEid.parseCompactId(scopeIdString);
KapuaId deviceId = KapuaEid.parseCompactId(deviceIdString);

DeviceKeystoreItemQuery itemQuery = DEVICE_KEYSTORE_MANAGEMENT_FACTORY.newDeviceKeystoreItemQuery();
DeviceKeystoreItemQuery itemQuery = new DeviceKeystoreItemQuery();
itemQuery.setKeystoreId(keystoreId);

DeviceKeystoreItems deviceKeystores = DEVICE_KEYSTORE_MANAGEMENT_SERVICE.getKeystoreItems(scopeId, deviceId, itemQuery, null);
Expand Down Expand Up @@ -144,7 +138,7 @@ public void createKeystoreCertificateRaw(GwtXSRFToken xsrfToken, String scopeIdS
KapuaId scopeId = KapuaEid.parseCompactId(scopeIdString);
KapuaId deviceId = KapuaEid.parseCompactId(deviceIdString);

DeviceKeystoreCertificate deviceKeystoreCertificate = DEVICE_KEYSTORE_MANAGEMENT_FACTORY.newDeviceKeystoreCertificate();
DeviceKeystoreCertificate deviceKeystoreCertificate = new DeviceKeystoreCertificate();
deviceKeystoreCertificate.setKeystoreId(gwtKeystoreCertificate.getKeystoreId());
deviceKeystoreCertificate.setAlias(gwtKeystoreCertificate.getAlias());
deviceKeystoreCertificate.setCertificate(gwtKeystoreCertificate.getCertificate());
Expand All @@ -156,7 +150,8 @@ public void createKeystoreCertificateRaw(GwtXSRFToken xsrfToken, String scopeIdS
}

@Override
public void createKeystoreCertificateInfo(GwtXSRFToken xsrfToken, String scopeIdString, String deviceIdString, String keystoreId, String alias, String certificateInfoIdString) throws GwtKapuaException {
public void createKeystoreCertificateInfo(GwtXSRFToken xsrfToken, String scopeIdString, String deviceIdString, String keystoreId, String alias, String certificateInfoIdString)
throws GwtKapuaException {
try {
checkXSRFToken(xsrfToken);

Expand All @@ -178,7 +173,7 @@ public void createKeystoreKeypair(GwtXSRFToken xsrfToken, String scopeIdString,
KapuaId scopeId = KapuaEid.parseCompactId(scopeIdString);
KapuaId deviceId = KapuaEid.parseCompactId(deviceIdString);

DeviceKeystoreKeypair deviceKeystoreKeypair = DEVICE_KEYSTORE_MANAGEMENT_FACTORY.newDeviceKeystoreKeypair();
DeviceKeystoreKeypair deviceKeystoreKeypair = new DeviceKeystoreKeypair();
deviceKeystoreKeypair.setKeystoreId(gwtKeystoreKeypair.getKeystoreId());
deviceKeystoreKeypair.setAlias(gwtKeystoreKeypair.getAlias());
deviceKeystoreKeypair.setAlgorithm(gwtKeystoreKeypair.getAlgorithm());
Expand All @@ -200,7 +195,7 @@ public GwtDeviceKeystoreCertificate createKeystoreCsr(GwtXSRFToken xsrfToken, St
KapuaId scopeId = KapuaEid.parseCompactId(scopeIdString);
KapuaId deviceId = KapuaEid.parseCompactId(deviceIdString);

DeviceKeystoreCSRInfo deviceKeystoreCsrInfo = DEVICE_KEYSTORE_MANAGEMENT_FACTORY.newDeviceKeystoreCSRInfo();
DeviceKeystoreCSRInfo deviceKeystoreCsrInfo = new DeviceKeystoreCSRInfo();
deviceKeystoreCsrInfo.setKeystoreId(gwtKeystoreCsr.getKeystoreId());
deviceKeystoreCsrInfo.setAlias(gwtKeystoreCsr.getAlias());
deviceKeystoreCsrInfo.setSignatureAlgorithm(gwtKeystoreCsr.getSignatureAlgorithm());
Expand All @@ -219,7 +214,6 @@ public GwtDeviceKeystoreCertificate createKeystoreCsr(GwtXSRFToken xsrfToken, St
}
}


@Override
public void deleteKeystoreItem(GwtXSRFToken xsrfToken, String scopeIdString, String deviceIdString, String keystoreId, String alias) throws GwtKapuaException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreItemQuery;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreItems;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreKeypair;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreXmlRegistry;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystores;
import org.eclipse.kapua.service.device.management.packages.model.DevicePackages;
import org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadRequest;
Expand Down Expand Up @@ -185,7 +184,6 @@ public JAXBContext getJAXBContext() throws KapuaException {
DeviceKeystoreKeypair.class,
DeviceKeystoreCSRInfo.class,
DeviceKeystoreCSR.class,
DeviceKeystoreXmlRegistry.class,

// Device Management Packages
DevicePackageDownloadRequest.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreItemQuery;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreItems;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreKeypair;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreXmlRegistry;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystores;
import org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadOptions;
import org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadRequest;
Expand Down Expand Up @@ -140,7 +139,6 @@ public JAXBContext getJAXBContext() throws KapuaException {
DeviceKeystoreKeypair.class,
DeviceKeystoreCSRInfo.class,
DeviceKeystoreCSR.class,
DeviceKeystoreXmlRegistry.class,

// Jobs
Job.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreItemQuery;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreItems;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreKeypair;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystoreXmlRegistry;
import org.eclipse.kapua.service.device.management.keystore.model.DeviceKeystores;
import org.eclipse.kapua.service.device.management.packages.model.DevicePackages;
import org.eclipse.kapua.service.device.management.packages.model.download.DevicePackageDownloadRequest;
Expand Down Expand Up @@ -194,7 +193,6 @@ public JAXBContext getJAXBContext() throws KapuaException {
DeviceKeystoreItemQuery.class,
DeviceKeystoreItems.class,
DeviceKeystoreKeypair.class,
DeviceKeystoreXmlRegistry.class,
DeviceKeystores.class,

KuraDeviceComponentConfiguration.class,
Expand Down
Loading

0 comments on commit 27aefd4

Please sign in to comment.