jrihtarsic commented on code in PR #234: URL: https://github.com/apache/santuario-xml-security-java/pull/234#discussion_r1385009645
########## src/test/java/org/apache/xml/security/testutils/JDKTestUtils.java: ########## @@ -0,0 +1,149 @@ +/** + * 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. + */ +package org.apache.xml.security.testutils; + +import java.lang.System.Logger.Level; +import java.lang.reflect.Constructor; +import java.security.Provider; +import java.security.Security; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + + +/** + * The class provides testing utility methods to test XMLSEC functionality with various JDK version. Where possible + * we use JDK provided algorithm implementations. However, some algorithms are not supported in lower JDK versions. For example + * XDH keys were supported from JDK 11, EdDSA keys from JDK 16, etc. To ensure tests are executed for various JDK versions, + * we need to know which algorithms are supported from particular JDK version. + * + * If the JDK security providers do not support algorithm, the class provides auxiliary security provider (BouncyCastle) to the test + * xmlsec functionality ... + * + */ +public class JDKTestUtils { + + + // Purpose of auxiliary security provider is to enable testing of algorithms not supported by default JDK security providers. + private static final String TEST_PROVIDER_CLASSNAME_PROPERTY = "test.auxiliary.jce.provider.classname"; + private static final String TEST_PROVIDER_CLASSNAME_DEFAULT = "org.bouncycastle.jce.provider.BouncyCastleProvider"; + private static final System.Logger LOG = System.getLogger(JDKTestUtils.class.getName()); + + private static Provider auxiliaryProvider; + private static boolean auxiliaryProviderInitialized = false; + private static Set<String> supportedAuxiliaryProviderAlgorithms = null; + + private static Map<String, Integer> javaAlgSupportFrom = Stream.of( Review Comment: and is done as final :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
