import org.apache.poi.poifs.crypt.dsig.services.TimeStampServiceValidator;
import org.apache.poi.poifs.storage.RawDataUtil;
import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.apache.poi.util.ConditionalExecution.DisabledOnJreEx;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.TempFile;
}
@Test
+ @DisabledOnJreEx("1.8.0_292")
void testSignSpreadsheetWithSignatureInfo() throws Exception {
initKeyPair();
String testFile = "hello-world-unsigned.xlsx";
}
@Test
+ @DisabledOnJreEx("1.8.0_292")
void testSignEnvelopingDocument() throws Exception {
String testFile = "hello-world-unsigned.xlsx";
File sigCopy = testdata.getFile(testFile);
}
@Test
+ @DisabledOnJreEx("1.8.0_292")
void testNonSha1() throws Exception {
String testFile = "hello-world-unsigned.xlsx";
initKeyPair();
// Test signing of external references / hyperlinks
@Test
+ @DisabledOnJreEx("1.8.0_292")
void bug65214() throws Exception {
initKeyPair();
}
@Test
+ @DisabledOnJreEx("1.8.0_292")
void bug58630() throws Exception {
// test deletion of sheet 0 and signing
File tpl = copy(testdata.getFile("bug58630.xlsx"));
}
@Test
+ @DisabledOnJreEx("1.8.0_292")
void testSignatureImage() throws Exception {
initKeyPair();
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+/* ====================================================================
+ This product contains an ASLv2 licensed version of the OOXML signer
+ package from the eID Applet project
+ http://code.google.com/p/eid-applet/source/browse/trunk/README.txt
+ Copyright (C) 2008-2014 FedICT.
+ ================================================================= */
+package org.apache.poi.util;
+
+import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
+import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
+import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Arrays;
+import java.util.regex.Pattern;
+
+import org.junit.jupiter.api.extension.ConditionEvaluationResult;
+import org.junit.jupiter.api.extension.ExecutionCondition;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.platform.commons.util.Preconditions;
+
+/**
+ * Collection of Junit annotations to control the executions of tests
+ */
+public class ConditionalExecution {
+ @Target({ ElementType.TYPE, ElementType.METHOD })
+ @Retention(RetentionPolicy.RUNTIME)
+ @Documented
+ @ExtendWith(DisabledOnJreExCondition.class)
+ public @interface DisabledOnJreEx {
+
+ /**
+ * Version-Strings as Regex
+ */
+ String[] value();
+
+ /**
+ * Reason to provide if the test of container ends up being disabled.
+ */
+ String disabledReason() default "";
+
+ }
+
+ public static class DisabledOnJreExCondition implements ExecutionCondition {
+
+ DisabledOnJreExCondition() {
+ }
+
+ @Override
+ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
+ String version = Runtime.class.getPackage().getImplementationVersion();
+ return findAnnotation(context.getElement(), DisabledOnJreEx.class).filter(annotation -> !isEnabled(annotation))
+ .map(annotation -> disabled("PatchLevel skipped", "JRE version " + version + " skipped"))
+ .orElseGet(() -> enabled("PatchLevel not matched"));
+ }
+
+
+ boolean isEnabled(DisabledOnJreEx annotation) {
+ String[] versions = annotation.value();
+ Preconditions.condition(versions.length > 0, "You must declare at least one JRE version in @DisabledOnJreEx");
+ String version = Runtime.class.getPackage().getImplementationVersion();
+ return Arrays.stream(versions).noneMatch(p -> Pattern.matches(p, version));
+ }
+
+ }
+
+}