-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathFilterMavenPropertiesInValues.java
49 lines (38 loc) · 1.37 KB
/
FilterMavenPropertiesInValues.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.ndx.aadarchi.maven.cdi.helper.properties;
import java.util.logging.Logger;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.ndx.aadarchi.cdi.deltaspike.ConfigFilter;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@ApplicationScoped
public class FilterMavenPropertiesInValues implements ConfigFilter {
private static final Logger logger = Logger.getLogger(FilterMavenPropertiesInValues.class.getName());
private PluginParameterExpressionEvaluator evaluator;
public FilterMavenPropertiesInValues() {
super();
}
@Inject
public void createMavenExpressionEvaluator(MavenSession mavenSession, MojoExecution execution) {
evaluator = new PluginParameterExpressionEvaluator(mavenSession, execution);
}
@Override
public String filterValue(String key, String value) {
logger.info("Filtering value "+key);
try {
return evaluator.evaluate(value).toString();
} catch (ExpressionEvaluationException e) {
return value;
}
}
@Override
public String filterValueForLog(String key, String value) {
if (key.contains("password")) {
return "***************";
} else {
return filterValue(key, value);
}
}
}