summaryrefslogtreecommitdiff
path: root/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2019-12-04 19:43:32 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2019-12-04 19:43:32 +0100
commit759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f (patch)
tree2132024fc058b1ef5338bf50df575a3244cc3f9f /eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
parent4f15bdc45b08724d20c66c9fd74ea6a43a03c32f (diff)
downloadEAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.tar.gz
EAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.tar.bz2
EAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.zip
common EGIZ code-style refactoring
Diffstat (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java516
1 files changed, 281 insertions, 235 deletions
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 e096b8e6..7c143ca2 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
@@ -1,24 +1,20 @@
/*******************************************************************************
- * Copyright 2017 Graz University of Technology
- * EAAF-Core Components has been developed in a cooperation between EGIZ,
- * A-SIT Plus, A-SIT, and Graz University of Technology.
+ * Copyright 2017 Graz University of Technology EAAF-Core Components has been developed in a
+ * cooperation between EGIZ, A-SIT Plus, A-SIT, and Graz University of Technology.
*
- * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
+ * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European
+ * Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work except in
+ * compliance with the Licence. You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/news/understanding-eupl-v12
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
+ * Unless required by applicable law or agreed to in writing, software distributed under the Licence
+ * is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the Licence for the specific language governing permissions and limitations under
+ * the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text file for details on the
+ * various modules and licenses. The "NOTICE" text file is part of the distribution. Any derivative
+ * works that you distribute must include a readable copy of the "NOTICE" text file.
*******************************************************************************/
/*******************************************************************************
*******************************************************************************/
@@ -29,226 +25,276 @@ package at.gv.egiz.eaaf.core.impl.idp.auth.data;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-
+import at.gv.egiz.eaaf.core.api.data.EAAFConstants;
+import at.gv.egiz.eaaf.core.api.idp.EaafAuthProcessDataConstants;
+import at.gv.egiz.eaaf.core.api.idp.auth.data.IAuthProcessDataContainer;
+import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink;
+import at.gv.egiz.eaaf.core.exceptions.EaafStorageException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.gv.egiz.eaaf.core.api.data.EAAFConstants;
-import at.gv.egiz.eaaf.core.api.idp.EAAFAuthProcessDataConstants;
-import at.gv.egiz.eaaf.core.api.idp.auth.data.IAuthProcessDataContainer;
-import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink;
-import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException;
-
-public class AuthProcessDataWrapper implements IAuthProcessDataContainer, EAAFAuthProcessDataConstants {
- private static final Logger log = LoggerFactory.getLogger(AuthProcessDataWrapper.class);
-
- protected Map<String, Object> authProcessData;
-
- public AuthProcessDataWrapper(Map<String, Object> authProcessData) {
- this.authProcessData = authProcessData;
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getIssueInstant()
- */
- @Override
- public String getIssueInstant() {
- return wrapStringObject(VALUE_ISSUEINSTANT, null, String.class);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setIssueInstant(java.lang.String)
- */
- @Override
- public void setIssueInstant(String issueInstant) {
- authProcessData.put(VALUE_ISSUEINSTANT, issueInstant);
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isAuthenticated()
- */
- @Override
- public boolean isAuthenticated() {
- return wrapStringObject(FLAG_IS_AUTHENTICATED, false, Boolean.class);
-
- }
-
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setAuthenticated(boolean)
- */
- @Override
- public void setAuthenticated(boolean authenticated) {
- authProcessData.put(FLAG_IS_AUTHENTICATED, authenticated);
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getIdentityLink()
- */
- @Override
- public IIdentityLink getIdentityLink() {
- return wrapStringObject(VALUE_IDENTITYLINK, null, IIdentityLink.class);
-
- }
-
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setIdentityLink(at.gv.egovernment.moa.id.auth.data.IdentityLink)
- */
- @Override
- public void setIdentityLink(IIdentityLink identityLink) {
- authProcessData.put(VALUE_IDENTITYLINK, identityLink);
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isMandateUsed()
- */
- @Override
- public boolean isMandateUsed() {
- return wrapStringObject(FLAG_USE_MANDATE, false, Boolean.class);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setUseMandates(boolean)
- */
- @Override
- public void setUseMandates(boolean useMandates) {
- authProcessData.put(FLAG_USE_MANDATE, useMandates);
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getQAALevel()
- */
- @Override
- public String getQAALevel() {
- return wrapStringObject(VALUE_QAALEVEL, null, String.class);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setQAALevel(java.lang.String)
- */
- @Override
- public void setQAALevel(String qAALevel) {
- authProcessData.put(VALUE_QAALEVEL, qAALevel);
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isForeigner()
- */
- @Override
- public boolean isForeigner() {
- return wrapStringObject(FLAG_IS_FOREIGNER, false, Boolean.class);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setForeigner(boolean)
- */
- @Override
- public void setForeigner(boolean isForeigner) {
- authProcessData.put(FLAG_IS_FOREIGNER, isForeigner);
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isOW()
- */
- @Override
- public boolean isOW() {
- return wrapStringObject(FLAG_IS_ORGANWALTER, false, Boolean.class);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setOW(boolean)
- */
- @Override
- public void setOW(boolean isOW) {
- authProcessData.put(FLAG_IS_ORGANWALTER, isOW);
-
- }
-
- @Override
- public boolean isEIDProcess() {
- return wrapStringObject(FLAG_IS_NEW_EID_PROCESS, false, Boolean.class);
- }
-
- @Override
- public void setEIDProcess(boolean value) {
- authProcessData.put(FLAG_IS_NEW_EID_PROCESS, value);
-
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getSessionCreated()
- */
- @Override
- public Date getSessionCreated() {
- return wrapStringObject(EAAFConstants.AUTH_DATA_CREATED, null, Date.class);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getGenericSessionDataStorage()
- */
- @Override
- public Map<String, Object> getGenericSessionDataStorage() {
- final Map<String, Object> result = new HashMap<String, Object>();
- for (final String el : authProcessData.keySet()) {
- if (el.startsWith(GENERIC_PREFIX))
- result.put(el.substring(GENERIC_PREFIX.length()), authProcessData.get(el));
-
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getGenericDataFromSession(java.lang.String)
- */
- @Override
- public Object getGenericDataFromSession(String key) {
- return authProcessData.get(GENERIC_PREFIX + key);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getGenericDataFromSession(java.lang.String, java.lang.Class)
- */
- @Override
- public <T> T getGenericDataFromSession(String key, Class<T> clazz) {
- return wrapStringObject(GENERIC_PREFIX + key, null, clazz);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setGenericDataToSession(java.lang.String, java.lang.Object)
- */
- @Override
- public void setGenericDataToSession(String key, Object object) throws EAAFStorageException {
- authProcessData.put(GENERIC_PREFIX + key, object);
-
- }
-
- protected <T> T wrapStringObject(String key, Object defaultValue, Class<T> clazz) {
- if (StringUtils.isNotEmpty(key)) {
- final Object obj = authProcessData.get(key);
- if (obj != null && clazz.isInstance(obj))
- return (T) obj;
- }
-
- if (defaultValue == null)
- return null;
-
- else if (clazz.isInstance(defaultValue))
- return (T)defaultValue;
-
- else {
- log.error("DefaultValue: " + defaultValue.getClass().getName() + " is not of Type:" + clazz.getName());
- throw new IllegalStateException("DefaultValue: " + defaultValue.getClass().getName() + " is not of Type:" + clazz.getName());
-
- }
- }
+public class AuthProcessDataWrapper
+ implements IAuthProcessDataContainer, EaafAuthProcessDataConstants {
+ private static final Logger log = LoggerFactory.getLogger(AuthProcessDataWrapper.class);
+
+ protected Map<String, Object> authProcessData;
+
+ public AuthProcessDataWrapper(final Map<String, Object> authProcessData) {
+ this.authProcessData = authProcessData;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getIssueInstant()
+ */
+ @Override
+ public String getIssueInstant() {
+ return wrapStringObject(VALUE_ISSUEINSTANT, null, String.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setIssueInstant(java.lang.String)
+ */
+ @Override
+ public void setIssueInstant(final String issueInstant) {
+ authProcessData.put(VALUE_ISSUEINSTANT, issueInstant);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isAuthenticated()
+ */
+ @Override
+ public boolean isAuthenticated() {
+ return wrapStringObject(FLAG_IS_AUTHENTICATED, false, Boolean.class);
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setAuthenticated(boolean)
+ */
+ @Override
+ public void setAuthenticated(final boolean authenticated) {
+ authProcessData.put(FLAG_IS_AUTHENTICATED, authenticated);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getIdentityLink()
+ */
+ @Override
+ public IIdentityLink getIdentityLink() {
+ return wrapStringObject(VALUE_IDENTITYLINK, null, IIdentityLink.class);
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setIdentityLink(at.gv.egovernment.moa
+ * .id.auth.data.IdentityLink)
+ */
+ @Override
+ public void setIdentityLink(final IIdentityLink identityLink) {
+ authProcessData.put(VALUE_IDENTITYLINK, identityLink);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isMandateUsed()
+ */
+ @Override
+ public boolean isMandateUsed() {
+ return wrapStringObject(FLAG_USE_MANDATE, false, Boolean.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setUseMandates(boolean)
+ */
+ @Override
+ public void setUseMandates(final boolean useMandates) {
+ authProcessData.put(FLAG_USE_MANDATE, useMandates);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getQAALevel()
+ */
+ @Override
+ public String getQAALevel() {
+ return wrapStringObject(VALUE_QAALEVEL, null, String.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setQAALevel(java.lang.String)
+ */
+ @Override
+ public void setQAALevel(final String qAALevel) {
+ authProcessData.put(VALUE_QAALEVEL, qAALevel);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isForeigner()
+ */
+ @Override
+ public boolean isForeigner() {
+ return wrapStringObject(FLAG_IS_FOREIGNER, false, Boolean.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setForeigner(boolean)
+ */
+ @Override
+ public void setForeigner(final boolean isForeigner) {
+ authProcessData.put(FLAG_IS_FOREIGNER, isForeigner);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#isOW()
+ */
+ @Override
+ public boolean isOW() {
+ return wrapStringObject(FLAG_IS_ORGANWALTER, false, Boolean.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setOW(boolean)
+ */
+ @Override
+ public void setOW(final boolean isOW) {
+ authProcessData.put(FLAG_IS_ORGANWALTER, isOW);
+
+ }
+
+ @Override
+ public boolean isEIDProcess() {
+ return wrapStringObject(FLAG_IS_NEW_EID_PROCESS, false, Boolean.class);
+ }
+
+ @Override
+ public void setEIDProcess(final boolean value) {
+ authProcessData.put(FLAG_IS_NEW_EID_PROCESS, value);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getSessionCreated()
+ */
+ @Override
+ public Date getSessionCreated() {
+ return wrapStringObject(EAAFConstants.AUTH_DATA_CREATED, null, Date.class);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#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;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getGenericDataFromSession(java.lang.
+ * String)
+ */
+ @Override
+ public Object getGenericDataFromSession(final String key) {
+ return authProcessData.get(GENERIC_PREFIX + key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getGenericDataFromSession(java.lang.
+ * String, java.lang.Class)
+ */
+ @Override
+ public <T> T getGenericDataFromSession(final String key, final Class<T> clazz) {
+ return wrapStringObject(GENERIC_PREFIX + key, null, clazz);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setGenericDataToSession(java.lang.
+ * String, java.lang.Object)
+ */
+ @Override
+ public void setGenericDataToSession(final String key, final Object object)
+ throws EaafStorageException {
+ authProcessData.put(GENERIC_PREFIX + key, object);
+
+ }
+
+ protected <T> T wrapStringObject(final String key, final Object defaultValue,
+ final Class<T> clazz) {
+ if (StringUtils.isNotEmpty(key)) {
+ final Object obj = authProcessData.get(key);
+ if (obj != null && clazz.isInstance(obj)) {
+ return (T) obj;
+ }
+ }
+
+ if (defaultValue == null) {
+ return null;
+ } else if (clazz.isInstance(defaultValue)) {
+ return (T) defaultValue;
+ } else {
+ log.error("DefaultValue: " + defaultValue.getClass().getName() + " is not of Type:"
+ + clazz.getName());
+ throw new IllegalStateException("DefaultValue: " + defaultValue.getClass().getName()
+ + " is not of Type:" + clazz.getName());
+
+ }
+ }
}