summaryrefslogtreecommitdiff
path: root/eaaf_core_utils/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core_utils/src/test')
-rw-r--r--eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/TestAuthenticatedEncryptionPendingRequestIdGenerationStrategy.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/TestAuthenticatedEncryptionPendingRequestIdGenerationStrategy.java b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/TestAuthenticatedEncryptionPendingRequestIdGenerationStrategy.java
new file mode 100644
index 00000000..0ec9446c
--- /dev/null
+++ b/eaaf_core_utils/src/test/java/at/gv/egiz/eaaf/core/test/utils/TestAuthenticatedEncryptionPendingRequestIdGenerationStrategy.java
@@ -0,0 +1,39 @@
+package at.gv.egiz.eaaf.core.test.utils;
+
+import org.joda.time.DateTime;
+import org.jose4j.lang.JoseException;
+
+import at.gv.egiz.eaaf.core.exceptions.EaafException;
+import at.gv.egiz.eaaf.core.impl.utils.AuthenticatedEncryptionPendingRequestIdGenerationStrategy;
+import at.gv.egiz.eaaf.core.impl.utils.Random;
+
+/**
+ * {@link AuthenticatedEncryptionPendingRequestIdGenerationStrategy} with special methodes for software testing.
+ *
+ * @author tlenz
+ *
+ */
+public class TestAuthenticatedEncryptionPendingRequestIdGenerationStrategy extends
+ AuthenticatedEncryptionPendingRequestIdGenerationStrategy {
+
+ /**
+ * Generate a new pendingRequestId with a specific timestamp.
+ *
+ * <p>This method is only for software testing to generate expired pendingRequestId's</p>
+ *
+ * @param timestamp Timestamp on which this pendingRequestId was generated
+ * @return pendingRequestId
+ * @throws EaafException In case of an error
+ */
+ public String generateExternalPendingRequestId(DateTime timestamp) throws EaafException {
+ try {
+ final String toSign = buildInternalToken(Random.nextLongRandom(),timestamp);
+ return encryptAndEncodeToken(toSign);
+
+ } catch (final JoseException e) {
+ throw new EaafException("internal.pendingreqid.02", new Object[] { e.getMessage() }, e);
+
+ }
+ }
+
+}