Skip to content

Commit 0f07251

Browse files
committed
Initialize pattern layout with AccessController.doPrivileged
We need the `getClassLoader` permissions
1 parent f35761b commit 0f07251

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/audit/logfile/LoggingAuditTrailTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@
129129
import java.nio.charset.StandardCharsets;
130130
import java.nio.file.Files;
131131
import java.nio.file.Path;
132+
import java.security.AccessController;
133+
import java.security.PrivilegedAction;
132134
import java.time.Clock;
133135
import java.util.ArrayList;
134136
import java.util.Arrays;
@@ -247,7 +249,12 @@ public static void lookupPatternLayout() throws Exception {
247249
assertThat(properties.getProperty("appender.audit_rolling.layout.type"), is("PatternLayout"));
248250
final String patternLayoutFormat = properties.getProperty("appender.audit_rolling.layout.pattern");
249251
assertThat(patternLayoutFormat, is(notNullValue()));
250-
patternLayout = PatternLayout.newBuilder().withPattern(patternLayoutFormat).withCharset(StandardCharsets.UTF_8).build();
252+
patternLayout = AccessController.doPrivileged(
253+
(PrivilegedAction<PatternLayout>) () -> PatternLayout.newBuilder()
254+
.withPattern(patternLayoutFormat)
255+
.withCharset(StandardCharsets.UTF_8)
256+
.build()
257+
);
251258
customAnonymousUsername = randomAlphaOfLength(8);
252259
reservedRealmEnabled = randomBoolean();
253260
}

0 commit comments

Comments
 (0)