/* * 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: * 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. */ package at.gv.egiz.eaaf.core.impl.idp.module.test; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; import org.apache.commons.lang3.StringUtils; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.idp.ISpConfiguration; import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; /** * Test pending-request for jUnit tests. * * @author tlenz * */ public class TestRequestImpl implements IRequest { private static final long serialVersionUID = 3000578812622938236L; private String processInstanceID = null; private ISpConfiguration spConfig = null; private final Map storage = new HashMap<>(); private String transactionId = null; private String pendingReqId = null; private String authUrl = null; private boolean authenticated; private boolean needAuthentication = false; private boolean stoppedByUser; private boolean currentlyInIframe = false; private String piiTransactionId; /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#requestedModule() */ @Override public String requestedModule() { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#requestedAction() */ @Override public String requestedAction() { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#isPassiv() */ @Override public boolean isPassiv() { // TODO Auto-generated method stub return false; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#forceAuth() */ @Override public boolean forceAuth() { // TODO Auto-generated method stub return false; } /* * (non-Javadoc) * * @see * at.gv.egovernment.moa.id.moduls.IRequest#getGenericData(java.lang.String) */ @Override public Object getRawData(final String key) { return storage.get(key); } /* * (non-Javadoc) * * @see * at.gv.egovernment.moa.id.moduls.IRequest#getGenericData(java.lang.String, * java.lang.Class) */ @Override public T getRawData(final String key, final Class clazz) { return (T) storage.get(key); } /* * (non-Javadoc) * * @see * at.gv.egovernment.moa.id.moduls.IRequest#getUniqueTransactionIdentifier() */ @Override public String getUniqueTransactionIdentifier() { return this.transactionId; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#getUniqueSessionIdentifier() */ @Override public String getUniqueSessionIdentifier() { // TODO Auto-generated method stub return null; } @Override public String getUniquePiiTransactionIdentifier() { return this.piiTransactionId; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#getProcessInstanceId() */ @Override public String getProcessInstanceId() { return processInstanceID; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#getAuthURL() */ @Override public String getAuthUrl() { return this.authUrl; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#getAuthURLWithOutSlash() */ @Override public String getAuthUrlWithOutSlash() { if (this.authUrl != null && this.authUrl.endsWith("/")) { return this.authUrl.substring(0, this.authUrl.length() - 1); } else { return this.authUrl; } } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#isNeedAuthentication() */ @Override public boolean isNeedAuthentication() { return this.needAuthentication; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#needSingleSignOnFunctionality() */ @Override public boolean needSingleSignOnFunctionality() { // TODO Auto-generated method stub return false; } /* * (non-Javadoc) * * @see * at.gv.egovernment.moa.id.moduls.IRequest#setNeedSingleSignOnFunctionality( * boolean) */ @Override public void setNeedSingleSignOnFunctionality(final boolean needSso) { // TODO Auto-generated method stub } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#isAuthenticated() */ @Override public boolean isAuthenticated() { return this.authenticated; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#setAuthenticated(boolean) */ @Override public void setAuthenticated(final boolean isAuthenticated) { this.authenticated = isAuthenticated; } /** * Set process-instance id. * * @param processInstanceID the processInstanceID to set */ public void setProcessInstanceID(final String processInstanceID) { this.processInstanceID = processInstanceID; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#isAbortedByUser() */ @Override public boolean isAbortedByUser() { return this.stoppedByUser; } /* * (non-Javadoc) * * @see at.gv.egovernment.moa.id.moduls.IRequest#setAbortedByUser(boolean) */ @Override public void setAbortedByUser(final boolean isAborted) { this.stoppedByUser = isAborted; } @Override public String getSpEntityId() { // TODO Auto-generated method stub return null; } @Override public void setRawDataToTransaction(final String key, final Object object) throws EaafStorageException { if (StringUtils.isEmpty(key)) { throw new EaafStorageException("Generic request-data can not be stored with a 'null' key", null); } if (object != null) { if (!Serializable.class.isInstance(object)) { throw new EaafStorageException( "Generic request-data can only store objects which implements the 'Seralizable' interface", null); } } storage.put(key, object); } @Override public void setRawDataToTransaction(final Map map) throws EaafStorageException { storage.putAll(map); } @Override public String getPendingRequestId() { return this.pendingReqId; } @Override public String getInternalSsoSessionIdentifier() { // TODO Auto-generated method stub return null; } @Override public void setInternalSsoSessionIdentifier(final String internalSsoSessionId) { // TODO Auto-generated method stub } @Override public boolean isNeedUserConsent() { // TODO Auto-generated method stub return false; } @Override public void setNeedUserConsent(final boolean needConsent) { // TODO Auto-generated method stub } @Override public ISpConfiguration getServiceProviderConfiguration() { return spConfig; } @Override public T getServiceProviderConfiguration(final Class decorator) { return (T) spConfig; } public void setSpConfig(final ISpConfiguration spConfig) { this.spConfig = spConfig; } @Override public T getSessionData(final Class wrapper) { if (wrapper != null) { if (AuthProcessDataWrapper.class.isAssignableFrom(wrapper)) { try { return wrapper.getConstructor(Map.class).newInstance(this.storage); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException("Can NOT instance wrapper: " + wrapper.getName(), e); } } throw new RuntimeException("Can NOT wrap generic data into session data. " + "Reason: Wrapper " + wrapper.getName() + " is NOT a valid wrapper"); } return null; } public void setTransactionId(final String transactionId) { this.transactionId = transactionId; } public void setPendingReqId(final String pendingReqId) { this.pendingReqId = pendingReqId; } public void setPiiTransactionId(String piiTransactionId) { this.piiTransactionId = piiTransactionId; } public void setAuthUrl(final String authUrl) { this.authUrl = authUrl; } public void setNeedAuthentication(final boolean needAuthentication) { this.needAuthentication = needAuthentication; } @Override public boolean isProcessInIframe() { return this.currentlyInIframe; } @Override public void setProcessInFrame(boolean flag) { this.currentlyInIframe = flag; } }