Move artifact encryption to hawkbit-artifact-api where it does belong (#2540)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -22,6 +22,12 @@
|
||||
<name>hawkBit :: Artifact :: API</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository;
|
||||
package org.eclipse.hawkbit.repository.artifact;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
@@ -22,8 +22,10 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HexFormat;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
||||
import org.eclipse.hawkbit.repository.artifact.exception.ArtifactStoreException;
|
||||
import org.eclipse.hawkbit.repository.artifact.exception.HashNotMatchException;
|
||||
import org.eclipse.hawkbit.repository.artifact.model.AbstractDbArtifact;
|
||||
import org.eclipse.hawkbit.repository.artifact.model.DbArtifactHash;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,15 +7,17 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository;
|
||||
package org.eclipse.hawkbit.repository.artifact;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
||||
import org.eclipse.hawkbit.repository.artifact.exception.ArtifactStoreException;
|
||||
import org.eclipse.hawkbit.repository.artifact.exception.HashNotMatchException;
|
||||
import org.eclipse.hawkbit.repository.artifact.model.AbstractDbArtifact;
|
||||
import org.eclipse.hawkbit.repository.artifact.model.DbArtifactHash;
|
||||
|
||||
/**
|
||||
* ArtifactRepository service interface.
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.artifact.encryption;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.repository.artifact.exception.ArtifactEncryptionFailedException;
|
||||
|
||||
/**
|
||||
* Interface definition for artifact encryption.
|
||||
*/
|
||||
public interface ArtifactEncryption {
|
||||
|
||||
/**
|
||||
* Defines the required secret keys for particular encryption algorithm.
|
||||
*
|
||||
* @return list of required secret keys
|
||||
*/
|
||||
Set<String> requiredSecretKeys();
|
||||
|
||||
/**
|
||||
* Generates required secrets key/value pairs.
|
||||
*
|
||||
* @return secrets key/value pairs
|
||||
* @throws ArtifactEncryptionFailedException thrown in case of an error while generating secrets
|
||||
*/
|
||||
Map<String, String> generateSecrets();
|
||||
|
||||
/**
|
||||
* Encrypts artifact stream with provided secrets.
|
||||
*
|
||||
* @param secrets secrets key/value pairs to be used for encryption
|
||||
* @param stream artifact stream to encrypt
|
||||
* @return encrypted input stream
|
||||
* @throws ArtifactEncryptionFailedException thrown in case of an error while encrypting the provided stream
|
||||
*/
|
||||
InputStream encryptStream(final Map<String, String> secrets, final InputStream stream);
|
||||
|
||||
/**
|
||||
* Decrypts encrypted artifact stream based on provided secrets.
|
||||
*
|
||||
* @param secrets secrets key/value pairs to be used for decryption
|
||||
* @param stream artifact stream to decrypt
|
||||
* @return decrypted input stream
|
||||
* @throws ArtifactEncryptionFailedException thrown in case of an error while decrypting the provided stream
|
||||
*/
|
||||
InputStream decryptStream(final Map<String, String> secrets, final InputStream stream);
|
||||
|
||||
/**
|
||||
* Size of the underlying encryption algorithm overhead in bytes
|
||||
*
|
||||
* @return encryption overhead in byte
|
||||
*/
|
||||
int encryptionSizeOverhead();
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.artifact.encryption;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Interface definition for artifact encryption secrets store. It maintains secret key/value pairs
|
||||
* identified by id (e.g. software module id)
|
||||
*/
|
||||
public interface ArtifactEncryptionSecretsStore {
|
||||
|
||||
/**
|
||||
* Adds secret key/value pair associated with particular id (e.g. software module id) to the store.
|
||||
*
|
||||
* @param id id of the secret
|
||||
* @param secretKey key of the secret
|
||||
* @param secretValue value of the secret
|
||||
*/
|
||||
void addSecret(final long id, final String secretKey, final String secretValue);
|
||||
|
||||
/**
|
||||
* Checks if secret is present for particular id and key in the store.
|
||||
*
|
||||
* @param id id of the secret
|
||||
* @param secretKey key of the secret
|
||||
*/
|
||||
boolean secretExists(final long id, final String secretKey);
|
||||
|
||||
/**
|
||||
* Retrieves secret value associated with particular id and key from the store.
|
||||
*
|
||||
* @param id id of the secret
|
||||
* @param secretKey key of the secret
|
||||
*/
|
||||
Optional<String> getSecret(final long id, final String secretKey);
|
||||
|
||||
/**
|
||||
* Removes secret key/value pair associated with particular id from the store.
|
||||
*
|
||||
* @param id id of the secret
|
||||
* @param secretKey key of the secret
|
||||
*/
|
||||
void removeSecret(final long id, final String secretKey);
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.artifact.encryption;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.eclipse.hawkbit.repository.artifact.exception.ArtifactEncryptionUnsupportedException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Service responsible for encryption operations. Should be registered as a bean in order its autowired dependencies
|
||||
* to be injected.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@SuppressWarnings("java:S6548") // singleton holder ensures static access to spring resources in some places
|
||||
public final class ArtifactEncryptionService {
|
||||
|
||||
private static final ArtifactEncryptionService SINGLETON = new ArtifactEncryptionService();
|
||||
|
||||
private ArtifactEncryption artifactEncryption;
|
||||
private ArtifactEncryptionSecretsStore artifactEncryptionSecretsStore;
|
||||
|
||||
/**
|
||||
* @return the artifact encryption service singleton instance
|
||||
*/
|
||||
public static ArtifactEncryptionService getInstance() {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
@Autowired(required = false) // spring setter injection
|
||||
public void setArtifactEncryption(final ArtifactEncryption artifactEncryption) {
|
||||
this.artifactEncryption = artifactEncryption;
|
||||
}
|
||||
|
||||
@Autowired(required = false) // spring setter injection
|
||||
public void setArtifactEncryptionSecretsStore(final ArtifactEncryptionSecretsStore artifactEncryptionSecretsStore) {
|
||||
this.artifactEncryptionSecretsStore = artifactEncryptionSecretsStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if required encryption and secrets store beans are present.
|
||||
*
|
||||
* @return if encryption is supported
|
||||
*/
|
||||
public boolean isEncryptionSupported() {
|
||||
return artifactEncryption != null && artifactEncryptionSecretsStore != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates encryption secrets and saves them in secret store by id reference.
|
||||
*
|
||||
* @param id id of the secrets to be generated
|
||||
*/
|
||||
public void addEncryptionSecrets(final long id) {
|
||||
if (!isEncryptionSupported()) {
|
||||
throw new ArtifactEncryptionUnsupportedException("Encryption secrets generation is not supported.");
|
||||
}
|
||||
|
||||
final Map<String, String> secrets = artifactEncryption.generateSecrets();
|
||||
try {
|
||||
secrets.forEach((key, value) -> artifactEncryptionSecretsStore.addSecret(id, key, value));
|
||||
} finally {
|
||||
// clear secrets from memory as soon as possible
|
||||
secrets.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts artifact stream using the keys retrieved from secrets store by id reference.
|
||||
*
|
||||
* @param id id of the secrets
|
||||
* @param artifactStream artifact stream to encrypt
|
||||
* @return encrypted input stream
|
||||
*/
|
||||
public InputStream encryptArtifact(final long id, final InputStream artifactStream) {
|
||||
if (!isEncryptionSupported()) {
|
||||
throw new ArtifactEncryptionUnsupportedException("Artifact encryption is not supported.");
|
||||
}
|
||||
|
||||
final Map<String, String> secrets = getEncryptionSecrets(id);
|
||||
try {
|
||||
return artifactEncryption.encryptStream(secrets, artifactStream);
|
||||
} finally {
|
||||
// clear secrets from memory as soon as possible
|
||||
secrets.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts artifact stream using the keys retrieved from secrets store by id reference.
|
||||
*
|
||||
* @param id id of the secrets
|
||||
* @param encryptedArtifactStream artifact stream to decrypt
|
||||
* @return decrypted input stream
|
||||
*/
|
||||
public InputStream decryptArtifact(final long id, final InputStream encryptedArtifactStream) {
|
||||
if (!isEncryptionSupported()) {
|
||||
throw new ArtifactEncryptionUnsupportedException("Artifact decryption is not supported.");
|
||||
}
|
||||
|
||||
final var secrets = getEncryptionSecrets(id);
|
||||
try {
|
||||
return artifactEncryption.decryptStream(secrets, encryptedArtifactStream);
|
||||
} finally {
|
||||
// clear secrets from memory as soon as possible
|
||||
secrets.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of the underlying encryption algorithm overhead in bytes
|
||||
*
|
||||
* @return encryption overhead in byte
|
||||
*/
|
||||
public int encryptionSizeOverhead() {
|
||||
return artifactEncryption.encryptionSizeOverhead();
|
||||
}
|
||||
|
||||
private Map<String, String> getEncryptionSecrets(final long id) {
|
||||
final Set<String> requiredSecretsKeys = artifactEncryption.requiredSecretKeys();
|
||||
final Map<String, String> requiredSecrets = new HashMap<>();
|
||||
for (final String requiredSecretsKey : requiredSecretsKeys) {
|
||||
final Optional<String> requiredSecretsValue = artifactEncryptionSecretsStore.getSecret(id, requiredSecretsKey);
|
||||
requiredSecretsValue.ifPresent(secretValue -> requiredSecrets.put(requiredSecretsKey, secretValue));
|
||||
}
|
||||
return requiredSecrets;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.artifact.exception;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
|
||||
/**
|
||||
* Exception being thrown in case of error while generating encryption secrets, encrypting or decrypting artifacts.
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class ArtifactEncryptionFailedException extends AbstractServerRtException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Encryption operation that caused the exception.
|
||||
*/
|
||||
public enum EncryptionOperation {
|
||||
GENERATE_SECRETS, ENCRYPT, DECRYPT;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private final EncryptionOperation encryptionOperation;
|
||||
|
||||
public ArtifactEncryptionFailedException(final EncryptionOperation encryptionOperation) {
|
||||
this(encryptionOperation, null, null);
|
||||
}
|
||||
|
||||
public ArtifactEncryptionFailedException(final EncryptionOperation encryptionOperation, final String message) {
|
||||
this(encryptionOperation, message, null);
|
||||
}
|
||||
|
||||
public ArtifactEncryptionFailedException(final EncryptionOperation encryptionOperation, final String message, final Throwable cause) {
|
||||
super(message, SpServerError.SP_ARTIFACT_ENCRYPTION_FAILED, cause);
|
||||
this.encryptionOperation = encryptionOperation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.artifact.exception;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
|
||||
/**
|
||||
* Exception being thrown when artifact encryption is not supported
|
||||
*/
|
||||
public final class ArtifactEncryptionUnsupportedException extends AbstractServerRtException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ArtifactEncryptionUnsupportedException() {
|
||||
super(SpServerError.SP_ARTIFACT_ENCRYPTION_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message of the error
|
||||
*/
|
||||
public ArtifactEncryptionUnsupportedException(final String message) {
|
||||
super(message, SpServerError.SP_ARTIFACT_ENCRYPTION_NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository;
|
||||
package org.eclipse.hawkbit.repository.artifact.exception;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository;
|
||||
package org.eclipse.hawkbit.repository.artifact.exception;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.model;
|
||||
package org.eclipse.hawkbit.repository.artifact.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.model;
|
||||
package org.eclipse.hawkbit.repository.artifact.model;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.model;
|
||||
package org.eclipse.hawkbit.repository.artifact.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
/**
|
||||
* hawkBit API type.
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
@@ -20,7 +20,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.urlhandler.ArtifactUrlHandlerProperties.UrlProtocol;
|
||||
import org.eclipse.hawkbit.repository.artifact.urlhandler.ArtifactUrlHandlerProperties.UrlProtocol;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.artifact.encryption;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import org.eclipse.hawkbit.repository.artifact.exception.ArtifactEncryptionUnsupportedException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test class to verify that no {@link ArtifactEncryptionService} required beans
|
||||
* are loaded and therefore the encryption support is not given.
|
||||
* <p/>
|
||||
* Feature: Unit Tests - Repository<br/>
|
||||
* Story: Artifact Encryption Service
|
||||
*/
|
||||
class ArtifactEncryptionServiceTest {
|
||||
|
||||
/**
|
||||
* Verify that no artifact encryption support is given
|
||||
*/
|
||||
@Test
|
||||
void verifyNoArtifactEncryptionSupport() {
|
||||
final ArtifactEncryptionService artifactEncryptionService = ArtifactEncryptionService.getInstance();
|
||||
|
||||
assertThat(artifactEncryptionService.isEncryptionSupported()).isFalse();
|
||||
assertThatExceptionOfType(ArtifactEncryptionUnsupportedException.class)
|
||||
.isThrownBy(() -> artifactEncryptionService.addEncryptionSecrets(1L));
|
||||
assertThatExceptionOfType(ArtifactEncryptionUnsupportedException.class)
|
||||
.isThrownBy(() -> artifactEncryptionService.encryptArtifact(1L, null));
|
||||
assertThatExceptionOfType(ArtifactEncryptionUnsupportedException.class)
|
||||
.isThrownBy(() -> artifactEncryptionService.decryptArtifact(1L, null));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -15,8 +15,8 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.urlhandler.ArtifactUrlHandlerProperties.UrlProtocol;
|
||||
import org.eclipse.hawkbit.artifact.repository.urlhandler.URLPlaceholder.SoftwareData;
|
||||
import org.eclipse.hawkbit.repository.artifact.urlhandler.ArtifactUrlHandlerProperties.UrlProtocol;
|
||||
import org.eclipse.hawkbit.repository.artifact.urlhandler.URLPlaceholder.SoftwareData;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2022 Bosch.IO GmbH and others
|
||||
* Copyright (c) 2025 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
package org.eclipse.hawkbit.repository.artifact.urlhandler;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
Reference in New Issue
Block a user