summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java25
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java28
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java2
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java11
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java9
-rw-r--r--eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/auth/data/IAuthProcessDataContainer.java15
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/KeyValueUtils.java39
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/impl/utils/test/KeyValueUtilsTest.java3
-rw-r--r--eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/builder/PvpAttributeBuilder.java2
9 files changed, 67 insertions, 67 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
index 1378d49b..f1811022 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -205,22 +204,18 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
setCitizenCountryCode(internalAuthData, authProcessData);
// set generic authProcessData to authdata
- for (final Entry<String, Object> el : authProcessData.getGenericSessionDataStorage()
- .entrySet()) {
- if (el.getKey().startsWith(GENERIC_AUTHDATA_IDENTIFIER)) {
- log.trace("Find generic authProcessData {}. Map it directly to authData", el.getKey());
- try {
- internalAuthData.setGenericData(el.getKey(), el.getValue());
-
- } catch (final EaafStorageException e) {
- log.warn("Can NOT set authData with key: {}", el.getKey(), null, e);
-
- }
-
- }
+ authProcessData.getGenericSessionDataStream()
+ .filter(el -> el.getKey().startsWith(GENERIC_AUTHDATA_IDENTIFIER))
+ .forEach(el -> {
+ log.trace("Find generic authProcessData {}. Map it directly to authData", el.getKey());
+ try {
+ internalAuthData.setGenericData(el.getKey(), el.getValue());
- }
+ } catch (final EaafStorageException e) {
+ log.warn("Can NOT set authData with key: {}", el.getKey(), null, e);
+ }
+ });
}
/**
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
index 8eef4a8e..368652be 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
@@ -22,9 +22,11 @@ package at.gv.egiz.eaaf.core.impl.idp.auth.data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.TimeZone;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.annotation.Nullable;
@@ -264,16 +266,20 @@ public class AuthProcessDataWrapper
* getGenericSessionDataStorage()
*/
@Override
- public Map<String, Object> getGenericSessionDataStorage() {
- final Map<String, Object> result = new HashMap<>();
- for (final Map.Entry<String, Object> el : authProcessData.entrySet()) {
- if (el.getKey().startsWith(GENERIC_PREFIX)) {
- result.put(el.getKey().substring(GENERIC_PREFIX.length()), el.getValue());
- }
-
- }
-
- return result;
+ public Map<String, Object> getGenericSessionDataStorage() {
+ return authProcessData.entrySet().stream()
+ .filter(el -> el.getKey().startsWith(GENERIC_PREFIX))
+ .collect(
+ Collectors.toMap(
+ el -> el.getKey().substring(GENERIC_PREFIX.length()),
+ value -> value.getValue()));
+
+ }
+
+ @Override
+ public Stream<Entry<String, Object>> getGenericSessionDataStream() {
+ return getGenericSessionDataStorage().entrySet().stream();
+
}
/*
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java
index 135bd789..b554ad05 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java
@@ -24,7 +24,7 @@ public class AttributeBuilderRegistration {
log.info("Loading protocol attribut-builder modules:");
if (attributBuilderLoader != null) {
- final Iterator<IAttributeBuilder> moduleLoaderInterator = attributBuilderLoader.iterator();
+ final Iterator<IAttributeBuilder> moduleLoaderInterator = attributBuilderLoader.iterator();
while (moduleLoaderInterator.hasNext()) {
try {
final IAttributeBuilder modul = moduleLoaderInterator.next();
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java
index 328a25c5..08bf588f 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java
@@ -19,8 +19,6 @@
package at.gv.egiz.eaaf.core.impl.idp.controller.tasks;
-import java.util.Set;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -73,12 +71,9 @@ public class RestartAuthProzessManagement extends AbstractAuthServletTask {
} else {
// create a new execution context and copy all elements to new context
final ExecutionContext newec = new ExecutionContextImpl();
- final Set<String> entries = executionContext.keySet();
- for (final String key : entries) {
- newec.put(key, executionContext.get(key));
-
- }
-
+ executionContext.keySet().stream().forEach(
+ key -> newec.put(key, executionContext.get(key)));
+
log.debug("Select new auth.-process and restart restart process-engine ... ");
// select and create new process instance
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
index 61d2eb28..6e83a201 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
@@ -24,7 +24,6 @@ import java.io.Serializable;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.collections4.IterableUtils;
@@ -452,11 +451,9 @@ public class ProcessEngineImpl implements ProcessEngine {
final ExecutionContext executionContext =
new ExecutionContextImpl(piStore.getProcessInstanceId());
-
- final Map<String, Serializable> executionContextData = piStore.getExecutionContextData();
- for (final Entry<String, Serializable> el : executionContextData.entrySet()) {
- executionContext.put(el.getKey(), el.getValue());
- }
+
+ piStore.getExecutionContextData().entrySet().stream().forEach(
+ el -> executionContext.put(el.getKey(), el.getValue()));
final ProcessInstance pi = new ProcessInstance(
processDefinitions.get(piStore.getProcessDefinitionId()), executionContext);
diff --git a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/auth/data/IAuthProcessDataContainer.java b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/auth/data/IAuthProcessDataContainer.java
index 274f3f7f..cb9adbc8 100644
--- a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/auth/data/IAuthProcessDataContainer.java
+++ b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/auth/data/IAuthProcessDataContainer.java
@@ -21,6 +21,8 @@ package at.gv.egiz.eaaf.core.api.idp.auth.data;
import java.util.Date;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Stream;
import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
@@ -167,8 +169,21 @@ public interface IAuthProcessDataContainer {
*/
Date getSessionCreated();
+ /**
+ * Get all generic data from session.
+ *
+ * @return {@link Map} of generic data in key/value format
+ */
Map<String, Object> getGenericSessionDataStorage();
+
+ /**
+ * Get all generic data from session as {@link Stream} of {@link Entry} elements.
+ *
+ * @return {@link Stream} of generic data
+ */
+ Stream<Entry<String, Object>> getGenericSessionDataStream();
+
/**
* Returns a generic session-data object with is stored with a specific
* identifier.
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/KeyValueUtils.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/KeyValueUtils.java
index 0c5eeb40..49ef80e9 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/KeyValueUtils.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/KeyValueUtils.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -154,18 +155,14 @@ public class KeyValueUtils {
* null
*/
public static Map<String, String> removePrefixFromKeys(final Map<String, String> keys,
- final String prefix) {
- final Map<String, String> result = new HashMap<>();
- final Iterator<Entry<String, String>> interator = keys.entrySet().iterator();
- while (interator.hasNext()) {
- final Entry<String, String> el = interator.next();
- final String newKey = removePrefixFromKey(el.getKey(), prefix);
- if (StringUtils.isNotEmpty(newKey)) {
- result.put(newKey, el.getValue());
- }
- }
-
- return result;
+ final String prefix) {
+ return keys.entrySet().stream()
+ .filter(el -> StringUtils.isNotEmpty(removePrefixFromKey(el.getKey(), prefix)))
+ .collect(Collectors.toMap(
+ el -> removePrefixFromKey(el.getKey(), prefix),
+ el -> el.getValue()));
+
+
}
/**
@@ -351,19 +348,13 @@ public class KeyValueUtils {
* @return Map of Key / Value pairs, but never null
*/
public static Map<String, String> convertListToMap(final List<String> elements) {
- final Map<String, String> map = new HashMap<>();
- for (final String el : elements) {
- if (el.contains(KEYVVALUEDELIMITER)) {
- final String[] split = el.split(KEYVVALUEDELIMITER);
- map.put(split[0], split[1]);
-
- } else {
- log.debug("Key/Value Mapper: '" + el + "' contains NO '='. Ignore it.");
- }
-
- }
+ return elements.stream()
+ .filter(el -> el.contains(KEYVVALUEDELIMITER))
+ .map(el -> el.split(KEYVVALUEDELIMITER))
+ .collect(Collectors.toMap(
+ el -> el[0],
+ el -> el[1]));
- return map;
}
/**
diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/impl/utils/test/KeyValueUtilsTest.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/impl/utils/test/KeyValueUtilsTest.java
index 58788392..ca90f05b 100644
--- a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/impl/utils/test/KeyValueUtilsTest.java
+++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/impl/utils/test/KeyValueUtilsTest.java
@@ -153,7 +153,8 @@ public class KeyValueUtilsTest {
+ RandomStringUtils.randomAlphabetic(6) + KeyValueUtils.KEY_DELIMITER
+ RandomStringUtils.randomAlphabetic(5);
final Map<String, String> testMap = generateTestMap(testPrefix, 5, 5);
-
+ testMap.put(testPrefix, RandomStringUtils.randomAlphabetic(10));
+
final Map<String, String> result = KeyValueUtils.removePrefixFromKeys(testMap, testPrefix);
Assert.assertNotNull("Result is null", result);
Assert.assertFalse("Result is empty", result.isEmpty());
diff --git a/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/builder/PvpAttributeBuilder.java b/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/builder/PvpAttributeBuilder.java
index e8c06dd6..c05b96f3 100644
--- a/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/builder/PvpAttributeBuilder.java
+++ b/eaaf_modules/eaaf_module_pvp2_core/src/main/java/at/gv/egiz/eaaf/modules/pvp2/impl/builder/PvpAttributeBuilder.java
@@ -112,7 +112,7 @@ public class PvpAttributeBuilder {
*
* @return
*/
- public static List<Attribute> buildSupportedEmptyAttributes() {
+ public static List<Attribute> buildSupportedEmptyAttributes() {
final List<Attribute> attributes = new ArrayList<>();
final Iterator<IAttributeBuilder> builderIt = AttributeBuilderRegistration.getAllRegistratedBuilder();
while (builderIt.hasNext()) {