From 759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 4 Dec 2019 19:43:32 +0100 Subject: common EGIZ code-style refactoring --- .../spring/test/DummyTransactionStorage.java | 335 ++++++++++----------- .../spring/test/ExpressionContextAdapter.java | 100 +++--- .../impl/idp/process/spring/test/SimplePojo.java | 85 +++--- .../SpringExpressionAwareProcessEngineTest.java | 283 +++++++++-------- .../spring/test/SpringExpressionEvaluatorTest.java | 96 +++--- .../spring/test/task/CreateSAML1AssertionTask.java | 87 ------ .../spring/test/task/CreateSaml1AssertionTask.java | 82 +++++ .../spring/test/task/GetIdentityLinkTask.java | 85 +++--- .../process/spring/test/task/SelectBKUTask.java | 63 ---- .../process/spring/test/task/SelectBkuTask.java | 55 ++++ .../spring/test/task/SignAuthBlockTask.java | 88 +++--- .../spring/test/task/ValidateIdentityLinkTask.java | 69 ++--- .../test/task/ValidateSignedAuthBlockTask.java | 74 +++-- 13 files changed, 710 insertions(+), 792 deletions(-) delete mode 100644 eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/CreateSAML1AssertionTask.java create mode 100644 eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/CreateSaml1AssertionTask.java delete mode 100644 eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SelectBKUTask.java create mode 100644 eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SelectBkuTask.java (limited to 'eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test') diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java index 4795fdf4..cc1d57cd 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java @@ -1,189 +1,186 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; - import javax.sql.DataSource; - +import at.gv.egiz.eaaf.core.api.storage.ITransactionStorage; +import at.gv.egiz.eaaf.core.exceptions.EaafException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.gv.egiz.eaaf.core.api.storage.ITransactionStorage; -import at.gv.egiz.eaaf.core.exceptions.EAAFException; - /** - * Dummy DataSource implementation for convenience in test cases where a - * database connection will never actually be acquired. + * Dummy DataSource implementation for convenience in test cases where a database connection will + * never actually be acquired. * * @see DataSource * @author Chris Beams */ public class DummyTransactionStorage implements ITransactionStorage { - private static final Logger log = LoggerFactory.getLogger(DummyTransactionStorage.class); - - - public class DummyDBEntry{ - public DummyDBEntry(String key, Object value){ - this.obj =value; - this.key = key; - } - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } - public Object getObj() { - return obj; - } - public void setObj(Object obj) { - this.obj = obj; - } - private String key; - private Object obj; - } - - private ArrayList ds = new ArrayList(); - - - - @Override - public boolean containsKey(String key) { - // TODO Auto-generated method stub - Iterator it = ds.iterator(); - while(it.hasNext()){ - DummyDBEntry t = it.next(); - if(t.getKey().equals(key)) - return true; - } - return false; - } - - @Override - public void put(String key, Object value, int timeout) - throws EAAFException { - // TODO Auto-generated method stub - this.remove(key); - this.ds.add(new DummyDBEntry(key, value)); - - } - - @Override - public Object get(String key) throws EAAFException { - // TODO Auto-generated method stub - Iterator it = ds.iterator(); - while(it.hasNext()){ - DummyDBEntry t = it.next(); - if(t.getKey().equals(key)) - return t; - } - return null; - } - - @Override - public T get(String key, Class clazz) throws EAAFException { - - DummyDBEntry o = (DummyDBEntry) get(key); - if(o == null) - return null; - try { - @SuppressWarnings("unchecked") - T test = (T) (clazz.cast(o.getObj())); - return test; - - } catch (Exception e) { - log.warn("Sessioninformation Cast-Exception by using Artifact=" + key); - throw new EAAFException("Sessioninformation Cast-Exception"); - - } - } - - @Override - public T get(String key, Class clazz, long dataTimeOut) - throws EAAFException { - // TODO Auto-generated method stub - return get(key,clazz); - } - - @Override - public void changeKey(String oldKey, String newKey, Object value) - throws EAAFException { - this.remove(oldKey); - this.put(newKey, value, -1); - - } - - @Override - public void remove(String key) { - Iterator it = ds.iterator(); - while(it.hasNext()){ - DummyDBEntry t = it.next(); - if(t.getKey().equals(key)){ - this.ds.remove(t); - return; - } - } - - } - - @Override - public List clean(Date now, long dataTimeOut) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Object getRaw(String key) throws EAAFException { - // TODO Auto-generated method stub - return null; - } - - @Override - public void putRaw(String key, Object element) throws EAAFException { - // TODO Auto-generated method stub - - } - -// @Override -// public Object getAssertionStore(String key) throwsEAAFException { -// // TODO Auto-generated method stub -// return null; -// } -// -// @Override -// public void putAssertionStore(Object element) throws EAAFException { -// // TODO Auto-generated method stub -// -// } - - -} \ No newline at end of file + private static final Logger log = LoggerFactory.getLogger(DummyTransactionStorage.class); + + + public class DummyDbEntry { + public DummyDbEntry(final String key, final Object value) { + this.obj = value; + this.key = key; + } + + public String getKey() { + return key; + } + + public void setKey(final String key) { + this.key = key; + } + + public Object getObj() { + return obj; + } + + public void setObj(final Object obj) { + this.obj = obj; + } + + private String key; + private Object obj; + } + + private final ArrayList ds = new ArrayList<>(); + + + + @Override + public boolean containsKey(final String key) { + // TODO Auto-generated method stub + final Iterator it = ds.iterator(); + while (it.hasNext()) { + final DummyDbEntry t = it.next(); + if (t.getKey().equals(key)) { + return true; + } + } + return false; + } + + @Override + public void put(final String key, final Object value, final int timeout) throws EaafException { + // TODO Auto-generated method stub + this.remove(key); + this.ds.add(new DummyDbEntry(key, value)); + + } + + @Override + public Object get(final String key) throws EaafException { + // TODO Auto-generated method stub + final Iterator it = ds.iterator(); + while (it.hasNext()) { + final DummyDbEntry t = it.next(); + if (t.getKey().equals(key)) { + return t; + } + } + return null; + } + + @Override + public T get(final String key, final Class clazz) throws EaafException { + + final DummyDbEntry o = (DummyDbEntry) get(key); + if (o == null) { + return null; + } + try { + @SuppressWarnings("unchecked") + final T test = (clazz.cast(o.getObj())); + return test; + + } catch (final Exception e) { + log.warn("Sessioninformation Cast-Exception by using Artifact=" + key); + throw new EaafException("Sessioninformation Cast-Exception"); + + } + } + + @Override + public T get(final String key, final Class clazz, final long dataTimeOut) + throws EaafException { + // TODO Auto-generated method stub + return get(key, clazz); + } + + @Override + public void changeKey(final String oldKey, final String newKey, final Object value) + throws EaafException { + this.remove(oldKey); + this.put(newKey, value, -1); + + } + + @Override + public void remove(final String key) { + final Iterator it = ds.iterator(); + while (it.hasNext()) { + final DummyDbEntry t = it.next(); + if (t.getKey().equals(key)) { + this.ds.remove(t); + return; + } + } + + } + + @Override + public List clean(final Date now, final long dataTimeOut) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getRaw(final String key) throws EaafException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void putRaw(final String key, final Object element) throws EaafException { + // TODO Auto-generated method stub + + } + + // @Override + // public Object getAssertionStore(String key) throwsEAAFException { + // // TODO Auto-generated method stub + // return null; + // } + // + // @Override + // public void putAssertionStore(Object element) throws EAAFException { + // // TODO Auto-generated method stub + // + // } + + +} diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/ExpressionContextAdapter.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/ExpressionContextAdapter.java index 9a05f905..c00cc628 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/ExpressionContextAdapter.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/ExpressionContextAdapter.java @@ -1,29 +1,22 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test; @@ -31,48 +24,45 @@ import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Map; - import at.gv.egiz.eaaf.core.api.idp.process.ExpressionEvaluationContext; /** * Adapter class for {@link ExpressionEvaluationContext}. Intended to be used for testing purposes. - * + * * @author tknall - * + * */ public class ExpressionContextAdapter implements ExpressionEvaluationContext { - - private static final long serialVersionUID = 1L; - private Map ctxData = Collections.synchronizedMap(new HashMap()); + private static final long serialVersionUID = 1L; + + private final Map ctxData = + Collections.synchronizedMap(new HashMap()); - /** - * Returns a certain {@link Serializable} object associated with a certain {@code key}. - * - * @param key - * The key. - * @return The object or {@code null} if no object was found stored with that key or if a {@code null} value was - * stored. - */ - Serializable get(String key) { - return ctxData.get(key); - } + /** + * Returns a certain {@link Serializable} object associated with a certain {@code key}. + * + * @param key The key. + * @return The object or {@code null} if no object was found stored with that key or if a + * {@code null} value was stored. + */ + Serializable get(final String key) { + return ctxData.get(key); + } - /** - * Stores a {@link Serializable} with a certain {@code key}. - * - * @param key - * The key. - * @param object - * The object. - */ - void put(String key, Serializable object) { - ctxData.put(key, object); - } + /** + * Stores a {@link Serializable} with a certain {@code key}. + * + * @param key The key. + * @param object The object. + */ + void put(final String key, final Serializable object) { + ctxData.put(key, object); + } - @Override - public Map getCtx() { - return Collections.unmodifiableMap(ctxData); - } + @Override + public Map getCtx() { + return Collections.unmodifiableMap(ctxData); + } } diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SimplePojo.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SimplePojo.java index fa6a9f10..28dc57b4 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SimplePojo.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SimplePojo.java @@ -1,67 +1,60 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test; import at.gv.egiz.eaaf.core.api.idp.process.ExpressionEvaluator; /** * A dummy pojo used to test {@link ExpressionEvaluator} with Spring EL referencing Spring beans. - * + * * @author tknall - * + * */ public class SimplePojo { - private Boolean booleanValue; - private String stringValue; - private Integer integerValue; + private Boolean booleanValue; + private String stringValue; + private Integer integerValue; - public Boolean getBooleanValue() { - return booleanValue; - } + public Boolean getBooleanValue() { + return booleanValue; + } - public void setBooleanValue(Boolean booleanValue) { - this.booleanValue = booleanValue; - } + public void setBooleanValue(final Boolean booleanValue) { + this.booleanValue = booleanValue; + } - public String getStringValue() { - return stringValue; - } + public String getStringValue() { + return stringValue; + } - public void setStringValue(String stringValue) { - this.stringValue = stringValue; - } + public void setStringValue(final String stringValue) { + this.stringValue = stringValue; + } - public Integer getIntegerValue() { - return integerValue; - } + public Integer getIntegerValue() { + return integerValue; + } - public void setIntegerValue(Integer integerValue) { - this.integerValue = integerValue; - } + public void setIntegerValue(final Integer integerValue) { + this.integerValue = integerValue; + } } diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SpringExpressionAwareProcessEngineTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SpringExpressionAwareProcessEngineTest.java index 67675ff9..1d139b5e 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SpringExpressionAwareProcessEngineTest.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SpringExpressionAwareProcessEngineTest.java @@ -1,47 +1,30 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test; import static at.gv.egiz.eaaf.core.impl.idp.process.ProcessInstanceState.NOT_STARTED; import static at.gv.egiz.eaaf.core.impl.idp.process.ProcessInstanceState.SUSPENDED; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; - import java.io.IOException; import java.io.InputStream; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.api.idp.process.ProcessEngine; import at.gv.egiz.eaaf.core.exceptions.ProcessExecutionException; @@ -50,128 +33,132 @@ import at.gv.egiz.eaaf.core.impl.idp.process.ProcessDefinitionParserException; import at.gv.egiz.eaaf.core.impl.idp.process.ProcessEngineImpl; import at.gv.egiz.eaaf.core.impl.idp.process.ProcessInstance; import at.gv.egiz.eaaf.core.impl.idp.process.spring.SpringExpressionEvaluator; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** - * Tests the process engine using processes based on Spring EL referencing the process context and further Spring beans. - * + * Tests the process engine using processes based on Spring EL referencing the process context and + * further Spring beans. + * * @author tknall - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/process/spring/test/SpringExpressionAwareProcessEngineTest-context.xml") public class SpringExpressionAwareProcessEngineTest { - @Autowired private static ProcessEngine pe; - @Autowired private ApplicationContext applicationContext; - - private boolean isInitialized = false; - - @Before - public void init() throws IOException, ProcessDefinitionParserException { - - if (!isInitialized) { - - if (pe == null) { - pe = applicationContext.getBean("processEngine", ProcessEngine.class); - - } - - ((ProcessEngineImpl) pe).setTransitionConditionExpressionEvaluator(new SpringExpressionEvaluator()); - try (InputStream in = SpringExpressionAwareProcessEngineTest.class.getResourceAsStream("/process/spring/test/SampleProcessDefinitionWithExpression1.xml")) { - ((ProcessEngineImpl) pe).registerProcessDefinition(in); - } - try (InputStream in = SpringExpressionAwareProcessEngineTest.class.getResourceAsStream("/process/spring/test/SampleProcessDefinitionForSAML1Authentication.xml")) { - ((ProcessEngineImpl) pe).registerProcessDefinition(in); - } - - //initHibernateForTesting(); - } - } - - private static void initHibernateForTesting() throws IOException{ - -// InputStream in = SpringExpressionAwareProcessEngineTest.class.getResourceAsStream("/at/gv/egovernment/moa/id/process/hibernate.configuration.test.properties"); -// Properties props = new Properties(); -// props.load(in); -// -// try { -// //ConfigurationDBUtils.initHibernate(props); -// Configuration config = new Configuration(); -// config.addProperties(props); -// //config.addAnnotatedClass(ProcessInstanceStore.class); -// config.addAnnotatedClass(AssertionStore.class); -// //MOASessionDBUtils.initHibernate(config, props); -// } catch (Exception e) { -// e.printStackTrace(); -// } - } - - - @Test - public void testSampleProcessDefinitionWithExpression1() throws IOException, ProcessDefinitionParserException, ProcessExecutionException { - - TestRequestImpl req = new TestRequestImpl(); - - String piId = pe.createProcessInstance("SampleProcessWithExpression1"); - ProcessInstance pi = pe.getProcessInstance(piId); - assertEquals(NOT_STARTED, pi.getState()); - - - // start process - req.setProcessInstanceID(piId); - pe.start(req); - - //processInstance should be removed when it ends - try { - pi = pe.getProcessInstance(piId); - throw new ProcessExecutionException("ProcessInstance should be removed already, but it was found."); - //assertEquals(ENDED, pi.getState()); - - } catch (IllegalArgumentException e) { - // do nothing because processInstance should be already removed - - } - } - - @Test - public void testSampleProcessDefinitionForSAML1Authentication() throws IOException, ProcessDefinitionParserException, ProcessExecutionException { - - TestRequestImpl req = new TestRequestImpl(); - - String piId = pe.createProcessInstance("SampleProcessDefinitionForSAML1Authentication"); - ProcessInstance pi = pe.getProcessInstance(piId); - assertEquals(NOT_STARTED, pi.getState()); - - // start process - req.setProcessInstanceID(piId); - pe.start(req); - pi = pe.getProcessInstance(piId); - assertEquals(SUSPENDED, pi.getState()); - - ExecutionContext ec = pi.getExecutionContext(); - assertNotNull(ec); - System.out.println(ec.keySet()); - - assertNotNull(ec.get("bkuURL")); - assertNotNull(ec.get("IdentityLink")); - assertNotNull(ec.get("isIdentityLinkValidated")); - assertNotNull(ec.get("SignedAuthBlock")); - assertNotNull(ec.get("isSignedAuthBlockValidated")); - assertNotNull(ec.get("SAML1Assertion")); - - pe.signal(req); - try { - pi = pe.getProcessInstance(piId); - throw new ProcessExecutionException("ProcessInstance should be removed already, but it was found."); - //assertEquals(ENDED, pi.getState()); - - } catch (IllegalArgumentException e) { - // do nothing because processInstance should be already removed - - } - - - - } + @Autowired + private static ProcessEngine pe; + @Autowired + private ApplicationContext applicationContext; + + private final boolean isInitialized = false; + + /** + * jUnit test set-up. + * + * @throws IOException in case of an error + * @throws ProcessDefinitionParserException in case of an error + */ + @Before + public void init() throws IOException, ProcessDefinitionParserException { + + if (!isInitialized) { + + if (pe == null) { + pe = applicationContext.getBean("processEngine", ProcessEngine.class); + + } + + ((ProcessEngineImpl) pe) + .setTransitionConditionExpressionEvaluator(new SpringExpressionEvaluator()); + try (InputStream in = SpringExpressionAwareProcessEngineTest.class + .getResourceAsStream("/process/spring/test/SampleProcessDefinitionWithExpression1.xml")) { + ((ProcessEngineImpl) pe).registerProcessDefinition(in); + } + try (InputStream in = SpringExpressionAwareProcessEngineTest.class.getResourceAsStream( + "/process/spring/test/SampleProcessDefinitionForSAML1Authentication.xml")) { + ((ProcessEngineImpl) pe).registerProcessDefinition(in); + } + + // initHibernateForTesting(); + } + } + + @Test + public void testSampleProcessDefinitionWithExpression1() + throws IOException, ProcessDefinitionParserException, ProcessExecutionException { + + final TestRequestImpl req = new TestRequestImpl(); + + final String piId = pe.createProcessInstance("SampleProcessWithExpression1"); + ProcessInstance pi = pe.getProcessInstance(piId); + assertEquals(NOT_STARTED, pi.getState()); + + + // start process + req.setProcessInstanceID(piId); + pe.start(req); + + // processInstance should be removed when it ends + try { + pi = pe.getProcessInstance(piId); + throw new ProcessExecutionException( + "ProcessInstance should be removed already, but it was found."); + // assertEquals(ENDED, pi.getState()); + + } catch (final IllegalArgumentException e) { + // do nothing because processInstance should be already removed + + } + } + + @Test + public void testSampleProcessDefinitionForSaml1Authentication() + throws IOException, ProcessDefinitionParserException, ProcessExecutionException { + + final TestRequestImpl req = new TestRequestImpl(); + + final String piId = pe.createProcessInstance("SampleProcessDefinitionForSAML1Authentication"); + ProcessInstance pi = pe.getProcessInstance(piId); + assertEquals(NOT_STARTED, pi.getState()); + + // start process + req.setProcessInstanceID(piId); + pe.start(req); + pi = pe.getProcessInstance(piId); + assertEquals(SUSPENDED, pi.getState()); + + final ExecutionContext ec = pi.getExecutionContext(); + assertNotNull(ec); + System.out.println(ec.keySet()); + + assertNotNull(ec.get("bkuURL")); + assertNotNull(ec.get("IdentityLink")); + assertNotNull(ec.get("isIdentityLinkValidated")); + assertNotNull(ec.get("SignedAuthBlock")); + assertNotNull(ec.get("isSignedAuthBlockValidated")); + assertNotNull(ec.get("SAML1Assertion")); + + pe.signal(req); + try { + pi = pe.getProcessInstance(piId); + throw new ProcessExecutionException( + "ProcessInstance should be removed already, but it was found."); + // assertEquals(ENDED, pi.getState()); + + } catch (final IllegalArgumentException e) { + // do nothing because processInstance should be already removed + + } + + + + } } diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SpringExpressionEvaluatorTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SpringExpressionEvaluatorTest.java index bde24824..5697365e 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SpringExpressionEvaluatorTest.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/SpringExpressionEvaluatorTest.java @@ -1,34 +1,27 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - +import at.gv.egiz.eaaf.core.api.idp.process.ExpressionEvaluator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -36,45 +29,44 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import at.gv.egiz.eaaf.core.api.idp.process.ExpressionEvaluator; - /** - * Tests the {@link ExpressionEvaluator} using a Spring EL based implementation capable of dereferencing Spring beans. - * + * Tests the {@link ExpressionEvaluator} using a Spring EL based implementation capable of + * dereferencing Spring beans. + * * @author tknall - * + * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/process/spring/test/SpringExpressionEvaluatorTest-context.xml") public class SpringExpressionEvaluatorTest { - private ExpressionContextAdapter ctx; + private ExpressionContextAdapter ctx; - @Autowired - private ExpressionEvaluator expressionEvaluator; + @Autowired + private ExpressionEvaluator expressionEvaluator; - @Before - public void prepareTest() { - ctx = new ExpressionContextAdapter(); - } + @Before + public void prepareTest() { + ctx = new ExpressionContextAdapter(); + } - @Test - public void testEvaluateSimpleExpression() { - assertTrue(expressionEvaluator.evaluate(ctx, "'true'")); - } + @Test + public void testEvaluateSimpleExpression() { + assertTrue(expressionEvaluator.evaluate(ctx, "'true'")); + } - @Test - public void testEvaluateExpressionWithCtx() { - ctx.put("myProperty", false); - assertFalse(expressionEvaluator.evaluate(ctx, "ctx['myProperty']")); - } + @Test + public void testEvaluateExpressionWithCtx() { + ctx.put("myProperty", false); + assertFalse(expressionEvaluator.evaluate(ctx, "ctx['myProperty']")); + } -// @Test - public void testEvaluateExpressionWithBeanReference() { - assertTrue(expressionEvaluator.evaluate(ctx, "@simplePojo.booleanValue")); - assertTrue(expressionEvaluator.evaluate(ctx, "'HelloWorld'.equals(@simplePojo.stringValue)")); - assertTrue(expressionEvaluator.evaluate(ctx, "@simplePojo.integerValue == 42")); - assertTrue(expressionEvaluator.evaluate(ctx, "@simplePojo.stringValue.length() == 10")); - } + @Test + public void testEvaluateExpressionWithBeanReference() { + assertTrue(expressionEvaluator.evaluate(ctx, "@simplePojo.booleanValue")); + assertTrue(expressionEvaluator.evaluate(ctx, "'HelloWorld'.equals(@simplePojo.stringValue)")); + assertTrue(expressionEvaluator.evaluate(ctx, "@simplePojo.integerValue == 42")); + assertTrue(expressionEvaluator.evaluate(ctx, "@simplePojo.stringValue.length() == 10")); + } } diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/CreateSAML1AssertionTask.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/CreateSAML1AssertionTask.java deleted file mode 100644 index 9caba080..00000000 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/CreateSAML1AssertionTask.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * 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.process.spring.test.task; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Objects; - -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import at.gv.egiz.eaaf.core.api.IRequest; -import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; -import at.gv.egiz.eaaf.core.api.idp.process.Task; -import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; - -/** - * A dummy task simulating the creation of a SAML1 assertion. - *

- * Requires context data: - *

    - *
  • {@code IdentityLink}
  • - *
  • {@code isIdentityLinkValidated}
  • - *
  • {@code SignedAuthBlock}
  • - *
  • {@code isSignedAuthBlockValidated}
  • - *
- *

- *

- * Enriches context data with: - *

    - *
  • {@code SAML1Assertion}
  • - *
- *

- * - * @author tknall - * - */ -@Service("CreateSAML1AssertionTask") -public class CreateSAML1AssertionTask implements Task { - - private Logger log = LoggerFactory.getLogger(getClass()); - - @Override - public IRequest execute(IRequest penReq, ExecutionContext executionContext) throws TaskExecutionException { - Objects.requireNonNull(executionContext.get("IdentityLink")); - assert (Boolean.TRUE.equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated")))); - Objects.requireNonNull(executionContext.get("SignedAuthBlock")); - assert (Boolean.TRUE.equals(Objects.requireNonNull(executionContext.get("isSignedAuthBlockValidated")))); - - log.debug("Using IdentityLink and signed auth block in order to create SAML1 assertion."); - - try (InputStream in = getClass().getResourceAsStream("/process/spring/test/task/SAML1Assertion.xml")) { - executionContext.put("SAML1Assertion", IOUtils.toString(in, "UTF-8")); - } catch (IOException e) { - throw new TaskExecutionException(null, "", e); - } - - return null; - } - -} diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/CreateSaml1AssertionTask.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/CreateSaml1AssertionTask.java new file mode 100644 index 00000000..c699f093 --- /dev/null +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/CreateSaml1AssertionTask.java @@ -0,0 +1,82 @@ +/* + * 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.process.spring.test.task; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import at.gv.egiz.eaaf.core.api.IRequest; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.api.idp.process.Task; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +/** + * A dummy task simulating the creation of a SAML1 assertion. + *

+ * Requires context data: + *

    + *
  • {@code IdentityLink}
  • + *
  • {@code isIdentityLinkValidated}
  • + *
  • {@code SignedAuthBlock}
  • + *
  • {@code isSignedAuthBlockValidated}
  • + *
+ *

+ *

+ * Enriches context data with: + *

    + *
  • {@code SAML1Assertion}
  • + *
+ *

+ * + * @author tknall + * + */ +@Service("CreateSAML1AssertionTask") +public class CreateSaml1AssertionTask implements Task { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public IRequest execute(final IRequest penReq, final ExecutionContext executionContext) + throws TaskExecutionException { + Objects.requireNonNull(executionContext.get("IdentityLink")); + assert (Boolean.TRUE + .equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated")))); + Objects.requireNonNull(executionContext.get("SignedAuthBlock")); + assert (Boolean.TRUE + .equals(Objects.requireNonNull(executionContext.get("isSignedAuthBlockValidated")))); + + log.debug("Using IdentityLink and signed auth block in order to create SAML1 assertion."); + + try (InputStream in = + getClass().getResourceAsStream("/process/spring/test/task/SAML1Assertion.xml")) { + executionContext.put("SAML1Assertion", IOUtils.toString(in, "UTF-8")); + } catch (final IOException e) { + throw new TaskExecutionException(null, "", e); + } + + return null; + } + +} diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/GetIdentityLinkTask.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/GetIdentityLinkTask.java index e6f12d1e..93fcf6db 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/GetIdentityLinkTask.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/GetIdentityLinkTask.java @@ -1,44 +1,35 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test.task; import java.io.IOException; import java.io.InputStream; import java.util.Objects; - -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.api.idp.process.Task; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; /** * A dummy task simulating the retrieval of an IdentityLink. @@ -56,29 +47,31 @@ import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; *
  • {@code IdentityLink}
  • * *

    - * + * * @author tknall - * + * */ @Service("GetIdentityLinkTask") -public class GetIdentityLinkTask implements Task { +public class GetIdentityLinkTask implements Task { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public IRequest execute(final IRequest penReq, final ExecutionContext executionContext) + throws TaskExecutionException { + Objects.requireNonNull(executionContext.get("bkuURL")); - private Logger log = LoggerFactory.getLogger(getClass()); + log.debug("Using bkuURL in order to retrieve IdentityLink."); - @Override - public IRequest execute(IRequest penReq, ExecutionContext executionContext) throws TaskExecutionException { - Objects.requireNonNull(executionContext.get("bkuURL")); + try (InputStream in = getClass() + .getResourceAsStream("/process/spring/test/task/IdentityLink_Max_Mustermann.xml")) { + executionContext.put("IdentityLink", IOUtils.toString(in, "UTF-8")); - log.debug("Using bkuURL in order to retrieve IdentityLink."); + } catch (final IOException e) { + throw new TaskExecutionException(null, "", e); + } - try (InputStream in = getClass().getResourceAsStream("/process/spring/test/task/IdentityLink_Max_Mustermann.xml")) { - executionContext.put("IdentityLink", IOUtils.toString(in, "UTF-8")); - - } catch (IOException e) { - throw new TaskExecutionException(null, "", e); - } - - return null; - } + return null; + } } diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SelectBKUTask.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SelectBKUTask.java deleted file mode 100644 index 4cff97c6..00000000 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SelectBKUTask.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * 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.process.spring.test.task; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import at.gv.egiz.eaaf.core.api.IRequest; -import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; -import at.gv.egiz.eaaf.core.api.idp.process.Task; - -/** - * A dummy task simulating a bku selection. - *

    - * Asynchonous - *

    - * Enriches context data with: - *

      - *
    • {@code bkuURL}
    • - *
    - *

    - * - * @author tknall - * - */ -@Service("SelectBKUTask") -public class SelectBKUTask implements Task { - - private Logger log = LoggerFactory.getLogger(getClass()); - - @Override - public IRequest execute(IRequest penReq, ExecutionContext executionContext) { - log.debug("Providing BKU selection."); - executionContext.put("bkuURL", "https://127.0.0.1:3496/https-security-layer-request"); - return null; - } - -} diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SelectBkuTask.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SelectBkuTask.java new file mode 100644 index 00000000..a6e2ac2c --- /dev/null +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SelectBkuTask.java @@ -0,0 +1,55 @@ +/* + * 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.process.spring.test.task; + +import at.gv.egiz.eaaf.core.api.IRequest; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.api.idp.process.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +/** + * A dummy task simulating a bku selection. + *

    + * Asynchonous + *

    + * Enriches context data with: + *

      + *
    • {@code bkuURL}
    • + *
    + *

    + * + * @author tknall + * + */ +@Service("SelectBKUTask") +public class SelectBkuTask implements Task { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Override + public IRequest execute(final IRequest penReq, final ExecutionContext executionContext) { + log.debug("Providing BKU selection."); + executionContext.put("bkuURL", "https://127.0.0.1:3496/https-security-layer-request"); + return null; + } + +} diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SignAuthBlockTask.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SignAuthBlockTask.java index a2203676..41beefc8 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SignAuthBlockTask.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/SignAuthBlockTask.java @@ -1,44 +1,35 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test.task; import java.io.IOException; import java.io.InputStream; import java.util.Objects; - -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.api.idp.process.Task; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; /** * A dummy task simulating the signature of an auth block. @@ -58,29 +49,32 @@ import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; *
  • {@code SignedAuthBlock}
  • * *

    - * + * * @author tknall - * + * */ @Service("SignAuthBlockTask") -public class SignAuthBlockTask implements Task { +public class SignAuthBlockTask implements Task { + + private final Logger log = LoggerFactory.getLogger(getClass()); - private Logger log = LoggerFactory.getLogger(getClass()); + @Override + public IRequest execute(final IRequest penReq, final ExecutionContext executionContext) + throws TaskExecutionException { + Objects.requireNonNull(executionContext.get("IdentityLink")); + assert (Boolean.TRUE + .equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated")))); + Objects.requireNonNull(executionContext.get("bkuURL")); - @Override - public IRequest execute(IRequest penReq, ExecutionContext executionContext) throws TaskExecutionException { - Objects.requireNonNull(executionContext.get("IdentityLink")); - assert (Boolean.TRUE.equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated")))); - Objects.requireNonNull(executionContext.get("bkuURL")); + log.debug("Using validated IdentityLink and bkuURL in order to sign auth block."); + try (InputStream in = + getClass().getResourceAsStream("/process/spring/test/task/SignedAuthBlock.xml")) { + executionContext.put("SignedAuthBlock", IOUtils.toString(in, "UTF-8")); + } catch (final IOException e) { + throw new TaskExecutionException(null, "", e); - log.debug("Using validated IdentityLink and bkuURL in order to sign auth block."); - try (InputStream in = getClass().getResourceAsStream("/process/spring/test/task/SignedAuthBlock.xml")) { - executionContext.put("SignedAuthBlock", IOUtils.toString(in, "UTF-8")); - } catch (IOException e) { - throw new TaskExecutionException(null, "", e); - - } - return null; - } + } + return null; + } } diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/ValidateIdentityLinkTask.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/ValidateIdentityLinkTask.java index 7a1ba734..1a2cf5ee 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/ValidateIdentityLinkTask.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/ValidateIdentityLinkTask.java @@ -1,40 +1,31 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test.task; import java.util.Objects; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.api.idp.process.Task; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; /** * Dummy task simulating the validation of an IdentityLink. @@ -50,23 +41,23 @@ import at.gv.egiz.eaaf.core.api.idp.process.Task; *
  • {@code isIdentityLinkValidated}
  • * *

    - * - * @author tknall - * + * + * @author tknall + * */ @Service("ValidateIdentityLinkTask") public class ValidateIdentityLinkTask implements Task { - private Logger log = LoggerFactory.getLogger(getClass()); + private final Logger log = LoggerFactory.getLogger(getClass()); - @Override - public IRequest execute(IRequest penReq, ExecutionContext executionContext) { - Objects.requireNonNull(executionContext.get("IdentityLink")); + @Override + public IRequest execute(final IRequest penReq, final ExecutionContext executionContext) { + Objects.requireNonNull(executionContext.get("IdentityLink")); - log.debug("Validating IdentityLink."); + log.debug("Validating IdentityLink."); - executionContext.put("isIdentityLinkValidated", true); - return null; - } + executionContext.put("isIdentityLinkValidated", true); + return null; + } } diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/ValidateSignedAuthBlockTask.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/ValidateSignedAuthBlockTask.java index 1509033f..f07920cd 100644 --- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/ValidateSignedAuthBlockTask.java +++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/task/ValidateSignedAuthBlockTask.java @@ -1,41 +1,32 @@ -/******************************************************************************* - * 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. +*/ + package at.gv.egiz.eaaf.core.impl.idp.process.spring.test.task; import java.util.Objects; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.api.idp.process.Task; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; /** * A dummy task simulating the validation of an auth block. @@ -53,25 +44,28 @@ import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; *
  • {@code isSignedAuthBlockValidated}
  • * *

    - * + * * @author tknall - * + * */ @Service("ValidateSignedAuthBlockTask") public class ValidateSignedAuthBlockTask implements Task { - private Logger log = LoggerFactory.getLogger(getClass()); + private final Logger log = LoggerFactory.getLogger(getClass()); - @Override - public IRequest execute(IRequest penReq, ExecutionContext executionContext) throws TaskExecutionException { - Objects.requireNonNull(executionContext.get("IdentityLink")); - assert (Boolean.TRUE.equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated")))); - Objects.requireNonNull(executionContext.get("SignedAuthBlock")); + @Override + public IRequest execute(final IRequest penReq, final ExecutionContext executionContext) + throws TaskExecutionException { + Objects.requireNonNull(executionContext.get("IdentityLink")); + assert (Boolean.TRUE + .equals(Objects.requireNonNull(executionContext.get("isIdentityLinkValidated")))); + Objects.requireNonNull(executionContext.get("SignedAuthBlock")); - log.debug("Using validated IdentityLink and signed auth block in order to validate signed auth block."); + log.debug( + "Using validated IdentityLink and signed auth block in order to validate signed auth block."); - executionContext.put("isSignedAuthBlockValidated", true); - return null; - } + executionContext.put("isSignedAuthBlockValidated", true); + return null; + } } -- cgit v1.2.3