alopresto commented on a change in pull request #3672: NIFI-6363 Additional Sensitive Property Providers URL: https://github.com/apache/nifi/pull/3672#discussion_r318215217
########## File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/test/java/org/apache/nifi/properties/sensitive/keystore/KeyStoreSensitivePropertyProviderIT.java ########## @@ -0,0 +1,334 @@ +/* + * 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.nifi.properties.sensitive.keystore; + +import org.apache.nifi.properties.sensitive.AbstractSensitivePropertyProviderTest; +import org.apache.nifi.properties.sensitive.SensitivePropertyConfigurationException; +import org.apache.nifi.properties.sensitive.SensitivePropertyProvider; +import org.apache.nifi.security.util.CipherUtils; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.crypto.spec.SecretKeySpec; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.Security; +import java.security.cert.CertificateException; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + + +public class KeyStoreSensitivePropertyProviderIT extends AbstractSensitivePropertyProviderTest { + private static final Logger logger = LoggerFactory.getLogger(KeyStoreSensitivePropertyProviderIT.class); + + private static SecureRandom random = new SecureRandom(); + private static Map<String, KeyStoreTestCase> testCases = new HashMap<>(); + + private static class KeyStoreTestCase { + String storeType; // each test case has a KeyStore of this named type + String storePassword; // and has a random password + byte[] storeContents; // and has content serialized as bytes when built + + String keyAlias; // each test case also contains a key with this alias + String keyPassword; // and that key has a random password, too + } + + private static final String[] keyAlgos = {"RSA", "DSA", "ECDSA", "AES"}; Review comment: If the wrapped SPP in the `KeyStoreSensitivePropertyProvider` is `AESSensitivePropertyProvider`, I am confused about what actually happens when an RSA, DSA, or ECDSA key is retrieved from the keystore and used -- if it's just raw key bytes, the lengths still shouldn't match the 128, 192, or 256 bit expected key lengths. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
