From 806491d9b53ec823a1c6a212128c0353fb900aad Mon Sep 17 00:00:00 2001 From: kaizimmerm Date: Tue, 16 May 2017 16:57:07 +0200 Subject: [PATCH] Rename DMF model classes to avoid name clashes with the repository. Signed-off-by: kaizimmerm --- .../simulator/DeviceSimulatorUpdater.java | 14 ++-- .../simulator/amqp/SpReceiverService.java | 6 +- .../simulator/amqp/SpSenderService.java | 28 ++++---- .../AmqpAuthenticationMessageHandler.java | 35 +++++----- .../amqp/AmqpControllerAuthentication.java | 8 +-- .../amqp/AmqpMessageDispatcherService.java | 35 +++++----- .../amqp/AmqpMessageHandlerService.java | 12 ++-- .../AmqpControllerAuthenticationTest.java | 44 ++++++------- .../AmqpMessageDispatcherServiceTest.java | 20 +++--- .../amqp/AmqpMessageHandlerServiceTest.java | 38 +++++------ .../hawkbit/amqp/BaseAmqpServiceTest.java | 20 +++--- ...ticationMessageHandlerIntegrationTest.java | 64 +++++++++---------- ...pMessageHandlerServiceIntegrationTest.java | 46 ++++++------- .../AmqpServiceIntegrationTest.java | 15 ++--- .../matcher/SoftwareModuleJsonMatcher.java | 12 ++-- ...ActionStatus.java => DmfActionStatus.java} | 2 +- ...Status.java => DmfActionUpdateStatus.java} | 10 +-- .../model/{Artifact.java => DmfArtifact.java} | 8 +-- ...ArtifactHash.java => DmfArtifactHash.java} | 4 +- ...uteUpdate.java => DmfAttributeUpdate.java} | 2 +- ....java => DmfDownloadAndUpdateRequest.java} | 8 +-- ...Response.java => DmfDownloadResponse.java} | 8 +-- ...wareModule.java => DmfSoftwareModule.java} | 8 +-- ...Token.java => DmfTenantSecurityToken.java} | 8 +-- ...actHttpControllerAuthenticationFilter.java | 16 ++--- ...bstractControllerAuthenticationFilter.java | 4 +- ...lerPreAuthenticateSecurityTokenFilter.java | 10 +-- ...llerPreAuthenticatedAnonymousDownload.java | 6 +- ...rollerPreAuthenticatedAnonymousFilter.java | 8 +-- ...thenticatedGatewaySecurityTokenFilter.java | 8 +-- ...rPreAuthenticatedSecurityHeaderFilter.java | 10 +-- .../security/PreAuthentificationFilter.java | 8 +-- ...AuthenticatedSecurityHeaderFilterTest.java | 20 +++--- 33 files changed, 271 insertions(+), 274 deletions(-) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{ActionStatus.java => DmfActionStatus.java} (97%) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{ActionUpdateStatus.java => DmfActionUpdateStatus.java} (88%) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{Artifact.java => DmfArtifact.java} (90%) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{ArtifactHash.java => DmfArtifactHash.java} (88%) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{AttributeUpdate.java => DmfAttributeUpdate.java} (96%) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{DownloadAndUpdateRequest.java => DmfDownloadAndUpdateRequest.java} (88%) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{DownloadResponse.java => DmfDownloadResponse.java} (90%) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{SoftwareModule.java => DmfSoftwareModule.java} (90%) rename hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/{TenantSecurityToken.java => DmfTenantSecurityToken.java} (96%) diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java index 6b865d4e3..1d3768e13 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulatorUpdater.java @@ -31,8 +31,8 @@ import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContextBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.eclipse.hawkbit.dmf.json.model.Artifact; -import org.eclipse.hawkbit.dmf.json.model.SoftwareModule; +import org.eclipse.hawkbit.dmf.json.model.DmfArtifact; +import org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule; import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Protocol; import org.eclipse.hawkbit.simulator.UpdateStatus.ResponseStatus; import org.eclipse.hawkbit.simulator.amqp.SpSenderService; @@ -94,7 +94,7 @@ public class DeviceSimulatorUpdater { * process has been finished */ public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion, - final List modules, final String targetSecurityToken, final UpdaterCallback callback) { + final List modules, final String targetSecurityToken, final UpdaterCallback callback) { AbstractSimulatedDevice device = repository.get(tenant, id); // plug and play - non existing device will be auto created @@ -109,7 +109,7 @@ public class DeviceSimulatorUpdater { device.setSwversion(swVersion); } else { device.setSwversion( - modules.stream().map(SoftwareModule::getModuleVersion).collect(Collectors.joining(", "))); + modules.stream().map(DmfSoftwareModule::getModuleVersion).collect(Collectors.joining(", "))); } device.setTargetSecurityToken(targetSecurityToken); eventbus.post(new InitUpdate(device)); @@ -134,11 +134,11 @@ public class DeviceSimulatorUpdater { private final EventBus eventbus; private final ScheduledExecutorService threadPool; private final UpdaterCallback callback; - private final List modules; + private final List modules; private DeviceSimulatorUpdateThread(final AbstractSimulatedDevice device, final SpSenderService spSenderService, final long actionId, final EventBus eventbus, final ScheduledExecutorService threadPool, - final UpdaterCallback callback, final List modules) { + final UpdaterCallback callback, final List modules) { this.device = device; this.spSenderService = spSenderService; this.actionId = actionId; @@ -204,7 +204,7 @@ public class DeviceSimulatorUpdater { } private static void handleArtifact(final String targetToken, final List status, - final Artifact artifact) { + final DmfArtifact artifact) { if (artifact.getUrls().containsKey("HTTPS")) { status.add(downloadUrl(artifact.getUrls().get("HTTPS"), targetToken, artifact.getHashes().getSha1(), diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java index 16316a442..f224013b3 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java @@ -13,7 +13,7 @@ import java.util.Map; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.DownloadAndUpdateRequest; +import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest; import org.eclipse.hawkbit.simulator.DeviceSimulatorRepository; import org.eclipse.hawkbit.simulator.DeviceSimulatorUpdater; import org.slf4j.Logger; @@ -141,8 +141,8 @@ public class SpReceiverService extends ReceiverService { final Map headers = messageProperties.getHeaders(); final String tenant = (String) headers.get(MessageHeaderKey.TENANT); - final DownloadAndUpdateRequest downloadAndUpdateRequest = convertMessage(message, - DownloadAndUpdateRequest.class); + final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = convertMessage(message, + DmfDownloadAndUpdateRequest.class); final Long actionId = downloadAndUpdateRequest.getActionId(); final String targetSecurityToken = downloadAndUpdateRequest.getTargetSecurityToken(); diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java index b242d8459..94806cf44 100644 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java @@ -16,9 +16,9 @@ import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.ActionStatus; -import org.eclipse.hawkbit.dmf.json.model.ActionUpdateStatus; -import org.eclipse.hawkbit.dmf.json.model.AttributeUpdate; +import org.eclipse.hawkbit.dmf.json.model.DmfActionStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfActionUpdateStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfAttributeUpdate; import org.eclipse.hawkbit.simulator.SimulationProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,7 +66,7 @@ public class SpSenderService extends SenderService { * a description according the update process */ public void finishUpdateProcess(final SimulatedUpdate update, final List updateResultMessages) { - final Message updateResultMessage = createUpdateResultMessage(update, ActionStatus.FINISHED, + final Message updateResultMessage = createUpdateResultMessage(update, DmfActionStatus.FINISHED, updateResultMessages); sendMessage(spExchange, updateResultMessage); } @@ -96,7 +96,7 @@ public class SpSenderService extends SenderService { * the ID of the action for the error message */ public void sendErrorMessage(final String tenant, final List updateResultMessages, final Long actionId) { - final Message message = createActionStatusMessage(tenant, ActionStatus.ERROR, updateResultMessages, actionId); + final Message message = createActionStatusMessage(tenant, DmfActionStatus.ERROR, updateResultMessages, actionId); sendMessage(spExchange, message); } @@ -109,7 +109,7 @@ public class SpSenderService extends SenderService { * a warning description */ public void sendWarningMessage(final SimulatedUpdate update, final List updateResultMessages) { - final Message message = createActionStatusMessage(update, updateResultMessages, ActionStatus.WARNING); + final Message message = createActionStatusMessage(update, updateResultMessages, DmfActionStatus.WARNING); sendMessage(spExchange, message); } @@ -125,7 +125,7 @@ public class SpSenderService extends SenderService { * @param actionId * the cached value */ - public void sendActionStatusMessage(final String tenant, final ActionStatus actionStatus, + public void sendActionStatusMessage(final String tenant, final DmfActionStatus actionStatus, final List updateResultMessages, final Long actionId) { final Message message = createActionStatusMessage(tenant, actionStatus, updateResultMessages, actionId); sendMessage(message); @@ -179,7 +179,7 @@ public class SpSenderService extends SenderService { messagePropertiesForSP.setHeader(MessageHeaderKey.THING_ID, targetId); messagePropertiesForSP.setContentType(MessageProperties.CONTENT_TYPE_JSON); messagePropertiesForSP.setReplyTo(amqpProperties.getSenderForSpExchange()); - final AttributeUpdate attributeUpdate = new AttributeUpdate(); + final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate(); attributeUpdate.getAttributes().putAll(simulationProperties.getAttributes().stream().collect( Collectors.toMap(SimulationProperties.Attribute::getKey, SimulationProperties.Attribute::getValue))); @@ -206,7 +206,7 @@ public class SpSenderService extends SenderService { * a list of descriptions according the update process */ private void sendErrorgMessage(final SimulatedUpdate update, final List updateResultMessages) { - final Message message = createActionStatusMessage(update, updateResultMessages, ActionStatus.ERROR); + final Message message = createActionStatusMessage(update, updateResultMessages, DmfActionStatus.ERROR); sendMessage(spExchange, message); } @@ -222,11 +222,11 @@ public class SpSenderService extends SenderService { * @param cacheValue * the cacheValue value */ - private Message createActionStatusMessage(final String tenant, final ActionStatus actionStatus, + private Message createActionStatusMessage(final String tenant, final DmfActionStatus actionStatus, final List updateResultMessages, final Long actionId) { final MessageProperties messageProperties = new MessageProperties(); final Map headers = messageProperties.getHeaders(); - final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus(actionId, actionStatus); + final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(actionId, actionStatus); headers.put(MessageHeaderKey.TYPE, MessageType.EVENT.name()); headers.put(MessageHeaderKey.TENANT, tenant); headers.put(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); @@ -236,11 +236,11 @@ public class SpSenderService extends SenderService { return convertMessage(actionUpdateStatus, messageProperties); } - private Message createUpdateResultMessage(final SimulatedUpdate cacheValue, final ActionStatus actionStatus, + private Message createUpdateResultMessage(final SimulatedUpdate cacheValue, final DmfActionStatus actionStatus, final List updateResultMessages) { final MessageProperties messageProperties = new MessageProperties(); final Map headers = messageProperties.getHeaders(); - final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus(cacheValue.getActionId(), actionStatus); + final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(cacheValue.getActionId(), actionStatus); headers.put(MessageHeaderKey.TYPE, MessageType.EVENT.name()); headers.put(MessageHeaderKey.TENANT, cacheValue.getTenant()); headers.put(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); @@ -250,7 +250,7 @@ public class SpSenderService extends SenderService { } private Message createActionStatusMessage(final SimulatedUpdate update, final List updateResultMessages, - final ActionStatus status) { + final DmfActionStatus status) { return createActionStatusMessage(update.getTenant(), status, updateResultMessages, update.getActionId()); } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpAuthenticationMessageHandler.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpAuthenticationMessageHandler.java index 3146b44cf..02e87f028 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpAuthenticationMessageHandler.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpAuthenticationMessageHandler.java @@ -18,14 +18,15 @@ import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; import org.eclipse.hawkbit.cache.DownloadArtifactCache; import org.eclipse.hawkbit.cache.DownloadIdCache; import org.eclipse.hawkbit.cache.DownloadType; -import org.eclipse.hawkbit.dmf.json.model.Artifact; -import org.eclipse.hawkbit.dmf.json.model.ArtifactHash; -import org.eclipse.hawkbit.dmf.json.model.DownloadResponse; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken.FileResource; +import org.eclipse.hawkbit.dmf.json.model.DmfArtifact; +import org.eclipse.hawkbit.dmf.json.model.DmfArtifactHash; +import org.eclipse.hawkbit.dmf.json.model.DmfDownloadResponse; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken.FileResource; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; +import org.eclipse.hawkbit.repository.model.Artifact; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.amqp.AmqpRejectAndDontRequeueException; @@ -120,7 +121,7 @@ public class AmqpAuthenticationMessageHandler extends BaseAmqpService { * of the artifact to verify if the given target is allowed to * download it */ - private void checkIfArtifactIsAssignedToTarget(final TenantSecurityToken secruityToken, final String sha1Hash) { + private void checkIfArtifactIsAssignedToTarget(final DmfTenantSecurityToken secruityToken, final String sha1Hash) { if (secruityToken.getControllerId() != null) { checkByControllerId(sha1Hash, secruityToken.getControllerId()); @@ -154,8 +155,7 @@ public class AmqpAuthenticationMessageHandler extends BaseAmqpService { LOG.info("download security check for target {} and artifact {} granted", controllerId, sha1Hash); } - private Optional findArtifactByFileResource( - final FileResource fileResource) { + private Optional findArtifactByFileResource(final FileResource fileResource) { if (fileResource == null) { return Optional.empty(); @@ -182,29 +182,28 @@ public class AmqpAuthenticationMessageHandler extends BaseAmqpService { return Optional.empty(); } - private static Artifact convertDbArtifact(final DbArtifact dbArtifact) { - final Artifact artifact = new Artifact(); + private static DmfArtifact convertDbArtifact(final DbArtifact dbArtifact) { + final DmfArtifact artifact = new DmfArtifact(); artifact.setSize(dbArtifact.getSize()); final DbArtifactHash dbArtifactHash = dbArtifact.getHashes(); - artifact.setHashes(new ArtifactHash(dbArtifactHash.getSha1(), dbArtifactHash.getMd5())); + artifact.setHashes(new DmfArtifactHash(dbArtifactHash.getSha1(), dbArtifactHash.getMd5())); return artifact; } private Message handleAuthenticationMessage(final Message message) { - final DownloadResponse authentificationResponse = new DownloadResponse(); - final TenantSecurityToken secruityToken = convertMessage(message, TenantSecurityToken.class); + final DmfDownloadResponse authentificationResponse = new DmfDownloadResponse(); + final DmfTenantSecurityToken secruityToken = convertMessage(message, DmfTenantSecurityToken.class); final FileResource fileResource = secruityToken.getFileResource(); try { SecurityContextHolder.getContext().setAuthentication(authenticationManager.doAuthenticate(secruityToken)); - final String sha1Hash = findArtifactByFileResource(fileResource) - .map(org.eclipse.hawkbit.repository.model.Artifact::getSha1Hash) - .orElseThrow(() -> new EntityNotFoundException()); + final String sha1Hash = findArtifactByFileResource(fileResource).map(Artifact::getSha1Hash) + .orElseThrow(EntityNotFoundException::new); checkIfArtifactIsAssignedToTarget(secruityToken, sha1Hash); - final Artifact artifact = convertDbArtifact(artifactManagement.loadArtifactBinary(sha1Hash).orElseThrow( - () -> new EntityNotFoundException(org.eclipse.hawkbit.repository.model.Artifact.class, sha1Hash))); + final DmfArtifact artifact = convertDbArtifact(artifactManagement.loadArtifactBinary(sha1Hash) + .orElseThrow(() -> new EntityNotFoundException(Artifact.class, sha1Hash))); authentificationResponse.setArtifact(artifact); final String downloadId = UUID.randomUUID().toString(); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentication.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentication.java index 55a11719c..581d0dea8 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentication.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentication.java @@ -12,7 +12,7 @@ import java.util.List; import javax.annotation.PostConstruct; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.SystemManagement; @@ -121,7 +121,7 @@ public class AmqpControllerAuthentication { * the authentication request object * @return the authentication object */ - public Authentication doAuthenticate(final TenantSecurityToken securityToken) { + public Authentication doAuthenticate(final DmfTenantSecurityToken securityToken) { resolveTenant(securityToken); PreAuthenticatedAuthenticationToken authentication = new PreAuthenticatedAuthenticationToken(null, null); for (final PreAuthentificationFilter filter : filterChain) { @@ -136,7 +136,7 @@ public class AmqpControllerAuthentication { } - private void resolveTenant(final TenantSecurityToken securityToken) { + private void resolveTenant(final DmfTenantSecurityToken securityToken) { if (securityToken.getTenant() == null) { securityToken.setTenant(systemSecurityContext .runAsSystem(() -> systemManagement.getTenantMetadata(securityToken.getTenantId()).getTenant())); @@ -145,7 +145,7 @@ public class AmqpControllerAuthentication { } private static PreAuthenticatedAuthenticationToken createAuthentication(final PreAuthentificationFilter filter, - final TenantSecurityToken secruityToken) { + final DmfTenantSecurityToken secruityToken) { if (!filter.isEnable(secruityToken)) { return null; diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java index b45e2c676..71dcfcd2c 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java @@ -22,15 +22,17 @@ import org.eclipse.hawkbit.api.URLPlaceholder.SoftwareData; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.Artifact; -import org.eclipse.hawkbit.dmf.json.model.ArtifactHash; -import org.eclipse.hawkbit.dmf.json.model.DownloadAndUpdateRequest; -import org.eclipse.hawkbit.dmf.json.model.SoftwareModule; +import org.eclipse.hawkbit.dmf.json.model.DmfArtifact; +import org.eclipse.hawkbit.dmf.json.model.DmfArtifactHash; +import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest; +import org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent; +import org.eclipse.hawkbit.repository.model.Artifact; +import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.util.IpUtil; @@ -117,21 +119,21 @@ public class AmqpMessageDispatcherService extends BaseAmqpService { } void sendUpdateMessageToTarget(final String tenant, final Target target, final Long actionId, - final Collection modules) { + final Collection modules) { final URI targetAdress = target.getAddress(); if (!IpUtil.isAmqpUri(targetAdress)) { return; } - final DownloadAndUpdateRequest downloadAndUpdateRequest = new DownloadAndUpdateRequest(); + final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = new DmfDownloadAndUpdateRequest(); downloadAndUpdateRequest.setActionId(actionId); final String targetSecurityToken = systemSecurityContext.runAsSystem(target::getSecurityToken); downloadAndUpdateRequest.setTargetSecurityToken(targetSecurityToken); - for (final org.eclipse.hawkbit.repository.model.SoftwareModule softwareModule : modules) { - final SoftwareModule amqpSoftwareModule = convertToAmqpSoftwareModule(target, softwareModule); + for (final SoftwareModule softwareModule : modules) { + final DmfSoftwareModule amqpSoftwareModule = convertToAmqpSoftwareModule(target, softwareModule); downloadAndUpdateRequest.addSoftwareModule(amqpSoftwareModule); } @@ -228,20 +230,18 @@ public class AmqpMessageDispatcherService extends BaseAmqpService { return messageProperties; } - private SoftwareModule convertToAmqpSoftwareModule(final Target target, - final org.eclipse.hawkbit.repository.model.SoftwareModule softwareModule) { - final SoftwareModule amqpSoftwareModule = new SoftwareModule(); + private DmfSoftwareModule convertToAmqpSoftwareModule(final Target target, final SoftwareModule softwareModule) { + final DmfSoftwareModule amqpSoftwareModule = new DmfSoftwareModule(); amqpSoftwareModule.setModuleId(softwareModule.getId()); amqpSoftwareModule.setModuleType(softwareModule.getType().getKey()); amqpSoftwareModule.setModuleVersion(softwareModule.getVersion()); - final List artifacts = convertArtifacts(target, softwareModule.getArtifacts()); + final List artifacts = convertArtifacts(target, softwareModule.getArtifacts()); amqpSoftwareModule.setArtifacts(artifacts); return amqpSoftwareModule; } - private List convertArtifacts(final Target target, - final List localArtifacts) { + private List convertArtifacts(final Target target, final List localArtifacts) { if (localArtifacts.isEmpty()) { return Collections.emptyList(); } @@ -250,9 +250,8 @@ public class AmqpMessageDispatcherService extends BaseAmqpService { .collect(Collectors.toList()); } - private Artifact convertArtifact(final Target target, - final org.eclipse.hawkbit.repository.model.Artifact localArtifact) { - final Artifact artifact = new Artifact(); + private DmfArtifact convertArtifact(final Target target, final Artifact localArtifact) { + final DmfArtifact artifact = new DmfArtifact(); artifact.setUrls(artifactUrlHandler .getUrls(new URLPlaceholder(systemManagement.getTenantMetadata().getTenant(), @@ -263,7 +262,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService { .stream().collect(Collectors.toMap(ArtifactUrl::getProtocol, ArtifactUrl::getRef))); artifact.setFilename(localArtifact.getFilename()); - artifact.setHashes(new ArtifactHash(localArtifact.getSha1Hash(), localArtifact.getMd5Hash())); + artifact.setHashes(new DmfArtifactHash(localArtifact.getSha1Hash(), localArtifact.getMd5Hash())); artifact.setSize(localArtifact.getSize()); return artifact; } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java index 18059642b..d5901f520 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java @@ -20,8 +20,8 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.ActionUpdateStatus; -import org.eclipse.hawkbit.dmf.json.model.AttributeUpdate; +import org.eclipse.hawkbit.dmf.json.model.DmfActionUpdateStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfAttributeUpdate; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails; import org.eclipse.hawkbit.repository.ControllerManagement; @@ -223,7 +223,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService { } private void updateAttributes(final Message message) { - final AttributeUpdate attributeUpdate = convertMessage(message, AttributeUpdate.class); + final DmfAttributeUpdate attributeUpdate = convertMessage(message, DmfAttributeUpdate.class); final String thingId = getStringHeaderKey(message, MessageHeaderKey.THING_ID, "ThingId is null"); controllerManagement.updateControllerAttributes(thingId, attributeUpdate.getAttributes()); @@ -236,7 +236,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService { * the object form the ampq message */ private void updateActionStatus(final Message message) { - final ActionUpdateStatus actionUpdateStatus = convertMessage(message, ActionUpdateStatus.class); + final DmfActionUpdateStatus actionUpdateStatus = convertMessage(message, DmfActionUpdateStatus.class); final Action action = checkActionExist(message, actionUpdateStatus); final List messages = actionUpdateStatus.getMessage(); @@ -256,7 +256,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService { } } - private Status mapStatus(final Message message, final ActionUpdateStatus actionUpdateStatus, final Action action) { + private Status mapStatus(final Message message, final DmfActionUpdateStatus actionUpdateStatus, final Action action) { Status status = null; switch (actionUpdateStatus.getActionStatus()) { case DOWNLOAD: @@ -314,7 +314,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService { // Exception squid:S3655 - logAndThrowMessageError throws exception, i.e. // get will not be called @SuppressWarnings("squid:S3655") - private Action checkActionExist(final Message message, final ActionUpdateStatus actionUpdateStatus) { + private Action checkActionExist(final Message message, final DmfActionUpdateStatus actionUpdateStatus) { final Long actionId = actionUpdateStatus.getActionId(); LOG.debug("Target notifies intermediate about action {} with status {}.", actionId, diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java index 71f620dba..f1c0abc82 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java @@ -25,9 +25,9 @@ import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; import org.eclipse.hawkbit.cache.DownloadIdCache; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.DownloadResponse; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken.FileResource; +import org.eclipse.hawkbit.dmf.json.model.DmfDownloadResponse; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken.FileResource; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.SystemManagement; @@ -181,7 +181,7 @@ public class AmqpControllerAuthenticationTest { @Test @Description("Tests authentication manager without principal") public void testAuthenticationeBadCredantialsWithoutPricipal() { - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1(SHA1)); try { authenticationManager.doAuthenticate(securityToken); @@ -195,12 +195,12 @@ public class AmqpControllerAuthenticationTest { @Test @Description("Tests authentication manager without wrong credential") public void testAuthenticationBadCredantialsWithWrongCredential() { - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1(SHA1)); when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class))) .thenReturn(CONFIG_VALUE_TRUE); - securityToken.putHeader(TenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken 12" + CONTROLLER_ID); + securityToken.putHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken 12" + CONTROLLER_ID); try { authenticationManager.doAuthenticate(securityToken); fail("BadCredentialsException was excepeted due to wrong credential"); @@ -213,12 +213,12 @@ public class AmqpControllerAuthenticationTest { @Test @Description("Tests authentication successfull") public void testSuccessfullAuthentication() { - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1(SHA1)); when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class))) .thenReturn(CONFIG_VALUE_TRUE); - securityToken.putHeader(TenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLER_ID); + securityToken.putHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLER_ID); final Authentication authentication = authenticationManager.doAuthenticate(securityToken); assertThat(authentication).isNotNull(); } @@ -228,7 +228,7 @@ public class AmqpControllerAuthenticationTest { public void testAuthenticationMessageBadCredantialsWithoutPricipal() { final MessageProperties messageProperties = createMessageProperties(null); - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1(SHA1)); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken, messageProperties); @@ -237,7 +237,7 @@ public class AmqpControllerAuthenticationTest { final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); // verify - final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); + final DmfDownloadResponse downloadResponse = (DmfDownloadResponse) messageConverter.fromMessage(onMessage); assertThat(downloadResponse).isNotNull(); assertThat(downloadResponse.getResponseCode()).isEqualTo(HttpStatus.FORBIDDEN.value()); } @@ -246,12 +246,12 @@ public class AmqpControllerAuthenticationTest { @Description("Tests authentication message without wrong credential") public void testAuthenticationMessageBadCredantialsWithWrongCredential() { final MessageProperties messageProperties = createMessageProperties(null); - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, TENANT_ID, CONTROLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1(SHA1)); when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class))) .thenReturn(CONFIG_VALUE_TRUE); - securityToken.putHeader(TenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken 12" + CONTROLLER_ID); + securityToken.putHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken 12" + CONTROLLER_ID); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken, messageProperties); @@ -259,7 +259,7 @@ public class AmqpControllerAuthenticationTest { final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); // verify - final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); + final DmfDownloadResponse downloadResponse = (DmfDownloadResponse) messageConverter.fromMessage(onMessage); assertThat(downloadResponse).isNotNull(); assertThat(downloadResponse.getResponseCode()).isEqualTo(HttpStatus.FORBIDDEN.value()); } @@ -268,12 +268,12 @@ public class AmqpControllerAuthenticationTest { @Description("Tests authentication message successfull") public void successfullMessageAuthentication() { final MessageProperties messageProperties = createMessageProperties(null); - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, null, CONTROLLER_ID, null, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, null, CONTROLLER_ID, null, FileResource.createFileResourceBySha1(SHA1)); when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class))) .thenReturn(CONFIG_VALUE_TRUE); - securityToken.putHeader(TenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLER_ID); + securityToken.putHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLER_ID); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken, messageProperties); @@ -281,7 +281,7 @@ public class AmqpControllerAuthenticationTest { final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); // verify - final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); + final DmfDownloadResponse downloadResponse = (DmfDownloadResponse) messageConverter.fromMessage(onMessage); assertThat(downloadResponse).isNotNull(); assertThat(downloadResponse.getDownloadUrl()).isNotNull(); assertThat(downloadResponse.getResponseCode()).isEqualTo(HttpStatus.OK.value()); @@ -296,12 +296,12 @@ public class AmqpControllerAuthenticationTest { @Description("Tests authentication message successfull with targetId intead of controllerId provided and artifactId instead of SHA1.") public void successfullMessageAuthenticationWithTargetIdAndArtifactId() { final MessageProperties messageProperties = createMessageProperties(null); - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, null, null, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, null, null, TARGET_ID, FileResource.createFileResourceByArtifactId(ARTIFACT_ID)); when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class))) .thenReturn(CONFIG_VALUE_TRUE); - securityToken.putHeader(TenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLER_ID); + securityToken.putHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLER_ID); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken, messageProperties); @@ -309,7 +309,7 @@ public class AmqpControllerAuthenticationTest { final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); // verify - final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); + final DmfDownloadResponse downloadResponse = (DmfDownloadResponse) messageConverter.fromMessage(onMessage); assertThat(downloadResponse).isNotNull(); assertThat(downloadResponse.getDownloadUrl()).isNotNull(); assertThat(downloadResponse.getResponseCode()).isEqualTo(HttpStatus.OK.value()); @@ -324,12 +324,12 @@ public class AmqpControllerAuthenticationTest { @Description("Tests authentication message successfull") public void successfullMessageAuthenticationWithTenantid() { final MessageProperties messageProperties = createMessageProperties(null); - final TenantSecurityToken securityToken = new TenantSecurityToken(null, TENANT_ID, CONTROLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(null, TENANT_ID, CONTROLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1(SHA1)); when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class))) .thenReturn(CONFIG_VALUE_TRUE); - securityToken.putHeader(TenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLER_ID); + securityToken.putHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLER_ID); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken, messageProperties); @@ -337,7 +337,7 @@ public class AmqpControllerAuthenticationTest { final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); // verify - final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); + final DmfDownloadResponse downloadResponse = (DmfDownloadResponse) messageConverter.fromMessage(onMessage); assertThat(downloadResponse).isNotNull(); assertThat(downloadResponse.getDownloadUrl()).isNotNull(); assertThat(downloadResponse.getResponseCode()).isEqualTo(HttpStatus.OK.value()); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index 0f140c169..8617115d4 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -29,7 +29,7 @@ import org.eclipse.hawkbit.artifact.repository.model.DbArtifact; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.DownloadAndUpdateRequest; +import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; @@ -119,7 +119,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); final Message sendMessage = getCaptureAdressEvent(targetAssignDistributionSetEvent); - final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, 1L); + final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, 1L); assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN); assertTrue("No softwaremmodule should be contained in the request", downloadAndUpdateRequest.getSoftwareModules().isEmpty()); @@ -147,11 +147,11 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { action, serviceMatcher.getServiceId()); amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); final Message sendMessage = getCaptureAdressEvent(targetAssignDistributionSetEvent); - final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, + final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, action.getId()); assertThat(createDistributionSet.getModules()).hasSameSizeAs(downloadAndUpdateRequest.getSoftwareModules()); assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN); - for (final org.eclipse.hawkbit.dmf.json.model.SoftwareModule softwareModule : downloadAndUpdateRequest + for (final org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule softwareModule : downloadAndUpdateRequest .getSoftwareModules()) { assertTrue("Artifact list for softwaremodule should be empty", softwareModule.getArtifacts().isEmpty()); for (final SoftwareModule softwareModule2 : action.getDistributionSet().getModules()) { @@ -189,14 +189,14 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { action, serviceMatcher.getServiceId()); amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); final Message sendMessage = getCaptureAdressEvent(targetAssignDistributionSetEvent); - final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, + final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, action.getId()); assertEquals("DownloadAndUpdateRequest event should contains 3 software modules", 3, downloadAndUpdateRequest.getSoftwareModules().size()); assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN); - for (final org.eclipse.hawkbit.dmf.json.model.SoftwareModule softwareModule : downloadAndUpdateRequest + for (final org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule softwareModule : downloadAndUpdateRequest .getSoftwareModules()) { if (!softwareModule.getModuleId().equals(module.getId())) { continue; @@ -204,7 +204,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { assertThat(softwareModule.getArtifacts().size()).isEqualTo(module.getArtifacts().size()).isGreaterThan(0); module.getArtifacts().forEach(dbArtifact -> { - final Optional found = softwareModule.getArtifacts() + final Optional found = softwareModule.getArtifacts() .stream().filter(dmfartifact -> dmfartifact.getFilename().equals(dbArtifact.getFilename())) .findAny(); @@ -296,10 +296,10 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { .isEqualTo(MessageType.THING_DELETED); } - private DownloadAndUpdateRequest assertDownloadAndInstallMessage(final Message sendMessage, final Long action) { + private DmfDownloadAndUpdateRequest assertDownloadAndInstallMessage(final Message sendMessage, final Long action) { assertEventMessage(sendMessage); - final DownloadAndUpdateRequest downloadAndUpdateRequest = convertMessage(sendMessage, - DownloadAndUpdateRequest.class); + final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = convertMessage(sendMessage, + DmfDownloadAndUpdateRequest.class); assertEquals(downloadAndUpdateRequest.getActionId(), action); assertEquals("The topic of the event shuold contain DOWNLOAD_AND_INSTALL", EventTopic.DOWNLOAD_AND_INSTALL, sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC)); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java index baa65567c..5b1f576ad 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java @@ -34,12 +34,12 @@ import org.eclipse.hawkbit.cache.DownloadIdCache; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.ActionStatus; -import org.eclipse.hawkbit.dmf.json.model.ActionUpdateStatus; -import org.eclipse.hawkbit.dmf.json.model.AttributeUpdate; -import org.eclipse.hawkbit.dmf.json.model.DownloadResponse; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken.FileResource; +import org.eclipse.hawkbit.dmf.json.model.DmfActionStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfActionUpdateStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfAttributeUpdate; +import org.eclipse.hawkbit.dmf.json.model.DmfDownloadResponse; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken.FileResource; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.EntityFactory; @@ -181,7 +181,7 @@ public class AmqpMessageHandlerServiceTest { final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.THING_ID, "1"); messageProperties.setHeader(MessageHeaderKey.TOPIC, "UPDATE_ATTRIBUTES"); - final AttributeUpdate attributeUpdate = new AttributeUpdate(); + final DmfAttributeUpdate attributeUpdate = new DmfAttributeUpdate(); attributeUpdate.getAttributes().put("testKey1", "testValue1"); attributeUpdate.getAttributes().put("testKey2", "testValue2"); @@ -279,7 +279,7 @@ public class AmqpMessageHandlerServiceTest { when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.empty()); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); - final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus(1L, ActionStatus.DOWNLOAD); + final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.DOWNLOAD); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(actionUpdateStatus, messageProperties); @@ -298,7 +298,7 @@ public class AmqpMessageHandlerServiceTest { messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.empty()); - final ActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(ActionStatus.DOWNLOAD); + final DmfActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(DmfActionStatus.DOWNLOAD); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(actionUpdateStatus, messageProperties); @@ -315,7 +315,7 @@ public class AmqpMessageHandlerServiceTest { @Description("Tests that an download request is denied for an artifact which does not exists") public void authenticationRequestDeniedForArtifactWhichDoesNotExists() { final MessageProperties messageProperties = createMessageProperties(null); - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, TENANT_ID, CONTROLLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, TENANT_ID, CONTROLLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1("12345")); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken, messageProperties); @@ -324,7 +324,7 @@ public class AmqpMessageHandlerServiceTest { final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); // verify - final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); + final DmfDownloadResponse downloadResponse = (DmfDownloadResponse) messageConverter.fromMessage(onMessage); assertThat(downloadResponse).as("Message body should not null").isNotNull(); assertThat(downloadResponse.getResponseCode()).as("Message body response code is wrong") .isEqualTo(HttpStatus.NOT_FOUND.value()); @@ -334,7 +334,7 @@ public class AmqpMessageHandlerServiceTest { @Description("Tests that an download request is denied for an artifact which is not assigned to the requested target") public void authenticationRequestDeniedForArtifactWhichIsNotAssignedToTarget() { final MessageProperties messageProperties = createMessageProperties(null); - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, TENANT_ID, CONTROLLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, TENANT_ID, CONTROLLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1("12345")); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken, messageProperties); @@ -348,7 +348,7 @@ public class AmqpMessageHandlerServiceTest { final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); // verify - final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); + final DmfDownloadResponse downloadResponse = (DmfDownloadResponse) messageConverter.fromMessage(onMessage); assertThat(downloadResponse).as("Message body should not null").isNotNull(); assertThat(downloadResponse.getResponseCode()).as("Message body response code is wrong") .isEqualTo(HttpStatus.NOT_FOUND.value()); @@ -358,7 +358,7 @@ public class AmqpMessageHandlerServiceTest { @Description("Tests that an download request is allowed for an artifact which exists and assigned to the requested target") public void authenticationRequestAllowedForArtifactWhichExistsAndAssignedToTarget() throws MalformedURLException { final MessageProperties messageProperties = createMessageProperties(null); - final TenantSecurityToken securityToken = new TenantSecurityToken(TENANT, TENANT_ID, CONTROLLLER_ID, TARGET_ID, + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken(TENANT, TENANT_ID, CONTROLLLER_ID, TARGET_ID, FileResource.createFileResourceBySha1("12345")); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken, messageProperties); @@ -381,7 +381,7 @@ public class AmqpMessageHandlerServiceTest { final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); // verify - final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); + final DmfDownloadResponse downloadResponse = (DmfDownloadResponse) messageConverter.fromMessage(onMessage); assertThat(downloadResponse).as("Message body should not null").isNotNull(); assertThat(downloadResponse.getResponseCode()).as("Message body response code is wrong") .isEqualTo(HttpStatus.OK.value()); @@ -410,7 +410,7 @@ public class AmqpMessageHandlerServiceTest { final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); - final ActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(ActionStatus.FINISHED, 23L); + final DmfActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(DmfActionStatus.FINISHED, 23L); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(actionUpdateStatus, messageProperties); @@ -433,12 +433,12 @@ public class AmqpMessageHandlerServiceTest { } - private ActionUpdateStatus createActionUpdateStatus(final ActionStatus status) { + private DmfActionUpdateStatus createActionUpdateStatus(final DmfActionStatus status) { return createActionUpdateStatus(status, 2L); } - private ActionUpdateStatus createActionUpdateStatus(final ActionStatus status, final Long id) { - final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus(id, status); + private DmfActionUpdateStatus createActionUpdateStatus(final DmfActionStatus status, final Long id) { + final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(id, status); actionUpdateStatus.setSoftwareModuleId(Long.valueOf(2)); return actionUpdateStatus; } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java index bf67e67ef..16279e899 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java @@ -12,8 +12,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; import static org.mockito.Mockito.when; -import org.eclipse.hawkbit.dmf.json.model.ActionStatus; -import org.eclipse.hawkbit.dmf.json.model.ActionUpdateStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfActionStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfActionUpdateStatus; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.test.matcher.Expect; import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents; @@ -52,12 +52,12 @@ public class BaseAmqpServiceTest { @Test @Description("Verify that the message conversion works") public void convertMessageTest() { - final ActionUpdateStatus actionUpdateStatus = createActionStatus(); + final DmfActionUpdateStatus actionUpdateStatus = createActionStatus(); final Message message = rabbitTemplate.getMessageConverter().toMessage(actionUpdateStatus, createJsonProperties()); - final ActionUpdateStatus convertedActionUpdateStatus = baseAmqpService.convertMessage(message, - ActionUpdateStatus.class); + final DmfActionUpdateStatus convertedActionUpdateStatus = baseAmqpService.convertMessage(message, + DmfActionUpdateStatus.class); assertThat(convertedActionUpdateStatus).isEqualToComparingFieldByField(actionUpdateStatus); @@ -68,7 +68,7 @@ public class BaseAmqpServiceTest { @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void convertMessageWithNullContent() { try { - baseAmqpService.convertMessage(new Message(null, createJsonProperties()), ActionUpdateStatus.class); + baseAmqpService.convertMessage(new Message(null, createJsonProperties()), DmfActionUpdateStatus.class); fail("Expected MessageConversionException for inavlid JSON"); } catch (final MessageConversionException e) { // expected @@ -82,7 +82,7 @@ public class BaseAmqpServiceTest { public void updateActionStatusWithEmptyContent() { try { baseAmqpService.convertMessage(new Message("".getBytes(), createJsonProperties()), - ActionUpdateStatus.class); + DmfActionUpdateStatus.class); fail("Expected MessageConversionException for inavlid JSON"); } catch (final MessageConversionException e) { // expected @@ -101,15 +101,15 @@ public class BaseAmqpServiceTest { public void updateActionStatusWithInvalidJsonContent() { try { baseAmqpService.convertMessage(new Message("Invalid Json".getBytes(), createJsonProperties()), - ActionUpdateStatus.class); + DmfActionUpdateStatus.class); fail("Expected MessageConversionException for inavlid JSON"); } catch (final MessageConversionException e) { // expected } } - private ActionUpdateStatus createActionStatus() { - final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus(1L, ActionStatus.RUNNING); + private DmfActionUpdateStatus createActionStatus() { + final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING); actionUpdateStatus.setSoftwareModuleId(2L); actionUpdateStatus.addMessage("Message 1"); actionUpdateStatus.addMessage("Message 2"); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java index ae91b0103..91b71202b 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java @@ -17,9 +17,9 @@ import java.util.List; import org.eclipse.hawkbit.amqp.AmqpProperties; import org.eclipse.hawkbit.amqp.DmfApiConfiguration; import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; -import org.eclipse.hawkbit.dmf.json.model.DownloadResponse; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken.FileResource; +import org.eclipse.hawkbit.dmf.json.model.DmfDownloadResponse; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken.FileResource; import org.eclipse.hawkbit.rabbitmq.test.AbstractAmqpIntegrationTest; import org.eclipse.hawkbit.rabbitmq.test.AmqpTestConfiguration; import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration; @@ -82,7 +82,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq @Test @Description("Tenant in the message is null. This message is invalid and should not be requeued. Additional the receive message is null") public void securityTokenTenantIsNull() { - final TenantSecurityToken securityToken = createTenantSecurityToken(null, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(null, TARGET, FileResource.createFileResourceBySha1(TARGET_SECRUITY_TOKEN)); final Message createAndSendMessage = sendAndReceiveAuthenticationMessage(securityToken); assertThat(createAndSendMessage).isNull(); @@ -93,7 +93,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq @Description("Target in the message is null.This message is invalid and should not requeued. Additional the receive message is null") public void securityTokenFileResourceIsNull() { enableAnonymousAuthentification(); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, null); + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, null); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); verifyResult(returnMessage, HttpStatus.NOT_FOUND, null); } @@ -103,7 +103,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq public void loginFailedBadCredentials() { tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED, false); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceBySha1(TARGET_SECRUITY_TOKEN)); final Message createAndSendMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -115,7 +115,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq @Description("Verify that the receive message contains a 404 code,if the artifact could not found") public void fileResourceGetSha1InSecurityTokenIsNull() { enableAnonymousAuthentification(); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceBySha1(null)); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -132,7 +132,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); final String sha1Hash = artifacts.get(0).getSha1Hash(); - final TenantSecurityToken securityToken = createTenantSecurityToken(target.getTenant(), target.getId(), null, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(target.getTenant(), target.getId(), null, FileResource.createFileResourceBySha1(sha1Hash)); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -144,7 +144,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq @Description("Verify that the receive message contains a 404 code, if there is no artifact for the given sha1") public void artifactForFileResourceSHA1NotFound() { enableAnonymousAuthentification(); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceBySha1(TARGET_SECRUITY_TOKEN)); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -160,7 +160,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); final String sha1Hash = artifacts.get(0).getSha1Hash(); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceBySha1(sha1Hash)); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -176,7 +176,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceBySha1(artifacts.get(0).getSha1Hash())); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -193,7 +193,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); final Artifact artifact = artifacts.get(0); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceBySha1(artifact.getSha1Hash())); deploymentManagement.assignDistributionSet(distributionSet.getId(), @@ -212,7 +212,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); final Artifact artifact = artifacts.get(0); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, target.getId(), null, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, target.getId(), null, FileResource.createFileResourceBySha1(artifact.getSha1Hash())); deploymentManagement.assignDistributionSet(distributionSet.getId(), @@ -230,7 +230,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); final Artifact artifact = artifacts.get(0); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, null, null, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, null, null, FileResource.createFileResourceBySha1(artifact.getSha1Hash())); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -246,7 +246,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); final Artifact artifact = artifacts.get(0); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceBySha1(artifact.getSha1Hash())); deploymentManagement.assignDistributionSet(distributionSet.getId(), @@ -261,7 +261,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq @Description("Verify that the receive message contains a 404, if there is no artifact to the given filename") public void artifactForFileResourceFileNameNotFound() { enableAnonymousAuthentification(); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceByFilename("Test.txt")); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -277,7 +277,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.createFileResourceByFilename(artifacts.get(0).getFilename())); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -293,7 +293,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final DistributionSet distributionSet = createDistributionSet(); final List artifacts = createArtifacts(distributionSet); final FileResource fileResource = FileResource.createFileResourceByArtifactId(artifacts.get(0).getId()); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, fileResource); + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, fileResource); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); verifyResult(returnMessage, HttpStatus.NOT_FOUND, "Artifact for resource FileResource [sha1=null, artifactId=" @@ -310,7 +310,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final List artifacts = createArtifacts(distributionSet); final Artifact artifact = artifacts.get(0); final FileResource fileResource = FileResource.createFileResourceByArtifactId(artifact.getId()); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, fileResource); + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, fileResource); deploymentManagement.assignDistributionSet(distributionSet.getId(), Arrays.asList(new TargetWithActionType(TARGET))); @@ -324,7 +324,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq @Description("Verify that the receive message contains a 404, if there is no artifact to the given softwareModuleFilename") public void artifactForFileResourceSoftwareModuleFilenameNotFound() { enableAnonymousAuthentification(); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, FileResource.softwareModuleFilename(1L, "Test.txt")); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); @@ -345,7 +345,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final FileResource fileResource = FileResource.softwareModuleFilename(softwareModule.getId(), softwareModule.getArtifact(artifact.getId()).get().getFilename()); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, fileResource); + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, fileResource); final Message returnMessage = sendAndReceiveAuthenticationMessage(securityToken); verifyResult(returnMessage, HttpStatus.NOT_FOUND, @@ -366,7 +366,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq final FileResource fileResource = FileResource.softwareModuleFilename(softwareModule.getId(), softwareModule.getArtifact(artifact.getId()).get().getFilename()); - final TenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, fileResource); + final DmfTenantSecurityToken securityToken = createTenantSecurityToken(TENANT_EXIST, TARGET, fileResource); deploymentManagement.assignDistributionSet(distributionSet.getId(), Arrays.asList(new TargetWithActionType(TARGET))); @@ -377,7 +377,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq } private void verifyOkResult(Message returnMessage, Artifact artifact) { - final DownloadResponse convertedMessage = verifyResult(returnMessage, HttpStatus.OK, null); + final DmfDownloadResponse convertedMessage = verifyResult(returnMessage, HttpStatus.OK, null); assertThat(convertedMessage.getDownloadUrl()).isNotNull(); assertThat(convertedMessage.getArtifact()).isNotNull(); assertThat(convertedMessage.getArtifact().getHashes().getSha1()).isEqualTo(artifact.getSha1Hash()); @@ -403,18 +403,18 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq entityFactory.target().create().controllerId(controllerId).securityToken(TARGET_SECRUITY_TOKEN)); } - private TenantSecurityToken createTenantSecurityToken(final String tenant, final String controllerId, + private DmfTenantSecurityToken createTenantSecurityToken(final String tenant, final String controllerId, final FileResource fileResource) { - final TenantSecurityToken tenantSecurityToken = new TenantSecurityToken(tenant, controllerId, fileResource); - tenantSecurityToken.putHeader(TenantSecurityToken.AUTHORIZATION_HEADER, TARGET_TOKEN_HEADER); + final DmfTenantSecurityToken tenantSecurityToken = new DmfTenantSecurityToken(tenant, controllerId, fileResource); + tenantSecurityToken.putHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER, TARGET_TOKEN_HEADER); return tenantSecurityToken; } - private TenantSecurityToken createTenantSecurityToken(final String tenant, final Long targetId, + private DmfTenantSecurityToken createTenantSecurityToken(final String tenant, final Long targetId, final String controllerId, final FileResource fileResource) { - final TenantSecurityToken tenantSecurityToken = new TenantSecurityToken(tenant, null, controllerId, targetId, + final DmfTenantSecurityToken tenantSecurityToken = new DmfTenantSecurityToken(tenant, null, controllerId, targetId, fileResource); - tenantSecurityToken.putHeader(TenantSecurityToken.AUTHORIZATION_HEADER, TARGET_TOKEN_HEADER); + tenantSecurityToken.putHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER, TARGET_TOKEN_HEADER); return tenantSecurityToken; } @@ -430,9 +430,9 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq return artifacts; } - private DownloadResponse verifyResult(final Message returnMessage, final HttpStatus expectedStatus, + private DmfDownloadResponse verifyResult(final Message returnMessage, final HttpStatus expectedStatus, final String expectedMessage) { - final DownloadResponse convertedMessage = (DownloadResponse) getDmfClient().getMessageConverter() + final DmfDownloadResponse convertedMessage = (DmfDownloadResponse) getDmfClient().getMessageConverter() .fromMessage(returnMessage); assertThat(convertedMessage.getResponseCode()).isEqualTo(expectedStatus.value()); @@ -442,7 +442,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq return convertedMessage; } - private Message sendAndReceiveAuthenticationMessage(final TenantSecurityToken securityToken) { + private Message sendAndReceiveAuthenticationMessage(final DmfTenantSecurityToken securityToken) { return getDmfClient().sendAndReceive(createMessage(securityToken, new MessageProperties())); } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java index 351e47f1a..7b04a7451 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java @@ -19,9 +19,9 @@ import org.eclipse.hawkbit.amqp.AmqpProperties; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.ActionStatus; -import org.eclipse.hawkbit.dmf.json.model.ActionUpdateStatus; -import org.eclipse.hawkbit.dmf.json.model.AttributeUpdate; +import org.eclipse.hawkbit.dmf.json.model.DmfActionStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfActionUpdateStatus; +import org.eclipse.hawkbit.dmf.json.model.DmfAttributeUpdate; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent; @@ -327,7 +327,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Description("Tests invalid topic message header. This message should forwarded to the deadletter queue") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) public void updateActionStatusWithInvalidActionId() { - final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus(1L, ActionStatus.RUNNING); + final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING); final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, actionUpdateStatus); getDmfClient().send(eventMessage); @@ -343,7 +343,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) }) public void finishActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(ActionStatus.FINISHED, Status.FINISHED); + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED); } @Test @@ -355,7 +355,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void runningActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(ActionStatus.RUNNING, Status.RUNNING); + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING); } @Test @@ -367,7 +367,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void downloadActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(ActionStatus.DOWNLOAD, Status.DOWNLOAD); + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD); } @Test @@ -379,7 +379,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) }) public void errorActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(ActionStatus.ERROR, Status.ERROR); + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR); } @Test @@ -391,7 +391,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void warningActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(ActionStatus.WARNING, Status.WARNING); + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING); } @Test @@ -403,7 +403,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void retrievedActionStatus() { - registerTargetAndSendAndAssertUpdateActionStatus(ActionStatus.RETRIEVED, Status.RETRIEVED); + registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED); } @Test @@ -415,7 +415,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void cancelNotAllowActionStatus() { - registerTargetAndSendActionStatus(ActionStatus.CANCELED); + registerTargetAndSendActionStatus(DmfActionStatus.CANCELED); verifyOneDeadLetterMessage(); } @@ -482,7 +482,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra final Long actionId = registerTargetAndCancelActionId(); final Long actionNotExist = actionId + 1; - sendActionUpdateStatus(new ActionUpdateStatus(actionNotExist, ActionStatus.CANCELED)); + sendActionUpdateStatus(new DmfActionUpdateStatus(actionNotExist, DmfActionStatus.CANCELED)); verifyOneDeadLetterMessage(); } @@ -495,7 +495,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) public void canceledRejectedNotAllowActionStatus() { - registerTargetAndSendActionStatus(ActionStatus.CANCEL_REJECTED); + registerTargetAndSendActionStatus(DmfActionStatus.CANCEL_REJECTED); verifyOneDeadLetterMessage(); } @@ -511,7 +511,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra public void canceledRejectedActionStatus() { final Long actionId = registerTargetAndCancelActionId(); - sendActionUpdateStatus(new ActionUpdateStatus(actionId, ActionStatus.CANCEL_REJECTED)); + sendActionUpdateStatus(new DmfActionUpdateStatus(actionId, DmfActionStatus.CANCEL_REJECTED)); assertAction(actionId, Status.RUNNING, Status.CANCELING, Status.CANCEL_REJECTED); } @@ -524,7 +524,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra // setup final String target = "ControllerAttributeTestTarget"; registerAndAssertTargetWithExistingTenant(target, 1); - final AttributeUpdate controllerAttribute = new AttributeUpdate(); + final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); controllerAttribute.getAttributes().put("test1", "testA"); controllerAttribute.getAttributes().put("test2", "testB"); @@ -544,7 +544,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra // setup final String target = "ControllerAttributeTestTarget"; registerAndAssertTargetWithExistingTenant(target, 1); - final AttributeUpdate controllerAttribute = new AttributeUpdate(); + final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); controllerAttribute.getAttributes().put("test1", "testA"); controllerAttribute.getAttributes().put("test2", "testB"); final Message createUpdateAttributesMessage = createUpdateAttributesMessage(null, TENANT_EXIST, @@ -556,7 +556,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra // verify verifyOneDeadLetterMessage(); - final AttributeUpdate controllerAttributeEmpty = new AttributeUpdate(); + final DmfAttributeUpdate controllerAttributeEmpty = new DmfAttributeUpdate(); assertUpdateAttributes(target, controllerAttributeEmpty.getAttributes()); } @@ -569,7 +569,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra // setup final String target = "ControllerAttributeTestTarget"; registerAndAssertTargetWithExistingTenant(target, 1); - final AttributeUpdate controllerAttribute = new AttributeUpdate(); + final DmfAttributeUpdate controllerAttribute = new DmfAttributeUpdate(); controllerAttribute.getAttributes().put("test1", "testA"); controllerAttribute.getAttributes().put("test2", "testB"); final Message createUpdateAttributesMessageWrongBody = createUpdateAttributesMessageWrongBody(target, @@ -582,19 +582,19 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra verifyOneDeadLetterMessage(); } - private Long registerTargetAndSendActionStatus(final ActionStatus sendActionStatus) { + private Long registerTargetAndSendActionStatus(final DmfActionStatus sendActionStatus) { final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(); final Long actionId = assignmentResult.getActions().get(0); - sendActionUpdateStatus(new ActionUpdateStatus(actionId, sendActionStatus)); + sendActionUpdateStatus(new DmfActionUpdateStatus(actionId, sendActionStatus)); return actionId; } - private void sendActionUpdateStatus(final ActionUpdateStatus actionStatus) { + private void sendActionUpdateStatus(final DmfActionUpdateStatus actionStatus) { final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, actionStatus); getDmfClient().send(eventMessage); } - private void registerTargetAndSendAndAssertUpdateActionStatus(final ActionStatus sendActionStatus, + private void registerTargetAndSendAndAssertUpdateActionStatus(final DmfActionStatus sendActionStatus, final Status expectedActionStatus) { final Long actionId = registerTargetAndSendActionStatus(sendActionStatus); assertAction(actionId, Status.RUNNING, expectedActionStatus); @@ -625,7 +625,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra } private void sendUpdateAttributeMessage(final String target, final String tenant, - final AttributeUpdate attributeUpdate) { + final DmfAttributeUpdate attributeUpdate) { final Message updateMessage = createUpdateAttributesMessage(target, tenant, attributeUpdate); getDmfClient().send(updateMessage); } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java index 62566bb49..4fc969c26 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java @@ -21,8 +21,8 @@ import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageType; -import org.eclipse.hawkbit.dmf.json.model.AttributeUpdate; -import org.eclipse.hawkbit.dmf.json.model.DownloadAndUpdateRequest; +import org.eclipse.hawkbit.dmf.json.model.DmfAttributeUpdate; +import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest; import org.eclipse.hawkbit.integration.listener.DeadletterListener; import org.eclipse.hawkbit.integration.listener.ReplyToListener; import org.eclipse.hawkbit.matcher.SoftwareModuleJsonMatcher; @@ -31,6 +31,7 @@ import org.eclipse.hawkbit.rabbitmq.test.AmqpTestConfiguration; import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; +import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.util.IpUtil; @@ -111,8 +112,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration } protected DistributionSetAssignmentResult registerTargetAndAssignDistributionSet(final Long assignDs, - final TargetUpdateStatus expectedStatus, - final Set expectedSoftwareModulesInMessage) { + final TargetUpdateStatus expectedStatus, final Set expectedSoftwareModulesInMessage) { registerAndAssertTargetWithExistingTenant(REGISTER_TARGET, 1, expectedStatus, CREATED_BY); final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(assignDs, REGISTER_TARGET); @@ -138,12 +138,11 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration assertThat(headers.get(MessageHeaderKey.TYPE)).isEqualTo(MessageType.THING_DELETED.toString()); } - protected void assertDownloadAndInstallMessage( - final Set dsModules) { + protected void assertDownloadAndInstallMessage(final Set dsModules) { final Message replyMessage = assertReplyMessageHeader(EventTopic.DOWNLOAD_AND_INSTALL); assertAllTargetsCount(1); - final DownloadAndUpdateRequest downloadAndUpdateRequest = (DownloadAndUpdateRequest) getDmfClient() + final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = (DmfDownloadAndUpdateRequest) getDmfClient() .getMessageConverter().fromMessage(replyMessage); Assert.assertThat(dsModules, @@ -255,7 +254,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration } protected Message createUpdateAttributesMessage(final String target, final String tenant, - final AttributeUpdate attributeUpdate) { + final DmfAttributeUpdate attributeUpdate) { final MessageProperties messageProperties = createMessagePropertiesWithTenant(tenant); messageProperties.getHeaders().put(MessageHeaderKey.THING_ID, target); messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.EVENT.toString()); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java index 1bc28e7e2..ad0ca16f1 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java @@ -19,7 +19,7 @@ import org.hamcrest.Factory; /** * Set matcher for {@link SoftwareModule} and a list of - * {@link org.eclipse.hawkbit.dmf.json.model.SoftwareModule}. + * {@link org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule}. */ public final class SoftwareModuleJsonMatcher { @@ -45,20 +45,20 @@ public final class SoftwareModuleJsonMatcher { */ @Factory public static SoftwareModulesMatcher containsExactly( - final List expectedModules) { + final List expectedModules) { return new SoftwareModulesMatcher(expectedModules); } private static class SoftwareModulesMatcher extends BaseMatcher> { - private final List expectedModules; + private final List expectedModules; - public SoftwareModulesMatcher(List expectedModules) { + public SoftwareModulesMatcher(List expectedModules) { this.expectedModules = expectedModules; } static boolean containsExactly(Object actual, - List expected) { + List expected) { if (actual == null) { return expected == null; } @@ -73,7 +73,7 @@ public final class SoftwareModuleJsonMatcher { for (final SoftwareModule repoSoftwareModule : modules) { boolean containsElement = false; - for (final org.eclipse.hawkbit.dmf.json.model.SoftwareModule jsonSoftwareModule : expected) { + for (final org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule jsonSoftwareModule : expected) { if (!jsonSoftwareModule.getModuleId().equals(repoSoftwareModule.getId())) { continue; } diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfActionStatus.java similarity index 97% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfActionStatus.java index 2c38a771c..10b3d870c 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfActionStatus.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public enum ActionStatus { +public enum DmfActionStatus { /** * Action requests download by this target which has now started. */ diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionUpdateStatus.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfActionUpdateStatus.java similarity index 88% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionUpdateStatus.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfActionUpdateStatus.java index 473b3c3cd..ac48c002e 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionUpdateStatus.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfActionUpdateStatus.java @@ -23,10 +23,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ActionUpdateStatus { +public class DmfActionUpdateStatus { private final Long actionId; - private final ActionStatus actionStatus; + private final DmfActionStatus actionStatus; @JsonProperty private Long softwareModuleId; @@ -34,8 +34,8 @@ public class ActionUpdateStatus { @JsonProperty private List message; - public ActionUpdateStatus(@JsonProperty(value = "actionId", required = true) Long actionId, - @JsonProperty(value = "actionStatus", required = true) ActionStatus actionStatus) { + public DmfActionUpdateStatus(@JsonProperty(value = "actionId", required = true) Long actionId, + @JsonProperty(value = "actionStatus", required = true) DmfActionStatus actionStatus) { this.actionId = actionId; this.actionStatus = actionStatus; } @@ -52,7 +52,7 @@ public class ActionUpdateStatus { this.softwareModuleId = softwareModuleId; } - public ActionStatus getActionStatus() { + public DmfActionStatus getActionStatus() { return actionStatus; } diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/Artifact.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfArtifact.java similarity index 90% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/Artifact.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfArtifact.java index 8375663b8..8c58f631b 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/Artifact.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfArtifact.java @@ -24,12 +24,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class Artifact { +public class DmfArtifact { @JsonProperty private String filename; @JsonProperty - private ArtifactHash hashes; + private DmfArtifactHash hashes; @JsonProperty private Long size; @@ -57,11 +57,11 @@ public class Artifact { this.filename = filename; } - public ArtifactHash getHashes() { + public DmfArtifactHash getHashes() { return hashes; } - public void setHashes(final ArtifactHash hashes) { + public void setHashes(final DmfArtifactHash hashes) { this.hashes = hashes; } diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ArtifactHash.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfArtifactHash.java similarity index 88% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ArtifactHash.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfArtifactHash.java index 6f86fe4a4..d8f8a9426 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ArtifactHash.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfArtifactHash.java @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** * JSON representation of artifact hash. */ -public class ArtifactHash { +public class DmfArtifactHash { @JsonProperty private String sha1; @@ -31,7 +31,7 @@ public class ArtifactHash { * the md5 hash */ @JsonCreator - public ArtifactHash(@JsonProperty("sha1") final String sha1, @JsonProperty("md5") final String md5) { + public DmfArtifactHash(@JsonProperty("sha1") final String sha1, @JsonProperty("md5") final String md5) { super(); this.sha1 = sha1; this.md5 = md5; diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/AttributeUpdate.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfAttributeUpdate.java similarity index 96% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/AttributeUpdate.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfAttributeUpdate.java index e3496a70b..1df890e07 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/AttributeUpdate.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfAttributeUpdate.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class AttributeUpdate { +public class DmfAttributeUpdate { @JsonProperty private final Map attributes = new HashMap<>(); diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadAndUpdateRequest.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadAndUpdateRequest.java similarity index 88% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadAndUpdateRequest.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadAndUpdateRequest.java index 8664f639e..2a6d75f07 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadAndUpdateRequest.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadAndUpdateRequest.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class DownloadAndUpdateRequest { +public class DmfDownloadAndUpdateRequest { @JsonProperty private Long actionId; @@ -31,7 +31,7 @@ public class DownloadAndUpdateRequest { private String targetSecurityToken; @JsonProperty - private List softwareModules; + private List softwareModules; public Long getActionId() { return actionId; @@ -49,7 +49,7 @@ public class DownloadAndUpdateRequest { this.targetSecurityToken = targetSecurityToken; } - public List getSoftwareModules() { + public List getSoftwareModules() { if (softwareModules == null) { return Collections.emptyList(); } @@ -63,7 +63,7 @@ public class DownloadAndUpdateRequest { * @param createSoftwareModule * the module */ - public void addSoftwareModule(final SoftwareModule createSoftwareModule) { + public void addSoftwareModule(final DmfSoftwareModule createSoftwareModule) { if (softwareModules == null) { softwareModules = new ArrayList<>(); } diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadResponse.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadResponse.java similarity index 90% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadResponse.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadResponse.java index f81adbbb4..bbac47ea4 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadResponse.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadResponse.java @@ -21,13 +21,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class DownloadResponse { +public class DmfDownloadResponse { @JsonProperty private String downloadUrl; @JsonProperty - private Artifact artifact; + private DmfArtifact artifact; @JsonProperty private int responseCode; @@ -59,11 +59,11 @@ public class DownloadResponse { this.downloadUrl = downloadUrl; } - public Artifact getArtifact() { + public DmfArtifact getArtifact() { return artifact; } - public void setArtifact(final Artifact artifact) { + public void setArtifact(final DmfArtifact artifact) { this.artifact = artifact; } } diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/SoftwareModule.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfSoftwareModule.java similarity index 90% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/SoftwareModule.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfSoftwareModule.java index 70a7880d8..d85643f23 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/SoftwareModule.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfSoftwareModule.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class SoftwareModule { +public class DmfSoftwareModule { @JsonProperty private Long moduleId; @@ -35,7 +35,7 @@ public class SoftwareModule { @JsonProperty private String moduleVersion; @JsonProperty - private List artifacts; + private List artifacts; public String getModuleType() { return moduleType; @@ -53,7 +53,7 @@ public class SoftwareModule { this.moduleVersion = moduleVersion; } - public List getArtifacts() { + public List getArtifacts() { if (artifacts == null) { return Collections.emptyList(); } @@ -70,7 +70,7 @@ public class SoftwareModule { this.moduleId = moduleId; } - public void setArtifacts(final List artifacts) { + public void setArtifacts(final List artifacts) { this.artifacts = artifacts; } diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/TenantSecurityToken.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfTenantSecurityToken.java similarity index 96% rename from hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/TenantSecurityToken.java rename to hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfTenantSecurityToken.java index d2248fed8..2f7b26ea5 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/TenantSecurityToken.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfTenantSecurityToken.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class TenantSecurityToken { +public class DmfTenantSecurityToken { public static final String AUTHORIZATION_HEADER = "Authorization"; @@ -58,7 +58,7 @@ public class TenantSecurityToken { * the file to obtain */ @JsonCreator - public TenantSecurityToken(@JsonProperty("tenant") final String tenant, + public DmfTenantSecurityToken(@JsonProperty("tenant") final String tenant, @JsonProperty("tenantId") final Long tenantId, @JsonProperty("controllerId") final String controllerId, @JsonProperty("targetId") final Long targetId, @JsonProperty("fileResource") final FileResource fileResource) { @@ -79,7 +79,7 @@ public class TenantSecurityToken { * @param fileResource * the file to obtain */ - public TenantSecurityToken(final String tenant, final String controllerId, final FileResource fileResource) { + public DmfTenantSecurityToken(final String tenant, final String controllerId, final FileResource fileResource) { this(tenant, null, controllerId, null, fileResource); } @@ -93,7 +93,7 @@ public class TenantSecurityToken { * @param fileResource * the file to obtain */ - public TenantSecurityToken(final Long tenantId, final Long targetId, final FileResource fileResource) { + public DmfTenantSecurityToken(final Long tenantId, final Long targetId, final FileResource fileResource) { this(null, tenantId, null, targetId, fileResource); } diff --git a/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/AbstractHttpControllerAuthenticationFilter.java b/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/AbstractHttpControllerAuthenticationFilter.java index f62307789..ff8750c9a 100644 --- a/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/AbstractHttpControllerAuthenticationFilter.java +++ b/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/AbstractHttpControllerAuthenticationFilter.java @@ -20,8 +20,8 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken.FileResource; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken.FileResource; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.TenantAware; import org.slf4j.Logger; @@ -97,7 +97,7 @@ public abstract class AbstractHttpControllerAuthenticationFilter extends Abstrac return; } - final TenantSecurityToken secruityToken = createTenantSecruityTokenVariables((HttpServletRequest) request); + final DmfTenantSecurityToken secruityToken = createTenantSecruityTokenVariables((HttpServletRequest) request); if (secruityToken == null) { chain.doFilter(request, response); return; @@ -134,7 +134,7 @@ public abstract class AbstractHttpControllerAuthenticationFilter extends Abstrac * request does not match the pattern and no variables could be * extracted */ - protected TenantSecurityToken createTenantSecruityTokenVariables(final HttpServletRequest request) { + protected DmfTenantSecurityToken createTenantSecruityTokenVariables(final HttpServletRequest request) { final String requestURI = request.getRequestURI(); if (pathExtractor.match(request.getContextPath() + CONTROLLER_REQUEST_ANT_PATTERN, requestURI)) { @@ -166,9 +166,9 @@ public abstract class AbstractHttpControllerAuthenticationFilter extends Abstrac } } - private TenantSecurityToken createTenantSecruityTokenVariables(final HttpServletRequest request, + private DmfTenantSecurityToken createTenantSecruityTokenVariables(final HttpServletRequest request, final String tenant, final String controllerId) { - final TenantSecurityToken secruityToken = new TenantSecurityToken(tenant, null, controllerId, null, + final DmfTenantSecurityToken secruityToken = new DmfTenantSecurityToken(tenant, null, controllerId, null, FileResource.createFileResourceBySha1("")); final UnmodifiableIterator forEnumeration = Iterators.forEnumeration(request.getHeaderNames()); forEnumeration.forEachRemaining(header -> secruityToken.putHeader(header, request.getHeader(header))); @@ -177,7 +177,7 @@ public abstract class AbstractHttpControllerAuthenticationFilter extends Abstrac @Override protected Object getPreAuthenticatedPrincipal(final HttpServletRequest request) { - final TenantSecurityToken secruityToken = createTenantSecruityTokenVariables(request); + final DmfTenantSecurityToken secruityToken = createTenantSecruityTokenVariables(request); if (secruityToken == null) { return null; } @@ -186,7 +186,7 @@ public abstract class AbstractHttpControllerAuthenticationFilter extends Abstrac @Override protected Object getPreAuthenticatedCredentials(final HttpServletRequest request) { - final TenantSecurityToken secruityToken = createTenantSecruityTokenVariables(request); + final DmfTenantSecurityToken secruityToken = createTenantSecruityTokenVariables(request); if (secruityToken == null) { return null; } diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/AbstractControllerAuthenticationFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/AbstractControllerAuthenticationFilter.java index 54ccfdbba..79b77142f 100644 --- a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/AbstractControllerAuthenticationFilter.java +++ b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/AbstractControllerAuthenticationFilter.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.security; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.TenantAware; import org.slf4j.Logger; @@ -41,7 +41,7 @@ public abstract class AbstractControllerAuthenticationFilter implements PreAuthe protected abstract String getTenantConfigurationKey(); @Override - public boolean isEnable(final TenantSecurityToken secruityToken) { + public boolean isEnable(final DmfTenantSecurityToken secruityToken) { return tenantAware.runAsTenant(secruityToken.getTenant(), configurationKeyTenantRunner); } diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticateSecurityTokenFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticateSecurityTokenFilter.java index 5c51b6fc1..646ffd3be 100644 --- a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticateSecurityTokenFilter.java +++ b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticateSecurityTokenFilter.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.security; import java.util.Optional; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.model.Target; @@ -62,9 +62,9 @@ public class ControllerPreAuthenticateSecurityTokenFilter extends AbstractContro } @Override - public HeaderAuthentication getPreAuthenticatedPrincipal(final TenantSecurityToken secruityToken) { + public HeaderAuthentication getPreAuthenticatedPrincipal(final DmfTenantSecurityToken secruityToken) { final String controllerId = resolveControllerId(secruityToken); - final String authHeader = secruityToken.getHeader(TenantSecurityToken.AUTHORIZATION_HEADER); + final String authHeader = secruityToken.getHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER); if ((authHeader != null) && authHeader.startsWith(TARGET_SECURITY_TOKEN_AUTH_SCHEME)) { LOGGER.debug("found authorization header with scheme {} using target security token for authentication", TARGET_SECURITY_TOKEN_AUTH_SCHEME); @@ -77,7 +77,7 @@ public class ControllerPreAuthenticateSecurityTokenFilter extends AbstractContro } @Override - public HeaderAuthentication getPreAuthenticatedCredentials(final TenantSecurityToken securityToken) { + public HeaderAuthentication getPreAuthenticatedCredentials(final DmfTenantSecurityToken securityToken) { final Optional target = systemSecurityContext.runAsSystemAsTenant(() -> { if (securityToken.getTargetId() != null) { return controllerManagement.findByTargetId(securityToken.getTargetId()); @@ -90,7 +90,7 @@ public class ControllerPreAuthenticateSecurityTokenFilter extends AbstractContro .orElse(null); } - private String resolveControllerId(final TenantSecurityToken securityToken) { + private String resolveControllerId(final DmfTenantSecurityToken securityToken) { if (securityToken.getControllerId() != null) { return securityToken.getControllerId(); } diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousDownload.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousDownload.java index e3651a508..ed2bdc2f2 100644 --- a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousDownload.java +++ b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousDownload.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.security; import java.util.Collection; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.TenantAware; @@ -48,12 +48,12 @@ public class ControllerPreAuthenticatedAnonymousDownload extends AbstractControl } @Override - public HeaderAuthentication getPreAuthenticatedPrincipal(final TenantSecurityToken secruityToken) { + public HeaderAuthentication getPreAuthenticatedPrincipal(final DmfTenantSecurityToken secruityToken) { return new HeaderAuthentication(secruityToken.getControllerId(), secruityToken.getControllerId()); } @Override - public HeaderAuthentication getPreAuthenticatedCredentials(final TenantSecurityToken secruityToken) { + public HeaderAuthentication getPreAuthenticatedCredentials(final DmfTenantSecurityToken secruityToken) { return new HeaderAuthentication(secruityToken.getControllerId(), secruityToken.getControllerId()); } diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousFilter.java index 4aed42c95..270229f1b 100644 --- a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousFilter.java +++ b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousFilter.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.security; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; /** * An anonymous controller filter which is only enabled in case of anonymous @@ -30,17 +30,17 @@ public class ControllerPreAuthenticatedAnonymousFilter implements PreAuthentific } @Override - public HeaderAuthentication getPreAuthenticatedPrincipal(final TenantSecurityToken secruityToken) { + public HeaderAuthentication getPreAuthenticatedPrincipal(final DmfTenantSecurityToken secruityToken) { return new HeaderAuthentication(secruityToken.getControllerId(), secruityToken.getControllerId()); } @Override - public HeaderAuthentication getPreAuthenticatedCredentials(final TenantSecurityToken secruityToken) { + public HeaderAuthentication getPreAuthenticatedCredentials(final DmfTenantSecurityToken secruityToken) { return new HeaderAuthentication(secruityToken.getControllerId(), secruityToken.getControllerId()); } @Override - public boolean isEnable(final TenantSecurityToken secruityToken) { + public boolean isEnable(final DmfTenantSecurityToken secruityToken) { return ddiSecurityConfiguration.getAuthentication().getAnonymous().isEnabled(); } diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedGatewaySecurityTokenFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedGatewaySecurityTokenFilter.java index 87da5753b..8b386e7f7 100644 --- a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedGatewaySecurityTokenFilter.java +++ b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedGatewaySecurityTokenFilter.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.security; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; @@ -56,8 +56,8 @@ public class ControllerPreAuthenticatedGatewaySecurityTokenFilter extends Abstra } @Override - public HeaderAuthentication getPreAuthenticatedPrincipal(final TenantSecurityToken secruityToken) { - final String authHeader = secruityToken.getHeader(TenantSecurityToken.AUTHORIZATION_HEADER); + public HeaderAuthentication getPreAuthenticatedPrincipal(final DmfTenantSecurityToken secruityToken) { + final String authHeader = secruityToken.getHeader(DmfTenantSecurityToken.AUTHORIZATION_HEADER); if ((authHeader != null) && authHeader.startsWith(GATEWAY_SECURITY_TOKEN_AUTH_SCHEME)) { LOGGER.debug("found authorization header with scheme {} using target security token for authentication", GATEWAY_SECURITY_TOKEN_AUTH_SCHEME); @@ -71,7 +71,7 @@ public class ControllerPreAuthenticatedGatewaySecurityTokenFilter extends Abstra } @Override - public HeaderAuthentication getPreAuthenticatedCredentials(final TenantSecurityToken secruityToken) { + public HeaderAuthentication getPreAuthenticatedCredentials(final DmfTenantSecurityToken secruityToken) { final String gatewayToken = tenantAware.runAsTenant(secruityToken.getTenant(), gatewaySecurityTokenKeyConfigRunner); return new HeaderAuthentication(secruityToken.getControllerId(), gatewayToken); diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java index 4c044a103..6a06d9589 100644 --- a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java +++ b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java @@ -12,7 +12,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; @@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory; /** * An pre-authenticated processing filter which extracts the principal from a * request URI and the credential from a request header in a the - * {@link TenantSecurityToken}. + * {@link DmfTenantSecurityToken}. * */ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractControllerAuthenticationFilter { @@ -77,7 +77,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractCont } @Override - public HeaderAuthentication getPreAuthenticatedPrincipal(final TenantSecurityToken secruityToken) { + public HeaderAuthentication getPreAuthenticatedPrincipal(final DmfTenantSecurityToken secruityToken) { // retrieve the common name header and the authority name header from // the http request and combine them together final String commonNameValue = secruityToken.getHeader(caCommonNameHeader); @@ -98,7 +98,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractCont } @Override - public Object getPreAuthenticatedCredentials(final TenantSecurityToken secruityToken) { + public Object getPreAuthenticatedCredentials(final DmfTenantSecurityToken secruityToken) { final String authorityNameConfigurationValue = tenantAware.runAsTenant(secruityToken.getTenant(), sslIssuerNameConfigTenantRunner); String controllerId = secruityToken.getControllerId(); @@ -121,7 +121,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractCont * It's ok if we find the the hash in any the trusted CA chain to accept * this request for this tenant. */ - private String getIssuerHashHeader(final TenantSecurityToken secruityToken, final String knownIssuerHashes) { + private String getIssuerHashHeader(final DmfTenantSecurityToken secruityToken, final String knownIssuerHashes) { // there may be several knownIssuerHashes configured for the tenant final List knownHashes = splitMultiHashBySemicolon(knownIssuerHashes); diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthentificationFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthentificationFilter.java index f0801ff4d..272daa011 100644 --- a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthentificationFilter.java +++ b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthentificationFilter.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.security; import java.util.Collection; import java.util.Collections; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; @@ -27,7 +27,7 @@ public interface PreAuthentificationFilter { * the secruity info * @return is enabled diabled */ - boolean isEnable(TenantSecurityToken secruityToken); + boolean isEnable(DmfTenantSecurityToken secruityToken); /** * Extract the principal information from the current secruityToken. @@ -36,7 +36,7 @@ public interface PreAuthentificationFilter { * the secruityToken * @return the extracted tenant and controller id */ - HeaderAuthentication getPreAuthenticatedPrincipal(TenantSecurityToken secruityToken); + HeaderAuthentication getPreAuthenticatedPrincipal(DmfTenantSecurityToken secruityToken); /** * Extract the principal credentials from the current secruityToken. @@ -45,7 +45,7 @@ public interface PreAuthentificationFilter { * the secruityToken * @return the extracted tenant and controller id */ - Object getPreAuthenticatedCredentials(TenantSecurityToken secruityToken); + Object getPreAuthenticatedCredentials(DmfTenantSecurityToken secruityToken); /** * Allows to add additional authorities to the successful authenticated diff --git a/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilterTest.java b/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilterTest.java index 7a8e61bb3..8225cb970 100644 --- a/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilterTest.java +++ b/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilterTest.java @@ -15,8 +15,8 @@ import static org.mockito.Mockito.when; import java.util.Collection; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken; -import org.eclipse.hawkbit.dmf.json.model.TenantSecurityToken.FileResource; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken; +import org.eclipse.hawkbit.dmf.json.model.DmfTenantSecurityToken.FileResource; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; @@ -41,7 +41,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { private TenantConfigurationManagement tenantConfigurationManagementMock; @Mock - private TenantSecurityToken tenantSecurityTokenMock; + private DmfTenantSecurityToken tenantSecurityTokenMock; private final SecurityContextTenantAware tenantAware = new SecurityContextTenantAware(); @@ -71,7 +71,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { @Test @Description("Tests the filter for issuer hash based authentication with a single known hash") public void testIssuerHashBasedAuthenticationWithSingleKnownHash() { - final TenantSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); + final DmfTenantSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); // use single known hash when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME), eq(String.class))) @@ -82,7 +82,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { @Test @Description("Tests the filter for issuer hash based authentication with multiple known hashes") public void testIssuerHashBasedAuthenticationWithMultipleKnownHashes() { - final TenantSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); + final DmfTenantSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); // use multiple known hashes when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME), eq(String.class))) @@ -93,7 +93,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { @Test @Description("Tests the filter for issuer hash based authentication with unknown hash") public void testIssuerHashBasedAuthenticationWithUnknownHash() { - final TenantSecurityToken securityToken = prepareSecurityToken(UNKNOWN_HASH); + final DmfTenantSecurityToken securityToken = prepareSecurityToken(UNKNOWN_HASH); // use single known hash when(tenantConfigurationManagementMock.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME), eq(String.class))) @@ -104,8 +104,8 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { @Test @Description("Tests different values for issuer hash header and inspects the credentials") public void useDifferentValuesForIssuerHashHeader() { - final TenantSecurityToken securityToken1 = prepareSecurityToken(SINGLE_HASH); - final TenantSecurityToken securityToken2 = prepareSecurityToken(SECOND_HASH); + final DmfTenantSecurityToken securityToken1 = prepareSecurityToken(SINGLE_HASH); + final DmfTenantSecurityToken securityToken2 = prepareSecurityToken(SECOND_HASH); final HeaderAuthentication expected1 = new HeaderAuthentication(CA_COMMON_NAME_VALUE, SINGLE_HASH); final HeaderAuthentication expected2 = new HeaderAuthentication(CA_COMMON_NAME_VALUE, SECOND_HASH); @@ -130,8 +130,8 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { } - private static TenantSecurityToken prepareSecurityToken(final String issuerHashHeaderValue) { - final TenantSecurityToken securityToken = new TenantSecurityToken("DEFAULT", CA_COMMON_NAME_VALUE, + private static DmfTenantSecurityToken prepareSecurityToken(final String issuerHashHeaderValue) { + final DmfTenantSecurityToken securityToken = new DmfTenantSecurityToken("DEFAULT", CA_COMMON_NAME_VALUE, FileResource.createFileResourceBySha1("12345")); securityToken.putHeader(CA_COMMON_NAME, CA_COMMON_NAME_VALUE); securityToken.putHeader(X_SSL_ISSUER_HASH_1, issuerHashHeaderValue);