You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2021/11/08 14:48:16 UTC
[incubator-streampipes] branch STREAMPIPES-426 updated (12024d3 ->
dd7fe47)
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a change to branch STREAMPIPES-426
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git.
from 12024d3 Merge branch 'STREAMPIPES-426' of github.com:apache/incubator-streampipes into STREAMPIPES-426
new 8a0acb1 [STREAMPIPES-426] Improve management of secrets
new aa25058 [STREAMPIPES-426] Fix element recommendation and wrong typecast of data sets
new dd7fe47 Merge branch 'STREAMPIPES-426' of github.com:apache/incubator-streampipes into STREAMPIPES-426
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
...llationConstants.java => DefaultEnvValues.java} | 4 +-
.../apache/streampipes/commons/constants/Envs.java | 7 +-
.../streampipes/config/backend/BackendConfig.java | 5 --
.../config/backend/BackendConfigKeys.java | 1 -
.../master/management/SourcesManagement.java | 6 +-
.../master/management/WorkerRestClient.java | 8 +-
.../manager/execution/http/PipelineExecutor.java | 6 +-
.../execution/http/PipelineStorageService.java | 6 +-
.../streampipes/manager/operations/Operations.java | 4 +-
.../manager/recommender/ElementRecommender.java | 9 +-
.../manager/setup/AutoInstallation.java | 12 +--
.../management/AdapterResourceManager.java | 7 +-
.../management/DataStreamResourceManager.java | 3 +-
.../management}/secret/ISecretHandler.java | 4 +-
.../management}/secret/SecretDecrypter.java | 8 +-
.../management}/secret/SecretEncrypter.java | 8 +-
.../management}/secret/SecretProvider.java | 10 +--
.../resource/management}/secret/SecretService.java | 19 ++++-
.../resource/management}/secret/SecretVisitor.java | 9 +-
.../resource/utils/AdapterEncryptionService.java | 66 ---------------
.../streampipes/rest/impl/PipelineResource.java | 18 ++--
.../rest/security/RecommendationMessageFilter.java | 17 ++--
...StreamPipesClientRuntimeConnectionResolver.java | 6 +-
streampipes-user-management/pom.xml | 6 ++
.../management/encryption/CredentialsManager.java | 96 ----------------------
.../encryption/SecretEncryptionManager.java | 48 +++++++++++
26 files changed, 148 insertions(+), 245 deletions(-)
rename streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/{InstallationConstants.java => DefaultEnvValues.java} (91%)
rename {streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager => streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management}/secret/ISecretHandler.java (89%)
rename {streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager => streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management}/secret/SecretDecrypter.java (83%)
rename {streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager => streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management}/secret/SecretEncrypter.java (83%)
rename {streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager => streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management}/secret/SecretProvider.java (73%)
rename {streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager => streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management}/secret/SecretService.java (70%)
rename {streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager => streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management}/secret/SecretVisitor.java (91%)
delete mode 100644 streampipes-resource-management/src/main/java/org/apache/streampipes/resource/utils/AdapterEncryptionService.java
copy streampipes-client/src/main/java/org/apache/streampipes/client/model/InputStreamIndex.java => streampipes-rest/src/main/java/org/apache/streampipes/rest/security/RecommendationMessageFilter.java (73%)
delete mode 100644 streampipes-user-management/src/main/java/org/apache/streampipes/user/management/encryption/CredentialsManager.java
create mode 100644 streampipes-user-management/src/main/java/org/apache/streampipes/user/management/encryption/SecretEncryptionManager.java
[incubator-streampipes] 02/03: [STREAMPIPES-426] Fix element
recommendation and wrong typecast of data sets
Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch STREAMPIPES-426
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit aa250584f28ac25d36950dbd1e0a246fcc3b3ddb
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon Nov 8 15:46:39 2021 +0100
[STREAMPIPES-426] Fix element recommendation and wrong typecast of data sets
---
.../streampipes/manager/operations/Operations.java | 4 ++--
.../manager/recommender/ElementRecommender.java | 9 ++++-----
.../resource/management/DataStreamResourceManager.java | 3 ++-
.../apache/streampipes/rest/impl/PipelineResource.java | 18 ++++++++++--------
.../rest/security/RecommendationMessageFilter.java | 18 +++++++-----------
5 files changed, 25 insertions(+), 27 deletions(-)
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/operations/Operations.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/operations/Operations.java
index 38bf667..78706b6 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/operations/Operations.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/operations/Operations.java
@@ -101,8 +101,8 @@ public class Operations {
return new TypeExtractor(graphData).getTypeVerifier().verifyAndUpdate();
}
- public static PipelineElementRecommendationMessage findRecommendedElements(String email, Pipeline partialPipeline) throws NoSuitableSepasAvailableException {
- return new ElementRecommender(email, partialPipeline).findRecommendedElements();
+ public static PipelineElementRecommendationMessage findRecommendedElements(Pipeline partialPipeline) throws NoSuitableSepasAvailableException {
+ return new ElementRecommender(partialPipeline).findRecommendedElements();
}
public static void storePipeline(Pipeline pipeline) {
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/recommender/ElementRecommender.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/recommender/ElementRecommender.java
index e40f3b2..8ce5afc 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/recommender/ElementRecommender.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/recommender/ElementRecommender.java
@@ -39,6 +39,7 @@ import org.apache.streampipes.model.graph.DataSinkInvocation;
import org.apache.streampipes.model.pipeline.Pipeline;
import org.apache.streampipes.model.pipeline.PipelineElementRecommendation;
import org.apache.streampipes.model.pipeline.PipelineElementRecommendationMessage;
+import org.apache.streampipes.resource.management.SpResourceManager;
import org.apache.streampipes.storage.api.INoSqlStorage;
import org.apache.streampipes.storage.api.IPipelineElementDescriptionStorage;
import org.apache.streampipes.storage.management.StorageDispatcher;
@@ -56,11 +57,9 @@ public class ElementRecommender {
private static final Logger LOG = LoggerFactory.getLogger(ElementRecommender.class);
private Pipeline pipeline;
- private String email;
private PipelineElementRecommendationMessage recommendationMessage;
- public ElementRecommender(String email, Pipeline partialPipeline) {
- this.email = email;
+ public ElementRecommender(Pipeline partialPipeline) {
this.pipeline = partialPipeline;
this.recommendationMessage = new PipelineElementRecommendationMessage();
}
@@ -153,7 +152,7 @@ public class ElementRecommender {
}
private List<ConsumableStreamPipesEntity> getAllSepas() {
- List<String> userObjects = getUserService().getOwnSepaUris(email);
+ List<String> userObjects = new SpResourceManager().manageDataProcessors().findAllIdsOnly();
return getTripleStore()
.getAllDataProcessors()
.stream()
@@ -164,7 +163,7 @@ public class ElementRecommender {
private List<ConsumableStreamPipesEntity> getAllSecs() {
- List<String> userObjects = getUserService().getOwnActionUris(email);
+ List<String> userObjects = new SpResourceManager().manageDataSinks().findAllIdsOnly();
return getTripleStore()
.getAllDataSinks()
.stream()
diff --git a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/DataStreamResourceManager.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/DataStreamResourceManager.java
index 700283d..40e27fe 100644
--- a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/DataStreamResourceManager.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/DataStreamResourceManager.java
@@ -17,6 +17,7 @@
*/
package org.apache.streampipes.resource.management;
+import org.apache.streampipes.model.SpDataSet;
import org.apache.streampipes.model.SpDataStream;
import org.apache.streampipes.storage.api.IDataStreamStorage;
import org.apache.streampipes.storage.management.StorageDispatcher;
@@ -29,6 +30,6 @@ public class DataStreamResourceManager extends AbstractPipelineElementResourceMa
@Override
protected SpDataStream toInvocation(SpDataStream description) {
- return new SpDataStream(description);
+ return description instanceof SpDataSet ? new SpDataSet((SpDataSet) description) : new SpDataStream(description);
}
}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
index b155dfc..18bdae1 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
@@ -36,6 +36,7 @@ import org.apache.streampipes.model.message.NotificationType;
import org.apache.streampipes.model.message.Notifications;
import org.apache.streampipes.model.message.SuccessMessage;
import org.apache.streampipes.model.pipeline.Pipeline;
+import org.apache.streampipes.model.pipeline.PipelineElementRecommendationMessage;
import org.apache.streampipes.model.pipeline.PipelineOperationStatus;
import org.apache.streampipes.rest.core.base.impl.AbstractAuthGuardedRestResource;
import org.apache.streampipes.rest.security.AuthConstants;
@@ -173,19 +174,20 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@JacksonSerialized
@Hidden
@PreAuthorize(AuthConstants.HAS_WRITE_PIPELINE_PRIVILEGE)
- public Response recommend(Pipeline pipeline) {
+ //@PostAuthorize("@recommendationFilter.hasPermission(auth, filterObject)")
+ public PipelineElementRecommendationMessage recommend(Pipeline pipeline) {
try {
- return ok(Operations.findRecommendedElements(getAuthenticatedUsername(), pipeline));
+ return Operations.findRecommendedElements(pipeline);
} catch (JsonSyntaxException e) {
- return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR,
- e.getMessage()));
+ throw new WebApplicationException(badRequest(new Notification(NotificationType.UNKNOWN_ERROR,
+ e.getMessage())));
} catch (NoSuitableSepasAvailableException e) {
- return constructErrorMessage(new Notification(NotificationType.NO_SEPA_FOUND,
- e.getMessage()));
+ throw new WebApplicationException(badRequest(new Notification(NotificationType.NO_SEPA_FOUND,
+ e.getMessage())));
} catch (Exception e) {
e.printStackTrace();
- return constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR,
- e.getMessage()));
+ throw new WebApplicationException(serverError(constructErrorMessage(new Notification(NotificationType.UNKNOWN_ERROR,
+ e.getMessage()))));
}
}
diff --git a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/DataStreamResourceManager.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/security/RecommendationMessageFilter.java
similarity index 57%
copy from streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/DataStreamResourceManager.java
copy to streampipes-rest/src/main/java/org/apache/streampipes/rest/security/RecommendationMessageFilter.java
index 700283d..dfcb529 100644
--- a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/DataStreamResourceManager.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/security/RecommendationMessageFilter.java
@@ -15,20 +15,16 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.resource.management;
+package org.apache.streampipes.rest.security;
-import org.apache.streampipes.model.SpDataStream;
-import org.apache.streampipes.storage.api.IDataStreamStorage;
-import org.apache.streampipes.storage.management.StorageDispatcher;
+import org.springframework.security.core.Authentication;
+import org.springframework.stereotype.Component;
-public class DataStreamResourceManager extends AbstractPipelineElementResourceManager<IDataStreamStorage, SpDataStream, SpDataStream> {
+@Component("recommendationFilter")
+public class RecommendationMessageFilter {
- public DataStreamResourceManager() {
- super(StorageDispatcher.INSTANCE.getNoSqlStore().getDataStreamStorage());
+ public boolean hasPermission(Authentication auth) {
+ return true;
}
- @Override
- protected SpDataStream toInvocation(SpDataStream description) {
- return new SpDataStream(description);
- }
}
[incubator-streampipes] 03/03: Merge branch 'STREAMPIPES-426' of
github.com:apache/incubator-streampipes into STREAMPIPES-426
Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch STREAMPIPES-426
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit dd7fe47b1cc6e9fd061f2da38d04a1bee29865b0
Merge: aa25058 12024d3
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon Nov 8 15:46:54 2021 +0100
Merge branch 'STREAMPIPES-426' of github.com:apache/incubator-streampipes into STREAMPIPES-426
.../backend/StreamPipesResourceConfig.java | 4 ---
.../streampipes/client/StreamPipesClient.java | 4 +++
.../org/apache/streampipes/client/api/FileApi.java | 35 +++++++++++-----------
.../{GetRequest.java => BinaryGetRequest.java} | 35 ++++++++++------------
.../streampipes/client/http/DeleteRequest.java | 2 +-
.../apache/streampipes/client/http/GetRequest.java | 2 +-
.../streampipes/client/http/HttpRequest.java | 13 ++++++--
.../streampipes/model}/file/FileMetadata.java | 2 +-
.../streampipes/manager/file/FileManager.java | 2 +-
.../apache/streampipes/rest/ResetManagement.java | 2 +-
.../streampipes/rest/impl/PipelineElementFile.java | 8 ++++-
.../storage/api/IFileMetadataStorage.java | 2 +-
.../couchdb/impl/FileMetadataStorageImpl.java | 2 +-
.../tests/pipelineElement/SinglePipelineElement.ts | 2 +-
14 files changed, 63 insertions(+), 52 deletions(-)
[incubator-streampipes] 01/03: [STREAMPIPES-426] Improve management
of secrets
Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch STREAMPIPES-426
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit 8a0acb1beae627f03dd318655a702e1474a85e96
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon Nov 8 14:47:05 2021 +0100
[STREAMPIPES-426] Improve management of secrets
---
...llationConstants.java => DefaultEnvValues.java} | 4 +-
.../apache/streampipes/commons/constants/Envs.java | 7 +-
.../streampipes/config/backend/BackendConfig.java | 5 --
.../config/backend/BackendConfigKeys.java | 1 -
.../master/management/SourcesManagement.java | 6 +-
.../master/management/WorkerRestClient.java | 8 +-
.../manager/execution/http/PipelineExecutor.java | 6 +-
.../execution/http/PipelineStorageService.java | 6 +-
.../manager/setup/AutoInstallation.java | 12 +--
.../management/AdapterResourceManager.java | 7 +-
.../management}/secret/ISecretHandler.java | 4 +-
.../management}/secret/SecretDecrypter.java | 8 +-
.../management}/secret/SecretEncrypter.java | 8 +-
.../management}/secret/SecretProvider.java | 10 +--
.../resource/management}/secret/SecretService.java | 19 ++++-
.../resource/management}/secret/SecretVisitor.java | 9 +-
.../resource/utils/AdapterEncryptionService.java | 66 ---------------
...StreamPipesClientRuntimeConnectionResolver.java | 6 +-
streampipes-user-management/pom.xml | 6 ++
.../management/encryption/CredentialsManager.java | 96 ----------------------
.../encryption/SecretEncryptionManager.java | 48 +++++++++++
21 files changed, 123 insertions(+), 219 deletions(-)
diff --git a/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/InstallationConstants.java b/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/DefaultEnvValues.java
similarity index 91%
rename from streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/InstallationConstants.java
rename to streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/DefaultEnvValues.java
index 4acb05c..5a7b2f5 100644
--- a/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/InstallationConstants.java
+++ b/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/DefaultEnvValues.java
@@ -17,11 +17,13 @@
*/
package org.apache.streampipes.commons.constants;
-public class InstallationConstants {
+public class DefaultEnvValues {
public static final String INITIAL_ADMIN_EMAIL_DEFAULT = "admin@streampipes.apache.org";
public static final String INITIAL_ADMIN_PW_DEFAULT = "admin";
public static final String INITIAL_CLIENT_USER_DEFAULT = "sp-service-client";
public static final String INITIAL_CLIENT_SECRET_DEFAULT = "my-apache-streampipes-secret-key-change-me";
public static final boolean INSTALL_PIPELINE_ELEMENTS = true;
+
+ public static final String DEFAULT_ENCRYPTION_PASSCODE = "eGgemyGBoILAu3xckoIp";
}
diff --git a/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/Envs.java b/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/Envs.java
index 6324bc9..7b1e24b 100644
--- a/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/Envs.java
+++ b/streampipes-commons/src/main/java/org/apache/streampipes/commons/constants/Envs.java
@@ -30,7 +30,8 @@ public enum Envs {
SP_INITIAL_CLIENT_SECRET("SP_INITIAL_CLIENT_SECRET"),
SP_SETUP_INSTALL_PIPELINE_ELEMENTS("SP_SETUP_INSTALL_PIPELINE_ELEMENTS"),
SP_CLIENT_USER("SP_CLIENT_USER"),
- SP_CLIENT_SECRET("SP_CLIENT_SECRET");
+ SP_CLIENT_SECRET("SP_CLIENT_SECRET"),
+ SP_ENCRYPTION_PASSCODE("SP_ENCRYPTION_PASSCODE");
private final String envVariableName;
@@ -58,4 +59,8 @@ public enum Envs {
return envVariableName;
}
+ public String getValueOrDefault(String defaultValue) {
+ return this.exists() ? this.getValue() : defaultValue;
+ }
+
}
diff --git a/streampipes-config/src/main/java/org/apache/streampipes/config/backend/BackendConfig.java b/streampipes-config/src/main/java/org/apache/streampipes/config/backend/BackendConfig.java
index c711153..eef333e 100644
--- a/streampipes-config/src/main/java/org/apache/streampipes/config/backend/BackendConfig.java
+++ b/streampipes-config/src/main/java/org/apache/streampipes/config/backend/BackendConfig.java
@@ -73,7 +73,6 @@ public enum BackendConfig {
config.registerObject(BackendConfigKeys.MESSAGING_SETTINGS, MessagingSettings.fromDefault(),
"Default Messaging Settings");
- config.register(BackendConfigKeys.ENCRYPTION_KEY, randomKey(), "A random secret key");
config.registerObject(BackendConfigKeys.LOCAL_AUTH_CONFIG, LocalAuthConfig.fromDefaults(getJwtSecret()), "Local authentication settings");
config.registerObject(BackendConfigKeys.EMAIL_CONFIG, EmailConfig.fromDefaults(), "Email settings");
config.registerObject(BackendConfigKeys.GENERAL_CONFIG, new GeneralConfig(), "General settings");
@@ -234,10 +233,6 @@ public enum BackendConfig {
return config.getString(BackendConfigKeys.INFLUX_DATA_BASE);
}
- public String getEncryptionKey() {
- return config.getString(BackendConfigKeys.ENCRYPTION_KEY);
- }
-
public LocalAuthConfig getLocalAuthConfig() {
return config.getObject(BackendConfigKeys.LOCAL_AUTH_CONFIG, LocalAuthConfig.class, LocalAuthConfig.fromDefaults(getJwtSecret()));
}
diff --git a/streampipes-config/src/main/java/org/apache/streampipes/config/backend/BackendConfigKeys.java b/streampipes-config/src/main/java/org/apache/streampipes/config/backend/BackendConfigKeys.java
index 612ed1e..087794d 100644
--- a/streampipes-config/src/main/java/org/apache/streampipes/config/backend/BackendConfigKeys.java
+++ b/streampipes-config/src/main/java/org/apache/streampipes/config/backend/BackendConfigKeys.java
@@ -47,7 +47,6 @@ public class BackendConfigKeys {
public static final String MESSAGING_SETTINGS = "SP_MESSAGING_SETTINGS";
public static final String LOCAL_AUTH_CONFIG = "SP_LOCAL_AUTH_CONFIG";
- public static final String ENCRYPTION_KEY = "SP_ENCRYPTION_KEY";
public static final String EMAIL_CONFIG = "SP_EMAIL_CONFIG";
public static final String GENERAL_CONFIG = "SP_GENERAL_CONFIG";
diff --git a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/SourcesManagement.java b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/SourcesManagement.java
index 9ee701d..454a5a7 100644
--- a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/SourcesManagement.java
+++ b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/SourcesManagement.java
@@ -28,8 +28,7 @@ import org.apache.streampipes.model.connect.adapter.AdapterDescription;
import org.apache.streampipes.model.connect.adapter.AdapterSetDescription;
import org.apache.streampipes.model.connect.adapter.AdapterStreamDescription;
import org.apache.streampipes.model.grounding.EventGrounding;
-import org.apache.streampipes.model.util.Cloner;
-import org.apache.streampipes.resource.utils.AdapterEncryptionService;
+import org.apache.streampipes.resource.management.secret.SecretProvider;
import org.apache.streampipes.sdk.helpers.SupportedProtocols;
import org.apache.streampipes.storage.couchdb.impl.AdapterInstanceStorageImpl;
import org.slf4j.Logger;
@@ -111,7 +110,8 @@ public class SourcesManagement {
private AdapterDescription getAndDecryptAdapter(String adapterId) {
AdapterDescription adapter = this.adapterInstanceStorage.getAdapter(adapterId);
- return new AdapterEncryptionService(new Cloner().adapterDescription(adapter)).decrypt();
+ SecretProvider.getDecryptionService().apply(adapter);
+ return adapter;
}
}
diff --git a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/WorkerRestClient.java b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/WorkerRestClient.java
index b0e9026..f7dd363 100644
--- a/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/WorkerRestClient.java
+++ b/streampipes-connect-container-master/src/main/java/org/apache/streampipes/connect/container/master/management/WorkerRestClient.java
@@ -21,7 +21,6 @@ package org.apache.streampipes.connect.container.master.management;
import org.apache.http.client.fluent.Request;
import org.apache.http.entity.ContentType;
import org.apache.streampipes.connect.api.exception.AdapterException;
-import org.apache.streampipes.resource.utils.AdapterEncryptionService;
import org.apache.streampipes.connect.container.master.util.WorkerPaths;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
import org.apache.streampipes.model.connect.adapter.AdapterSetDescription;
@@ -29,6 +28,7 @@ import org.apache.streampipes.model.connect.adapter.AdapterStreamDescription;
import org.apache.streampipes.model.runtime.RuntimeOptionsRequest;
import org.apache.streampipes.model.runtime.RuntimeOptionsResponse;
import org.apache.streampipes.model.util.Cloner;
+import org.apache.streampipes.resource.management.secret.SecretProvider;
import org.apache.streampipes.serializers.json.JacksonSerializer;
import org.apache.streampipes.storage.api.IAdapterStorage;
import org.apache.streampipes.storage.couchdb.impl.AdapterInstanceStorageImpl;
@@ -231,13 +231,15 @@ public class WorkerRestClient {
}
private static void encryptAndUpdateAdapter(AdapterDescription adapter) {
- AdapterDescription encryptedDescription = new AdapterEncryptionService(new Cloner().adapterDescription(adapter)).encrypt();
+ AdapterDescription encryptedDescription = new Cloner().adapterDescription(adapter);
+ SecretProvider.getEncryptionService().apply(encryptedDescription);
getAdapterStorage().updateAdapter(encryptedDescription);
}
private static AdapterDescription getAndDecryptAdapter(String adapterId) {
AdapterDescription adapter = getAdapterStorage().getAdapter(adapterId);
- return new AdapterEncryptionService(new Cloner().adapterDescription(adapter)).decrypt();
+ SecretProvider.getDecryptionService().apply(adapter);
+ return adapter;
}
private static IAdapterStorage getAdapterStorage() {
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/execution/http/PipelineExecutor.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/execution/http/PipelineExecutor.java
index 9901619..8953b77 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/execution/http/PipelineExecutor.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/execution/http/PipelineExecutor.java
@@ -25,7 +25,7 @@ import org.apache.streampipes.commons.exceptions.NoServiceEndpointsAvailableExce
import org.apache.streampipes.manager.execution.endpoint.ExtensionsServiceEndpointGenerator;
import org.apache.streampipes.manager.execution.endpoint.ExtensionsServiceEndpointUtils;
import org.apache.streampipes.manager.execution.status.PipelineStatusManager;
-import org.apache.streampipes.manager.secret.SecretProvider;
+import org.apache.streampipes.resource.management.secret.SecretProvider;
import org.apache.streampipes.manager.util.TemporaryGraphStorage;
import org.apache.streampipes.model.SpDataSet;
import org.apache.streampipes.model.base.InvocableStreamPipesEntity;
@@ -183,11 +183,11 @@ public class PipelineExecutor {
}
private void decryptSecrets(List<InvocableStreamPipesEntity> graphs) {
- SecretProvider.getDecryptionService(pipeline.getCreatedByUser()).apply(graphs);
+ SecretProvider.getDecryptionService().apply(graphs);
}
private void encryptSecrets(List<InvocableStreamPipesEntity> graphs) {
- SecretProvider.getEncryptionService(pipeline.getCreatedByUser()).apply(graphs);
+ SecretProvider.getEncryptionService().apply(graphs);
}
public PipelineOperationStatus stopPipeline() {
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/execution/http/PipelineStorageService.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/execution/http/PipelineStorageService.java
index b80ec80..9914e55 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/execution/http/PipelineStorageService.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/execution/http/PipelineStorageService.java
@@ -21,7 +21,7 @@ package org.apache.streampipes.manager.execution.http;
import org.apache.streampipes.manager.data.PipelineGraph;
import org.apache.streampipes.manager.data.PipelineGraphBuilder;
import org.apache.streampipes.manager.matching.InvocationGraphBuilder;
-import org.apache.streampipes.manager.secret.SecretProvider;
+import org.apache.streampipes.resource.management.secret.SecretProvider;
import org.apache.streampipes.model.base.InvocableStreamPipesEntity;
import org.apache.streampipes.model.graph.DataProcessorInvocation;
import org.apache.streampipes.model.graph.DataSinkInvocation;
@@ -63,11 +63,11 @@ public class PipelineStorageService {
}
private void encryptSecrets(List<InvocableStreamPipesEntity> graphs) {
- SecretProvider.getEncryptionService(pipeline.getCreatedByUser()).apply(graphs);
+ SecretProvider.getEncryptionService().apply(graphs);
}
private void encryptSecrets(Pipeline pipeline) {
- SecretProvider.getEncryptionService(pipeline.getCreatedByUser()).apply(pipeline);
+ SecretProvider.getEncryptionService().apply(pipeline);
}
private <T> List<T> filter(List<InvocableStreamPipesEntity> graphs, Class<T> clazz) {
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/AutoInstallation.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/AutoInstallation.java
index 984e3ad..92e93b7 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/AutoInstallation.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/setup/AutoInstallation.java
@@ -19,7 +19,7 @@ package org.apache.streampipes.manager.setup;
import org.apache.streampipes.commons.constants.CustomEnvs;
import org.apache.streampipes.commons.constants.Envs;
-import org.apache.streampipes.commons.constants.InstallationConstants;
+import org.apache.streampipes.commons.constants.DefaultEnvValues;
import org.apache.streampipes.config.backend.BackendConfig;
import org.apache.streampipes.model.client.setup.InitialSettings;
import org.slf4j.Logger;
@@ -66,35 +66,35 @@ public class AutoInstallation {
if (Envs.SP_SETUP_INSTALL_PIPELINE_ELEMENTS.exists()) {
return Envs.SP_SETUP_INSTALL_PIPELINE_ELEMENTS.getValueAsBoolean();
} else {
- return InstallationConstants.INSTALL_PIPELINE_ELEMENTS;
+ return DefaultEnvValues.INSTALL_PIPELINE_ELEMENTS;
}
}
private String findServiceAccountSecret() {
return getStringOrDefault(
Envs.SP_INITIAL_CLIENT_SECRET.getEnvVariableName(),
- InstallationConstants.INITIAL_CLIENT_SECRET_DEFAULT
+ DefaultEnvValues.INITIAL_CLIENT_SECRET_DEFAULT
);
}
private String findServiceAccountName() {
return getStringOrDefault(
Envs.SP_INITIAL_CLIENT_USER.getEnvVariableName(),
- InstallationConstants.INITIAL_CLIENT_USER_DEFAULT
+ DefaultEnvValues.INITIAL_CLIENT_USER_DEFAULT
);
}
private String findAdminUser() {
return getStringOrDefault(
Envs.SP_INITIAL_ADMIN_EMAIL.getEnvVariableName(),
- InstallationConstants.INITIAL_ADMIN_EMAIL_DEFAULT
+ DefaultEnvValues.INITIAL_ADMIN_EMAIL_DEFAULT
);
}
private String findAdminPassword() {
return getStringOrDefault(
Envs.SP_INITIAL_ADMIN_PASSWORD.getEnvVariableName(),
- InstallationConstants.INITIAL_ADMIN_PW_DEFAULT
+ DefaultEnvValues.INITIAL_ADMIN_PW_DEFAULT
);
}
diff --git a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/AdapterResourceManager.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/AdapterResourceManager.java
index 11c7769..ed8aa51 100644
--- a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/AdapterResourceManager.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/AdapterResourceManager.java
@@ -19,7 +19,7 @@ package org.apache.streampipes.resource.management;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;
import org.apache.streampipes.model.util.Cloner;
-import org.apache.streampipes.resource.utils.AdapterEncryptionService;
+import org.apache.streampipes.resource.management.secret.SecretProvider;
import org.apache.streampipes.storage.api.IAdapterStorage;
import org.apache.streampipes.storage.management.StorageDispatcher;
@@ -31,8 +31,9 @@ public class AdapterResourceManager extends AbstractResourceManager<IAdapterStor
public String encryptAndCreate(AdapterDescription ad) {
// Encrypt adapter description to store it in db
- AdapterDescription encryptedAdapterDescription =
- new AdapterEncryptionService(new Cloner().adapterDescription(ad)).encrypt();
+
+ AdapterDescription encryptedAdapterDescription = new Cloner().adapterDescription(ad);
+ SecretProvider.getEncryptionService().apply(encryptedAdapterDescription);
// store in db
encryptedAdapterDescription.setRev(null);
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/ISecretHandler.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/ISecretHandler.java
similarity index 89%
rename from streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/ISecretHandler.java
rename to streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/ISecretHandler.java
index 2537ce3..29292d4 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/ISecretHandler.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/ISecretHandler.java
@@ -15,11 +15,11 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.manager.secret;
+package org.apache.streampipes.resource.management.secret;
public interface ISecretHandler {
- String apply(String username, String extractedValue);
+ String apply(String extractedValue);
boolean shouldApply(boolean encrypted);
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretDecrypter.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretDecrypter.java
similarity index 83%
rename from streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretDecrypter.java
rename to streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretDecrypter.java
index 9685632..3692271 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretDecrypter.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretDecrypter.java
@@ -15,10 +15,10 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.manager.secret;
+package org.apache.streampipes.resource.management.secret;
-import org.apache.streampipes.user.management.encryption.CredentialsManager;
+import org.apache.streampipes.user.management.encryption.SecretEncryptionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,9 +29,9 @@ public class SecretDecrypter implements ISecretHandler {
private static final Logger LOG = LoggerFactory.getLogger(SecretDecrypter.class);
@Override
- public String apply(String username, String extractedValue) {
+ public String apply(String extractedValue) {
try {
- return CredentialsManager.decrypt(username, extractedValue);
+ return SecretEncryptionManager.decrypt(extractedValue);
} catch (GeneralSecurityException e) {
LOG.error("Could not decrypt value, returning original value");
return extractedValue;
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretEncrypter.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretEncrypter.java
similarity index 83%
rename from streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretEncrypter.java
rename to streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretEncrypter.java
index 877858d..6b2bbd1 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretEncrypter.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretEncrypter.java
@@ -15,9 +15,9 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.manager.secret;
+package org.apache.streampipes.resource.management.secret;
-import org.apache.streampipes.user.management.encryption.CredentialsManager;
+import org.apache.streampipes.user.management.encryption.SecretEncryptionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -27,9 +27,9 @@ public class SecretEncrypter implements ISecretHandler {
private static final Logger LOG = LoggerFactory.getLogger(SecretEncrypter.class);
@Override
- public String apply(String username, String extractedValue) {
+ public String apply(String extractedValue) {
try {
- return CredentialsManager.encrypt(username, extractedValue);
+ return SecretEncryptionManager.encrypt(extractedValue);
} catch (GeneralSecurityException e) {
LOG.error("Could not encrypt value, returning original value");
return extractedValue;
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretProvider.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretProvider.java
similarity index 73%
rename from streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretProvider.java
rename to streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretProvider.java
index 9676677..cfc375e 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretProvider.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretProvider.java
@@ -15,16 +15,16 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.manager.secret;
+package org.apache.streampipes.resource.management.secret;
public class SecretProvider {
- public static SecretService getEncryptionService(String username) {
- return new SecretService(username, new SecretEncrypter()) {
+ public static SecretService getEncryptionService() {
+ return new SecretService(new SecretEncrypter()) {
};
}
- public static SecretService getDecryptionService(String username) {
- return new SecretService(username, new SecretDecrypter());
+ public static SecretService getDecryptionService() {
+ return new SecretService(new SecretDecrypter());
}
}
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretService.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretService.java
similarity index 70%
rename from streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretService.java
rename to streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretService.java
index 4f4223b..b7641a0 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretService.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretService.java
@@ -15,9 +15,11 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.manager.secret;
+package org.apache.streampipes.resource.management.secret;
import org.apache.streampipes.model.base.InvocableStreamPipesEntity;
+import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+import org.apache.streampipes.model.connect.adapter.GenericAdapterDescription;
import org.apache.streampipes.model.pipeline.Pipeline;
import org.apache.streampipes.model.staticproperty.StaticProperty;
@@ -27,9 +29,8 @@ public class SecretService {
private SecretVisitor visitor;
- public SecretService(String username,
- ISecretHandler secretHandler) {
- this.visitor = new SecretVisitor(username, secretHandler);
+ public SecretService(ISecretHandler secretHandler) {
+ this.visitor = new SecretVisitor(secretHandler);
}
public void apply(Pipeline pipeline) {
@@ -37,6 +38,16 @@ public class SecretService {
pipeline.getActions().forEach(this::apply);
}
+ public void apply(AdapterDescription adapterDescription) {
+ if (adapterDescription.getConfig() != null) {
+ applyConfig(adapterDescription.getConfig());
+ }
+
+ if (adapterDescription instanceof GenericAdapterDescription) {
+ applyConfig(((GenericAdapterDescription) adapterDescription).getProtocolDescription().getConfig());
+ }
+ }
+
public void apply(List<InvocableStreamPipesEntity> graphs) {
graphs.forEach(this::apply);
}
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretVisitor.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretVisitor.java
similarity index 91%
rename from streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretVisitor.java
rename to streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretVisitor.java
index b51945e..a783fc9 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/secret/SecretVisitor.java
+++ b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/secret/SecretVisitor.java
@@ -15,18 +15,15 @@
* limitations under the License.
*
*/
-package org.apache.streampipes.manager.secret;
+package org.apache.streampipes.resource.management.secret;
import org.apache.streampipes.model.staticproperty.*;
public class SecretVisitor implements StaticPropertyVisitor {
- private String username;
private ISecretHandler secretHandler;
- public SecretVisitor(String username,
- ISecretHandler secretHandler) {
- this.username = username;
+ public SecretVisitor(ISecretHandler secretHandler) {
this.secretHandler = secretHandler;
}
@@ -88,7 +85,7 @@ public class SecretVisitor implements StaticPropertyVisitor {
@Override
public void visit(SecretStaticProperty secretStaticProperty) {
if (secretHandler.shouldApply(secretStaticProperty.getEncrypted())) {
- String newValue = secretHandler.apply(username, secretStaticProperty.getValue());
+ String newValue = secretHandler.apply(secretStaticProperty.getValue());
secretStaticProperty.setValue(newValue);
secretStaticProperty.setEncrypted(!secretStaticProperty.getEncrypted());
}
diff --git a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/utils/AdapterEncryptionService.java b/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/utils/AdapterEncryptionService.java
deleted file mode 100644
index 320e1d6..0000000
--- a/streampipes-resource-management/src/main/java/org/apache/streampipes/resource/utils/AdapterEncryptionService.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.resource.utils;
-
-import org.apache.streampipes.model.connect.adapter.AdapterDescription;
-import org.apache.streampipes.model.connect.adapter.GenericAdapterDescription;
-import org.apache.streampipes.model.staticproperty.StaticProperty;
-
-import java.util.List;
-
-public class AdapterEncryptionService {
-
- private AdapterDescription ad;
-
- public AdapterEncryptionService(AdapterDescription ad) {
- this.ad = ad;
- }
-
- public AdapterDescription encrypt() {
- if (ad.getConfig() != null) {
- encrypt(ad.getConfig());
- }
-
- if (ad instanceof GenericAdapterDescription) {
- encrypt(((GenericAdapterDescription) ad).getProtocolDescription().getConfig());
- }
-
- return ad;
- }
-
- public AdapterDescription decrypt() {
- if (ad.getConfig() != null) {
- decrypt(ad.getConfig());
- }
- if (ad instanceof GenericAdapterDescription) {
- decrypt(((GenericAdapterDescription) ad).getProtocolDescription().getConfig());
- }
-
- return ad;
- }
-
- private void encrypt(List<StaticProperty> staticProperties) {
- // TODO uncomment
-// SecretProvider.getEncryptionService(ad.getUserName()).applyConfig(staticProperties);
- }
-
- private void decrypt(List<StaticProperty> staticProperties) {
- // TODO uncomment
-// SecretProvider.getDecryptionService(ad.getUserName()).applyConfig(staticProperties);
- }
-}
diff --git a/streampipes-service-extensions-base/src/main/java/org/apache/streampipes/service/extensions/base/client/StreamPipesClientRuntimeConnectionResolver.java b/streampipes-service-extensions-base/src/main/java/org/apache/streampipes/service/extensions/base/client/StreamPipesClientRuntimeConnectionResolver.java
index de3c67d..3f3ca01 100644
--- a/streampipes-service-extensions-base/src/main/java/org/apache/streampipes/service/extensions/base/client/StreamPipesClientRuntimeConnectionResolver.java
+++ b/streampipes-service-extensions-base/src/main/java/org/apache/streampipes/service/extensions/base/client/StreamPipesClientRuntimeConnectionResolver.java
@@ -21,7 +21,7 @@ import org.apache.streampipes.client.credentials.CredentialsProvider;
import org.apache.streampipes.client.credentials.StreamPipesTokenCredentials;
import org.apache.streampipes.client.model.ClientConnectionUrlResolver;
import org.apache.streampipes.commons.constants.Envs;
-import org.apache.streampipes.commons.constants.InstallationConstants;
+import org.apache.streampipes.commons.constants.DefaultEnvValues;
import org.apache.streampipes.svcdiscovery.SpServiceDiscovery;
import org.apache.streampipes.svcdiscovery.api.model.DefaultSpServiceGroups;
import org.apache.streampipes.svcdiscovery.api.model.DefaultSpServiceTags;
@@ -49,7 +49,7 @@ public class StreamPipesClientRuntimeConnectionResolver implements ClientConnect
if (Envs.SP_CLIENT_USER.exists()) {
return Envs.SP_CLIENT_USER.getValue();
} else {
- return InstallationConstants.INITIAL_CLIENT_USER_DEFAULT;
+ return DefaultEnvValues.INITIAL_CLIENT_USER_DEFAULT;
}
}
@@ -57,7 +57,7 @@ public class StreamPipesClientRuntimeConnectionResolver implements ClientConnect
if (Envs.SP_CLIENT_SECRET.exists()) {
return Envs.SP_CLIENT_SECRET.getValue();
} else {
- return InstallationConstants.INITIAL_CLIENT_SECRET_DEFAULT;
+ return DefaultEnvValues.INITIAL_CLIENT_SECRET_DEFAULT;
}
}
diff --git a/streampipes-user-management/pom.xml b/streampipes-user-management/pom.xml
index 779eb0f..b3c243a 100644
--- a/streampipes-user-management/pom.xml
+++ b/streampipes-user-management/pom.xml
@@ -67,6 +67,12 @@
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jasypt</groupId>
+ <artifactId>jasypt</artifactId>
+ <version>1.9.3</version>
+ </dependency>
+
<!-- Test dependencies -->
<dependency>
diff --git a/streampipes-user-management/src/main/java/org/apache/streampipes/user/management/encryption/CredentialsManager.java b/streampipes-user-management/src/main/java/org/apache/streampipes/user/management/encryption/CredentialsManager.java
deleted file mode 100644
index 7181d42..0000000
--- a/streampipes-user-management/src/main/java/org/apache/streampipes/user/management/encryption/CredentialsManager.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.streampipes.user.management.encryption;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.streampipes.config.backend.BackendConfig;
-import org.apache.streampipes.user.management.service.UserService;
-
-import java.security.GeneralSecurityException;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.InvalidKeySpecException;
-import java.util.Arrays;
-import java.util.Base64;
-
-import javax.crypto.Cipher;
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.PBEKeySpec;
-import javax.crypto.spec.PBEParameterSpec;
-
-
-public class CredentialsManager {
-
- private static final String COLON = ":";
- private static final String TRANSFORMATION = "PBEWithMD5AndDES";
-
- private static String encrypt(String email, byte[] property) throws GeneralSecurityException {
- String[] userProperties = getUserProperties(email);
- byte[] salt = getShortenedSalt(userProperties[1]);
-
- SecretKey key = makeSecretKey(userProperties[2].toCharArray());
- Cipher pbeCipher = Cipher.getInstance(TRANSFORMATION);
- pbeCipher.init(Cipher.ENCRYPT_MODE, key,
- new PBEParameterSpec(salt, 20));
-
- return Base64.getEncoder().encodeToString(pbeCipher.doFinal(property));
- }
-
- private static String encrypt(String email, char[] property) throws GeneralSecurityException {
- byte[] bytes = new byte[property.length];
- for (int i = 0; i < property.length; i++) {
- bytes[i] = (byte) property[i];
- }
- return encrypt(email, bytes);
- }
-
- public static String encrypt(String email, String property) throws GeneralSecurityException {
- return encrypt(email, property.getBytes());
- }
-
- public static String decrypt(String email, String property) throws GeneralSecurityException {
- String[] userProperties = getUserProperties(email);
- byte[] salt = getShortenedSalt(userProperties[1]);
- SecretKey key = makeSecretKey(userProperties[2].toCharArray());
- Cipher pbeCipher = Cipher.getInstance(TRANSFORMATION);
- pbeCipher.init(Cipher.DECRYPT_MODE, key,
- new PBEParameterSpec(salt,
- 20));
- return new String(pbeCipher.doFinal(Base64.getDecoder().decode(property)));
- }
-
- private static SecretKey makeSecretKey(char[] key) throws NoSuchAlgorithmException,
- InvalidKeySpecException {
- SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(TRANSFORMATION);
- return keyFactory.generateSecret(new PBEKeySpec(key));
- }
-
- private static String[] getUserProperties(String email) {
- String hashedProperty = new UserService(email).getPassword();
- return hashedProperty.split(COLON);
- }
-
- private static byte[] getShortenedSalt(String salt) {
- String mergedSalt = DigestUtils.sha256Hex(salt + getBackendEncryptionKey());
- return Arrays.copyOfRange(mergedSalt.getBytes(), 0, 8);
- }
-
- private static String getBackendEncryptionKey() {
- return BackendConfig.INSTANCE.getEncryptionKey();
- }
-}
diff --git a/streampipes-user-management/src/main/java/org/apache/streampipes/user/management/encryption/SecretEncryptionManager.java b/streampipes-user-management/src/main/java/org/apache/streampipes/user/management/encryption/SecretEncryptionManager.java
new file mode 100644
index 0000000..1b824ff
--- /dev/null
+++ b/streampipes-user-management/src/main/java/org/apache/streampipes/user/management/encryption/SecretEncryptionManager.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.streampipes.user.management.encryption;
+
+import org.apache.streampipes.commons.constants.DefaultEnvValues;
+import org.apache.streampipes.commons.constants.Envs;
+import org.jasypt.encryption.StringEncryptor;
+import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
+import org.jasypt.iv.RandomIvGenerator;
+
+import java.security.GeneralSecurityException;
+
+
+public class SecretEncryptionManager {
+
+ public static String encrypt(String property) throws GeneralSecurityException {
+ return getEncryptor().encrypt(property);
+ }
+
+ public static String decrypt(String property) throws GeneralSecurityException {
+ return getEncryptor().decrypt(property);
+ }
+
+ private static StringEncryptor getEncryptor() {
+ StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
+ encryptor.setPassword(Envs.SP_ENCRYPTION_PASSCODE.getValueOrDefault(DefaultEnvValues.DEFAULT_ENCRYPTION_PASSCODE));
+ encryptor.setAlgorithm("PBEWithHMACSHA512AndAES_256");
+ encryptor.setIvGenerator(new RandomIvGenerator());
+
+ return encryptor;
+
+ }
+}