mirror of https://github.com/apache/nifi.git
NIFI-9988 Corrected Property Decryption for Authorizers and Providers
- Updated Protection Scheme Resolver to support both Name matching and Path matching Signed-off-by: Nathan Gough <thenatog@gmail.com> This closes #6017.
This commit is contained in:
parent
e20aa0ea2a
commit
272325cb4e
|
@ -37,7 +37,9 @@ public class StandardProtectionSchemeResolver implements ProtectionSchemeResolve
|
||||||
public ProtectionScheme getProtectionScheme(final String scheme) {
|
public ProtectionScheme getProtectionScheme(final String scheme) {
|
||||||
Objects.requireNonNull(scheme, "Scheme required");
|
Objects.requireNonNull(scheme, "Scheme required");
|
||||||
return Arrays.stream(PropertyProtectionScheme.values())
|
return Arrays.stream(PropertyProtectionScheme.values())
|
||||||
.filter(propertyProtectionScheme -> propertyProtectionScheme.name().equals(scheme))
|
.filter(propertyProtectionScheme ->
|
||||||
|
propertyProtectionScheme.name().equals(scheme) || scheme.startsWith(propertyProtectionScheme.getPath())
|
||||||
|
)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow(() -> new SensitivePropertyProtectionException(String.format("Protection Scheme [%s] not supported", scheme)));
|
.orElseThrow(() -> new SensitivePropertyProtectionException(String.format("Protection Scheme [%s] not supported", scheme)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ public class StandardProtectionSchemeResolverTest {
|
||||||
|
|
||||||
private static final String AES_GCM_PATH = "aes/gcm";
|
private static final String AES_GCM_PATH = "aes/gcm";
|
||||||
|
|
||||||
|
private static final String AES_GCM_256_PATH = "aes/gcm/256";
|
||||||
|
|
||||||
private static final String UNKNOWN = "UNKNOWN";
|
private static final String UNKNOWN = "UNKNOWN";
|
||||||
|
|
||||||
private StandardProtectionSchemeResolver resolver;
|
private StandardProtectionSchemeResolver resolver;
|
||||||
|
@ -46,6 +48,13 @@ public class StandardProtectionSchemeResolverTest {
|
||||||
assertEquals(AES_GCM_PATH, protectionScheme.getPath());
|
assertEquals(AES_GCM_PATH, protectionScheme.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getProtectionSchemeAesGcm256Found() {
|
||||||
|
final ProtectionScheme protectionScheme = resolver.getProtectionScheme(AES_GCM_256_PATH);
|
||||||
|
assertNotNull(protectionScheme);
|
||||||
|
assertEquals(AES_GCM_PATH, protectionScheme.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getProtectionSchemeUnknownNotFound() {
|
public void getProtectionSchemeUnknownNotFound() {
|
||||||
final SensitivePropertyProtectionException exception = assertThrows(SensitivePropertyProtectionException.class, () -> resolver.getProtectionScheme(UNKNOWN));
|
final SensitivePropertyProtectionException exception = assertThrows(SensitivePropertyProtectionException.class, () -> resolver.getProtectionScheme(UNKNOWN));
|
||||||
|
|
Loading…
Reference in New Issue