SLING-10687 : Don't log values when validating secrets
diff --git a/src/main/java/org/apache/sling/feature/extension/apiregions/api/config/validation/PropertyValidator.java b/src/main/java/org/apache/sling/feature/extension/apiregions/api/config/validation/PropertyValidator.java
index 6a586de..5617b9a 100644
--- a/src/main/java/org/apache/sling/feature/extension/apiregions/api/config/validation/PropertyValidator.java
+++ b/src/main/java/org/apache/sling/feature/extension/apiregions/api/config/validation/PropertyValidator.java
@@ -181,7 +181,7 @@
}
}
if ( found ) {
- setResult(context, desc, "Required excluded value " + exc + " found");
+ setResult(context, desc, "Not allowed excluded value " + exc + " found");
}
}
}
@@ -189,7 +189,7 @@
private static final List<String> PLACEHOLDERS = Arrays.asList("$[env:", "$[secret:", "$[prop:");
- void validateValue(final Context context, final DescribableEntity desc, final Object value) {
+ void validateValue(final Context context, final PropertyDescription desc, final Object value) {
if ( value != null ) {
// check for placeholder
boolean hasPlaceholder = false;
@@ -472,15 +472,19 @@
}
}
- void validateRegex(final Context context, final DescribableEntity desc, final Pattern pattern, final Object value) {
+ void validateRegex(final Context context, final PropertyDescription desc, final Pattern pattern, final Object value) {
if ( pattern != null ) {
if ( !pattern.matcher(value.toString()).matches() ) {
- setResult(context, desc, "Value " + value + " does not match regex " + pattern.pattern());
+ if ( desc.getType() == PropertyType.PASSWORD ) {
+ setResult(context, desc, "Value does not match regex " + pattern.pattern());
+ } else {
+ setResult(context, desc, "Value " + value + " does not match regex " + pattern.pattern());
+ }
}
}
}
- void validateOptions(final Context context, final DescribableEntity desc, final Object value) {
+ void validateOptions(final Context context, final PropertyDescription desc, final Object value) {
if ( context.description.getOptions() != null ) {
boolean found = false;
for(final Option opt : context.description.getOptions()) {
@@ -489,7 +493,11 @@
}
}
if ( !found ) {
- setResult(context, desc, "Value " + value + " does not match provided options");
+ if ( desc.getType() == PropertyType.PASSWORD ) {
+ setResult(context, desc, "Value does not match provided options");
+ } else {
+ setResult(context, desc, "Value " + value + " does not match provided options");
+ }
}
}
}